Merge branch 'main' of https://code.obanana.io/Obanana.Corporation/obanana_b2b_test into mark_4
This commit is contained in:
commit
0c368796a7
|
@ -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>
|
||||
|
|
|
@ -101,7 +101,7 @@ $users = getUsers();
|
|||
<div class="row">
|
||||
<?php
|
||||
$totalUsers = count($users);
|
||||
$usersPerPage = 20;
|
||||
$usersPerPage = 15;
|
||||
$totalPages = ceil($totalUsers / $usersPerPage);
|
||||
$currentPage = isset($_GET['page']) ? $_GET['page'] : 1;
|
||||
$start = ($currentPage - 1) * $usersPerPage;
|
||||
|
@ -266,8 +266,31 @@ $users = getUsers();
|
|||
<!-- Pagination Links -->
|
||||
<div class="pagination">
|
||||
<?php
|
||||
for ($page = 1; $page <= $totalPages; $page++) {
|
||||
/* for ($page = 1; $page <= $totalPages; $page++) {
|
||||
echo '<a href="?page=' . $page . '">' . $page . '</a>';
|
||||
} */
|
||||
$maxPages = 5; // Maximum number of pages to display
|
||||
$ellipsis = true; // Whether to show ellipsis if there are more pages
|
||||
|
||||
$startPage = max(1, $currentPage - floor($maxPages / 2));
|
||||
$endPage = min($totalPages, $startPage + $maxPages - 1);
|
||||
|
||||
if ($ellipsis && $startPage > 1) {
|
||||
echo '<a href="?page=1">1</a>';
|
||||
if ($startPage > 2) {
|
||||
echo '<span>...</span>';
|
||||
}
|
||||
}
|
||||
|
||||
for ($page = $startPage; $page <= $endPage; $page++) {
|
||||
echo '<a href="?page=' . $page . '">' . $page . '</a>';
|
||||
}
|
||||
|
||||
if ($ellipsis && $endPage < $totalPages) {
|
||||
if ($endPage < $totalPages - 1) {
|
||||
echo '<span>...</span>';
|
||||
}
|
||||
echo '<a href="?page=' . $totalPages . '">' . $totalPages . '</a>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
|
|
@ -814,11 +814,32 @@ function validateEmail(vendorId) {
|
|||
// echo "<a href='?page=$i' class='" . ($currentpage == $i ? 'active' : '') . "'>$i</a>";
|
||||
// }
|
||||
|
||||
if ($totalVendors >= $vendorsPerPage) {
|
||||
/* if ($totalVendors >= $vendorsPerPage) {
|
||||
for ($i = 1; $i <= $totalPages; $i++) {
|
||||
echo "<a href='?page=$i' class='" . ($currentpage == $i ? 'active' : '') . "'>$i</a>";
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
$start = max(1, $currentpage - 2);
|
||||
$end = min($totalPages, $start + 4);
|
||||
|
||||
if ($start > 1) {
|
||||
echo "<a href='?page=1'>1</a>";
|
||||
if ($start > 2) {
|
||||
echo "<span> ... </span>";
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = $start; $i <= $end; $i++) {
|
||||
echo "<a href='?page=$i' class='" . ($currentpage == $i ? 'active' : '') . "'>$i</a> ";
|
||||
}
|
||||
|
||||
if ($end < $totalPages) {
|
||||
if ($end < $totalPages - 1) {
|
||||
echo "<span> ... </span>";
|
||||
}
|
||||
echo "<a href='?page=$totalPages'>$totalPages</a>";
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -65,21 +65,21 @@ foreach ($vendorPayouts as $payout) {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($_SESSION["token"])) {
|
||||
$token = $_SESSION["token"];
|
||||
$token_parts = explode(".", $token);
|
||||
$token_payload = base64_decode($token_parts[1]);
|
||||
$token_data = json_decode($token_payload);
|
||||
// if (isset($_SESSION["token"])) {
|
||||
// $token = $_SESSION["token"];
|
||||
// $token_parts = explode(".", $token);
|
||||
// $token_payload = base64_decode($token_parts[1]);
|
||||
// $token_data = json_decode($token_payload);
|
||||
|
||||
$issued_at_time = $token_data->iat;
|
||||
$expiration_time = $token_data->exp;
|
||||
$renewal_time = $issued_at_time + 3000;
|
||||
// $issued_at_time = $token_data->iat;
|
||||
// $expiration_time = $token_data->exp;
|
||||
// $renewal_time = $issued_at_time + 200;
|
||||
|
||||
// if (time() >= $renewal_time || time() >= $expiration_time) {
|
||||
// header("Location: token-renew.php");
|
||||
// exit;
|
||||
// }
|
||||
}
|
||||
// // if (time() >= $renewal_time || time() >= $expiration_time) {
|
||||
// // header("Location: token-renew.php");
|
||||
// // exit;
|
||||
// // }
|
||||
// }
|
||||
// $token = loginRenew($_SESSION["email"], $_SESSION["password"], $token);
|
||||
// $_SESSION["token"] = $token;
|
||||
|
||||
|
@ -122,26 +122,54 @@ date_default_timezone_set('Asia/Manila');
|
|||
}
|
||||
|
||||
setInterval(function() {
|
||||
var currentTime = <?php echo time(); ?>;
|
||||
var renewalTime = <?php echo $renewal_time; ?>;
|
||||
var expirationTime = <?php echo $expiration_time; ?>;
|
||||
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> -->
|
||||
<script>
|
||||
function renewToken() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "token-renew.php", true);
|
||||
xhr.send();
|
||||
console.log("Token renewed at: " + new Date().toLocaleString());
|
||||
}
|
||||
|
||||
var token_parts = "<?php echo $_SESSION["token"]; ?>".split(".");
|
||||
console.log("Token Payload: " + token_parts[1]);
|
||||
var token_payload = atob(token_parts[1]);
|
||||
var token_data = JSON.parse(token_payload);
|
||||
|
||||
|
||||
var issued_at_time = token_data.iat;
|
||||
var expiration_time = token_data.exp;
|
||||
var renewal_time = issued_at_time + 200;
|
||||
console.log("Issued At Time: " + new Date(issued_at_time * 1000).toLocaleString());
|
||||
console.log("Expiration Time: " + new Date(expiration_time * 1000).toLocaleString());
|
||||
console.log("Renewal Time: " + new Date(renewal_time * 1000).toLocaleString());
|
||||
function renewToken() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "token-renew.php", true);
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
|
||||
var newToken = xhr.responseText;
|
||||
token_parts = newToken.split(".");
|
||||
token_payload = atob(token_parts[1]);
|
||||
token_data = JSON.parse(token_payload);
|
||||
issued_at_time = token_data.iat
|
||||
renewal_time = issued_at_time + 200
|
||||
expiration_time = token_data.exp;
|
||||
|
||||
console.log("New Token: " + token_parts)
|
||||
console.log("Token renewed at: " + new Date().toLocaleString());
|
||||
console.log("New expiration time: " + new Date(expiration_time * 1000).toLocaleString());
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
|
||||
setInterval(function() {
|
||||
var currentTime = <?php echo time(); ?>;
|
||||
var renewalTime = <?php echo $renewal_time; ?>;
|
||||
var expirationTime = <?php echo $expiration_time; ?>;
|
||||
var currentTime = Date.now() / 1000;
|
||||
var renewalTime = renewal_time;
|
||||
var expirationTime = expiration_time;
|
||||
console.log("Current Time: " + new Date(currentTime * 1000).toLocaleString());
|
||||
console.log("Renewal Time: " + new Date(renewalTime * 1000).toLocaleString());
|
||||
console.log("Expiration Time: " + new Date(expirationTime * 1000).toLocaleString());
|
||||
|
|
|
@ -507,16 +507,16 @@ function popupAddToCart(
|
|||
console.error("Error parsing customer JSON: ", error);
|
||||
}
|
||||
let vendorData = decodeURIComponent(productVendor);
|
||||
console.log(vendorData);
|
||||
|
||||
var vendorObj = JSON.parse(vendorData);
|
||||
|
||||
var sessionToken = token;
|
||||
var productImage = productObj.images;
|
||||
var productId = productObj._id;
|
||||
var productName = productObj.product_name;
|
||||
var productPrice = productObj.sale_price
|
||||
? productObj.sale_price
|
||||
: productObj.regular_price;
|
||||
// var productPrice = productObj.sale_price
|
||||
// ? productObj.sale_price
|
||||
// : productObj.regular_price;
|
||||
var shippingFee =
|
||||
productObj.shipping_fee && productObj.shipping_fee !== ""
|
||||
? productObj.shipping_fee
|
||||
|
@ -533,7 +533,7 @@ function popupAddToCart(
|
|||
console.log("Product Image: " + productImage);
|
||||
console.log("Product ID: " + productId);
|
||||
console.log("Product Name: " + productName);
|
||||
console.log("Product Price: " + productPrice);
|
||||
// console.log("Product Price: " + productPrice);
|
||||
console.log("Product Vendor ID: " + productVendorId);
|
||||
console.log("Product Vendor Name: " + vendorName);
|
||||
console.log("Product Quantity: " + productQuantity);
|
||||
|
@ -541,6 +541,53 @@ function popupAddToCart(
|
|||
console.log("Customer Names: " + customerName);
|
||||
|
||||
login(email, password, function (token) {
|
||||
var priceMatrix = productObj.price_matrix !=="" ? productObj.price_matrix : "[]";
|
||||
// var quantityValue = productData.quantity;
|
||||
var minimumOrder = productObj.minimum_order;
|
||||
|
||||
var quantityValue = productObj.minimum_order =="" ? productQuantity : '1';
|
||||
|
||||
|
||||
|
||||
// var minimumOrder = productObj.minimum_order !=="" ? productObj.minimum_order : '1';
|
||||
// var quantityValue = minimumOrder ;
|
||||
|
||||
if (parseInt(quantityValue) < minimumOrder) {
|
||||
quantityValue = minimumOrder;
|
||||
alert("The minimum order quantity is " + minimumOrder);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Apply Matrix
|
||||
var productPrice;
|
||||
var foundPrice = false;
|
||||
|
||||
if (priceMatrix.length > 0) {
|
||||
for (var i = 0; i < priceMatrix.length; i++) {
|
||||
for (var j = 0; j < priceMatrix[i].length; j++) {
|
||||
var currentQuantity = parseFloat(priceMatrix[i][j].quantity);
|
||||
var nextQuantity = (j < priceMatrix[i].length - 1) ? parseFloat(priceMatrix[i][j + 1].quantity) : Infinity;
|
||||
|
||||
if (quantityValue >= currentQuantity && quantityValue < nextQuantity) {
|
||||
productPrice = parseFloat(priceMatrix[i][j].price);
|
||||
foundPrice = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundPrice) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundPrice) {
|
||||
productPrice = productObj.sale_price ? productObj.sale_price : productObj.regular_price;
|
||||
// productPrice = parseFloat(document.getElementById("productNewPrice") ? document.getElementById("productNewPrice").innerText : document.getElementById("productPrice"));
|
||||
// productPrice = parseFloat(document.getElementById("productNewPrice") ? document.getElementById("productNewPrice").innerText : document.getElementById("productPrice"));
|
||||
// productPrice;
|
||||
}
|
||||
|
||||
var productData = {
|
||||
product: {
|
||||
product_image: productImage,
|
||||
|
@ -548,11 +595,14 @@ function popupAddToCart(
|
|||
name: productName,
|
||||
},
|
||||
price: productPrice,
|
||||
quantity: productQuantity,
|
||||
quantity: quantityValue,
|
||||
vendor_id: productVendorId,
|
||||
vendor_name: vendorName,
|
||||
};
|
||||
|
||||
//Apply Matrix
|
||||
console.log("Product dataa:", productData);
|
||||
|
||||
var totalAmount = productData.price * productData.quantity;
|
||||
|
||||
var customerData = {
|
||||
|
@ -560,6 +610,10 @@ function popupAddToCart(
|
|||
name: customerName,
|
||||
};
|
||||
|
||||
console.log("Customer data:", customerData);
|
||||
// console.log("Price Matrix: " + priceMatrix);
|
||||
|
||||
// Check if the product is already in the order API
|
||||
var existingOrder;
|
||||
var orderCheckXhr = new XMLHttpRequest();
|
||||
orderCheckXhr.open(
|
||||
|
@ -635,35 +689,36 @@ function popupAddToCart(
|
|||
var cartList = document.querySelector(".eccart-pro-items");
|
||||
|
||||
var newOrder = document.createElement("li");
|
||||
newOrder.className = "rowcart";
|
||||
newOrder.id = `order_${response._id}`;
|
||||
var imageUrl = response.items[0].product.product_image
|
||||
? response.items[0].product.product_image.split(",")[0].trim()
|
||||
: "https://api.obanana.com/images/storage/web_images/1709002636671-viber_image_2024-02-22_15-54-42-498.png";
|
||||
console.log(response);
|
||||
|
||||
newOrder.innerHTML = `
|
||||
<input type="checkbox" class="rowcartCheckbox" name="cart-item[]" value="${response._id}"/>
|
||||
|
||||
<a href="product-left-sidebar.php?id=${response.items[0]._id}" class="sidekka_pro_img">
|
||||
<img src="${imageUrl}" alt="product" />
|
||||
</a>
|
||||
<div class="ec-pro-content">
|
||||
<a href="product-left-sidebar.php?id=${response.items[0]._id}" class="cart_pro_title">${response.items[0].product.name}</a>
|
||||
<span class="cart-price" id="cart-price">
|
||||
Unit Price: <span>${response.items[0].price}</span>
|
||||
</span>
|
||||
<span id="subtotal-${response._id}" class="subtotal-${response._id}">Subtotal: ${totalAmount}</span>
|
||||
<!-- 02-16-2024 Stacy added style -->
|
||||
<div class="qty-plus-minuses" style="display:flex; overflow:visible; align-items:center; padding-top:10px;">
|
||||
<div class="qty-btn" style="color:#ffaa00; font-size:35px; padding-right:5px; cursor: pointer;" onclick="qtyDecrement('${response._id}', '${response.items[0]._id}', true)">-</div>
|
||||
<input style="width:80px; height:40px" id="qty-input-${response.items[0]._id}" class="qty-input" type="number" name="ec_qtybtn" value="${productData.quantity}" oninput="handleQtyInput(this, '${response._id}', '${response.items[0]._id}', true)"/>
|
||||
<div class="qty-btn" style="color:#ffaa00; font-size:30px; padding-left:5px; cursor: pointer;" onclick="qtyIncrement('${response._id}', '${response.items[0]._id}', true)">+</div>
|
||||
<a href="#" style="margin-left:10px;" class="removeCart" onclick="deleteOrder('${response._id}')"><i class="ecicon eci-trash" style="padding:20px; opacity:70%"></i></a>
|
||||
</div>
|
||||
<!-- 02-16-2024 Stacy added style -->
|
||||
</div>
|
||||
`;
|
||||
newOrder.innerHTML = `
|
||||
<a href="product-left-sidebar.php?id=${response.items[0]._id}" class="sidekka_pro_img">
|
||||
<img src="${imageUrl}" alt="product" />
|
||||
</a>
|
||||
<div class="ec-pro-content">
|
||||
<a href="product-left-sidebar.php?id=${response.items[0]._id}" class="cart_pro_title">${response.items[0].product.name}</a>
|
||||
<span class="cart-price" id="cart-price">Unit Price11: <span>${response.items[0].price}</span>
|
||||
<div class="cart-price">
|
||||
<span id="subtotal-${response._id}" class="subtotal-${response._id}">Subtotal: ${totalAmount}</span>
|
||||
</div>
|
||||
<!-- 02-16-2024 Stacy added style -->
|
||||
<div class="qty-plus-minuses" style="display:flex; overflow:visible; align-items:center; margin-top:5px;">
|
||||
<div class="qty-btn" style="color:#ffaa00; font-size:35px; margin-right:5px; cursor: pointer;" onclick="qtyDecrement('${response._id}', '${response.items[0]._id}', true)"
|
||||
onmouseover="this.style.color='#a15d00'" onmouseout="this.style.color='#ffaa00'">-</div>
|
||||
<input style="width:100px; height:40px" id="qty-input-${response.items[0]._id}" class="qty-input" type="number" name="ec_qtybtn" value="${productData.quantity}" oninput="handleQtyInput(this, '${response._id}', '${response.items[0]._id}', true)"/>
|
||||
<div class="qty-btn" style="color:#ffaa00; font-size:30px; margin-left:5px; cursor: pointer;" onclick="qtyIncrement('${response._id}', '${response.items[0]._id}', true)"
|
||||
onmouseover="this.style.color='#a15d00'" onmouseout="this.style.color='#ffaa00'">+</div>
|
||||
<a href="#" class="removeCart" style="margin-left:30px;" onclick="deleteOrder('${response._id}')">
|
||||
<i class="ecicon eci-trash" style="color:#7e7e7e;" onmouseover="this.style.color='#aaaaaa'"
|
||||
onmouseout="this.style.color='#7e7e7e'"></i></a>
|
||||
</div>
|
||||
<!-- 02-16-2024 Stacy added style -->
|
||||
</div>
|
||||
`;
|
||||
getLatestOrders();
|
||||
updateCartItemCount();
|
||||
cartList.appendChild(newOrder);
|
||||
|
@ -679,7 +734,7 @@ function popupAddToCart(
|
|||
}
|
||||
|
||||
function getLatestOrders() {
|
||||
// var customerId = '<?php echo $customer_data[0]['_id'] ?>'
|
||||
var customerId = '<?php echo $customer_data[0][\'_id\'] ?>'
|
||||
// Fetch the order data
|
||||
fetch(`https://api.obanana.shop/api/v1/orders/customer/${customerId}`)
|
||||
.then((response) => response.json())
|
||||
|
@ -731,22 +786,27 @@ function popupAddToCart(
|
|||
|
||||
// If the cart item already exists, update its content using innerHTML
|
||||
cartItem.innerHTML = `
|
||||
<a href="product-left-sidebar.php?id=${response.items[0]._id}"" class="sidekka_pro_img">
|
||||
<img src="${imageUrl}" alt="product">
|
||||
</a>
|
||||
<div class="ec-pro-content">
|
||||
<a href="product-left-sidebar.php?id=${response.items[0]._id}"" class="cart_pro_title">${response.items[0].product.name}</a>
|
||||
<span class="cart-price" id="cart-price">
|
||||
Unit Price: <span>${response.items[0].price}</span>
|
||||
</span>
|
||||
<span id="subtotal-${response._id}" class="subtotal-${response._id}">Subtotal: ${totalAmount}</span>
|
||||
<div class="qty-plus-minuses" style="display:flex; overflow:visible; align-items:center; padding-top:10px;">
|
||||
<div class="qty-btn" style="color:#ffaa00; font-size:35px; padding-right:5px; cursor: pointer;" onclick="qtyDecrement('${response._id}', '${response.items[0]._id}', true)">-</div>
|
||||
<input style="width:100px; height:40px" id="qty-input-${response.items[0]._id}" class="qty-input" type="number" name="ec_qtybtn" value="${productData.quantity}" oninput="handleQtyInput(this, '${response._id}', '${response.items[0]._id}', true)"/>
|
||||
<div class="qty-btn" style="color:#ffaa00; font-size:30px; padding-left:5px; cursor: pointer;" onclick="qtyIncrement('${response._id}', '${response.items[0]._id}', true)">+</div>
|
||||
<a href="#" class="removeCart" onclick="deleteOrder('${response._id}')"><i class="ecicon eci-trash" style="padding:20px; opacity:70%"></i></a>
|
||||
</div>
|
||||
`;
|
||||
<a href="product-left-sidebar.php?id=${response.items[0]._id}"" class="sidekka_pro_img">
|
||||
<img src="${imageUrl}" alt="product">
|
||||
</a>
|
||||
<div class="ec-pro-content">
|
||||
<a href="product-left-sidebar.php?id=${response.items[0]._id}"" class="cart_pro_title">${response.items[0].product.name}</a>
|
||||
<span class="cart-price" id="cart-price">Unit Price: <span>${response.items[0].price}</span>
|
||||
<div class="cart-price">
|
||||
<span id="subtotal-${response._id}" class="subtotal-${response._id}">Subtotal: ${totalAmount}</span>
|
||||
</div>
|
||||
<div class="qty-plus-minuses" style="display:flex; overflow:visible; align-items:center; margin-top:5px;">
|
||||
<div class="qty-btn" style="color:#ffaa00; font-size:35px; margin-right:5px; cursor: pointer;" onclick="qtyDecrement('${response._id}', '${response.items[0]._id}', true)"
|
||||
onmouseover="this.style.color='#a15d00'" onmouseout="this.style.color='#ffaa00'">-</div>
|
||||
<input style="width:100px; height:40px" id="qty-input-${response.items[0]._id}" class="qty-input" type="number" name="ec_qtybtn" value="${productData.quantity}" oninput="handleQtyInput(this, '${response._id}', '${response.items[0]._id}', true)"/>
|
||||
<div class="qty-btn" style="color:#ffaa00; font-size:30px; margin-left:5px; cursor: pointer;" onclick="qtyIncrement('${response._id}', '${response.items[0]._id}', true)"
|
||||
onmouseover="this.style.color='#a15d00'" onmouseout="this.style.color='#ffaa00'">+</div>
|
||||
<a href="#" class="removeCart" style="margin-left:30px;" onclick="deleteOrder('${response._id}')">
|
||||
<i class="ecicon eci-trash" style="color:#7e7e7e;" onmouseover="this.style.color='#aaaaaa'"
|
||||
onmouseout="this.style.color='#7e7e7e'"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
document.getElementById(
|
||||
`qty-input-${response.items[0]._id}`
|
||||
).value = updatedQuantity;
|
||||
|
@ -765,11 +825,36 @@ function popupAddToCart(
|
|||
}
|
||||
};
|
||||
var existingQuantity = parseInt(existingOrder.items[0].quantity, 10);
|
||||
var newQuantity = parseInt(productQuantity, 10);
|
||||
var newQuantity = parseInt(quantityValue, 10);
|
||||
var updatedQuantity = existingQuantity + newQuantity;
|
||||
|
||||
// Check if the updated quantity exceeds the previous price matrix
|
||||
var newProductPrice = productPrice;
|
||||
var foundNewPrice = false;
|
||||
if (priceMatrix.length > 0) {
|
||||
for (var i = 0; i < priceMatrix.length; i++) {
|
||||
for (var j = 0; j < priceMatrix[i].length; j++) {
|
||||
var currentQuantity = parseFloat(priceMatrix[i][j].quantity);
|
||||
var nextQuantity = (j < priceMatrix[i].length - 1) ? parseFloat(priceMatrix[i][j + 1].quantity) : Infinity;
|
||||
if (updatedQuantity >= currentQuantity && updatedQuantity < nextQuantity) {
|
||||
newProductPrice = parseFloat(priceMatrix[i][j].price);
|
||||
foundNewPrice = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundNewPrice) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundNewPrice) {
|
||||
productPrice = newProductPrice;
|
||||
}
|
||||
|
||||
var updateData = {
|
||||
quantity: updatedQuantity,
|
||||
price: productPrice
|
||||
};
|
||||
|
||||
updateOrderXhr.send(JSON.stringify(updateData));
|
||||
|
@ -783,10 +868,10 @@ function popupAddToCart(
|
|||
patchTotalAmountXhr.setRequestHeader("Content-Type", "application/json");
|
||||
patchTotalAmountXhr.setRequestHeader("Authorization", "Bearer " + token);
|
||||
|
||||
var originalPrice = productPrice;
|
||||
var totalAmount = originalPrice * updatedQuantity;
|
||||
console.log(originalPrice);
|
||||
console.log(totalAmount);
|
||||
// var originalPrice = productPrice;
|
||||
var totalAmount = productPrice * updatedQuantity;
|
||||
// console.log(originalPrice);
|
||||
// console.log(totalAmount);
|
||||
var patchData = {
|
||||
total_amount: totalAmount,
|
||||
};
|
||||
|
|
28
cart.php
28
cart.php
|
@ -229,19 +229,35 @@ if ($_SESSION["userId"] <> "") {
|
|||
?>
|
||||
|
||||
<tr id="cart_order_<?php echo $order['_id'] ?>">
|
||||
<td data-label="Product" class="ec-cart-pro-name"><a href="product-left-sidebar.php?id=<?php echo $order['items'][0]['product']['product_id']; ?>"><img loading="lazy" class="ec-cart-pro-img mr-4" src="<?php echo $order['items'][0]['product']['product_image']; ?>" alt="" /><?php echo $order['items'][0]['product']['name']; ?></a></td>
|
||||
<td data-label="Product" class="ec-cart-pro-name"><a href="product-left-sidebar.php?id=<?php echo $order['items'][0]['product']['product_id']; ?>">
|
||||
<img loading="lazy" class="ec-cart-pro-img mr-4" src="<?php echo $order['items'][0]['product']['product_image']; ?>" alt="" />
|
||||
<?php echo $order['items'][0]['product']['name']; ?></a>
|
||||
</td>
|
||||
<td data-label="Price" class="ec-cart-pro-price"><span class="amount"><?php echo $order['items'][0]['price']; ?></span></td>
|
||||
<td data-label="Quantity" class="ec-cart-pro-qty" style="text-align: center;">
|
||||
<div class="cart-qty-plus-minus2" style="width:100px; margin:auto;">
|
||||
<div class="qty-btn" onclick="qtyDecrementCart('<?php echo $order['_id']; ?>' , '<?php echo $order['items'][0]['_id']; ?>',false, '<?php echo $order['items'][0]['product']['product_id']; ?>')">-</div>
|
||||
<input id="cart_qty-input-<?php echo $order['items'][0]['_id']; ?>" class="qty-input" type="number" name="ec_qtybtn" value="<?php echo $order['items'][0]['quantity']; ?>" oninput="handleQtyInputCart(this, '<?php echo $order['_id']; ?>', '<?php echo $order['items'][0]['_id']; ?>','<?php echo $order['items'][0]['product']['product_id']; ?>')" />
|
||||
<div class="qty-btn" onclick="qtyIncrementCart('<?php echo $order['_id']; ?>' , '<?php echo $order['items'][0]['_id']; ?>',false, '<?php echo $order['items'][0]['product']['product_id']; ?>')">+</div>
|
||||
<!-- CART UI -->
|
||||
<div class="cart-qty-plus-minus2 d-flex justify-content-center mt-1">
|
||||
<div class="qty-btn" style="color:#ffaa00; font-size:35px; margin-right:5px; cursor: pointer;" onclick="qtyDecrementCart('<?php echo $order['_id']; ?>' ,
|
||||
'<?php echo $order['items'][0]['_id']; ?>',false, '<?php echo $order['items'][0]['product']['product_id']; ?>')"
|
||||
onmouseover="this.style.color='#a15d00'" onmouseout="this.style.color='#ffaa00'">-
|
||||
</div>
|
||||
<input style="width:100px; height:40px mt-3" id="cart_qty-input-<?php echo $order['items'][0]['_id']; ?>" class="qty-input" type="number" name="ec_qtybtn"
|
||||
value="<?php echo $order['items'][0]['quantity']; ?>" oninput="handleQtyInputCart(this, '<?php echo $order['_id']; ?>',
|
||||
'<?php echo $order['items'][0]['_id']; ?>','<?php echo $order['items'][0]['product']['product_id']; ?>')" />
|
||||
<div class="qty-btn" style="color:#ffaa00; font-size:30px; margin-left:5px; cursor: pointer;" onclick="qtyIncrementCart('<?php echo $order['_id']; ?>' ,
|
||||
'<?php echo $order['items'][0]['_id']; ?>',false, '<?php echo $order['items'][0]['product']['product_id']; ?>')"
|
||||
onmouseover="this.style.color='#a15d00'" onmouseout="this.style.color='#ffaa00'">+</div>
|
||||
</div>
|
||||
<span id="cart_qty_<?php echo $order['_id'] ?>"></span>
|
||||
</td>
|
||||
<td data-label="Total" class="cart_subtotal-<?php echo $order['_id']; ?>" style="font-weight:bold"> <?php echo $order['total_amount'] ?></td>
|
||||
<td data-label="Remove" class="ec-cart-pro-remove">
|
||||
<a onclick="deleteOrderCart('<?php echo $order['_id']; ?>')"><i class="ecicon eci-trash-o"></i></a>
|
||||
<!-- <a onclick="deleteOrderCart('<?php # echo $order['_id']; ?>')"><i class="ecicon eci-trash-o"></i></a> -->
|
||||
<a href="#" class="removeCart" onclick="deleteOrderCart('<?php echo $order['_id']; ?>')">
|
||||
<i class="ecicon eci-trash" style="color:#7e7e7e;" onmouseover="this.style.color='#aaaaaa'"
|
||||
onmouseout="this.style.color='#7e7e7e'">
|
||||
</i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
102
checkouttest.php
102
checkouttest.php
|
@ -403,7 +403,7 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label for="addressContact" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
|
||||
<input type="number" class="form-control" id="addressContact">
|
||||
<input type="text" class="form-control" id="addressContact" value="+63 " oninput="preventErasePrefix(this)">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="addressBuilding" class="text-dark font-weight-medium pt-3 mb-2"> Building,Number </label>
|
||||
|
@ -433,7 +433,7 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label for="addressCountry" class="text-dark font-weight-medium pt-3 mb-2">Country</label>
|
||||
<input type="text" class="form-control" id="addressCountry">
|
||||
<input type="text" class="form-control" id="addressCountry" value="Philippines">
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary" id="submitBtn">Submit</button>
|
||||
</form>
|
||||
|
@ -466,7 +466,7 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
<div class="form-group">
|
||||
|
||||
<label for="addressContact" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
|
||||
<input type="text" class="form-control" id="addressContact2" value="<?php echo $address['phone']; ?>">
|
||||
<input type="text" class="form-control" id="addressContact2" value="<?php echo $address['phone']; ?>" oninput="preventEraseThePrefix(this)">
|
||||
|
||||
|
||||
<!-- <label for="addressContact" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
|
||||
|
@ -526,6 +526,39 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function preventErasePrefix(input) { /* secondmodal */
|
||||
|
||||
var numericValue = input.value.replace(/\D/g, '');
|
||||
if (numericValue.startsWith('63')) {
|
||||
input.value = "+63 " + numericValue.substring(2);
|
||||
} else {
|
||||
input.value = "+63 " + numericValue;
|
||||
}
|
||||
|
||||
if (input.value.length > 14) {
|
||||
input.value = input.value.slice(0, 14);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function preventEraseThePrefix(input) { /* thirdmodal */
|
||||
|
||||
var numericValue = input.value.replace(/\D/g, '');
|
||||
if (numericValue.startsWith('63')) {
|
||||
input.value = "+63 " + numericValue.substring(2);
|
||||
} else {
|
||||
input.value = "+63 " + numericValue;
|
||||
}
|
||||
|
||||
if (input.value.length > 14) {
|
||||
input.value = input.value.slice(0, 14);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
// raymart/sir mark added function to show the addresses of the customer in the third modal march 04 2024
|
||||
$('#thirdModal').on('shown.bs.modal', function (event) {
|
||||
|
@ -1469,6 +1502,21 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
const randomIndex = Math.floor(Math.random() * refchar.length);
|
||||
uniqueRef += refchar.charAt(randomIndex);
|
||||
}
|
||||
let paymentDeetsId = 'obn_cod_id_';
|
||||
for (let i = 0; i < 16; i++) {
|
||||
const randomIndex = Math.floor(Math.random() * refchar.length);
|
||||
paymentDeetsId += refchar.charAt(randomIndex);
|
||||
}
|
||||
let paymentUniqueId = '';
|
||||
for (let i = 0; i < 24; i++) {
|
||||
const randomIndex = Math.floor(Math.random() * refchar.length);
|
||||
paymentUniqueId += refchar.charAt(randomIndex);
|
||||
}
|
||||
let dataPaymentUniqueId = '';
|
||||
for (let i = 0; i < 24; i++) {
|
||||
const randomIndex = Math.floor(Math.random() * refchar.length);
|
||||
dataPaymentUniqueId += refchar.charAt(randomIndex);
|
||||
}
|
||||
|
||||
const selectedFName = document.getElementById('selectedFName').innerText;
|
||||
const selectedLName = document.getElementById('selectedLName').innerText;
|
||||
|
@ -1535,6 +1583,54 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
payment: {
|
||||
status: "UNPAID",
|
||||
reference_number: uniqueRef,
|
||||
details: [
|
||||
{
|
||||
id: paymentDeetsId,
|
||||
attributes:{
|
||||
data:{
|
||||
attributes:{
|
||||
amount: parseFloat(orderId.total_amount) * 100 ,
|
||||
description: orderId.items[0].product.name + " (" + orderId.items[0].quantity + ")" ,
|
||||
status: "unpaid",
|
||||
fee:shippingFees * 100,
|
||||
tax_amount:"null",
|
||||
taxes:[],
|
||||
reference_number: uniqueRef,
|
||||
payments:[
|
||||
{
|
||||
attributes:{
|
||||
billing:{
|
||||
phone: billingNumber
|
||||
},
|
||||
source: {
|
||||
type: "Cash On Delivery"
|
||||
},
|
||||
amount:parseFloat(orderId.total_amount) * 100,
|
||||
currency: "PHP",
|
||||
description: orderId.items[0].product.name + " (" + orderId.items[0].quantity + ")" ,
|
||||
fee:shippingFees,
|
||||
net_amount: parseFloat(orderId.total_amount) * 100,
|
||||
statement_descriptor: "Obanana E-commerce Checkout",
|
||||
status: "unpaid",
|
||||
tax_amount:0,
|
||||
refunds: [],
|
||||
},
|
||||
_id: paymentUniqueId,
|
||||
createdAt: iso8601String,
|
||||
updatedAt: iso8601String
|
||||
}
|
||||
],
|
||||
currency:"PHP",
|
||||
},
|
||||
_id:dataPaymentUniqueId,
|
||||
createdAt: iso8601String,
|
||||
updatedAt: iso8601String
|
||||
},
|
||||
created_at: iso8601String,
|
||||
updated_at: iso8601String
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
total_amount: parseFloat(orderId.total_amount) + shippingFees,
|
||||
status: "TO PAY",
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
include "functions.php";
|
||||
include "../";
|
||||
|
||||
|
||||
$url = $_SESSION["url"];
|
||||
$_SESSION["email"] = $_POST["name"];
|
||||
|
|
|
@ -318,14 +318,14 @@ if (isset($_GET['id'])) {
|
|||
?>
|
||||
<div class="single-slide zoom-image-hover" style="width: 100%; height: 500px; border: 1px solid #ddd; text-align: center; overflow: hidden;">
|
||||
<?php
|
||||
$placeholderImage = 'https://upload.wikimedia.org/wikipedia/commons/6/65/No-Image-Placeholder.svg';
|
||||
$placeholderImage = 'https://api.obanana.com/images/storage/web_images/1710214273217-no_image.png';
|
||||
if (!isset($product_details["images"]) or $product_details["images"] == "") {
|
||||
$productImage = $placeholderImage;
|
||||
} else {
|
||||
$productImage = $i;
|
||||
}
|
||||
?>
|
||||
<img loading="lazy" id="mainProductImage" class="img-responsive" src="<?php echo $productImage; ?>" alt="" style="width: 100%; height: 100%; object-fit: cover; object-position: center center;">
|
||||
<img id="mainProductImage" class="img-responsive" src="<?php echo $productImage; ?>" alt="" style="width: 100%; height: 100%; object-fit: cover; object-position: center center;">
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ if (isset($_GET['id'])) {
|
|||
?>
|
||||
<div class="single-slides">
|
||||
<?php
|
||||
$placeholderImage = 'https://upload.wikimedia.org/wikipedia/commons/6/65/No-Image-Placeholder.svg';
|
||||
$placeholderImage = 'https://api.obanana.com/images/storage/web_images/1710214273217-no_image.png';
|
||||
if (!isset($product_details["images"]) or $product_details["images"] == "") {
|
||||
$productImage = $placeholderImage;
|
||||
} else {
|
||||
|
@ -347,7 +347,7 @@ if (isset($_GET['id'])) {
|
|||
<!-- <img loading="lazy" class="img-responsive" src="<?php #echo $productImage;
|
||||
?>" alt="" style="width: 100%; height: 100%; object-fit: cover; object-position: center center;"> -->
|
||||
<!-- 02-26-2024 Stacy updated img width & height -->
|
||||
<img loading="lazy" class="img-responsive" src="<?php echo $productImage; ?>" alt="" style="max/width: 90px; height: 120px; object-fit: cover; object-position: center center;">
|
||||
<img class="img-responsive" src="<?php echo $productImage; ?>" alt="" style="max/width: 90px; height: 120px; object-fit: cover; object-position: center center;">
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ if (isset($_GET['id'])) {
|
|||
<span class="ec-single-ps-title seller-header">Seller information</span>
|
||||
<div class="vendor_wrap">
|
||||
|
||||
<img loading="lazy" class="vendor_img img-responsive" src="<?php echo isset( $vendor_details['vendor_image']) ?$vendor_details['vendor_image'] :'https://upload.wikimedia.org/wikipedia/commons/6/65/No-Image-Placeholder.svg'; ?>" alt="">
|
||||
<img loading="lazy" class="vendor_img img-responsive" src="<?php echo isset( $vendor_details['vendor_image']) ?$vendor_details['vendor_image'] :'https://api.obanana.com/images/storage/web_images/1710214273217-no_image.png'; ?>" alt="">
|
||||
<div class="vendor_details">
|
||||
<h6>
|
||||
<?php echo $vendor_details['user_login']; ?>
|
||||
|
@ -446,12 +446,23 @@ if (isset($_GET['id'])) {
|
|||
<span>VARIATION</span>
|
||||
<div class="ec-pro-variation-content">
|
||||
<ul class="eccart-pro-items">
|
||||
<!-- <?php
|
||||
$main_product_image = isset($product_details["images"]) ? $product_details["images"] : 'https://api.obanana.com/images/storage/web_images/1710214273217-no_image.png';
|
||||
?>
|
||||
<a href="javascript:void(0);" onclick="selectVariation(<?php // echo htmlspecialchars(json_encode($product_details), ENT_QUOTES, 'UTF-8'); ?>)">
|
||||
<li style="width: 100px; height: 100px">
|
||||
<img src="<?php // echo $main_product_image; ?>" alt="product">
|
||||
<?php // foreach ($product_details['variables'] as $variable) { ?>
|
||||
<p><?php // echo $variable['name'] . ': ' . $variable['value']; ?></p>
|
||||
<?php // } ?>
|
||||
</li>
|
||||
</a> -->
|
||||
<?php
|
||||
$main_product_image = isset($product_details["images"]) ? $product_details["images"] : 'https://upload.wikimedia.org/wikipedia/commons/6/65/No-Image-Placeholder.svg';
|
||||
$main_product_image = isset($product_details["images"]) ? strtok($product_details["images"], ',') : 'https://api.obanana.com/images/storage/web_images/1710214273217-no_image.png';
|
||||
?>
|
||||
<a href="javascript:void(0);" onclick="selectVariation(<?php echo htmlspecialchars(json_encode($product_details), ENT_QUOTES, 'UTF-8'); ?>)">
|
||||
<li style="width: 100px; height: 100px">
|
||||
<img loading="lazy" src="<?php echo $main_product_image; ?>" alt="product">
|
||||
<img src="<?php echo $main_product_image; ?>" alt="product">
|
||||
<?php foreach ($product_details['variables'] as $variable) { ?>
|
||||
<p><?php echo $variable['name'] . ': ' . $variable['value']; ?></p>
|
||||
<?php } ?>
|
||||
|
@ -460,11 +471,11 @@ if (isset($_GET['id'])) {
|
|||
|
||||
<?php
|
||||
foreach ($variation_details as $index => $variation) {
|
||||
$variationImage = isset($variation["images"]) ? $variation["images"] : 'https://upload.wikimedia.org/wikipedia/commons/6/65/No-Image-Placeholder.svg';
|
||||
$variationImage = isset($variation["images"]) ? $variation["images"] : 'https://api.obanana.com/images/storage/web_images/1710214273217-no_image.png';
|
||||
?>
|
||||
<a href="javascript:void(0);" onclick="selectVariation(<?php echo htmlspecialchars(json_encode($variation), ENT_QUOTES, 'UTF-8'); ?>)">
|
||||
<li style="width: 100px; height: 100px">
|
||||
<img loading="lazy" src="<?php echo $variationImage; ?>" alt="product">
|
||||
<img src="<?php echo $variationImage; ?>" alt="product">
|
||||
<?php foreach ($variation['variables'] as $variable) { ?>
|
||||
<p><?php echo $variable['name'] . ': ' . $variable['value']; ?></p>
|
||||
<?php } ?>
|
||||
|
@ -486,10 +497,9 @@ if (isset($_GET['id'])) {
|
|||
document.getElementById("shortDescription").innerHTML = variation.product_description;
|
||||
document.getElementById("productTitle").innerText = variation.product_name;
|
||||
document.getElementById("product_Id").value = variation._id;
|
||||
var productImage = variation.images || 'https://upload.wikimedia.org/wikipedia/commons/6/65/No-Image-Placeholder.svg';
|
||||
|
||||
var productImage = variation.images ? variation.images.split(',')[0] : 'https://api.obanana.com/images/storage/web_images/1710214273217-no_image.png';
|
||||
$('.zoom-image-hover').trigger('zoom.destroy');
|
||||
document.getElementById('mainProductImage').src = productImage;
|
||||
document.getElementById('mainProductImage').classList.remove('zoom-image-hover');
|
||||
$('.zoom-image-hover').zoom();
|
||||
document.getElementById("productTitlemodal").innerText = variation.product_name;
|
||||
document.getElementById('mainProductImagemodal').src = productImage;
|
||||
|
@ -534,7 +544,7 @@ if (isset($_GET['id'])) {
|
|||
onmouseover="this.style.color=\'#a15d00\'" onmouseout="this.style.color=\'#ffaa00\'">-</div>';
|
||||
echo '<input class="qty-inputs" style="width:110px; height:40px" type="number" name="ec_qtybtn" value="';
|
||||
echo (!empty($product_details['minimum_order'])) ? $product_details['minimum_order'] : "1";
|
||||
echo '" id="qty-input" />';
|
||||
echo '" id="qty-input" oninput="handleInput()" />';
|
||||
echo '<div class="qty-btn" style="color:#ffaa00; font-size:25px; padding-left:5px; cursor: pointer;" onclick="increment()"
|
||||
onmouseover="this.style.color=\'#a15d00\'" onmouseout="this.style.color=\'#ffaa00\'">+</div>';
|
||||
echo '<div style="display:flex; margin-left:45px;"><button type="button" class="btn btn-primary" id="contactSellerButton" style="background:#ffaa00; width:190px;"
|
||||
|
@ -549,7 +559,7 @@ if (isset($_GET['id'])) {
|
|||
onmouseover="this.style.color=\'#a15d00\'" onmouseout="this.style.color=\'#ffaa00\'">-</div>';
|
||||
echo '<input class="qty-inputs" style="width:100px; height:40px" type="number" name="ec_qtybtn" value="';
|
||||
echo (!empty($product_details['minimum_order'])) ? $product_details['minimum_order'] : "1";
|
||||
echo '" id="qty-input" />';
|
||||
echo '" id="qty-input" oninput="handleInput()" />';
|
||||
echo '<div class="qty-btn" style="color:#ffaa00; font-size:25px; margin-left:5px; cursor: pointer;" onclick="increment()"
|
||||
onmouseover="this.style.color=\'#a15d00\'" onmouseout="this.style.color=\'#ffaa00\'">+</div>';
|
||||
echo '<div> <div id="addToCartMessage" style="padding-left:45px;"></div> <button class="btn btn-primary" id="addToCartButton" style="text-wrap:nowrap;
|
||||
|
|
|
@ -111,10 +111,7 @@ $_SESSION["isVendor"] = false;
|
|||
<label>Password*</label>
|
||||
<input type="password" name="password" placeholder="Enter your password" required />
|
||||
</span>
|
||||
<p><input type="checkbox"> 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>
|
||||
<p><input type="checkbox" required> I accept this Terms & Conditions and Privacy Policy </p>
|
||||
<span class="ec-login-wrap ec-login-btn">
|
||||
<button class="btn btn-primary" type="submit">Register</button>
|
||||
</span>
|
||||
|
|
|
@ -513,7 +513,7 @@ function loadProducts(page,isFilter) {
|
|||
let imageUrls = product.images.split(',');
|
||||
let firstImageUrl = imageUrls[0].trim();
|
||||
let img = document.createElement("img");
|
||||
img.setAttribute("style", "width: 290px; height: 200px; object-fit: cover;");
|
||||
img.setAttribute("style", "border: 1px solid #eeeeee; height: 330px; object-fit: cover;");
|
||||
img.setAttribute("class", "main-image");
|
||||
img.setAttribute("src", firstImageUrl);
|
||||
img.setAttribute("loading", "lazy");
|
||||
|
@ -538,14 +538,21 @@ function loadProducts(page,isFilter) {
|
|||
card.classList.add("col-lg-4", "col-md-6", "col-sm-6", "col-xs-6", "mb-6", "pro-gl-content", "width-100");
|
||||
card.innerHTML = `
|
||||
<div class="ec-product-inner">
|
||||
<div class="ec-pro-image-outer" style="width: 290px; height: 200px;">
|
||||
<div class="ec-pro-image-outer" style="max-width: 290px; height: 350px;">
|
||||
<div class="ec-pro-image">
|
||||
<a href="product-left-sidebar.php?id=${product._id}">
|
||||
${imageContainer.innerHTML} <!-- Include the dynamically loaded image here -->
|
||||
</a>
|
||||
<div class="ec-pro-actions" style="bottom: -36px;">
|
||||
<button title="Add To Cart" onclick="popupAddToCart('${encodeURIComponent(JSON.stringify(product))}','${encodeURIComponent(JSON.stringify(vendorOfProduct))}', '${token}', '${email}', '${password}', '${encodeURIComponent(JSON.stringify(customer_data))}');" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('${encodeURIComponent(JSON.stringify(product))}', '${encodeURIComponent(JSON.stringify(customer_data))}');"><i class="fi-rr-heart"></i></a>
|
||||
${
|
||||
(product["sale_price"] && product["sale_price"] > 0) ?
|
||||
`<button title="Add To Cart" onclick="popupAddToCart('${encodeURIComponent(JSON.stringify(product))}','${encodeURIComponent(JSON.stringify(vendorOfProduct))}', '${token}', '${email}', '${password}', '${encodeURIComponent(JSON.stringify(customer_data))}');" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('${encodeURIComponent(JSON.stringify(product))}', '${encodeURIComponent(JSON.stringify(customer_data))}');"><i class="fi-rr-heart"></i></a>` :
|
||||
(product["regular_price"] && product["regular_price"] != "") ?
|
||||
`<button title="Add To Cart" onclick="popupAddToCart('${encodeURIComponent(JSON.stringify(product))}','${encodeURIComponent(JSON.stringify(vendorOfProduct))}', '${token}', '${email}', '${password}', '${encodeURIComponent(JSON.stringify(customer_data))}');" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('${encodeURIComponent(JSON.stringify(product))}', '${encodeURIComponent(JSON.stringify(customer_data))}');"><i class="fi-rr-heart"></i></a>` :
|
||||
`<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('${encodeURIComponent(JSON.stringify(product))}', '${encodeURIComponent(JSON.stringify(customer_data))}');"><i class="fi-rr-heart"></i></a>`
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -612,9 +619,20 @@ function updatePaginationUI(page, totalProducts) {
|
|||
|
||||
// Display ellipsis at the beginning if necessary
|
||||
if (startPage > 1) {
|
||||
let li = document.createElement("li");
|
||||
li.textContent = "...";
|
||||
paginationInner.appendChild(li);
|
||||
let firstPageLi = document.createElement("li");
|
||||
let firstPageLink = document.createElement("a");
|
||||
firstPageLink.setAttribute("href", "#");
|
||||
firstPageLink.setAttribute("data-page", 1);
|
||||
firstPageLink.textContent = 1;
|
||||
firstPageLi.appendChild(firstPageLink);
|
||||
paginationInner.appendChild(firstPageLi);
|
||||
|
||||
// Display ellipsis after the first page link if necessary
|
||||
if (startPage > 2) {
|
||||
let ellipsisLi = document.createElement("li");
|
||||
ellipsisLi.textContent = "...";
|
||||
paginationInner.appendChild(ellipsisLi);
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = startPage; i <= endPage; i++) {
|
||||
|
@ -630,11 +648,20 @@ function updatePaginationUI(page, totalProducts) {
|
|||
paginationInner.appendChild(li);
|
||||
}
|
||||
|
||||
|
||||
// Display ellipsis at the end if necessary
|
||||
if (endPage < totalPages) {
|
||||
let li = document.createElement("li");
|
||||
li.textContent = "...";
|
||||
paginationInner.appendChild(li);
|
||||
|
||||
let lastPageLi = document.createElement("li");
|
||||
let lastPageLink = document.createElement("a");
|
||||
lastPageLink.setAttribute("href", "#");
|
||||
lastPageLink.setAttribute("data-page", totalPages);
|
||||
lastPageLink.textContent = totalPages;
|
||||
lastPageLi.appendChild(lastPageLink);
|
||||
paginationInner.appendChild(lastPageLi);
|
||||
}
|
||||
|
||||
// Update pagination indicator
|
||||
|
|
|
@ -1057,8 +1057,24 @@ if ($_SESSION["isVendor"] == true) {
|
|||
}
|
||||
|
||||
function updateCompletedStatus(orderId, referenceNumber) {
|
||||
login(email, password, function(token) {
|
||||
login(email, password, async function(token) {
|
||||
// const token = '<?php echo $_SESSION["token"] ?>';
|
||||
const orderResponse = await fetch(`https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/orders/${orderId}`);
|
||||
const orderData = await orderResponse.json();
|
||||
const updatedDetails = orderData.payment.details.map(detail => ({
|
||||
...detail,
|
||||
attributes: {
|
||||
...detail.attributes,
|
||||
data: {
|
||||
...detail.attributes.data,
|
||||
attributes: {
|
||||
...detail.attributes.data.attributes,
|
||||
status: 'paid'
|
||||
}
|
||||
}
|
||||
},
|
||||
status: 'paid'
|
||||
}));
|
||||
fetch(`https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/orders/${orderId}`, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
|
@ -1069,7 +1085,8 @@ if ($_SESSION["isVendor"] == true) {
|
|||
status: 'COMPLETED',
|
||||
payment: {
|
||||
status: 'PAID',
|
||||
reference_number: referenceNumber
|
||||
reference_number: orderData.payment.reference_number,
|
||||
details: updatedDetails,
|
||||
}
|
||||
}),
|
||||
})
|
||||
|
@ -1079,7 +1096,7 @@ if ($_SESSION["isVendor"] == true) {
|
|||
if (data && data !== "") {
|
||||
// Update the status in the table without reloading the page
|
||||
// document.querySelector(`[data-order-id="${orderId}"] .order-status`).innerText = 'COMPLETED';
|
||||
location.reload();
|
||||
// location.reload();
|
||||
|
||||
} else {
|
||||
alert('Failed to update order status');
|
||||
|
|
|
@ -330,7 +330,7 @@ if ($_SESSION["isVendor"] == true) {
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label for="addressContact" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
|
||||
<input type="number" class="form-control" id="addressContact">
|
||||
<input type="text" class="form-control" id="addressContact" value="+63 " oninput="preventErasePrefix(this)">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="addressBuilding" class="text-dark font-weight-medium pt-3 mb-2"> Building,Number </label>
|
||||
|
@ -360,7 +360,7 @@ if ($_SESSION["isVendor"] == true) {
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label for="addressCountry" class="text-dark font-weight-medium pt-3 mb-2">Country</label>
|
||||
<input type="text" class="form-control" id="addressCountry" >
|
||||
<input type="text" class="form-control" id="addressCountry" value="Philippines">
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary mt-4" id="submitBtn">Submit</button>
|
||||
|
||||
|
@ -397,7 +397,7 @@ if ($_SESSION["isVendor"] == true) {
|
|||
<div class="form-group">
|
||||
|
||||
<label for="addressContact" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
|
||||
<input type="text" class="form-control" id="addressContact2" value="<?php echo $address['phone']; ?>">
|
||||
<input type="text" class="form-control" id="addressContact2" value="<?php echo $address['phone']; ?>" oninput="preventEraseThePrefix(this)">
|
||||
|
||||
|
||||
<!-- <label for="addressContact" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
|
||||
|
@ -455,6 +455,54 @@ if ($_SESSION["isVendor"] == true) {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function preventErasePrefix(input) { /* secondmodal */
|
||||
|
||||
var numericValue = input.value.replace(/\D/g, '');
|
||||
if (numericValue.startsWith('63')) {
|
||||
input.value = "+63 " + numericValue.substring(2);
|
||||
} else {
|
||||
input.value = "+63 " + numericValue;
|
||||
}
|
||||
|
||||
if (input.value.length > 14) {
|
||||
input.value = input.value.slice(0, 14);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function preventEraseThePrefix(input) { /* thirdmodal */
|
||||
|
||||
var numericValue = input.value.replace(/\D/g, '');
|
||||
if (numericValue.startsWith('63')) {
|
||||
input.value = "+63 " + numericValue.substring(2);
|
||||
} else {
|
||||
input.value = "+63 " + numericValue;
|
||||
}
|
||||
|
||||
if (input.value.length > 14) {
|
||||
input.value = input.value.slice(0, 14);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function preventEraseInPrefix(input) { /* edit details */
|
||||
|
||||
var numericValue = input.value.replace(/\D/g, '');
|
||||
if (numericValue.startsWith('63')) {
|
||||
input.value = "+63 " + numericValue.substring(2);
|
||||
} else {
|
||||
input.value = "+63 " + numericValue;
|
||||
}
|
||||
|
||||
if (input.value.length > 14) {
|
||||
input.value = input.value.slice(0, 14);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
// var myElement = document.getElementById('myElement');
|
||||
// myElement.style.backgroundImage = 'red';
|
||||
|
@ -484,11 +532,11 @@ if ($_SESSION["isVendor"] == true) {
|
|||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
console.log('Email update successful');
|
||||
console.log('Profile updated Successful');
|
||||
location.reload();
|
||||
// Handle any other actions after the successful email update
|
||||
} else {
|
||||
console.error('Email update failed');
|
||||
console.error('Profile Failed to Upload');
|
||||
// Handle errors or display a message to the user
|
||||
}
|
||||
})
|
||||
|
@ -1205,10 +1253,10 @@ if ($_SESSION["isVendor"] == true) {
|
|||
})
|
||||
.then(secondResponse => {
|
||||
if (secondResponse.ok) {
|
||||
console.log('Second request successful');
|
||||
location.reload();
|
||||
console.log('Image Uploaded Successful');
|
||||
// location.reload();
|
||||
} else {
|
||||
console.error('Second request failed');
|
||||
console.error('Image Failed to Upload');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
|
@ -1237,7 +1285,7 @@ if ($_SESSION["isVendor"] == true) {
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label for="phone-" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
|
||||
<input type="text" class="form-control" id="phone-" value="<?php echo $customer_data[0]['phone_number'] ?>">
|
||||
<input type="text" class="form-control" id="phone-" value="<?php echo $customer_data[0]['phone_number'] ?>" oninput="preventEraseInPrefix(this)">
|
||||
</div>
|
||||
|
||||
<!-- <div class="col-md-12 space-t-15">
|
||||
|
@ -1246,7 +1294,7 @@ if ($_SESSION["isVendor"] == true) {
|
|||
aria-label="Close">Close</a>
|
||||
</div> -->
|
||||
</form>
|
||||
<button type="button" class="btn btn-primary btn-pill my-3" onclick="editUser()">Upload</button>
|
||||
<button type="button" class="btn btn-primary btn-pill mt-3" onclick="editUser()">Upload</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
|
@ -252,11 +257,19 @@ $array = json_decode($result, true);
|
|||
<?php
|
||||
if ($array['status'] === 'TO PAY' || $array['status'] === 'To Pay') {
|
||||
echo '<button type="submit" class="btn btn-primary">To Ship</button>';
|
||||
echo '<button type="button" value="Back" onclick="window.history.back();" class="btn btn-primary mt-3">Back</button>';
|
||||
} elseif ($array['status'] === 'TO SHIP' || $array['status'] === 'To Ship') {
|
||||
echo '<button type="submit" class="btn btn-primary">To Receive</button>';
|
||||
echo '<button type="button" value="Back" onclick="window.history.back();" class="btn btn-primary mt-3">Back</button>';
|
||||
} elseif ($array['status'] === 'TO RECEIVE' || $array['status'] === 'To Receive') {
|
||||
echo '<button type="submit" class="btn btn-primary">Completed</button>';
|
||||
echo '<button type="button" value="Back" onclick="window.history.back();" class="btn btn-primary mt-3">Back</button>';
|
||||
} elseif ($array['status'] === 'COMPLETED' || $array['status'] === 'Completed') {
|
||||
echo '<button type="button" value="Back" onclick="window.history.back();" class="btn btn-primary">Back</button>';
|
||||
} elseif ($array['status'] === 'RETURNED' || $array['status'] === 'Returned') {
|
||||
echo '<button type="button" value="Back" onclick="window.history.back();" class="btn btn-primary">Back</button>';
|
||||
}
|
||||
|
||||
?>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -239,6 +239,9 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
<div class="shipping">
|
||||
<?php foreach ($vendorData['address'] as $address) : ?>
|
||||
<?php if ($address['shipping']) : ?>
|
||||
<div>
|
||||
<span style="font-size:16px;font-weight:800;">Shipping Address:</span>
|
||||
</div>
|
||||
<div class="sName">
|
||||
<span>Name:
|
||||
<span id="selectedFName"><?php echo $address['first_name']; ?></span>
|
||||
|
@ -261,6 +264,34 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="billing">
|
||||
<?php foreach ($vendorData['address'] as $address) : ?>
|
||||
<?php if ($address['billing']) : ?>
|
||||
<div>
|
||||
<span style="font-size:16px;font-weight:800;">Billing Address:</span>
|
||||
</div>
|
||||
<div class="sName">
|
||||
<span>Name:
|
||||
<span id="selectedBillingFName"><?php echo $address['first_name']; ?></span>
|
||||
<span id="selectedBillingLName"> <?php echo $address['last_name']; ?></span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="sContact">
|
||||
<span id="selectedBillingContact">Contact #: <?php echo $address['phone']; ?></span>
|
||||
</div>
|
||||
<div class="sAddress">
|
||||
<span>Address:
|
||||
<span id="sBillingBuilding"><?php echo $address['address_1']; ?></span>
|
||||
<span id="sBillingStreet"><?php echo $address['address_2']; ?></span>
|
||||
<span id="sBillingBarangay"><?php echo $address['barangay']; ?></span>
|
||||
<span id="sBillingCity"><?php echo $address['city']; ?></span>
|
||||
<span id="sBillingProvince"><?php echo $address['province']; ?></span>
|
||||
<span id="sBillingCountry"><?php echo $address['country']; ?></span>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -530,17 +561,19 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
<div class="card-body">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12 mx-auto">
|
||||
<label class="form-check-label" for="address_<?php echo $vendor_index; ?>_<?php echo $bank_index; ?>">
|
||||
<strong style="font-weight: bold;">Bank Name: </strong><?php echo $bank['bank_name']; ?> <br>
|
||||
<strong style="font-weight: bold;">Bank Account Number: </strong><?php echo $bank['bank_account_number']; ?> <br>
|
||||
<strong style="font-weight: bold;">Bank Account Name: </strong><?php echo $bank['bank_account_name']; ?>
|
||||
<div class="selectWrap" style="display: flex; justify-content: center; align-items: center; width: 50%;">
|
||||
<input type="radio" name="payout_bank" id="payout_bank_<?php echo $vendor_index; ?>_<?php echo $bank_index; ?>" value="<?php echo $vendor_index; ?>_<?php echo $bank_index; ?>" onchange="setPayoutBank('<?php echo $vendor['_id']; ?>', <?php echo $bank_index; ?>, true)" <?php echo $bank['bank_payout'] ? 'checked' : ''; ?>>
|
||||
<label for="payout_bank_<?php echo $vendor_index; ?>_<?php echo $bank_index; ?>">Set as Payout Bank</label>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col-md-12 mx-auto">
|
||||
<div class="form-check" style="display: flex; align-items: center;">
|
||||
<label class="form-check-label" for="address_<?php echo $vendor_index; ?>_<?php echo $bank_index; ?>">
|
||||
<strong style="font-weight: bold;">Bank Name: </strong><?php echo $bank['bank_name']; ?> <br>
|
||||
<strong style="font-weight: bold;">Bank Account Number: </strong><?php echo $bank['bank_account_number']; ?> <br>
|
||||
<strong style="font-weight: bold;">Bank Account Name: </strong><?php echo $bank['bank_account_name']; ?>
|
||||
</label>
|
||||
<div class="selectWrap" style="margin-left: auto; display: flex; align-items: center;">
|
||||
<input type="radio" style="height:15px !important; width: 15px !important;" name="payout_bank" id="payout_bank_<?php echo $vendor_index; ?>_<?php echo $bank_index; ?>" value="<?php echo $vendor_index; ?>_<?php echo $bank_index; ?>" onchange="setPayoutBank('<?php echo $vendor['_id']; ?>', <?php echo $bank_index; ?>, true)" <?php echo $bank['bank_payout'] ? 'checked' : ''; ?>>
|
||||
<label for="payout_bank_<?php echo $vendor_index; ?>_<?php echo $bank_index; ?>" style="margin-bottom: 0; margin-left: 5px;">Set as Payout Bank</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -607,11 +640,11 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
console.log('Email update successful');
|
||||
console.log('Profile updated successful');
|
||||
location.reload();
|
||||
// Handle any other actions after the successful email update
|
||||
} else {
|
||||
console.error('Email update failed');
|
||||
console.error('Profile failed to update');
|
||||
// Handle errors or display a message to the user
|
||||
}
|
||||
})
|
||||
|
@ -654,7 +687,7 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
// location.reload();
|
||||
location.reload();
|
||||
// filter the delete action
|
||||
document.getElementById('form-check-' + addressIndex).remove();
|
||||
} else {
|
||||
|
@ -942,62 +975,66 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
});
|
||||
|
||||
|
||||
|
||||
$('#submitBtn').on('click', function() {
|
||||
console.log('clickkkkkkkk')
|
||||
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/vendors/' + vendorid)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const existingAddresses = data.address || [];
|
||||
console.log('clickkkkkkkk')
|
||||
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/vendors/' + vendorid)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const existingAddresses = data.address || [];
|
||||
|
||||
const firstName = $('#addressFirstName').val();
|
||||
const lastName = $('#addressLastName').val();
|
||||
const contact = $('#addressContact').val();
|
||||
const buildingNumber = $('#addressBuilding').val();
|
||||
const street = $('#addressStreet').val();
|
||||
const province = $('#provinceSelect :selected').text();
|
||||
const city = $('#citySelect :selected').text();
|
||||
const barangay = $('#barangaySelect :selected').text();
|
||||
const country = $('#addressCountry').val();
|
||||
const firstName = $('#addressFirstName').val();
|
||||
const lastName = $('#addressLastName').val();
|
||||
const contact = $('#addressContact').val();
|
||||
const buildingNumber = $('#addressBuilding').val();
|
||||
const street = $('#addressStreet').val();
|
||||
const province = $('#provinceSelect :selected').text();
|
||||
const city = $('#citySelect :selected').text();
|
||||
const barangay = $('#barangaySelect :selected').text();
|
||||
const country = $('#addressCountry').val();
|
||||
|
||||
const newAddress = {
|
||||
first_name: firstName,
|
||||
last_name: lastName,
|
||||
phone: contact,
|
||||
address_1: buildingNumber,
|
||||
address_2: street,
|
||||
city: city,
|
||||
province: province,
|
||||
barangay: barangay,
|
||||
country: country,
|
||||
};
|
||||
|
||||
const newAddress = {
|
||||
first_name: firstName,
|
||||
last_name: lastName,
|
||||
phone: contact,
|
||||
address_1: buildingNumber,
|
||||
address_2: street,
|
||||
city: city,
|
||||
province: province,
|
||||
barangay: barangay,
|
||||
country: country,
|
||||
};
|
||||
// Check if it's the first address
|
||||
if (existingAddresses.length === 0) {
|
||||
newAddress.shipping = true; // Set shipping to true
|
||||
}
|
||||
|
||||
existingAddresses.push(newAddress);
|
||||
existingAddresses.push(newAddress);
|
||||
|
||||
return fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/vendors/' + vendorid, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
address: existingAddresses
|
||||
}),
|
||||
});
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
location.reload();
|
||||
} else {
|
||||
console.error('Failed to submit data');
|
||||
alert('Failed to submit data');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('Error submitting data');
|
||||
});
|
||||
});
|
||||
|
||||
return fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/vendors/' + vendorid, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
address: existingAddresses
|
||||
}),
|
||||
});
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
location.reload();
|
||||
} else {
|
||||
console.error('Failed to submit data');
|
||||
alert('Failed to submit data');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('Error submitting data');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
@ -1180,6 +1217,27 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
if (!updateResponse.ok) {
|
||||
throw new Error(`Failed to update address: ${updateResponse.status}`);
|
||||
}
|
||||
// console.log(`Address updated successfully for vendor ${vendorid}`);
|
||||
const selectedBillingElement = document.getElementById('selectedBillingFName');
|
||||
const selectedBillingLNameElement = document.getElementById('selectedBillingLName');
|
||||
const selectedBillingContactElement = document.getElementById('selectedBillingContact');
|
||||
const sBillingBuildingElement = document.getElementById('sBillingBuilding');
|
||||
const sBillingStreetElement = document.getElementById('sBillingStreet');
|
||||
const sBillingBarangayElement = document.getElementById('sBillingBarangay');
|
||||
const sBillingCityElement = document.getElementById('sBillingCity');
|
||||
const sBillingProvinceElement = document.getElementById('sBillingProvince');
|
||||
const sBillingCountryElement = document.getElementById('sBillingCountry');
|
||||
if (selectedBillingElement) {
|
||||
selectedBillingElement.textContent = vendorsData.address[addressIndex].first_name;
|
||||
selectedBillingLNameElement.textContent = vendorsData.address[addressIndex].last_name;
|
||||
selectedBillingContactElement.textContent = 'Contact #: ' + vendorsData.address[addressIndex].phone;
|
||||
sBillingBuildingElement.textContent = vendorsData.address[addressIndex].address_1;
|
||||
sBillingStreetElement.textContent = vendorsData.address[addressIndex].address_2;
|
||||
sBillingBarangayElement.textContent = vendorsData.address[addressIndex].barangay;
|
||||
sBillingCityElement.textContent = vendorsData.address[addressIndex].city;
|
||||
sBillingProvinceElement.textContent = vendorsData.address[addressIndex].province;
|
||||
sBillingCountryElement.textContent = vendorsData.address[addressIndex].country;
|
||||
}
|
||||
console.log(`Address updated successfully for vendor ${vendorid}`);
|
||||
} catch (error) {
|
||||
console.error('Error updating address:', error.message);
|
||||
|
@ -1434,10 +1492,10 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
})
|
||||
.then(secondResponse => {
|
||||
if (secondResponse.ok) {
|
||||
console.log('Second request successful');
|
||||
location.reload();
|
||||
console.log('Profile Image Uploaded Successful');
|
||||
// location.reload();
|
||||
} else {
|
||||
console.error('Second request failed');
|
||||
console.error('Profile Image Failed to Upload');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
|
@ -1527,10 +1585,10 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
})
|
||||
.then(secondResponse => {
|
||||
if (secondResponse.ok) {
|
||||
console.log('Second request successful');
|
||||
location.reload();
|
||||
console.log('Profile Banner Uploaded Successful');
|
||||
// location.reload();
|
||||
} else {
|
||||
console.error('Second request failed');
|
||||
console.error('Profile Banner Failed to Upload');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
|
|
33
wishlist.php
33
wishlist.php
|
@ -182,20 +182,31 @@ if ($_SESSION["isVendor"] == true) {
|
|||
<div class="ec-product-inner">
|
||||
<!-- raymart added style for checkboxes feb 19 2024 -->
|
||||
<input type="checkbox" class="product-checkbox" style="width: 20px; height: 20px; "value="<?php echo $product["_id"]; ?>">
|
||||
<div class="ec-pro-image-outer">
|
||||
<div class="ec-pro-image-outer" style="max-width: 290px; height: 350px;">
|
||||
<div class="ec-pro-image">
|
||||
<a href="product-left-sidebar.php?id=<?php echo $product["_id"]; ?>" class="image">
|
||||
<!-- <a href="shop-left-sidebar-col-4.php" class="image"> -->
|
||||
<img loading="lazy" class="main-image" src="<?php echo $product["product_image"]; ?>" alt="Product" />
|
||||
<!-- <img loading="lazy" class="hover-image" src="<?php echo $product["product_image"]; ?>" alt="Product" /> -->
|
||||
|
||||
<img loading="lazy" class="main-image" src="<?php echo $product["images"]; ?>" alt="Product" style="border: 1px solid #eeeeee; height: 330px; object-fit: cover;"/>
|
||||
<!-- <img loading="lazy" class="hover-image" src="<?php echo $product["images"]; ?>" alt="Product" /> -->
|
||||
</a>
|
||||
<span class="ec-com-remove ec-remove-wishlist">
|
||||
<a href="javascript:void(0)" class="remove-product" data-product-id="<?php echo $product["_id"]; ?>" id="removeItem<?php echo $product["_id"]; ?>">×</a>
|
||||
</span>
|
||||
<!-- raymart edit action feb 14 2024 -->
|
||||
<div class="ec-pro-actions">
|
||||
<button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($product), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($product), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
<div class="ec-pro-actions" style="bottom: -70px;">
|
||||
<!-- <button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($product), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button> -->
|
||||
<!-- <a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($product), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a> -->
|
||||
<?php if (isset($product["sale_price"]) && $product["sale_price"] > 0) : ?>
|
||||
<button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($product), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
|
||||
<?php elseif (isset($product["regular_price"]) && $product["regular_price"] != "") : ?>
|
||||
<button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($product), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
|
||||
<?php else : ($product["regular_price"] == "" || $product["regular_price"] == null) ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -227,7 +238,7 @@ if ($_SESSION["isVendor"] == true) {
|
|||
echo '<span class="ec-price">';
|
||||
echo '<span class="old-price">' . $product['regular_price'] . '</span>';
|
||||
echo '<span class="new-price">' . $product['sale_price'] . '</span>';
|
||||
echo '</span>';
|
||||
echo '</span>';
|
||||
} else {
|
||||
echo '<span class="new-price">' . $product['regular_price'] . '</span>';
|
||||
}
|
||||
|
@ -335,7 +346,7 @@ if ($_SESSION["isVendor"] == true) {
|
|||
if (xhr.status === 200) {
|
||||
// Product removed successfully, you can handle the UI update here if needed
|
||||
console.log('Product removed successfully');
|
||||
// location.reload(); // Refresh the page after removing the product
|
||||
location.reload(); // Refresh the page after removing the product
|
||||
} else {
|
||||
// Handle error response
|
||||
console.error('Error removing product:', xhr.responseText);
|
||||
|
@ -368,9 +379,9 @@ if ($_SESSION["isVendor"] == true) {
|
|||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||||
if (xhr.status === 200) {
|
||||
if (xhr.status === 0) {
|
||||
console.log('Products removed successfully');
|
||||
// location.reload();
|
||||
location.reload();
|
||||
} else {
|
||||
console.error('Error removing products:', xhr.responseText);
|
||||
}
|
||||
|
@ -777,7 +788,7 @@ if ($_SESSION["isVendor"] == true) {
|
|||
<!-- <script src="assets/js/tester10.js"></script> -->
|
||||
<?php
|
||||
if ($_SESSION["is_test"]==true) {
|
||||
echo '<script src="assets/js/tester10.js"></script>';
|
||||
echo '<script src="assets/js/tester11.js"></script>';
|
||||
} else {
|
||||
echo '<script src="assets/js/produc3.js"></script>';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue