Added recent orders, daily orders, daily revenue
This commit is contained in:
parent
04903b33ed
commit
3d9d52dfcc
228
admin/index.php
228
admin/index.php
|
@ -13,6 +13,10 @@ if ($_SESSION["userId"] <> "") {
|
|||
if($_SESSION["user_type"]!="admin"){
|
||||
header("location: login.php?alert=Only admins allowed here!");
|
||||
}
|
||||
|
||||
$all_orders = getAllOrder();
|
||||
|
||||
$num_orders = count($all_orders);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" dir="ltr">
|
||||
|
@ -719,8 +723,27 @@ if($_SESSION["user_type"]!="admin"){
|
|||
<div class="col-xl-3 col-sm-6 p-b-15 lbl-card">
|
||||
<div class="card card-mini dash-card card-3">
|
||||
<div class="card-body">
|
||||
<h2 class="mb-1">15,503</h2>
|
||||
<p>Daily Order</p>
|
||||
<?php
|
||||
$currentDate = date('m-d-Y'); // Get current date
|
||||
$orderCount = 0; // Initialize order count
|
||||
$dailyRevenue = 0;
|
||||
|
||||
foreach ($all_orders as $x => $val) {
|
||||
$paymentStatus = strtolower($val['payment']['status']);
|
||||
|
||||
$formattedOrderDate = date('m-d-Y', strtotime($val['order_date']));
|
||||
if ($formattedOrderDate == $currentDate) {
|
||||
$orderCount++;
|
||||
if($paymentStatus == "paid"){
|
||||
$dailyRevenue += $val['total_amount'];
|
||||
} // Increment order count for each order on the current date
|
||||
}
|
||||
}
|
||||
|
||||
$finalDailyRevenue = number_format($dailyRevenue, 2, '.', ',');
|
||||
?>
|
||||
<h2 class="mb-1"><?php echo $orderCount; ?></h2>
|
||||
<p>Today's Order</p>
|
||||
<span class="mdi mdi-package-variant"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -728,9 +751,9 @@ if($_SESSION["user_type"]!="admin"){
|
|||
<div class="col-xl-3 col-sm-6 p-b-15 lbl-card">
|
||||
<div class="card card-mini dash-card card-4">
|
||||
<div class="card-body">
|
||||
<h2 class="mb-1">$98,503</h2>
|
||||
<p>Daily Revenue</p>
|
||||
<span class="mdi mdi-currency-usd"></span>
|
||||
<h2 class="mb-1"> ₱ <?php echo $finalDailyRevenue ?></h2>
|
||||
<p>Today's Revenue</p>
|
||||
<span class="mdi mdi-cash-multiple"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -741,6 +764,7 @@ if($_SESSION["user_type"]!="admin"){
|
|||
<!-- Sales Graph -->
|
||||
<div id="user-acquisition" class="card card-default">
|
||||
<div class="card-header">
|
||||
|
||||
<h2>Sales Report</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
@ -995,9 +1019,6 @@ if($_SESSION["user_type"]!="admin"){
|
|||
<div class="card card-table-border-none card-default recent-orders" id="recent-orders">
|
||||
<div class="card-header justify-content-between">
|
||||
<h2>Recent Orders</h2>
|
||||
<div class="date-range-report">
|
||||
<span></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body pt-0 pb-5">
|
||||
<table class="table card-table table-responsive table-responsive-large"
|
||||
|
@ -1005,155 +1026,60 @@ if($_SESSION["user_type"]!="admin"){
|
|||
<thead>
|
||||
<tr>
|
||||
<th>Order ID</th>
|
||||
<th>Product Name</th>
|
||||
<th class="d-none d-lg-table-cell">Units</th>
|
||||
<th>Customer Name</th>
|
||||
<th class="d-none d-lg-table-cell">Vendor Name</th>
|
||||
<th class="d-none d-lg-table-cell">Total Amount</th>
|
||||
<th class="d-none d-lg-table-cell">Order Date</th>
|
||||
<th class="d-none d-lg-table-cell">Order Cost</th>
|
||||
<th>Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>24541</td>
|
||||
<td>
|
||||
<a class="text-dark" href=""> Coach Swagger</a>
|
||||
</td>
|
||||
<td class="d-none d-lg-table-cell">1 Unit</td>
|
||||
<td class="d-none d-lg-table-cell">Oct 20, 2018</td>
|
||||
<td class="d-none d-lg-table-cell">$230</td>
|
||||
<td>
|
||||
<span class="badge badge-success">Completed</span>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div class="dropdown show d-inline-block widget-dropdown">
|
||||
<a class="dropdown-toggle icon-burger-mini" href=""
|
||||
role="button" id="dropdown-recent-order1"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="false" data-display="static"></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li class="dropdown-item">
|
||||
<a href="#">View</a>
|
||||
</li>
|
||||
<li class="dropdown-item">
|
||||
<a href="#">Remove</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>24541</td>
|
||||
<td>
|
||||
<a class="text-dark" href=""> Toddler Shoes, Gucci Watch</a>
|
||||
</td>
|
||||
<td class="d-none d-lg-table-cell">2 Units</td>
|
||||
<td class="d-none d-lg-table-cell">Nov 15, 2018</td>
|
||||
<td class="d-none d-lg-table-cell">$550</td>
|
||||
<td>
|
||||
<span class="badge badge-primary">Delayed</span>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div class="dropdown show d-inline-block widget-dropdown">
|
||||
<a class="dropdown-toggle icon-burger-mini" href="#"
|
||||
role="button" id="dropdown-recent-order2"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="false" data-display="static"></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li class="dropdown-item">
|
||||
<a href="#">View</a>
|
||||
</li>
|
||||
<li class="dropdown-item">
|
||||
<a href="#">Remove</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>24541</td>
|
||||
<td>
|
||||
<a class="text-dark" href=""> Hat Black Suits</a>
|
||||
</td>
|
||||
<td class="d-none d-lg-table-cell">1 Unit</td>
|
||||
<td class="d-none d-lg-table-cell">Nov 18, 2018</td>
|
||||
<td class="d-none d-lg-table-cell">$325</td>
|
||||
<td>
|
||||
<span class="badge badge-warning">On Hold</span>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div class="dropdown show d-inline-block widget-dropdown">
|
||||
<a class="dropdown-toggle icon-burger-mini" href="#"
|
||||
role="button" id="dropdown-recent-order3"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="false" data-display="static"></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li class="dropdown-item">
|
||||
<a href="#">View</a>
|
||||
</li>
|
||||
<li class="dropdown-item">
|
||||
<a href="#">Remove</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>24541</td>
|
||||
<td>
|
||||
<a class="text-dark" href=""> Backpack Gents, Swimming Cap Slin</a>
|
||||
</td>
|
||||
<td class="d-none d-lg-table-cell">5 Units</td>
|
||||
<td class="d-none d-lg-table-cell">Dec 13, 2018</td>
|
||||
<td class="d-none d-lg-table-cell">$200</td>
|
||||
<td>
|
||||
<span class="badge badge-success">Completed</span>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div class="dropdown show d-inline-block widget-dropdown">
|
||||
<a class="dropdown-toggle icon-burger-mini" href="#"
|
||||
role="button" id="dropdown-recent-order4"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="false" data-display="static"></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li class="dropdown-item">
|
||||
<a href="#">View</a>
|
||||
</li>
|
||||
<li class="dropdown-item">
|
||||
<a href="#">Remove</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>24541</td>
|
||||
<td>
|
||||
<a class="text-dark" href=""> Speed 500 Ignite</a>
|
||||
</td>
|
||||
<td class="d-none d-lg-table-cell">1 Unit</td>
|
||||
<td class="d-none d-lg-table-cell">Dec 23, 2018</td>
|
||||
<td class="d-none d-lg-table-cell">$150</td>
|
||||
<td>
|
||||
<span class="badge badge-danger">Cancelled</span>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div class="dropdown show d-inline-block widget-dropdown">
|
||||
<a class="dropdown-toggle icon-burger-mini" href="#"
|
||||
role="button" id="dropdown-recent-order5"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="false" data-display="static"></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li class="dropdown-item">
|
||||
<a href="#">View</a>
|
||||
</li>
|
||||
<li class="dropdown-item">
|
||||
<a href="#">Remove</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$totalOrders = count($all_orders);
|
||||
|
||||
// Slice the array to get the last 10 elements and reverse it to maintain order
|
||||
$latestOrders = array_slice($all_orders, max(0, $totalOrders - 10), 10);
|
||||
foreach (array_reverse($latestOrders) as $x => $val) {
|
||||
date_default_timezone_set('Asia/Manila');
|
||||
$paymentStatus = strtolower($val['payment']['status']);
|
||||
$formattedOrderDate = date('m-d-Y', strtotime($val['order_date']));
|
||||
$orderId = $val['_id'];
|
||||
$customerName = $val['customer'][0]['name'];
|
||||
$vendorName = $val['items'][0]['vendor_name'];
|
||||
$totalAmount = $val['total_amount'];
|
||||
$orderStatus = strtoupper($val['status']);
|
||||
|
||||
$statusClass = '';
|
||||
if ($orderStatus === 'UNPAID') {
|
||||
$statusClass = '#cb3747';
|
||||
} elseif ($orderStatus === 'TO PAY') {
|
||||
$statusClass = '#4a90e2';
|
||||
} elseif ($orderStatus === 'TO SHIP') {
|
||||
$statusClass = '#ffcc66';
|
||||
}
|
||||
elseif ($orderStatus === 'TO RECEIVE') {
|
||||
$statusClass = '#ffc319';
|
||||
} elseif ($orderStatus === 'COMPLETED') {
|
||||
$statusClass = '#56ba5a';
|
||||
}
|
||||
|
||||
if ($formattedOrderDate == $currentDate) {
|
||||
$displayDate = date('m-d-Y, g:i A', strtotime($val['order_date']));
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $orderId ?></td>
|
||||
<td><?php echo $customerName ?></td>
|
||||
<td><?php echo $vendorName ?></td>
|
||||
<td><?php echo $totalAmount ?></td>
|
||||
<td><?php echo $displayDate ?></td>
|
||||
<td><span style="color: <?php echo $statusClass; ?>"><?php echo $orderStatus ?></span></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue