<?php 
include('common/header.php');

// if(isset($_GET['order_id']) && $_GET['order_id'] != '') {
//   $o_id = htmlspecialchars(strip_tags(trim($_GET['order_id'])), ENT_QUOTES, 'UTF-8');
//   $sql_ordr = mysqli_fetch_assoc(mysqli_query($conn, "SELECT tel_no FROM order_details WHERE inv_no='$o_id'"));
//   $tel_no = $sql_ordr['tel_no'];

// } else {
//   $redirectUrl = "index";
//   echo "<script type=\"text/javascript\">";
//   echo "window.location.href = '$redirectUrl'";
//   echo "</script>"; 
// }

$menu_cat = '';
?>

<!-- Header Wrap Ends -->

<?php include "common/navbar.php"; ?> 

<!-- Main Container Starts -->
<div class="main-container" >
  <!-- Product Container Starts -->
  <div id="product-product" class="container" style="background: black; ">
    <!-- Row Starts -->  
    <div class="row col-sm-12">

      <!-- Content Area Starts -->
      <div id="content" class="col-lg-12 login">

       <div class="row justify-content-lg-around position-relative pt-5">
        <div class="col-lg-12 col-md-12">
          <div class="p-3 p-md-4 bg-white shadow">
            <div class="row">
              <div class="col-md-12">
                <section class="b-detail-holder">
                  <div style="padding-left: 50px">
                    <div class="heading_s1">
                    <h3 style="color: green">Your order is completed!</h3>
                  </div>
                  <hr>
                  <p>Thank you for your order! Your order is being processed and will be completed within 3-6 hours. You will receive an email confirmation when your order is completed.</p>
                </div>
              </section>
              <hr>
            </div>
          </div>
        </div>
      </div>
    </div>


    <div class="form-group pt-5 m-0">
      <a href="index" class="btn btn-inverse"  style="float:right"> Continue Shopping</a>
    </div>


  </div>

</div>
<!-- Content Area Ends -->    

</div>
<!-- Row Ends -->  
</div>
<!-- Product Container Ends -->

</div>


<!-- Main Container Ends -->
<!-- Footer Starts -->
<?php include "common/footer.php"; ?> 

<script>
 cart_data_load_main();

 function cart_data_load_main() {
  $(".cart_adding").css("display", "block");
  var tot = 0;
  var tableData;
  var postData = {
    cart_data_load: 'table'
  };
  $.post('cart_reload.php', {
    'cart_data_load': 'data'
  }, function(e) {

    $('#cart_tbody').html('').append(e);

    $('.plus').on('click', function() {

      if ($(this).prev().val()) {
        $(this).prev().val(+$(this).prev().val() + 1);

        var row_id = $(this).parents("tr").attr('id');
        var value = $(this).prev().val();

        $.post('connection/cart_data_load.php', {
          'update_qty': 'data',
          id: row_id,
          val: value
        }, function(data) {

          cart_data_load_main();

        });

      }

    });
    $('.minus').on('click', function() {
      if ($(this).next().val() > 1) {
        if ($(this).next().val() > 1) $(this).next().val(+$(this).next().val() - 1);

        var row_id = $(this).parents("tr").attr('id');
        var value = $(this).next().val();

        $.post('connection/cart_data_load.php', {
          'update_qty': 'data',
          id: row_id,
          val: value
        }, function(data) {

          cart_data_load_main();

        });
      }
    });

    $('#total_price_dis').text('MVR: ' + tot.toFixed(2));
    $('#gtotal_price_dis').text('MVR: ' + tot.toFixed(2));

    totalx = tot.toFixed(2);
    $('.cart_quantity').on('change', function() {

      var row_id = $(this).parents("tr").attr('id');
      var value = $(this).val();

      $.post('connection/cart_data_load.php', {
        'update_qty': 'data',
        id: row_id,
        val: value
      }, function(data) {

        cart_data_load_main();

      });
    });

    $(".btn_del").click(function() {
      id_for_delete = $(this).attr('data-row-no');

      $.post("connection/cart_data_load.php", {
        delete_cart_row: 'delete',
        id_for_delete: id_for_delete
      }, function(delMsg) {
        $.each(delMsg, function(index, valueDel) {
          if (valueDel.msgType === 1) {
            alert('Deleted data successfully');
          } else if (valueDel.msgType === 2) {
            alert('Something went wrong.Please check your field');
          }
        });
        cart_data_load_main();
      }, "json");

    });
    var checked = [];
    var $this, input, text, obj;
    $(".itm_id_holder").each(function() {
      obj = {};
      obj['itm_id'] = parseInt($(this).val());
      obj['qty'] = $(this).parents("tr").find(".cart_quantity").val();

      checked.push(obj);
    });

    $.post("connection/order_back.php", {
      stock_validation: 'data',
      items: checked
    }, function(e) {

      $.each(e, function(index, data) {
        $('.' + data).find(".stock_cal").replaceWith("<span class='pr_flash bg-danger stock_cal' style='position: unset;'>Out of stock</span>");
      });

    }, "json");


  });
  cart_data_load();
  $(".cart_adding").fadeOut();
}
</script>



</body>
</html> 


