From 2da9f773494534bc70c15ded21ca0eb9c83a728b Mon Sep 17 00:00:00 2001 From: jouls Date: Thu, 2 May 2024 15:59:16 +0800 Subject: [PATCH 1/9] Improved data table and layout of vendouy payouts page --- vendor-payouts.php | 376 +++++++++++++++++++++++++-------------------- 1 file changed, 206 insertions(+), 170 deletions(-) diff --git a/vendor-payouts.php b/vendor-payouts.php index 6cf41e5..5fb5685 100644 --- a/vendor-payouts.php +++ b/vendor-payouts.php @@ -75,8 +75,11 @@ $vendorPayoutData = json_decode($response, true); + - + + + @@ -84,7 +87,6 @@ $vendorPayoutData = json_decode($response, true); - +
-
- \ No newline at end of file + + + \ No newline at end of file diff --git a/catalog-single-vendor.php b/catalog-single-vendor.php index 88b4844..e5e3b09 100644 --- a/catalog-single-vendor.php +++ b/catalog-single-vendor.php @@ -350,7 +350,9 @@ function updateWishItemCount() {
Seller since
-

+ +

+
@@ -526,7 +528,7 @@ xhrVendors1.onreadystatechange = function() { 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("alt", "Product"); @@ -537,7 +539,7 @@ xhrVendors1.onreadystatechange = function() { } else { let img = document.createElement("img"); img.className = "main-image"; - img.setAttribute("style", "width: 290px; height: 200px; object-fit: cover;"); + img.setAttribute("style", "border: 1px solid #eeeeee; height: 330px; object-fit: cover;"); img.setAttribute("loading", "lazy"); img.setAttribute("class", "main-image"); img.setAttribute("src", "https://api.obanana.com/images/storage/web_images/1709002636671-viber_image_2024-02-22_15-54-42-498.png"); @@ -550,14 +552,21 @@ xhrVendors1.onreadystatechange = function() { card.classList.add("col-lg-4", "col-md-6", "col-sm-6", "col-xs-6", "mb-6", "pro-gl-content", "width-100"); card.innerHTML = `
-
+
${imageContainer.innerHTML}
- - + ${ + (product["sale_price"] && product["sale_price"] > 0) ? + ` + ` : + (product["regular_price"] && product["regular_price"] != "") ? + ` + ` : + `` + }
@@ -1166,7 +1175,7 @@ maxPriceInput.addEventListener('input', function() { -
+ diff --git a/footer.php b/footer.php index 8af24e6..27ddb86 100644 --- a/footer.php +++ b/footer.php @@ -1,3 +1,7 @@ + +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+ - \ No newline at end of file + diff --git a/header.php b/header.php index 7a2418d..4249e27 100644 --- a/header.php +++ b/header.php @@ -139,6 +139,20 @@ if ($_SESSION["userId"] <> "") { font-size: 16px; line-height: 1; } + + @media (hover: hover), (hover: none) { + .fi-rr-heart:hover, + .fi-rr-heart:active, + .fi-rr-user:hover, + .fi-rr-user:active, + .fi-rr-shopping-bag:hover, + .fi-rr-shopping-bag:active, + .fi-rr-home:hover, + .fi-rr-home:active { + cursor: pointer !important; + color: #005eff !important; + } + } @@ -288,13 +302,13 @@ if ($_SESSION["userId"] <> "") {
- 0 + 0
- 0 + 0
@@ -1130,23 +1144,41 @@ if ($_SESSION["userId"] <> "") { -->
  • Hot Offers
  • - + + +
  • Offers
  • Top Vendors
  • Services
  • New Arrivals
  • - - +
  • Client + Review
  • +
  • Instagram Feed
  • - + -->
    diff --git a/index.php b/index.php index 8b02804..4379ba6 100644 --- a/index.php +++ b/index.php @@ -224,9 +224,9 @@ if ($_SESSION["userId"] <> "") { $vendorOfProduct = getVendorbyId($forAll[$pid]['vendor_api_id']); ?>
    -
    +
    -
    +
    "> @@ -237,7 +237,7 @@ if ($_SESSION["userId"] <> "") { if (!empty($image_urls)) { $first_image_url = trim($image_urls[0]); ?> - edit + edit "") { $vendorOfProduct = getVendorbyId($electronics[$pid]['vendor_api_id']); ?>
    -
    +
    -
    +
    "> @@ -357,7 +357,7 @@ if ($_SESSION["userId"] <> "") { if (!empty($image_urls)) { $first_image_url = trim($image_urls[0]); ?> - edit + edit "") { $vendorOfProduct = getVendorbyId($smartHome[$pid]['vendor_api_id']); ?>
    -
    +
    -
    +
    "> @@ -479,7 +479,7 @@ if ($_SESSION["userId"] <> "") { if (!empty($image_urls)) { $first_image_url = trim($image_urls[0]); ?> - edit + edit "") { $vendorOfProduct = getVendorbyId($forVehicle[$pid]['vendor_api_id']); ?>
    -
    +
    -
    +
    "> @@ -599,7 +599,7 @@ if ($_SESSION["userId"] <> "") { if (!empty($image_urls)) { $first_image_url = trim($image_urls[0]); ?> - edit + edit "") { $vendorOfProduct = getVendorbyId($newArrival[$pid]['vendor_api_id']); ?>
    -
    +
    -
    +
    -
    + diff --git a/next_day_delivery.php b/next_day_delivery.php index fccdf26..3c748a5 100644 --- a/next_day_delivery.php +++ b/next_day_delivery.php @@ -321,7 +321,7 @@ function loadProducts(page,isFilter) { let product = prod; // let vendor = prod.vendor; - let vendorOfProduct = prod.vendor; + let vendorOfProduct = prod; // let card = document.createElement("div"); let token =""; let email =""; @@ -334,7 +334,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("loading", "lazy"); @@ -345,7 +345,7 @@ function loadProducts(page,isFilter) { } else { let img = document.createElement("img"); img.className = "main-image"; - img.setAttribute("style", "width: 290px; height: 200px; object-fit: cover;"); + img.setAttribute("style", "border: 1px solid #eeeeee; height: 330px; object-fit: cover;"); img.setAttribute("loading", "lazy"); img.setAttribute("class", "main-image"); img.setAttribute("src", "https://api.obanana.com/images/storage/web_images/1709002636671-viber_image_2024-02-22_15-54-42-498.png"); @@ -358,14 +358,21 @@ function loadProducts(page,isFilter) { card.classList.add("col-lg-3", "col-md-6", "col-sm-6", "col-xs-6", "mb-6", "pro-gl-content", "width-100"); card.innerHTML = `
    -
    +
    ${imageContainer.innerHTML}
    - - + ${ + (product["sale_price"] && product["sale_price"] > 0) ? + ` + ` : + (product["regular_price"] && product["regular_price"] != "") ? + ` + ` : + `` + }
    @@ -925,7 +932,7 @@ maxPriceInput.addEventListener('input', function() { -
    + diff --git a/product-left-sidebar.php b/product-left-sidebar.php index 5cd385a..4e4e6f5 100644 --- a/product-left-sidebar.php +++ b/product-left-sidebar.php @@ -2027,7 +2027,7 @@ if (isset($_GET['id'])) { -
    + diff --git a/register_customer.php b/register_customer.php index 194788f..16af521 100644 --- a/register_customer.php +++ b/register_customer.php @@ -129,8 +129,7 @@ $customerData = json_decode($customers, true); - " placeholder="Enter your phone number" - required /> + " oninput="preventEraseInPrefix(this)" required />
    + + diff --git a/register_vendor.php b/register_vendor.php index fcd8063..6347247 100644 --- a/register_vendor.php +++ b/register_vendor.php @@ -144,7 +144,7 @@ $vendorData = json_decode($vendors, true); - + diff --git a/shop-list-left-sidebar.php b/shop-list-left-sidebar.php index 22ef2f7..b8d58c0 100644 --- a/shop-list-left-sidebar.php +++ b/shop-list-left-sidebar.php @@ -1108,20 +1108,22 @@ maxPriceInput.addEventListener('input', function() { -
    + -
    + +
    + 0 +
    - +
    @@ -1129,7 +1131,7 @@ maxPriceInput.addEventListener('input', function() {
    -
    +
    --> diff --git a/vendor-list.php b/vendor-list.php index 5c78616..976e198 100644 --- a/vendor-list.php +++ b/vendor-list.php @@ -74,7 +74,7 @@ $products = productList(); text-decoration: none; padding: 5px 10px; border: 1px solid #ccc; - /* margin: 0 5px; */ + margin: 0 5px; border-radius: 4px; } @@ -262,7 +262,8 @@ $products = productList();
    Seller since
    -

    + +

    @@ -417,7 +418,7 @@ $products = productList(); -
    + diff --git a/vendor-settings.php b/vendor-settings.php index e987313..1f3a2b3 100644 --- a/vendor-settings.php +++ b/vendor-settings.php @@ -419,7 +419,7 @@ if ($_SESSION["isCustomer"] == true) {
    - +
    @@ -449,7 +449,7 @@ if ($_SESSION["isCustomer"] == true) {
    - +
    @@ -486,7 +486,7 @@ if ($_SESSION["isCustomer"] == true) {
    - +
    @@ -1651,7 +1700,7 @@ if ($_SESSION["isCustomer"] == true) { -
    + diff --git a/wishlist.php b/wishlist.php index b089bb2..6b84754 100644 --- a/wishlist.php +++ b/wishlist.php @@ -379,7 +379,7 @@ if ($_SESSION["isVendor"] == true) { xhr.setRequestHeader('Content-Type', 'application/json'); xhr.onreadystatechange = function() { if (xhr.readyState === XMLHttpRequest.DONE) { - if (xhr.status === 0) { + if (xhr.status === 200) { console.log('Products removed successfully'); location.reload(); } else { @@ -527,7 +527,7 @@ if ($_SESSION["isVendor"] == true) { -
    + From 22a3a404aa8bb46dc385d8adbe1ce6b10f14f13e Mon Sep 17 00:00:00 2001 From: gelonspr Date: Fri, 3 May 2024 17:00:39 +0800 Subject: [PATCH 4/9] fixed dynamic data for admin sales report chart --- admin/assets/js/dashboard-chart.js | 238 +++++++++++++++++++++++++++-- vendor-payments.php | 23 ++- 2 files changed, 235 insertions(+), 26 deletions(-) diff --git a/admin/assets/js/dashboard-chart.js b/admin/assets/js/dashboard-chart.js index 793d5f5..fce85d6 100644 --- a/admin/assets/js/dashboard-chart.js +++ b/admin/assets/js/dashboard-chart.js @@ -7,12 +7,18 @@ $(document).ready(function() { fetchData() .then(function (response) { responseData = response.data; - console.log(responseData); + // console.log(responseData); const completedOrdersCount = countCompletedOrders(responseData); const toPayOrdersCount = countToPayOrders(responseData); const toShipOrdersCount = countToShipOrders(responseData); const returnedOrdersCount = countReturnedOrders(responseData); + const { cod_monthly_totals, obpay_monthly_totals, months } = countMonthlySales(responseData); + const { cod_daily_totals, obpay_daily_totals } = countDailySales(responseData); + const { cod_yearly_totals, obpay_yearly_totals, years } = countYearlySales(responseData); initializeChart(completedOrdersCount, toPayOrdersCount, toShipOrdersCount, returnedOrdersCount); + initializeSalesChart(cod_daily_totals, obpay_daily_totals, cod_monthly_totals, + obpay_monthly_totals, months, cod_yearly_totals, obpay_yearly_totals, years + ); }) .catch(function (error) { console.error('Error fetching data:', error); @@ -47,6 +53,207 @@ $(document).ready(function() { return completedOrdersCount; } + function countYearlySales(data) { + const now = new Date(); + const years = []; + const cod_yearly_totals = Array(5).fill(0); + const obpay_yearly_totals = Array(5).fill(0); + + // Initialize years array with the current year and the previous four years + for (let i = 4; i >= 0; i--) { + const year = new Date(now.getFullYear() - i, 0, 1); // January 1st of each year + years.push(year); + } + + data.forEach(order => { + const orderDate = new Date(order.order_date); + orderDate.setHours(0, 0, 0, 0); + + // Check if payment status exists and is not null + if (order.payment && order.payment.status) { + const payment_status = order.payment.status.toLowerCase(); + + years.forEach((year, index) => { + if (orderDate.getFullYear() === year.getFullYear()) { + if (payment_status === "paid") { + const total_amount = parseInt(order.total_amount); + if (order.payment_method === "Cash On Delivery") { + cod_yearly_totals[4 - index] += total_amount; // Adjust index since we are going from current to past + } else if (order.payment_method === "Obananapay") { + obpay_yearly_totals[4 - index] += total_amount; + } + } + } + }); + } + }); + cod_yearly_totals.reverse(); + obpay_yearly_totals.reverse(); + return { + cod_yearly_totals, + obpay_yearly_totals, + years: years.map(year => year.getFullYear().toString()) // Return year labels for use in charts or displays + }; +} + + + function countMonthlySales(data) { + const now = new Date(); + const months = []; + const cod_monthly_totals = Array(12).fill(0); + const obpay_monthly_totals = Array(12).fill(0); + for (let i = 11; i >= 0; i--) { + const month = new Date(now.getFullYear(), now.getMonth() - i, 1); + months.push(month); + } + + data.forEach(order => { + if (order.payment && order.payment.status){ + const orderDate = new Date(order.order_date); + orderDate.setHours(0, 0, 0, 0); + const payment_status = order.payment.status.toLowerCase(); + + months.forEach((month, index) => { + if (orderDate.getFullYear() === month.getFullYear() && orderDate.getMonth() === month.getMonth()) { + if (payment_status === "paid") { + const total_amount = parseInt(order.total_amount); + if (order.payment_method === "Cash On Delivery") { + cod_monthly_totals[11 - index] += total_amount; + } else if (order.payment_method === "Obananapay") { + obpay_monthly_totals[11 - index] += total_amount; + } + } + } + }); + } + }); + console.log(cod_monthly_totals) + cod_monthly_totals.reverse(); + obpay_monthly_totals.reverse(); + return { + cod_monthly_totals, + obpay_monthly_totals, + months: months.map(month => `${month.toLocaleString('default', { month: 'short' })} ${month.getFullYear()}`) // Return month labels for use in charts or displays + }; +} + + + + function countDailySales(data) { + const today = new Date(); + today.setHours(0, 0, 0, 0); + + const sevenDaysAgo = new Date(); + sevenDaysAgo.setDate(today.getDate() - 6); + sevenDaysAgo.setHours(0, 0, 0, 0); + + const sixDaysAgo = new Date(); + sixDaysAgo.setDate(today.getDate() - 5); + sixDaysAgo.setHours(0, 0, 0, 0); + + const fiveDaysAgo = new Date(); + fiveDaysAgo.setDate(today.getDate() - 4); + fiveDaysAgo.setHours(0, 0, 0, 0); + + const fourDaysAgo = new Date(); + fourDaysAgo.setDate(today.getDate() - 3); + fourDaysAgo.setHours(0, 0, 0, 0); + + const threeDaysAgo = new Date(); + threeDaysAgo.setDate(today.getDate() - 2); + threeDaysAgo.setHours(0, 0, 0, 0); + + const twoDaysAgo = new Date(); + twoDaysAgo.setDate(today.getDate() - 1); + twoDaysAgo.setHours(0, 0, 0, 0); + //variables for total daily sales on COD + let cod_total_7 = 0; + let cod_total_6 = 0; + let cod_total_5 = 0; + let cod_total_4 = 0; + let cod_total_3 = 0; + let cod_total_2 = 0; + let cod_total_1 = 0; + + //variables for total daily sales on ObananaPay + let obpay_total_7 = 0; + let obpay_total_6 = 0; + let obpay_total_5 = 0; + let obpay_total_4 = 0; + let obpay_total_3 = 0; + let obpay_total_2 = 0; + let obpay_total_1 = 0; + + + data.forEach(order => { + const orderDate = new Date(order.order_date); + orderDate.setHours(0, 0, 0, 0); + const payment_status = order.payment.status; + if (orderDate.getTime() === sevenDaysAgo.getTime() ) { + if(payment_status.toLowerCase() === "paid" && order.payment_method === "Cash On Delivery" ){ + cod_total_7 += parseInt(order.total_amount); + console.log(order) + // console.log("compare:" + sevenDaysAgo) + }else if (payment_status.toLowerCase() === "paid" && order.payment_method === "Obananapay") { + obpay_total_7 += parseInt(order.total_amount); + } + }else if (orderDate.getTime() === sixDaysAgo.getTime() ) { + if(payment_status.toLowerCase() === "paid" && order.payment_method === "Cash On Delivery" ){ + cod_total_6 += parseInt(order.total_amount); + console.log(order) + // console.log("compare:" + sevenDaysAgo) + }else if (payment_status.toLowerCase() === "paid" && order.payment_method === "Obananapay") { + obpay_total_6 += parseInt(order.total_amount); + } + }else if (orderDate.getTime() === fiveDaysAgo.getTime() ) { + if(payment_status.toLowerCase() === "paid" && order.payment_method === "Cash On Delivery" ){ + cod_total_5 += parseInt(order.total_amount); + console.log(order) + // console.log("compare:" + sevenDaysAgo) + }else if (payment_status.toLowerCase() === "paid" && order.payment_method === "Obananapay") { + obpay_total_5 += parseInt(order.total_amount); + } + }else if (orderDate.getTime() === fourDaysAgo.getTime() ) { + if(payment_status.toLowerCase() === "paid" && order.payment_method === "Cash on Delivery" ){ + cod_total_4 += parseInt(order.total_amount); + console.log(order) + // console.log("compare:" + sevenDaysAgo) + }else if (payment_status.toLowerCase() === "paid" && order.payment_method === "Obananapay") { + obpay_total_4 += parseInt(order.total_amount); + } + }else if (orderDate.getTime() === threeDaysAgo.getTime() ) { + if(payment_status.toLowerCase() === "paid" && order.payment_method === "Cash On Delivery" ){ + cod_total_3 += parseInt(order.total_amount); + console.log(order) + // console.log("compare:" + sevenDaysAgo) + }else if (payment_status.toLowerCase() === "paid" && order.payment_method === "Obananapay") { + obpay_total_3 += parseInt(order.total_amount); + } + }else if (orderDate.getTime() === twoDaysAgo.getTime() ) { + if(payment_status.toLowerCase() === "paid" && order.payment_method === "Cash On Delivery" ){ + cod_total_2 += parseInt(order.total_amount); + console.log(order) + // console.log("compare:" + sevenDaysAgo) + }else if (payment_status.toLowerCase() === "paid" && order.payment_method === "Obananapay") { + obpay_total_2 += parseInt(order.total_amount); + } + }else if (orderDate.getTime() === today.getTime() ) { + if(payment_status.toLowerCase() === "paid" && order.payment_method === "Cash On Delivery" ){ + cod_total_1 += parseInt(order.total_amount); + console.log(order) + // console.log("compare:" + sevenDaysAgo) + }else if (payment_status.toLowerCase() === "paid" && order.payment_method === "Obananapay") { + obpay_total_1 += parseInt(order.total_amount); + } + } + }); + const cod_daily_totals = [cod_total_7, cod_total_6, cod_total_5, cod_total_4, cod_total_3, cod_total_2, cod_total_1,]; + const obpay_daily_totals = [obpay_total_7, obpay_total_6, obpay_total_5, obpay_total_4, obpay_total_3, obpay_total_2, obpay_total_1,]; + // console.log(total_7); + return { cod_daily_totals, obpay_daily_totals }; + } + + function countToPayOrders(data) { const filteredData = getCurrentMonthData(data); let toPayOrdersCount = 0; @@ -127,11 +334,13 @@ $(document).ready(function() { } } }); + } else { + } } - + function initializeSalesChart(cod_daily_totals, obpay_daily_totals, cod_monthly_totals, obpay_monthly_totals, months, cod_yearly_totals, obpay_yearly_totals, years) { var acquisition = document.getElementById("salesChart"); if (acquisition !== null) { function updateDailyLabels() { @@ -151,23 +360,23 @@ $(document).ready(function() { // 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 labelsMonthly = months; + var labelsYearly = years; var acqData = [ { //daily data - first: [91, 180, 44, 75, 150, 66, 70], //COD - second: [300, 44, 177, 76, 23, 189, 12], //ObPay + first: cod_daily_totals, //COD + second: obpay_daily_totals, //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 + first: cod_monthly_totals, //COD + second: obpay_monthly_totals, //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 + first: cod_yearly_totals, //COD + second: obpay_yearly_totals, //ObPay + third: [156, 23, 165, 88, 112 ] //Paymongo } ]; @@ -253,8 +462,8 @@ $(document).ready(function() { }, ticks: { beginAtZero: true, - stepSize: 100, - max: 1000 + stepSize: 20000, + max: 200000 } } ] @@ -313,9 +522,10 @@ $(document).ready(function() { lineAcq.update(); }); -}); + }); items[0].click(); } + } function convertToCSV(data) { const now = new Date(); diff --git a/vendor-payments.php b/vendor-payments.php index e30f341..2474204 100644 --- a/vendor-payments.php +++ b/vendor-payments.php @@ -209,16 +209,16 @@ if ($_SESSION["isCustomer"] == true) { @@ -898,8 +898,7 @@ if ($_SESSION["isCustomer"] == true) { - - + + - + + @@ -1537,7 +1568,8 @@ if ($_SESSION["isVendor"] == true) { - + + diff --git a/user-refund-history.php b/user-refund-history.php index cea1c0c..2fffbd7 100644 --- a/user-refund-history.php +++ b/user-refund-history.php @@ -54,9 +54,14 @@ if ($_SESSION["isVendor"] == true) { + + + + +