<?php
include("header.php");
$query = "SELECT * from orders where payment_status='unpaid'";
$orders = db::getRecords($query);
?>
<section id="breadcrumb-alignment">
<div class="row">
<div class="col-sm-12">
<div class="card">
<div class="card-body">
<div class="d-flex justify-content-between breadcrumb-wrapper">
<nav aria-label="breadcrumb ">
<ol class="breadcrumb mt-2">
<li class="breadcrumb-item"><a href="javascript:void(0)"><i class='bx bx-home-alt mx-1'></i>Dashboard</a></li>
<li class="breadcrumb-item"><a href="javascript:void(0)">Pending Orders</a></li>
</ol>
</nav>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Breadcrumb Alignment Ends -->
<div class="card">
<div class="card-body">
<!-- Row grouping -->
<section id="row-grouping-datatable">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-title">
<h2 class="mb-0 text-center h1 text-primary uppercase">Pending Orders</h2>
</div>
<hr>
<div class="card-datatable table-responsive">
<table id="example" class="table table-bordered" style="width:100%">
<thead>
<tr class="text-center">
<th>Id</th>
<th>Order Id</th>
<th>Customer Name</th>
<th>Phone</th>
<th>Email</th>
<th>Address</th>
<th>City</th>
<th>Total Products</th>
<th>Total Bill</th>
<th>Payment Status</th>
<th>Payment Method</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
$counter=0;
if($orders!=NULL){
foreach($orders as $order){
$counter++;
?>
<tr>
<td class="text-center" > <?php echo $counter; ?></td>
<td class="text-center" > <?php echo $order['order_id']; ?></td>
<td class="text-center" > <?php echo $order['name']; ?></td>
<td class="text-center" > <?php echo $order['phone']; ?></td>
<td class="text-center" > <?php echo $order['email']; ?></td>
<td class="text-center" > <?php echo $order['address']; ?></td>
<td class="text-center" > <?php echo $order['city']; ?></td>
<td class="text-center" > <?php echo $order['total_products']; ?></td>
<td > $<?php echo $order['total_bill']; ?></td>
<td class="text-capitalize" > <?php echo $order['payment_status']; ?></td>
<td class="text-capitalize" > <?php echo $order['payment_method']; ?></td>
<td>
<div class="col-lg-6 col-12">
<div class="btn-group" role="group" aria-label="Basic example">
<span data-toggle="modal" data-target="#edit_modal<?php echo $order['id']; ?>">
<a data-toggle="popover" data-trigger="hover" data-original-title="Paid Order" class="btn bg-success text-white"><i class=" fas fa-money-bill-wave-alt"></i></a>
</span>
<span data-toggle="modal" data-target="#delete_modal<?php echo $order['id']; ?>">
<a data-toggle="popover" data-trigger="hover" data-original-title="Delete Order" class="btn btn-pinterest ml-2"><i class="bx bx-trash"></i></a>
</span>
<span>
<a type="button" class="btn bg-info text-white ml-2" title="View Detail" data-toggle="modal" data-target="#productedit<?php echo $order['id']; ?>"><i class="fa fa-eye"></i></a>
</span>
</div>
</div>
<div class="modal fade" id="productedit<?php echo $order['id']; ?>">
<div class="modal-dialog" role="document">
<div class="modal-content" style="width:640px">
<div class="modal-header bg-info text-white">
<h3 class="modal-title text-white">View Order Detail</h3>
<button type="button" class="close" data-dismiss="modal"><span>×</span>
</button>
</div>
<div class="modal-body table-responsive" style="padding-bottom:0px;">
<?php
$order_id=$order['order_id'];
$query = "SELECT * from order_detail where order_id='$order_id'";
$order_details = db::getRecords($query);
?>
<table id="example5" class="table table-striped patient-list mb-4 dataTablesCard fs-14">
<thead>
<th>order id</th>
<th>product Name</th>
<th>quantity</th>
<th>Zip Code</th>
</thead>
<tr>
<?php
if($order_details!=NULL)
foreach($order_details as $order_detail)
{
$order_id=$order_detail['order_id'];
{
?>
<td>
<div class="text-center align-self-center">
<?php echo $order_detail['order_id']; ?>
</div>
</td>
<td>
<div class="text-center align-self-center">
<?php echo $order_detail['product_name']; ?>
</div>
</td>
<td>
<div class="text-center align-self-center">
<?php echo $order_detail['quantity']; ?>
</div>
</td>
<td>
<div class="text-center align-self-center">
<?php echo $order['postcode']; ?>
</div>
</td>
</tr>
<?php }}?>
</table>
<hr>
<div class="card">
<center>
<h2>ORDER NOTES</h2>
</center>
<center>
<p><?php echo $order['note']; ?></p>
</center>
</div>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div id="edit_modal<?php echo $order['id']; ?>" class="modal fade" data-backdrop="false" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content radius-30">
<div class="modal-header bg-success border-bottom-0">
<h4 class="modal-title my-1 text-white" >Paid Order</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body p-5">
<form action="../action.php" method="post" enctype="multipart/form-data">
<p class="text-primary" >Are You Sure to Paid This</p>
<input type="text" name="paid_id" value="<?php echo $order['order_id']; ?>" hidden>
<hr/>
<div class="form-group">
<button type="submit" class="btn bg-success text-white float-right btn-lg " name="order_paid">Paid Order</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="delete_modal<?php echo $order['id']; ?>" data-backdrop="false" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered ">
<div class="modal-content border-0">
<div class="modal-header bg-danger bg-darken-2 border-bottom-0">
<h5 class="modal-title pt-1" style="color:white;">Delete Order</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form action="../action.php" method="POST">
<div class="modal-body">
<p class="text-danger" >Are You Sure to Delete This</p>
</div>
<input type="text" value="<?php echo $order['order_id']; ?>" id="delete_id" name="delete_id" hidden>
<div class="modal-footer border-top-0">
<button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button>
<button type="submit" name="porder_delete" class="btn btn-outline-danger">Delete</button>
</div>
</form>
</div>
</div>
</div>
</div>
</td>
</tr>
<?php
}
}
?>
</tbody>
<tfoot>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</section>
<!--/ Row grouping -->
</div>
</div>
<?php
include("footer.php");
?>