<?php
session_start();
include("../includes/database.php");
include("../functions/functions.php");
if(!$_SESSION["customer_email"]){
header("location: ../account-login?msg=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"];
header("refresh: 300; url=index.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo $cust_name_a; ?>'s Account | <?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="row-one">
<div class="col-md-3 widget">
<div class="stats-left ">
<h5>Pending</h5>
<h4>Orders</h4>
</div>
<?php
$total_query = "select * from customer_orders where customer_id = '$cust_id_a' AND order_status = 'Pending' AND approval_status = 'approved'";
$run_total = mysqli_query($con, $total_query);
$count_total = mysqli_num_rows($run_total);
?>
<div class="stats-right">
<label> <?php echo $count_total; ?></label>
</div>
<div class="clearfix"> </div>
</div>
<div class="col-md-3 widget states-mdl">
<div class="stats-left ">
<h5>Approved</h5>
<h4>Orders</h4>
</div>
<?php
$order2_query = "select * from customer_orders where customer_id = '$cust_id_a' AND approval_status = 'approved'";
$run_order2 = mysqli_query($con, $order2_query);
$count_order2 = mysqli_num_rows($run_order2);
?>
<div class="stats-right">
<label> <?php echo $count_order2; ?></label>
</div>
<div class="clearfix"> </div>
</div>
<div class="col-md-3 widget states-last">
<div class="stats-left">
<h5>Cancelled</h5>
<h4>Orders</h4>
</div>
<?php
$order_query = "select * from customer_orders where customer_id = '$cust_id_a' AND approval_status = 'cancelled'";
$run_order = mysqli_query($con, $order_query);
$count_order = mysqli_num_rows($run_order);
?>
<div class="stats-right">
<label><?php echo $count_order; ?></label>
</div>
<div class="clearfix"> </div>
</div>
<div class="clearfix"> </div><hr />
</div>
<?php
include("../includes/database.php");
$init_query = "select * from customer_orders where customer_id = '$cust_id_a' AND approval_status = '' ORDER BY 1 DESC";
$run_init_query = mysqli_query($con, $init_query);
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_pmt_method = $row_init_query["payment_method"];
if($cst_pmt_method == "paypal"){
$cst_pmt_method = "PayPal";
}else if($cst_pmt_method == "cash_on_delivery"){
$cst_pmt_method = "Cash On Delivery";
}
$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">
<h4>This Order Has Been Received and is Awaiting Approval By BabyKish!</h4><br>
<h5 style="font-size: 17px;"><span style="color: skyblue; font-weight: bold;">Customer Name:</span> <?php echo $csta_name; ?> | <span style="color: skyblue; font-weight: bold;">Order Tracking No:</span> <?php echo $cst_trackID; ?> | <span style="color: skyblue; font-weight: bold;">Order Was Placed:</span> <time class="timeago" datetime="<?php echo $cst_ordDate; ?>"></time> | <span style="color: skyblue; font-weight: bold;">Payment Method:</span> <?php echo $cst_pmt_method; ?></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: 20%;"><center>Destination</center></th>
<th style="width: 20%;"><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><button class="btn btn-danger" actualID="<?php echo $cst_orderID; ?>" actualDate="<?php echo $cst_ordDate; ?>" id="orderCancel">Cancel</button></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="clearfix"> </div>
<div class="grid_3 grid_5 widget-shadow">
<h3 class="hdg">Welcome to Your Personal Control Panel</h3>
<div style="font-size: 18px;" class="well">
Welcome <?php echo $cust_name_a; ?> To Your Personal Customer Control Panel. Here You Can Track Your Orders.
</div>
<div style="font-size: 18px;" class="well">
Please Note That Your Orders Will Only Be Available For Review and Tracking After It Is Approved By Us Within 10 Minutes At Most.
</div>
<div style="font-size: 18px;" class="well">
Once Approved, You Can View Your Order Details With This Link: <a href="my_orders.php">My Order History Details</a>
</div>
<div style="font-size: 18px;" class="well">
You Have (<?php echo $count_total; ?>) Pending Order(s). To Continue Shop, Please Follow This Link: <a href="../index.php" target="_blank">Continue Shopping</a>
</div>
</div>
<div class="clearfix"> </div><hr />
</div>
</div>
<!--footer-->
<?php include("includes/footer.php"); ?>
<!--//footer-->
</div>
<script>
$(document).ready(function(){
//Cancel Button Action
$("body").delegate("#orderCancel","click",function(){
var buttonID = $(this).attr("actualID");
var placedOn = $(this).attr("actualDate");
var el = this;
if(confirm("Confirm Cancellation!")){
$.ajax({
type:"POST",
url:"cancelData.php",
data: { send_buttonID: buttonID, send_placedOn: placedOn },
success:function(new_entry){
$(el).closest(".msgBox").css("background","red");
$(el).closest(".msgBox").fadeOut(800,function(){
$(el).remove();
swal({
title: new_entry,
text: "Thanks for Using Wispaz!",
icon: "success",
button: "Click to Continue!",
});
});
}
});
}
});
});
</script>
</body>
</html>
<?php } ?>