Merge branch 'main' of https://code.obanana.io/Obanana.Corporation/obanana_b2b_test into stacy_branch
This commit is contained in:
commit
c361a31143
|
@ -11,7 +11,7 @@ $(document).ready(function() {
|
|||
const completedOrdersCount = countCompletedOrders(responseData);
|
||||
const toPayOrdersCount = countToPayOrders(responseData);
|
||||
const toShipOrdersCount = countToShipOrders(responseData);
|
||||
const returnedOrdersCount = countReturnedpOrders(responseData);
|
||||
const returnedOrdersCount = countReturnedOrders(responseData);
|
||||
initializeChart(completedOrdersCount, toPayOrdersCount, toShipOrdersCount, returnedOrdersCount);
|
||||
})
|
||||
.catch(function (error) {
|
||||
|
@ -24,50 +24,65 @@ $(document).ready(function() {
|
|||
}
|
||||
|
||||
|
||||
function countCompletedOrders(data) {
|
||||
let completedOrdersCount = 0;
|
||||
data.forEach(function(order) {
|
||||
function getCurrentMonthData(data) {
|
||||
const now = new Date();
|
||||
const currentMonth = now.getMonth();
|
||||
const currentYear = now.getFullYear();
|
||||
|
||||
return data.filter(order => {
|
||||
const orderDate = new Date(order.order_date);
|
||||
return orderDate.getMonth() === currentMonth && orderDate.getFullYear() === currentYear;
|
||||
});
|
||||
}
|
||||
|
||||
function countCompletedOrders(data) {
|
||||
const filteredData = getCurrentMonthData(data);
|
||||
let completedOrdersCount = 0;
|
||||
filteredData.forEach(function(order) {
|
||||
if (order.status === 'COMPLETED') {
|
||||
completedOrdersCount++;
|
||||
completedOrdersCount++;
|
||||
}
|
||||
});
|
||||
console.log(completedOrdersCount)
|
||||
return completedOrdersCount;
|
||||
}
|
||||
|
||||
|
||||
function countToPayOrders(data) {
|
||||
let toPayOrdersCount = 0;
|
||||
data.forEach(function(order) {
|
||||
});
|
||||
console.log(completedOrdersCount);
|
||||
return completedOrdersCount;
|
||||
}
|
||||
|
||||
function countToPayOrders(data) {
|
||||
const filteredData = getCurrentMonthData(data);
|
||||
let toPayOrdersCount = 0;
|
||||
filteredData.forEach(function(order) {
|
||||
if (order.status === 'TO PAY') {
|
||||
toPayOrdersCount++;
|
||||
toPayOrdersCount++;
|
||||
}
|
||||
});
|
||||
console.log(toPayOrdersCount)
|
||||
return toPayOrdersCount;
|
||||
}
|
||||
|
||||
|
||||
function countToShipOrders(data) {
|
||||
let toShipOrdersCount = 0;
|
||||
data.forEach(function(order) {
|
||||
});
|
||||
console.log(toPayOrdersCount);
|
||||
return toPayOrdersCount;
|
||||
}
|
||||
|
||||
function countToShipOrders(data) {
|
||||
const filteredData = getCurrentMonthData(data);
|
||||
let toShipOrdersCount = 0;
|
||||
filteredData.forEach(function(order) {
|
||||
if (order.status === 'TO SHIP') {
|
||||
toShipOrdersCount++;
|
||||
toShipOrdersCount++;
|
||||
}
|
||||
});
|
||||
console.log(toShipOrdersCount)
|
||||
return toShipOrdersCount;
|
||||
}
|
||||
function countReturnedpOrders(data) {
|
||||
let returnedOrdersCount = 0;
|
||||
data.forEach(function(order) {
|
||||
});
|
||||
console.log(toShipOrdersCount);
|
||||
return toShipOrdersCount;
|
||||
}
|
||||
|
||||
function countReturnedOrders(data) {
|
||||
const filteredData = getCurrentMonthData(data);
|
||||
let returnedOrdersCount = 0;
|
||||
filteredData.forEach(function(order) {
|
||||
if (order.status === 'RETURNED') {
|
||||
returnedOrdersCount++;
|
||||
returnedOrdersCount++;
|
||||
}
|
||||
});
|
||||
console.log(returnedOrdersCount)
|
||||
return returnedOrdersCount;
|
||||
}
|
||||
});
|
||||
console.log(returnedOrdersCount);
|
||||
return returnedOrdersCount;
|
||||
}
|
||||
|
||||
|
||||
function initializeChart(completedOrdersCount , toPayOrdersCount, toShipOrdersCount, returnedOrdersCount) {
|
||||
var doughnut = document.getElementById("doughnut-chart");
|
||||
|
@ -115,43 +130,248 @@ $(document).ready(function() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var acquisition = document.getElementById("salesChart");
|
||||
if (acquisition !== null) {
|
||||
function updateDailyLabels() {
|
||||
var labelsDaily = [];
|
||||
for (let i = 6; i >= 0; i--) {
|
||||
var date = new Date();
|
||||
date.setDate(date.getDate() - i);
|
||||
labelsDaily.push(formatDate(date));
|
||||
}
|
||||
return labelsDaily;
|
||||
}
|
||||
|
||||
function formatDate(date) {
|
||||
const options = { day: 'numeric', month: 'short' }; // E.g., 26 Apr
|
||||
return date.toLocaleDateString('en-US', options);
|
||||
}
|
||||
|
||||
// Updating labelsDaily dynamically
|
||||
var labelsDaily = updateDailyLabels();
|
||||
var labelsMonthly = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
||||
var labelsYearly = ["2021", "2022", "2023", "2024", "2025"];
|
||||
var acqData = [
|
||||
{ //daily data
|
||||
first: [91, 180, 44, 75, 150, 66, 70], //COD
|
||||
second: [300, 44, 177, 76, 23, 189, 12], //ObPay
|
||||
third: [44, 167, 102, 123, 183, 88, 134] //Paymongo
|
||||
},
|
||||
{ //monthly data
|
||||
first: [144, 44, 110, 5, 123, 89, 12], //COD
|
||||
second: [22, 123, 45, 130, 112, 54, 181], //ObPay
|
||||
third: [55, 44, 144, 75, 155, 166, 70] //Paymongo
|
||||
},
|
||||
{ //yearly data
|
||||
first: [134, 80, 123, 65, 171, 33, 22], //COD
|
||||
second: [44, 144, 77, 76, 123, 89, 112], //ObPay
|
||||
third: [156, 23, 165, 88, 112, 54, 181] //Paymongo
|
||||
}
|
||||
];
|
||||
|
||||
var configAcq = {
|
||||
// The type of chart we want to create
|
||||
type: "line",
|
||||
|
||||
// The data for our dataset
|
||||
data: {
|
||||
// labels: [
|
||||
// "4 Jan",
|
||||
// "5 Jan",
|
||||
// "6 Jan",
|
||||
// "7 Jan",
|
||||
// "8 Jan",
|
||||
// "9 Jan",
|
||||
// "10 Jan"
|
||||
// ],
|
||||
datasets: [
|
||||
{
|
||||
label: "Cash on Delivery",
|
||||
backgroundColor: "rgba(52, 116, 212, .2)",
|
||||
borderColor: "rgba(52, 116, 212, .7)",
|
||||
data: acqData[0].first,
|
||||
lineTension: 0.3,
|
||||
pointBackgroundColor: "rgba(52, 116, 212,0)",
|
||||
pointHoverBackgroundColor: "rgba(52, 116, 212,1)",
|
||||
pointHoverRadius: 3,
|
||||
pointHitRadius: 30,
|
||||
pointBorderWidth: 2,
|
||||
pointStyle: "rectRounded"
|
||||
},
|
||||
{
|
||||
label: "ObananaPay",
|
||||
backgroundColor: "rgba(255, 192, 203, .3)",
|
||||
borderColor: "rgba(255, 192, 203, .7)",
|
||||
data: acqData[0].second,
|
||||
lineTension: 0.3,
|
||||
pointBackgroundColor: "rgba(255, 192, 203, 0)",
|
||||
pointHoverBackgroundColor: "rgba(255, 192, 203, 1)",
|
||||
pointHoverRadius: 3,
|
||||
pointHitRadius: 30,
|
||||
pointBorderWidth: 2,
|
||||
pointStyle: "rectRounded"
|
||||
},
|
||||
{
|
||||
label: "Paymongo",
|
||||
backgroundColor: "rgb(178, 251, 212, .3)",
|
||||
borderColor: "rgba(178, 251, 212, .7)",
|
||||
data: acqData[0].third,
|
||||
lineTension: 0.3,
|
||||
pointBackgroundColor: "rgba(178, 251, 212, 0)",
|
||||
pointHoverBackgroundColor: "rgba(178, 251, 212, 1)",
|
||||
pointHoverRadius: 3,
|
||||
pointHitRadius: 30,
|
||||
pointBorderWidth: 2,
|
||||
pointStyle: "rectRounded"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
// Configuration options go here
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
scales: {
|
||||
xAxes: [
|
||||
{
|
||||
gridLines: {
|
||||
display: false
|
||||
}
|
||||
}
|
||||
],
|
||||
yAxes: [
|
||||
{
|
||||
gridLines: {
|
||||
display: true,
|
||||
color: "#eee",
|
||||
zeroLineColor: "#eee"
|
||||
},
|
||||
ticks: {
|
||||
beginAtZero: true,
|
||||
stepSize: 100,
|
||||
max: 1000
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
tooltips: {
|
||||
mode: "index",
|
||||
titleFontColor: "#888",
|
||||
bodyFontColor: "#555",
|
||||
titleFontSize: 12,
|
||||
bodyFontSize: 15,
|
||||
backgroundColor: "rgba(256,256,256,0.95)",
|
||||
displayColors: true,
|
||||
xPadding: 20,
|
||||
yPadding: 10,
|
||||
borderColor: "rgba(220, 220, 220, 0.9)",
|
||||
borderWidth: 2,
|
||||
caretSize: 10,
|
||||
caretPadding: 15
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var ctx = document.getElementById("salesChart").getContext("2d");
|
||||
var lineAcq = new Chart(ctx, configAcq);
|
||||
document.getElementById("acqLegend").innerHTML = lineAcq.generateLegend();
|
||||
|
||||
var items = document.querySelectorAll(
|
||||
"#user-acquisition .nav-tabs .nav-item"
|
||||
);
|
||||
items.forEach(function (item, index) {
|
||||
item.addEventListener("click", function() {
|
||||
// Determine which tab was clicked
|
||||
var selectedTab = this.textContent.trim();
|
||||
|
||||
// Choose data and labels based on the selected tab
|
||||
switch (selectedTab) {
|
||||
case "Daily":
|
||||
configAcq.data.labels = labelsDaily;
|
||||
configAcq.data.datasets[0].data = acqData[0].first;
|
||||
configAcq.data.datasets[1].data = acqData[0].second;
|
||||
configAcq.data.datasets[2].data = acqData[0].third;
|
||||
break;
|
||||
case "Monthly":
|
||||
configAcq.data.labels = labelsMonthly;
|
||||
configAcq.data.datasets[0].data = acqData[1].first;
|
||||
configAcq.data.datasets[1].data = acqData[1].second;
|
||||
configAcq.data.datasets[2].data = acqData[1].third;
|
||||
break;
|
||||
case "Yearly":
|
||||
configAcq.data.labels = labelsYearly;
|
||||
configAcq.data.datasets[0].data = acqData[2].first;
|
||||
configAcq.data.datasets[1].data = acqData[2].second;
|
||||
configAcq.data.datasets[2].data = acqData[2].third;
|
||||
break;
|
||||
}
|
||||
|
||||
lineAcq.update();
|
||||
});
|
||||
});
|
||||
items[0].click();
|
||||
}
|
||||
|
||||
function convertToCSV(data) {
|
||||
const columnTitles = ['ORDER ID', 'STATUS', 'BUYER NAME', 'TOTAL AMOUNT', 'ORDER DATE',
|
||||
'ORDER TIME', 'PRODUCT NAME','PRICE', 'QUANTITY',
|
||||
'VENDOR ID', 'VENDOR NAME',];
|
||||
const header = columnTitles.join(',') + '\n';
|
||||
const body = data.map(order => {
|
||||
const orderDate = new Date(order.order_date).toLocaleDateString('en-US');
|
||||
const orderTime = new Date(order.order_date).toLocaleTimeString('en-US');
|
||||
const productName = order.items.length > 0 ? `"${order.items[0].product.name}"` : '';
|
||||
return [
|
||||
order._id,
|
||||
order.status,
|
||||
order.customer[0]?.name,
|
||||
order.total_amount,
|
||||
orderDate,
|
||||
orderTime,
|
||||
productName,
|
||||
order.items[0]?.price,
|
||||
order.items[0]?.quantity,
|
||||
order.items[0]?.vendor_id,
|
||||
order.items[0]?.vendor_name
|
||||
].join(',');
|
||||
}).join('\n');
|
||||
return header + body;
|
||||
}
|
||||
function downloadCSV(filename) {
|
||||
const csv = convertToCSV(responseData);
|
||||
const blob = new Blob([csv], { type: 'text/csv' });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
const now = new Date();
|
||||
const currentMonth = now.getMonth(); // Months are 0-indexed (0 for January, 11 for December)
|
||||
const currentYear = now.getFullYear();
|
||||
|
||||
const filteredData = data.filter(order => {
|
||||
const orderDate = new Date(order.order_date);
|
||||
return orderDate.getMonth() === currentMonth && orderDate.getFullYear() === currentYear;
|
||||
});
|
||||
|
||||
const columnTitles = [
|
||||
'ORDER ID', 'STATUS', 'BUYER NAME', 'TOTAL AMOUNT', 'METHOD', 'ORDER DATE',
|
||||
'ORDER TIME', 'PRODUCT NAME', 'PRICE', 'QUANTITY', 'VENDOR ID', 'VENDOR NAME'
|
||||
];
|
||||
const header = columnTitles.join(',') + '\n';
|
||||
const body = filteredData.map(order => {
|
||||
const orderDate = new Date(order.order_date).toLocaleDateString('en-US');
|
||||
const orderTime = new Date(order.order_date).toLocaleTimeString('en-US');
|
||||
const productName = order.items.length > 0 ? `"${order.items[0].product.name}"` : '';
|
||||
return [
|
||||
order._id,
|
||||
order.status,
|
||||
order.customer[0]?.name,
|
||||
order.total_amount,
|
||||
order.payment_method,
|
||||
orderDate,
|
||||
orderTime,
|
||||
productName,
|
||||
order.items[0]?.price,
|
||||
order.items[0]?.quantity,
|
||||
order.items[0]?.vendor_id,
|
||||
order.items[0]?.vendor_name
|
||||
].join(',');
|
||||
}).join('\n');
|
||||
return header + body;
|
||||
}
|
||||
|
||||
function downloadCSV() {
|
||||
const now = new Date();
|
||||
const months = ["January", "February", "March", "April", "May", "June",
|
||||
"July", "August", "September", "October", "November", "December"];
|
||||
const currentMonthName = months[now.getMonth()];
|
||||
const filename = `${currentMonthName}_orders_overview.csv`;
|
||||
|
||||
const csv = convertToCSV(responseData); // Ensure responseData is up to date
|
||||
const blob = new Blob([csv], { type: 'text/csv' });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
$('#download-btn').on('click', function(event) {
|
||||
event.preventDefault();
|
||||
|
|
395
admin/index.php
395
admin/index.php
|
@ -14,8 +14,15 @@ if($_SESSION["user_type"]!="admin"){
|
|||
header("location: login.php?alert=Only admins allowed here!");
|
||||
}
|
||||
|
||||
$all_orders = getAllOrder();
|
||||
date_default_timezone_set('Asia/Manila');
|
||||
$currentDate = date('m-d-Y');
|
||||
|
||||
$all_orders = getAllOrder();
|
||||
$all_customers = getAllCustomers();
|
||||
$all_vendors = getAllVendors();
|
||||
|
||||
$allSignups = array_merge($all_customers, $all_vendors);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
@ -107,7 +114,7 @@ date_default_timezone_set('Asia/Manila');
|
|||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<a href="user-profile.html">
|
||||
<a href="#">
|
||||
<i class="mdi mdi-account"></i> My Profile
|
||||
</a>
|
||||
</li>
|
||||
|
@ -707,8 +714,19 @@ date_default_timezone_set('Asia/Manila');
|
|||
<div class="col-xl-3 col-sm-6 p-b-15 lbl-card">
|
||||
<div class="card card-mini dash-card card-1">
|
||||
<div class="card-body">
|
||||
<h2 class="mb-1">1,503</h2>
|
||||
<p>Daily Signups</p>
|
||||
<?php
|
||||
$signupCount = 0;
|
||||
|
||||
foreach ($allSignups as $signup) {
|
||||
$signupDate = date('m-d-Y', strtotime($signup['createdAt']));
|
||||
if ($signupDate === $currentDate) {
|
||||
$signupCount++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<h2 class="mb-1"><?php echo $signupCount; ?></h2>
|
||||
<!-- <h2 class="mb-1">1,503</h2> -->
|
||||
<p>Today's Signups</p>
|
||||
<span class="mdi mdi-account-arrow-left"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -716,9 +734,17 @@ date_default_timezone_set('Asia/Manila');
|
|||
<div class="col-xl-3 col-sm-6 p-b-15 lbl-card">
|
||||
<div class="card card-mini dash-card card-2">
|
||||
<div class="card-body">
|
||||
<h2 class="mb-1">79,503</h2>
|
||||
<p>Daily Visitors</p>
|
||||
<span class="mdi mdi-account-clock"></span>
|
||||
<?php
|
||||
$userCount = 0;
|
||||
|
||||
foreach ($allSignups as $signup) {
|
||||
$userCount++;
|
||||
}
|
||||
?>
|
||||
<h2 class="mb-1"><?php echo $userCount; ?></h2>
|
||||
<!-- <h2 class="mb-1">79,503</h2> -->
|
||||
<p>Total Users</p>
|
||||
<span class="mdi mdi-account-multiple"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -726,18 +752,19 @@ date_default_timezone_set('Asia/Manila');
|
|||
<div class="card card-mini dash-card card-3">
|
||||
<div class="card-body">
|
||||
<?php
|
||||
$currentDate = date('m-d-Y'); // Get current date
|
||||
// Get current date
|
||||
$orderCount = 0; // Initialize order count
|
||||
$dailyRevenue = 0;
|
||||
|
||||
foreach ($all_orders as $x => $val) {
|
||||
foreach (array_reverse($all_orders) as $x => $val) {
|
||||
$paymentStatus = strtolower($val['payment']['status']);
|
||||
|
||||
$returnStatus = strtolower($val['return_order']['status']);
|
||||
$orderStatus = strtolower($val['status']);
|
||||
$formattedOrderDate = date('m-d-Y', strtotime($val['order_date']));
|
||||
if ($formattedOrderDate == $currentDate) {
|
||||
$orderCount++;
|
||||
if($paymentStatus == "paid"){
|
||||
$dailyRevenue += $val['total_amount'];
|
||||
if($paymentStatus == "paid" && (!$returnStatus || $orderStatus != "returned" )){
|
||||
$dailyRevenue += $val['total_amount'];
|
||||
} // Increment order count for each order on the current date
|
||||
}
|
||||
}
|
||||
|
@ -745,7 +772,7 @@ date_default_timezone_set('Asia/Manila');
|
|||
$finalDailyRevenue = number_format($dailyRevenue, 2, '.', ',');
|
||||
?>
|
||||
<h2 class="mb-1"><?php echo $orderCount; ?></h2>
|
||||
<p>Today's Order</p>
|
||||
<p>Today's Orders</p>
|
||||
<span class="mdi mdi-package-variant"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -766,7 +793,6 @@ date_default_timezone_set('Asia/Manila');
|
|||
<!-- Sales Graph -->
|
||||
<div id="user-acquisition" class="card card-default">
|
||||
<div class="card-header">
|
||||
|
||||
<h2>Sales Report</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
@ -774,7 +800,7 @@ date_default_timezone_set('Asia/Manila');
|
|||
role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-bs-toggle="tab" href="#todays" role="tab"
|
||||
aria-selected="true">Today's</a>
|
||||
aria-selected="true">Daily</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-bs-toggle="tab" href="#monthly" role="tab"
|
||||
|
@ -788,7 +814,7 @@ date_default_timezone_set('Asia/Manila');
|
|||
<div class="tab-content pt-4" id="salesReport">
|
||||
<div class="tab-pane fade show active" id="source-medium" role="tabpanel">
|
||||
<div class="mb-6" style="max-height:247px">
|
||||
<canvas id="acquisition" class="chartjs2"></canvas>
|
||||
<canvas id="salesChart" class="chartjs2" style="width: 100%; height: 400px;"></canvas>
|
||||
<div id="acqLegend" class="customLegend mb-2"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -807,7 +833,7 @@ date_default_timezone_set('Asia/Manila');
|
|||
<canvas id="doughnut-chart"></canvas>
|
||||
</div>
|
||||
<a href="#" id="download-btn" class="pb-5 d-block text-center text-muted"><i
|
||||
class="mdi mdi-download mr-2"></i> Download overall report</a>
|
||||
class="mdi mdi-download mr-2"></i> Download Current Month's Overall Report</a>
|
||||
<div class="card-footer d-flex flex-wrap bg-white p-0">
|
||||
<div class="col-6">
|
||||
<div class="p-20">
|
||||
|
@ -1023,26 +1049,31 @@ date_default_timezone_set('Asia/Manila');
|
|||
style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Order ID</th>
|
||||
<th>Payment Method</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>Status</th>
|
||||
<th></th>
|
||||
<th>Return Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$iterationCount = 0;
|
||||
$ordersDisplayed = false;
|
||||
|
||||
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'];
|
||||
$paymentMethod = $val['payment_method'];
|
||||
$customerName = $val['customer'][0]['name'];
|
||||
$vendorName = $val['items'][0]['vendor_name'];
|
||||
$totalAmount = $val['total_amount'];
|
||||
$orderStatus = strtoupper($val['status']);
|
||||
$returnStatus = strtoupper($val['return_order']['status']);
|
||||
|
||||
|
||||
|
||||
$statusClass = '';
|
||||
if ($orderStatus === 'UNPAID' || $orderStatus === 'RETURNED') {
|
||||
|
@ -1059,23 +1090,34 @@ date_default_timezone_set('Asia/Manila');
|
|||
}
|
||||
|
||||
if ($formattedOrderDate == $currentDate) {
|
||||
$ordersDisplayed = true;
|
||||
|
||||
$displayDate = date('m-d-Y, g:i A', strtotime($val['order_date']));
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $orderId ?></td>
|
||||
<td><?php echo $paymentMethod ?></td>
|
||||
<td><?php echo $customerName ?></td>
|
||||
<td><?php echo $vendorName ?></td>
|
||||
<td><?php echo $totalAmount ?></td>
|
||||
<td>₱ <?php echo number_format($totalAmount, 2, '.', ',') ?></td>
|
||||
<td><?php echo $displayDate ?></td>
|
||||
<td><span style="color: <?php echo $statusClass; ?>"><?php echo $orderStatus ?></span></td>
|
||||
<td><?php echo $returnStatus?: "NONE" ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
$iterationCount++;
|
||||
if ($iterationCount >= 8) {
|
||||
break;
|
||||
}
|
||||
$iterationCount++;
|
||||
if ($iterationCount >= 8) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$ordersDisplayed) {
|
||||
?>
|
||||
<tr>
|
||||
<td class="align-self-center">No Recent Orders Yet.</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
|
@ -1086,12 +1128,16 @@ date_default_timezone_set('Asia/Manila');
|
|||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-5">
|
||||
<div class="col-xl-6">
|
||||
<!-- New Customers -->
|
||||
<div class="card ec-cust-card card-table-border-none card-default">
|
||||
<div class="card-header justify-content-between ">
|
||||
<?php
|
||||
$weekAgoDate = date('m-d-Y', strtotime('-7 days'));
|
||||
?>
|
||||
<h2>New Customers</h2>
|
||||
<div>
|
||||
<div> From <?php echo $weekAgoDate; ?> to <?php echo $currentDate; ?></div>
|
||||
<!-- <div>
|
||||
<button class="text-black-50 mr-2 font-size-20">
|
||||
<i class="mdi mdi-cached"></i>
|
||||
</button>
|
||||
|
@ -1106,220 +1152,139 @@ date_default_timezone_set('Asia/Manila');
|
|||
<li class="dropdown-item"><a href="#">Something else here</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="card-body pt-0 pb-15px">
|
||||
<table class="table ">
|
||||
<tbody>
|
||||
<?php
|
||||
$iterationCount = 0;
|
||||
$customersDisplayed = false;
|
||||
|
||||
foreach (array_reverse($all_customers) as $x => $val) {
|
||||
$formattedSignupDate = date('m-d-Y', strtotime($val['createdAt']));
|
||||
$imageUrl = $val['customer_image'];
|
||||
$fullName = $val['first_name'] . ' ' . $val['last_name'];
|
||||
$email = $val['user_email'];
|
||||
if ($formattedSignupDate >= $weekAgoDate && $formattedSignupDate <= $currentDate) {
|
||||
$customersDisplayed = true;
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="media">
|
||||
<div class="media-image mr-3 rounded-circle">
|
||||
<a href="profile.html"><img loading="lazy"
|
||||
class="profile-img rounded-circle w-45"
|
||||
src="assets/img/user/u1.jpg"
|
||||
alt="customer image"></a>
|
||||
<img loading="lazy"
|
||||
class="profile-img rounded-circle w-45"
|
||||
src="<?php echo $imageUrl !== null ? $imageUrl : 'assets/img/user/u1.jpg'; ?>"
|
||||
alt="customer image">
|
||||
</div>
|
||||
<div class="media-body align-self-center">
|
||||
<a href="profile.html">
|
||||
<h6 class="mt-0 text-dark font-weight-medium">Selena
|
||||
Wagner</h6>
|
||||
</a>
|
||||
<small>@selena.oi</small>
|
||||
<h6 class="mt-0 text-dark font-weight-medium"><?php echo $fullName; ?></h6>
|
||||
<small><?php echo $email; ?></small>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>2 Orders</td>
|
||||
<td class="text-dark d-none d-md-block">$150</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="media">
|
||||
<div class="media-image mr-3 rounded-circle">
|
||||
<a href="profile.html"><img loading="lazy"
|
||||
class="profile-img rounded-circle w-45"
|
||||
src="assets/img/user/u2.jpg"
|
||||
alt="customer image"></a>
|
||||
</div>
|
||||
<div class="media-body align-self-center">
|
||||
<a href="profile.html">
|
||||
<h6 class="mt-0 text-dark font-weight-medium">Walter
|
||||
Reuter</h6>
|
||||
</a>
|
||||
<small>@walter.me</small>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>5 Orders</td>
|
||||
<td class="text-dark d-none d-md-block">$200</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="media">
|
||||
<div class="media-image mr-3 rounded-circle">
|
||||
<a href="profile.html"><img loading="lazy"
|
||||
class="profile-img rounded-circle w-45"
|
||||
src="assets/img/user/u3.jpg"
|
||||
alt="customer image"></a>
|
||||
</div>
|
||||
<div class="media-body align-self-center">
|
||||
<a href="profile.html">
|
||||
<h6 class="mt-0 text-dark font-weight-medium">Larissa
|
||||
Gebhardt</h6>
|
||||
</a>
|
||||
<small>@larissa.gb</small>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>1 Order</td>
|
||||
<td class="text-dark d-none d-md-block">$50</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="media">
|
||||
<div class="media-image mr-3 rounded-circle">
|
||||
<a href="profile.html"><img loading="lazy"
|
||||
class="profile-img rounded-circle w-45"
|
||||
src="assets/img/user/u4.jpg"
|
||||
alt="customer image"></a>
|
||||
</div>
|
||||
<div class="media-body align-self-center">
|
||||
<a href="profile.html">
|
||||
<h6 class="mt-0 text-dark font-weight-medium">Albrecht
|
||||
Straub</h6>
|
||||
</a>
|
||||
<small>@albrech.as</small>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>2 Orders</td>
|
||||
<td class="text-dark d-none d-md-block">$100</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="media">
|
||||
<div class="media-image mr-3 rounded-circle">
|
||||
<a href="profile.html"><img loading="lazy"
|
||||
class="profile-img rounded-circle w-45"
|
||||
src="assets/img/user/u5.jpg"
|
||||
alt="customer image"></a>
|
||||
</div>
|
||||
<div class="media-body align-self-center">
|
||||
<a href="profile.html">
|
||||
<h6 class="mt-0 text-dark font-weight-medium">Leopold
|
||||
Ebert</h6>
|
||||
</a>
|
||||
<small>@leopold.et</small>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>1 Order</td>
|
||||
<td class="text-dark d-none d-md-block">$60</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="media">
|
||||
<div class="media-image mr-3 rounded-circle">
|
||||
<a href="profile.html"><img loading="lazy"
|
||||
class="profile-img rounded-circle w-45"
|
||||
src="assets/img/user/u3.jpg"
|
||||
alt="customer image"></a>
|
||||
</div>
|
||||
<div class="media-body align-self-center">
|
||||
<a href="profile.html">
|
||||
<h6 class="mt-0 text-dark font-weight-medium">Larissa
|
||||
Gebhardt</h6>
|
||||
</a>
|
||||
<small>@larissa.gb</small>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>1 Order</td>
|
||||
<td class="text-dark d-none d-md-block">$50</td>
|
||||
<td><?php echo $formattedSignupDate?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$iterationCount++;
|
||||
if ($iterationCount >= 8) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$customersDisplayed) {
|
||||
?>
|
||||
<tr>
|
||||
<td class="align-self-center">No new customers in the past week</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xl-7">
|
||||
<!-- Top Products -->
|
||||
<div class="card card-default ec-card-top-prod">
|
||||
<div class="card-header justify-content-between">
|
||||
<h2>Top Products</h2>
|
||||
<div>
|
||||
<button class="text-black-50 mr-2 font-size-20"><i
|
||||
class="mdi mdi-cached"></i></button>
|
||||
<div class="col-xl-6">
|
||||
<!-- New Customers -->
|
||||
<div class="card ec-cust-card card-table-border-none card-default">
|
||||
<div class="card-header justify-content-between ">
|
||||
<?php
|
||||
$weekAgoDate = date('m-d-Y', strtotime('-7 days'));
|
||||
?>
|
||||
<h2>New Vendors</h2>
|
||||
<div> From <?php echo $weekAgoDate; ?> to <?php echo $currentDate; ?></div>
|
||||
<!-- <div>
|
||||
<button class="text-black-50 mr-2 font-size-20">
|
||||
<i class="mdi mdi-cached"></i>
|
||||
</button>
|
||||
<div class="dropdown show d-inline-block widget-dropdown">
|
||||
<a class="dropdown-toggle icon-burger-mini" href="#" role="button"
|
||||
id="dropdown-product" data-bs-toggle="dropdown" aria-haspopup="true"
|
||||
id="dropdown-customar" 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="#">Update Data</a></li>
|
||||
<li class="dropdown-item"><a href="#">Detailed Log</a></li>
|
||||
<li class="dropdown-item"><a href="#">Statistics</a></li>
|
||||
<li class="dropdown-item"><a href="#">Clear Data</a></li>
|
||||
<li class="dropdown-item"><a href="#">Action</a></li>
|
||||
<li class="dropdown-item"><a href="#">Another action</a></li>
|
||||
<li class="dropdown-item"><a href="#">Something else here</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="card-body mt-10px mb-10px py-0">
|
||||
<div class="row media d-flex pt-15px pb-15px">
|
||||
<div
|
||||
class="col-lg-3 col-md-3 col-2 media-image align-self-center rounded">
|
||||
<a href="#"><img loading="lazy" src="assets/img/products/p1.jpg" alt="customer image"></a>
|
||||
</div>
|
||||
<div class="col-lg-9 col-md-9 col-10 media-body align-self-center ec-pos">
|
||||
<a href="#">
|
||||
<h6 class="mb-10px text-dark font-weight-medium">Baby cotton shoes</h6>
|
||||
</a>
|
||||
<p class="float-md-right sale"><span class="mr-2">58</span>Sales</p>
|
||||
<p class="d-none d-md-block">Statement belting with double-turnlock hardware
|
||||
adds “swagger” to a simple.</p>
|
||||
<p class="mb-0 ec-price">
|
||||
<span class="text-dark">$520</span>
|
||||
<del>$580</del>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row media d-flex pt-15px pb-15px">
|
||||
<div
|
||||
class="col-lg-3 col-md-3 col-2 media-image align-self-center rounded">
|
||||
<a href="#"><img loading="lazy" src="assets/img/products/p2.jpg" alt="customer image"></a>
|
||||
</div>
|
||||
<div class="col-lg-9 col-md-9 col-10 media-body align-self-center ec-pos">
|
||||
<a href="#">
|
||||
<h6 class="mb-10px text-dark font-weight-medium">Hoodies for men</h6>
|
||||
</a>
|
||||
<p class="float-md-right sale"><span class="mr-2">20</span>Sales</p>
|
||||
<p class="d-none d-md-block">Statement belting with double-turnlock hardware
|
||||
adds “swagger” to a simple.</p>
|
||||
<p class="mb-0 ec-price">
|
||||
<span class="text-dark">$250</span>
|
||||
<del>$300</del>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row media d-flex pt-15px pb-15px">
|
||||
<div
|
||||
class="col-lg-3 col-md-3 col-2 media-image align-self-center rounded">
|
||||
<a href="#"><img loading="lazy" src="assets/img/products/p3.jpg" alt="customer image"></a>
|
||||
</div>
|
||||
<div class="col-lg-9 col-md-9 col-10 media-body align-self-center ec-pos">
|
||||
<a href="#">
|
||||
<h6 class="mb-10px text-dark font-weight-medium">Long slive t-shirt</h6>
|
||||
</a>
|
||||
<p class="float-md-right sale"><span class="mr-2">10</span>Sales</p>
|
||||
<p class="d-none d-md-block">Statement belting with double-turnlock hardware
|
||||
adds “swagger” to a simple.</p>
|
||||
<p class="mb-0 ec-price">
|
||||
<span class="text-dark">$480</span>
|
||||
<del>$654</del>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body pt-0 pb-15px">
|
||||
<table class="table ">
|
||||
<tbody>
|
||||
<?php
|
||||
$iterationCount = 0;
|
||||
$vendorsDisplayed = false;
|
||||
foreach (array_reverse($all_vendors) as $x => $val) {
|
||||
$formattedSignupDate = date('m-d-Y', strtotime($val['createdAt']));
|
||||
$imageUrl = $val['vendor_image'];
|
||||
$shopName = $val['user_login'];
|
||||
$fullName = $val['first_name'] . ' ' . $val['last_name'];
|
||||
$email = $val['user_email'];
|
||||
if ($formattedSignupDate >= $weekAgoDate && $formattedSignupDate <= $currentDate) {
|
||||
$vendorsDisplayed = true;
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="media">
|
||||
<div class="media-image mr-3 rounded-circle">
|
||||
<img loading="lazy"
|
||||
class="profile-img rounded-circle w-45"
|
||||
src="<?php echo $imageUrl !== null ? $imageUrl : 'assets/img/user/u1.jpg'; ?>"
|
||||
alt="customer image">
|
||||
</div>
|
||||
<div class="media-body align-self-center">
|
||||
<h6 class="mt-0 text-dark font-weight-medium"><?php echo $shopName; ?></h6>
|
||||
<small><?php echo $fullName; ?> || </small>
|
||||
<small><?php echo $email; ?></small>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td><?php echo $formattedSignupDate?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$iterationCount++;
|
||||
if ($iterationCount >= 8) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$vendorsDisplayed) {
|
||||
?>
|
||||
<tr>
|
||||
<td class="align-self-center">No new vendors in the past week</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1333,7 +1298,7 @@ date_default_timezone_set('Asia/Manila');
|
|||
<p>
|
||||
Copyright © <span id="ec-year"></span><a class="text-primary"
|
||||
href="https://themeforest.net/user/ashishmaraviya" target="_blank"> Ekka Admin Dashboard</a>. All Rights Reserved.
|
||||
</p>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ if ($_SESSION["user_type"] != "admin") {
|
|||
header("location: login.php?alert=Only admins allowed here!");
|
||||
}
|
||||
$orders = getAllOrder();
|
||||
$allorders = json_encode($orders, true);
|
||||
// $allorders = json_encode($orders, true);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
@ -24,9 +24,9 @@ $allorders = json_encode($orders, true);
|
|||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="description" content="Ekka - Admin Dashboard HTML Template.">
|
||||
<meta name="description" content="oBanana B2B - Admin Dashboard">
|
||||
|
||||
<title>Ekka - Admin Dashboard HTML Template.</title>
|
||||
<title>oBanana B2B - Admin Dashboard</title>
|
||||
|
||||
<!-- GOOGLE FONTS -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
|
@ -82,7 +82,8 @@ $allorders = json_encode($orders, true);
|
|||
<table id="responsive-data-table" class="table" style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Updated Date</th>
|
||||
<th>Order Date</th>
|
||||
<th>Customer</th>
|
||||
<th>Vendor</th>
|
||||
<th>Product</th>
|
||||
|
@ -102,6 +103,7 @@ $allorders = json_encode($orders, true);
|
|||
?>
|
||||
<tr>
|
||||
<td><?php echo date('Y-m-d', strtotime($order['updatedAt'])) ?></td>
|
||||
<td><?php echo date('Y-m-d', strtotime($order['order_date'])) ?></td>
|
||||
<td><?php echo $order['customer'][0]['name'] ?></td>
|
||||
<td><?php echo $order['items'][0]['vendor_name'] ?></td>
|
||||
<td><?php echo $order['items'][0]['product']['name'] ?></td>
|
||||
|
|
|
@ -2010,3 +2010,48 @@ function updatePayout($token, $payoutId)
|
|||
return $response;
|
||||
}
|
||||
|
||||
function getAllCustomers ()
|
||||
{
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => "https://" . $_SESSION["data_endpoint"] . "/api/v1/customers",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'X-Api-Key: {{apiKey}}'
|
||||
),
|
||||
));
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
$json = json_decode($response, true);
|
||||
|
||||
return $json;
|
||||
}
|
||||
|
||||
function getAllVendors ()
|
||||
{
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => "https://" . $_SESSION["data_endpoint"] . "/api/v1/vendors",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'X-Api-Key: {{apiKey}}'
|
||||
),
|
||||
));
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
$json = json_decode($response, true);
|
||||
|
||||
return $json;
|
||||
}
|
|
@ -112,9 +112,6 @@ $_SESSION["isVendor"] = false;
|
|||
<input type="password" name="password" placeholder="Enter your password" required />
|
||||
</span>
|
||||
<p><input type="checkbox" required> I accept this Terms & Conditions and Privacy Policy </p>
|
||||
<span class="ec-login-wrap ec-login-fp">
|
||||
<label><a href="#">Forgot Password?</a></label>
|
||||
</span>
|
||||
<span class="ec-login-wrap ec-login-btn">
|
||||
<button class="btn btn-primary" type="submit">Register</button>
|
||||
</span>
|
||||
|
|
|
@ -19,6 +19,11 @@ if ($_SESSION["userId"] <> "") {
|
|||
$_SESSION["isLoggedIn"] = false;
|
||||
header("location: login.php");
|
||||
}
|
||||
|
||||
if ($_SESSION["isCustomer"] == true) {
|
||||
header("location: user-profile.php");
|
||||
}
|
||||
|
||||
$products = productList();
|
||||
?>
|
||||
<!--=========================================================
|
||||
|
|
|
@ -15,6 +15,11 @@ if ($_SESSION["userId"] <> "") {
|
|||
$_SESSION["isLoggedIn"] = false;
|
||||
header("location: login.php");
|
||||
}
|
||||
|
||||
if ($_SESSION["isCustomer"] == true) {
|
||||
header("location: user-profile.php");
|
||||
}
|
||||
|
||||
if (isset($_GET['id'])) {
|
||||
$_SESSION['vendorOrderId'] = $_GET['id'];
|
||||
}
|
||||
|
|
|
@ -211,9 +211,16 @@ $vendorPayoutData = json_decode($response, true);
|
|||
$vendorResponse = getVendorbyId($vendorId);
|
||||
$vendorInformation = json_decode($vendorResponse, true);
|
||||
$bankAccountNumber = $vendorInformation['bank_acount_details'][0]['bank_account_number'];
|
||||
$bankDetails = $vendorInformation['bank_acount_details'];
|
||||
foreach ($bankDetails as $details) {
|
||||
if ($details['bank_payout'] === true) {
|
||||
$bankName = $details['bank_name'];
|
||||
$bankAccountNumber = $details['bank_account_number'];
|
||||
}
|
||||
}
|
||||
$bankNumEnding = substr($bankAccountNumber, -3);
|
||||
?>
|
||||
Receipient: Philippine National Bank (PNB) Account ending in <?php echo $bankNumEnding?>
|
||||
Receipient: <?php echo $bankName; ?> Account ending in <?php echo $bankNumEnding?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue