louie_branch #65
231
admin/index.php
231
admin/index.php
|
@ -13,6 +13,11 @@ if ($_SESSION["userId"] <> "") {
|
|||
if($_SESSION["user_type"]!="admin"){
|
||||
header("location: login.php?alert=Only admins allowed here!");
|
||||
}
|
||||
|
||||
$all_orders = getAllOrder();
|
||||
date_default_timezone_set('Asia/Manila');
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" dir="ltr">
|
||||
|
@ -97,7 +102,7 @@ if($_SESSION["user_type"]!="admin"){
|
|||
<li class="dropdown-header">
|
||||
<img src="assets/img/user/user.png" class="img-circle" alt="User Image" />
|
||||
<div class="d-inline-block">
|
||||
John Deo <small class="pt-1">john.example@gmail.com</small>
|
||||
John Deo <small class="pt-1"><?php echo $_SESSION['email']?></small>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
|
@ -719,8 +724,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 +752,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 +765,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 +1020,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 +1027,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
|
||||
$iterationCount = 0;
|
||||
foreach (array_reverse($all_orders) as $x => $val) {
|
||||
$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' || $orderStatus === 'RETURNED') {
|
||||
$statusClass = '#cb3747';
|
||||
} elseif ($orderStatus === 'TO PAY') {
|
||||
$statusClass = '#50d7ab';
|
||||
} elseif ($orderStatus === 'TO SHIP') {
|
||||
$statusClass = '#9586cd';
|
||||
}
|
||||
elseif ($orderStatus === 'TO RECEIVE') {
|
||||
$statusClass = '#ffc319';
|
||||
} elseif ($orderStatus === 'COMPLETED') {
|
||||
$statusClass = '#88aaf3';
|
||||
}
|
||||
|
||||
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
|
||||
$iterationCount++;
|
||||
if ($iterationCount >= 8) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -83,7 +83,7 @@ if (isset($_SESSION["token"])) {
|
|||
// $token = loginRenew($_SESSION["email"], $_SESSION["password"], $token);
|
||||
// $_SESSION["token"] = $token;
|
||||
|
||||
|
||||
date_default_timezone_set('Asia/Manila');
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
@ -288,7 +288,7 @@ if (isset($_SESSION["token"])) {
|
|||
</div>
|
||||
|
||||
<div class="card-body pt-0 pb-0 table-responsive">
|
||||
<table class="table">
|
||||
<table id='paymentsTable'class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><input type="checkbox"></th>
|
||||
|
@ -312,12 +312,13 @@ if (isset($_SESSION["token"])) {
|
|||
|
||||
if ($orderItems['payment']['status'] === 'PAID') {
|
||||
foreach ($orderItems['items'] as $item) {
|
||||
$displayDate = date('m-d-Y, g:i A', strtotime($orderItems['updatedAt']));
|
||||
$isPayoutCompleted = !empty($orderItems['payout_status']);
|
||||
?>
|
||||
<tr>
|
||||
<td><input type="checkbox" <?php echo $isPayoutCompleted ? 'disabled' : ''; ?>></td>
|
||||
<td><?php echo $orderItems['payment_method']; ?></td>
|
||||
<td><?php echo $item['price']; ?></td>
|
||||
<td><?php echo $orderItems['total_amount']; ?></td>
|
||||
<td>
|
||||
<span class="badge badge-success"><?php echo $orderItems['payment']['status']; ?></span>
|
||||
</td>
|
||||
|
@ -327,7 +328,7 @@ if (isset($_SESSION["token"])) {
|
|||
<td>
|
||||
<a class="text-dark" href=""><?php echo $item['product']['name']; ?></a>
|
||||
</td>
|
||||
<td><?php echo $orderItems['updatedAt']; ?></td>
|
||||
<td><?php echo $displayDate; ?></td>
|
||||
<td hidden><?php echo $orderItems['_id']; ?></td>
|
||||
<td class="text-right">
|
||||
<div class="dropdown show d-inline-block widget-dropdown">
|
||||
|
|
|
@ -19,7 +19,13 @@
|
|||
if ($result > 0) {
|
||||
$_SESSION["isVendor"] = true;
|
||||
}
|
||||
header("location: $url");
|
||||
|
||||
if ($url == "/forgot_password.php" || $url == "/forget_otp.php")
|
||||
{
|
||||
header("location: index.php");
|
||||
}else {
|
||||
header("location: $url");
|
||||
}
|
||||
} else {
|
||||
// $_SESSION["loginError"] = "Invalid email or password. Please try again.";
|
||||
header("location: login.php?error=1");
|
||||
|
|
|
@ -84,6 +84,24 @@ $vendorPayoutData = json_decode($response, true);
|
|||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2@latest/dist/css/select2.min.css" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@latest/dist/js/select2.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
|
||||
<script>
|
||||
function renewToken() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "vendor-payoutsTokenRN.php", true);
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
setInterval(function() {
|
||||
var currentTime = <?php echo time(); ?>;
|
||||
var renewalTime = <?php echo $renewal_time; ?>;
|
||||
var expirationTime = <?php echo $expiration_time; ?>;
|
||||
|
||||
if (currentTime >= renewalTime || currentTime >= expirationTime) {
|
||||
renewToken();
|
||||
}
|
||||
}, 60000);
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body class="shop_page">
|
||||
|
@ -151,7 +169,7 @@ $vendorPayoutData = json_decode($response, true);
|
|||
<div class="ec-vendor-card-body">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-4 mb-5">
|
||||
<div class="col-md-12 mb-5">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h5 class="panel-title"><strong>Upcoming Payout</strong></h5>
|
||||
|
@ -167,9 +185,9 @@ $vendorPayoutData = json_decode($response, true);
|
|||
|
||||
foreach ($upcomingPayout as $x => $val) {
|
||||
$paymentStatus = strtolower($val['payment']['status']);
|
||||
$orderStatus = $val['status'];
|
||||
$orderStatus = strtolower($val['status']);
|
||||
$payoutStatus = empty($val['payout_status']);
|
||||
if(( $paymentStatus == "paid") && ( $orderStatus == "COMPLETED") && ($payoutStatus == true)){
|
||||
if(( $paymentStatus == "paid") && ( $orderStatus == "completed") && ($payoutStatus == true)){
|
||||
$orderAmount = $val['total_amount'];
|
||||
$payoutSum += $orderAmount;
|
||||
}
|
||||
|
@ -201,7 +219,8 @@ $vendorPayoutData = json_decode($response, true);
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-5">
|
||||
<!-- ADDITIONAL PANELS FOR PAYOUTS FOR FUTURE USE, DO NOT REMOVE -->
|
||||
<!-- <div class="col-md-4 mb-5">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h5 class="panel-title"><strong>Payout Generation Schedule</strong></h5>
|
||||
|
@ -242,19 +261,19 @@ $vendorPayoutData = json_decode($response, true);
|
|||
</strong>
|
||||
</div>
|
||||
</h4>
|
||||
<!-- <div class="text-sm mt-3">
|
||||
<- <div class="text-sm mt-3">
|
||||
Payout Generation: Tue, Mar 25, 2024
|
||||
</div>
|
||||
<div class="text-sm">
|
||||
Receive Payout on or before: Wed, Mar 26, 2024
|
||||
</div> -->
|
||||
</div> -
|
||||
<div class="text-sm">
|
||||
Receipient: Philippine National Bank (PNB) Account ending in <?php echo $bankNumEnding?>
|
||||
Receipient: Philippine National Bank (PNB) Account ending in <php echo $bankNumEnding?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="col-md-12 mt-3">
|
||||
<h5 class='m-0'><strong>Payout History</strong></h5>
|
||||
<div class="table-responsive px-4">
|
||||
|
@ -320,7 +339,7 @@ $vendorPayoutData = json_decode($response, true);
|
|||
<div class="modal-dialog modal-xl" style="min-width: 90%;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title fs-5" id="payoutsModalLabel">Payment ID: <span id="payoutIdSpan"></span></h5>
|
||||
<h5 class="modal-title fs-5" id="payoutsModalLabel">Payout ID: <span id="payoutIdSpan"></span></h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
@ -598,6 +617,7 @@ $vendorPayoutData = json_decode($response, true);
|
|||
console.log(response);
|
||||
var grossAmount = response.gross_amount;
|
||||
var totalFees = response.fees_deduction_adjustment;
|
||||
var feeBreakdown = response.breakdown[0].transfer_fee;
|
||||
var netAmount = response.net_amount;
|
||||
var payoutStatus = response.status;
|
||||
payoutStatus = payoutStatus.charAt(0).toUpperCase() + payoutStatus.slice(1).toLowerCase();
|
||||
|
@ -611,12 +631,19 @@ $vendorPayoutData = json_decode($response, true);
|
|||
{
|
||||
|
||||
var paymentType = log.Type;
|
||||
var transDate = log?.Transaction_date;
|
||||
var transDate = new Date(log?.Transaction_date).toLocaleString('en-US', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: 'numeric',
|
||||
minute: '2-digit',
|
||||
hour12: true
|
||||
});
|
||||
var transGrossAmount = log?.Gross_Amount;
|
||||
var transFee = log.Fee;
|
||||
var transNetAmount = log?.Net_Amount;
|
||||
var transDesc = log.Description;
|
||||
|
||||
|
||||
// Append HTML for current transaction log to the transactionLogsHtml string
|
||||
transactionLogsHtml += `
|
||||
<tr>
|
||||
|
@ -650,7 +677,7 @@ $vendorPayoutData = json_decode($response, true);
|
|||
<div class="fw-bold"> Fees, Deductions, Adjustments
|
||||
|
||||
</div>
|
||||
<div> - ${totalFees}</div>
|
||||
<div> - ${totalFees} (${feeBreakdown})</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-between p-2">
|
||||
<div class="fw-bold"> Net Amount</div>
|
||||
|
|
Loading…
Reference in New Issue