<?php
session_start();
include("../includes/database.php");
include("../functions/functions.php");
if(!$_SESSION["customer_email"]){
header("location: ../checkout.php?error=Please-Provide-Your-Login-Details-Thanks.");
}else{
$user_a = @$_SESSION["customer_email"];
$user_ip_a = getIp();
$get_user_a = "select * from customers where customer_email = '$user_a' AND customer_ip = '$user_ip_a'";
$run_user_a = mysqli_query($con, $get_user_a);
$row_a = mysqli_fetch_array($run_user_a);
$cust_id_a = $row_a["customer_id"];
$cust_name_a = $row_a["customer_name"];
$cust_image_a = $row_a["customer_image"];
$cust_email_a = $row_a["customer_email"];
$cust_pass_a = $row_a["customer_pass"];
$cust_address_a = $row_a["customer_address"];
$cust_gender_a = $row_a["customer_gender"];
$cust_location_a = $row_a["customer_location"];
$cust_phone_a = $row_a["customer_phone"];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo $cust_name_a; ?>'s Orders | <?php echo $comp_title; ?></title>
<?php include("includes/head.php"); ?>
</head>
<body class="cbp-spmenu-push">
<div class="main-content">
<!--left-fixed -navigation-->
<div class=" sidebar" role="navigation">
<div class="navbar-collapse">
<?php include("includes/menu.php"); ?>
</div>
</div>
<!--left-fixed -navigation-->
<!-- header-starts -->
<?php include("includes/header.php"); ?>
<!-- //header-ends -->
<!-- main content start-->
<div id="page-wrapper">
<div class="main-page">
<div class="grid_3 grid_5 widget-shadow">
<h3 class="hdg"><?php echo $cust_name_a; ?>'s Orders</h3>
<!-- Here -->
<?php
include("../includes/database.php");
$per_page = 20;
if(isset($_GET['page'])){
$page = preg_replace('#[^0-9]#', '', $_GET['page']);
}else{
$page = 1;
}
$start_from = ($page - 1) * $per_page;
$init_query = "select * from customer_orders where customer_id = '$cust_id_a' AND approval_status = 'approved' ORDER BY 1 DESC LIMIT $start_from, $per_page";
$run_init_query = mysqli_query($con, $init_query);
$count_orders = mysqli_num_rows($run_init_query);
if($count_orders > 0){
while($row_init_query = mysqli_fetch_array($run_init_query)){
$cst_orderID = $row_init_query["order_id"];
$cst_ID = $row_init_query["customer_id"];
$cst_amtToPay = $row_init_query["due_amount"];
$cst_trackID = $row_init_query["invoice_no"];
$cst_ordDate = $row_init_query["order_date"];
$cst_apprStat = $row_init_query["approval_status"];
$inv_no2 = base64_encode($cst_trackID);
$init2_query = "select * from customers where customer_id = '$cst_ID'";
$run_init2_query = mysqli_query($con, $init2_query);
$row_init2_query = mysqli_fetch_array($run_init2_query);
$csta_name = $row_init2_query["customer_name"];
$csta_addr = $row_init2_query["customer_address"];
$csta_phone = $row_init2_query["customer_phone"];
$csta_loc = $row_init2_query["customer_location"];
$csta_actLoc = $row_init2_query["actual_location"];
?>
<div class="grid-bottom widget-shadow msgBox">
<h5 style="font-size: 17px;">
<span style="color: skyblue; font-weight: bold;">Customer Name:</span> <?php echo $csta_name; ?> | <a href="delivery_process.php?tracking_id=<?php echo $inv_no2; ?>"><span class="" style="color: skyblue; font-weight: bold;">Order Tracking No: <?php echo $cst_trackID; ?></span></a> | <span style="color: skyblue; font-weight: bold;">Order Was Placed:</span> <time class="timeago" datetime="<?php echo $cst_ordDate; ?>"></time>
<span style="color: skyblue; float: right;">Status: <span id="apprStat"><?php echo $cst_apprStat; ?></span></span>
</h5>
<br>
<table class="table table-bordered table-striped no-margin grd_tble">
<thead>
<tr>
<th style="width: 40%;"><center>Address</center></th>
<th style="width: 20%;"><center>Phone Number</center></th>
<th style="width: 10%;"><center>Destination</center></th>
<th style="width: 10%;"><center>Amount Due</center></th>
<th style="width: 20%;"><center>Approval Status</center></th>
</tr>
</thead>
<tbody>
<tr>
<td><center><?php echo $csta_addr; ?></center></td>
<td><center><?php echo $csta_phone; ?></center></td>
<td><center><?php echo $csta_actLoc; ?></center></td>
<td><center><?php echo $currency; ?> <?php echo $cst_amtToPay; ?></center></td>
<td><center> <a href="order_details.php?order_details=<?php echo $inv_no2; ?>" class="btn btn-primary">View Order Details</a></center></td>
</tr>
</tbody>
</table>
<div class="row">
<?php
$init3_query = "select * from pending_orders where invoice_no = '$cst_trackID'";
$run_init3_query = mysqli_query($con, $init3_query);
while($row_init3_query = mysqli_fetch_array($run_init3_query)){
$grb_pro_id = $row_init3_query["product_id"];
$grb_pro_qty = $row_init3_query["quantity"];
$init4_query = "select * from product where product_id = '$grb_pro_id'";
$run_init4_query = mysqli_query($con, $init4_query);
$row_init4_query = mysqli_fetch_array($run_init4_query);
$grb_pro_img = $row_init4_query["product_image"];
$grb_pro_name = $row_init4_query["product_name"];
?>
<div class="col-md-2 col-sm-3 col-xs-3">
<img src="../images/product_images/<?php echo $grb_pro_img; ?>" class="img-responsive thumbnail" width="100" height="100" alt="<?php echo $grb_pro_name; ?>" title="<?php echo $grb_pro_name; ?>" />
<label>Qty: <?php echo $grb_pro_qty; ?></label>
</div>
<?php } ?>
</div>
</div><hr />
<?php } ?>
<!--<div class="row calender widget-shadow">
<h4 class="title">Calender</h4>
<div class="cal1">
</div>
</div>-->
<hr />
<center><?php include("orders_pagination.php"); ?></center><hr />
<div class="well">
<b>Important Notice:</b> To View Each of Your Orders Individually, Please Click on the Order Tracking Number.
</div>
<div class="well">
For Any Other Issues, Please Feel Free to Contact Us Through The Customer Service Link on The Left Menu Bar. Thanks for Shopping With Us.
</div>
<?php }else{
echo "
<div class='footer-top'>
<div class='col-md-12 top-footer'>
<div class='well'>
You have no pending order. To shop, please follow this link: <a href='../index.php'>Continue Shopping</a>
</div>
</div>
<div class='col-md-12 top-footer'>
<div class='well'>
For Any Other Issues, Please Feel Free to Contact Us Through The Customer Service Link on The Left Menu Bar. Thanks for Shopping With Us.
</div>
</div>
<div class='clearfix'> </div>
</div>
";
} ?>
<!-- Here -->
</div>
<div class="clearfix"> </div>
</div>
</div>
<!--footer-->
<?php include("includes/footer.php"); ?>
<!--//footer-->
</div>
</body>
</html>
<?php } ?>