diff --git a/about-us.php b/about-us.php index 205b216..4c8e21a 100644 --- a/about-us.php +++ b/about-us.php @@ -18,7 +18,10 @@ - + + diff --git a/admin/assets/js/dashboard-chart.js b/admin/assets/js/dashboard-chart.js index fce85d6..7ca03e5 100644 --- a/admin/assets/js/dashboard-chart.js +++ b/admin/assets/js/dashboard-chart.js @@ -7,7 +7,6 @@ $(document).ready(function() { fetchData() .then(function (response) { responseData = response.data; - // console.log(responseData); const completedOrdersCount = countCompletedOrders(responseData); const toPayOrdersCount = countToPayOrders(responseData); const toShipOrdersCount = countToShipOrders(responseData); @@ -339,7 +338,6 @@ $(document).ready(function() { } } - 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) { @@ -486,6 +484,7 @@ $(document).ready(function() { } }; + var ctx = document.getElementById("salesChart").getContext("2d"); var lineAcq = new Chart(ctx, configAcq); document.getElementById("acqLegend").innerHTML = lineAcq.generateLegend(); @@ -493,8 +492,8 @@ $(document).ready(function() { var items = document.querySelectorAll( "#user-acquisition .nav-tabs .nav-item" ); - items.forEach(function (item, index) { - item.addEventListener("click", function() { + items.forEach(function (item, index) { + item.addEventListener("click", function() { // Determine which tab was clicked var selectedTab = this.textContent.trim(); @@ -587,4 +586,196 @@ $(document).ready(function() { event.preventDefault(); downloadCSV('orders_data.csv'); }); + + let customer_data; + let vendor_data; + + function getDataAndInitializeChart () { + userData() + .then(function (users){ + vendorData() + .then(function (venues){ + customer_data = users.data; + vendor_data = venues.data; + const {customer_monthly_total, months} = countCustomerReg(customer_data) + const { vendor_monthly_total} = countVendorReg(vendor_data); + initializeActivityChart(customer_monthly_total, vendor_monthly_total, months); + }) + }) + } + getDataAndInitializeChart(); + + + function userData(){ + return axios.get('https://api.obanana.shop/api/v1/customers'); + } + function vendorData(){ + return axios.get('https://api.obanana.shop/api/v1/vendors'); + } + + function countCustomerReg(customers) { + const currentDate = new Date(); + const monthLabels = []; + const customer_monthly_total = Array(12).fill(0); + for (let i = 11; i >= 0; i--) { + const month = new Date(currentDate.getFullYear(), currentDate.getMonth() - i, 1); + monthLabels.push(month); + } + + console.log(monthLabels); + + customers.forEach(customer => { + const regDate = new Date(customer.createdAt); + regDate.setHours(0, 0, 0, 0); + + monthLabels.forEach((month, index) => { + let total_count = 0; + if (regDate.getFullYear() === month.getFullYear() && regDate.getMonth() === month.getMonth()) { + total_count ++; + customer_monthly_total[11 - index] += total_count; + } + }); + }); + + console.log(customer_monthly_total) + customer_monthly_total.reverse(); + return { + customer_monthly_total, + months: monthLabels.map(month => `${month.toLocaleString('default', { month: 'short' })} ${month.getFullYear()}`) // Return month labels for use in charts or displays + }; + } + + function countVendorReg(vendors) { + const currentDate = new Date(); + const monthLabels = []; + const vendor_monthly_total = Array(12).fill(0); + for (let i = 11; i >= 0; i--) { + const month = new Date(currentDate.getFullYear(), currentDate.getMonth() - i, 1); + monthLabels.push(month); + } + + console.log(monthLabels); + + vendors.forEach(vendor => { + const regDate = new Date(vendor.createdAt); + regDate.setHours(0, 0, 0, 0); + + monthLabels.forEach((month, index) => { + let total_count = 0; + if (regDate.getFullYear() === month.getFullYear() && regDate.getMonth() === month.getMonth()) { + total_count ++; + vendor_monthly_total[11 - index] += total_count; + } + }); + }); + + console.log(vendor_monthly_total) + vendor_monthly_total.reverse(); + return { + vendor_monthly_total, + }; + } + + function initializeActivityChart (customer_monthly_total, vendor_monthly_total, months){ + var activity = document.getElementById("registry"); + if (activity !== null) { + var activityData = [ + { + first: customer_monthly_total, + second: vendor_monthly_total + } + + ]; + + var config = { + // The type of chart we want to create + type: "line", + // The data for our dataset + data: { + labels: months, + datasets: [ + { + label: "Customer", + backgroundColor: "rgba(255, 165, 0, .3)", + borderColor: "rgba(255, 165, 0, .7)", + data: activityData[0].first, + lineTension: 0.3, + pointBackgroundColor: "rgba(255, 165, 0, 0)", + pointHoverBackgroundColor: "rgba(255, 165, 0, 1)", + pointHoverRadius: 3, + pointHitRadius: 30, + pointBorderWidth: 2, + pointStyle: "rectRounded" + }, + { + label: "Vendors", + backgroundColor: "rgba(135, 206, 235, .3)", + borderColor: "rgba(135, 206, 235, .7)", + data: activityData[0].second, + lineTension: 0.3, + pointBackgroundColor: "rgba(135, 206, 235, 0)", + pointHoverBackgroundColor: "rgba(135, 206, 235, 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: 10, + max: 30 + } + } + ] + }, + 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("registry").getContext("2d"); + var actLine = new Chart(ctx, config); + document.getElementById("actLegend").innerHTML = actLine.generateLegend(); + + + } + + } }); diff --git a/admin/assets/js/map.js b/admin/assets/js/map.js new file mode 100644 index 0000000..c492579 --- /dev/null +++ b/admin/assets/js/map.js @@ -0,0 +1,14 @@ +var southWest = L.latLng(4.64, 116.95), + northEast = L.latLng(20.53, 127.25), + bounds = L.latLngBounds(southWest, northEast); + +// Initialize the map and set the bounds +var map = L.map('map', { + maxBounds: bounds, + maxBoundsViscosity: 1.0 // Keeps the user within the bounds +}).setView([13.41, 122.56], 6); // Centered on the Philippines with a zoom level of 6 + +// Add a tile layer +L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: '© OpenStreetMap contributors' +}).addTo(map); \ No newline at end of file diff --git a/admin/index.php b/admin/index.php index 4811983..2eee72d 100644 --- a/admin/index.php +++ b/admin/index.php @@ -49,6 +49,14 @@ $allSignups = array_merge($all_customers, $all_vendors); + + + + @@ -108,12 +116,13 @@ $allSignups = array_merge($all_customers, $all_vendors); - @@ -825,7 +835,7 @@ $allSignups = array_merge($all_customers, $all_vendors);
-
+

Orders Overview

@@ -841,7 +851,7 @@ $allSignups = array_merge($all_customers, $all_vendors);
  • Order Completed
  • Order To Pay
  • + style="color: #80e1c1">Order To Pay
  • Order Returned
  • @@ -861,32 +871,35 @@ $allSignups = array_merge($all_customers, $all_vendors);
    -
    +
    -

    User Activity

    -
    +

    Monthly Users Registry

    +
    - + +
    +
    +
    -
    -
    +
    -
    +
    -

    Purchased by Country

    +

    Purchased by City

    -
    +
    @@ -933,8 +946,8 @@ $allSignups = array_merge($all_customers, $all_vendors);
    -
    - + +
    @@ -1073,21 +1086,40 @@ $allSignups = array_merge($all_customers, $all_vendors); $orderStatus = strtoupper($val['status']); $returnStatus = strtoupper($val['return_order']['status']); - + $style = ''; + $textColor = ''; + $backgroundColor = ''; - $statusClass = ''; - if ($orderStatus === 'UNPAID' || $orderStatus === 'RETURNED') { - $statusClass = '#cb3747'; - } elseif ($orderStatus === 'TO PAY') { - $statusClass = '#50d7ab'; - } elseif ($orderStatus === 'TO SHIP') { - $statusClass = '#9586cd'; - } - elseif ($orderStatus === 'TO RECEIVE') { - $statusClass = '#ffc319'; - } elseif ($orderStatus === 'COMPLETED') { - $statusClass = '#88aaf3'; + switch ($orderStatus) { + case 'TO SHIP': + $backgroundColor = '#8061ef'; + $textColor = 'white'; + break; + case 'TO PAY': + $backgroundColor = '#1E6E58'; + $textColor = 'white'; + break; + case 'TO RECEIVE': + $backgroundColor = '#FFD700'; + $textColor = 'black'; + break; + case 'COMPLETED': + $backgroundColor = '#4c84ff'; + $textColor = 'white'; + break; + case 'RETURNED': + $backgroundColor = '#ff7b7b'; + $textColor = 'white'; + break; + default: + $backgroundColor = '#464646'; + $textColor = 'white'; } + + $style = "display: flex; height: 15px; font-weight: bold; + width: 90px; font-size: 10px !important; padding: 10px; + justify-content: center; align-items: center; + background-color: $backgroundColor; border-radius: 30px; color: $textColor;"; if ($formattedOrderDate == $currentDate) { $ordersDisplayed = true; @@ -1100,7 +1132,7 @@ $allSignups = array_merge($all_customers, $all_vendors); - + @@ -1175,7 +1207,8 @@ $allSignups = array_merge($all_customers, $all_vendors);
    customer image
    @@ -1254,7 +1287,8 @@ $allSignups = array_merge($all_customers, $all_vendors);
    customer image
    @@ -1318,6 +1352,7 @@ $allSignups = array_merge($all_customers, $all_vendors); + diff --git a/admin/order-history.php b/admin/order-history.php index d786135..f09fd4f 100644 --- a/admin/order-history.php +++ b/admin/order-history.php @@ -115,7 +115,7 @@ $orders = getAllOrder(); - Details + Details @@ -85,6 +89,7 @@ } else { ?> + diff --git a/forget_otp.php b/forget_otp.php index 77a7fc8..7c19bef 100644 --- a/forget_otp.php +++ b/forget_otp.php @@ -20,7 +20,10 @@ - + + diff --git a/forget_password_reset.php b/forget_password_reset.php index 7f59019..991c23a 100644 --- a/forget_password_reset.php +++ b/forget_password_reset.php @@ -18,7 +18,10 @@ - + + diff --git a/forgot_password.php b/forgot_password.php index 78a8e0c..409935e 100644 --- a/forgot_password.php +++ b/forgot_password.php @@ -19,7 +19,10 @@ - + + diff --git a/index.php b/index.php index 929d99e..ea2dea5 100644 --- a/index.php +++ b/index.php @@ -39,7 +39,10 @@ if ($_SESSION["userId"] <> "") { - + + diff --git a/login.php b/login.php index 44a8ed6..0f9d353 100644 --- a/login.php +++ b/login.php @@ -21,7 +21,10 @@ - + + diff --git a/more-vendors.php b/more-vendors.php index 62fa742..74dc709 100644 --- a/more-vendors.php +++ b/more-vendors.php @@ -33,7 +33,10 @@ $vendorSearchResult = $_SESSION["vendorSearchResult"]; - + + diff --git a/next_day_delivery.php b/next_day_delivery.php index db5b03f..c55f3bc 100644 --- a/next_day_delivery.php +++ b/next_day_delivery.php @@ -31,7 +31,10 @@ if ($_SESSION["userId"] <> "") { - + + diff --git a/offer.php b/offer.php index 7b6efe1..46f7a13 100644 --- a/offer.php +++ b/offer.php @@ -37,6 +37,9 @@ if ($_SESSION["userId"] <> "") { + diff --git a/privacy-policy.php b/privacy-policy.php index 64538cc..0886d3e 100644 --- a/privacy-policy.php +++ b/privacy-policy.php @@ -17,7 +17,10 @@ - + + diff --git a/product-left-sidebar.php b/product-left-sidebar.php index 2e4f79e..77b3048 100644 --- a/product-left-sidebar.php +++ b/product-left-sidebar.php @@ -66,7 +66,10 @@ if (isset($_GET['id'])) { - + + diff --git a/prohibited-item.php b/prohibited-item.php index ffc37b7..fd0ab1c 100644 --- a/prohibited-item.php +++ b/prohibited-item.php @@ -17,7 +17,10 @@ - + + diff --git a/register.php b/register.php index 12ac1e8..d69cd42 100644 --- a/register.php +++ b/register.php @@ -22,7 +22,10 @@ $_SESSION["isVendor"] = false; - + + diff --git a/register_customer.php b/register_customer.php index bfa0707..1c3e5cb 100644 --- a/register_customer.php +++ b/register_customer.php @@ -25,7 +25,10 @@ $customerData = json_decode($customers, true); - + + diff --git a/register_otp.php b/register_otp.php index 2ae6844..6165883 100644 --- a/register_otp.php +++ b/register_otp.php @@ -20,7 +20,10 @@ - + + diff --git a/register_vendor.php b/register_vendor.php index 5e95ea1..e734026 100644 --- a/register_vendor.php +++ b/register_vendor.php @@ -25,7 +25,10 @@ $vendorData = json_decode($vendors, true); - + + diff --git a/same_day_delivery_old.php b/same_day_delivery_old.php index a73b6bd..f527ef6 100644 --- a/same_day_delivery_old.php +++ b/same_day_delivery_old.php @@ -32,7 +32,10 @@ if ($_SESSION["userId"] <> "") { - + + diff --git a/shop-left-sidebar-col-4.php b/shop-left-sidebar-col-4.php index 8610584..58e4b2e 100644 --- a/shop-left-sidebar-col-4.php +++ b/shop-left-sidebar-col-4.php @@ -28,7 +28,10 @@ - + + diff --git a/shop-list-left-sidebar-test.php b/shop-list-left-sidebar-test.php index 7dc7215..a009ad8 100644 --- a/shop-list-left-sidebar-test.php +++ b/shop-list-left-sidebar-test.php @@ -104,7 +104,10 @@ if (!empty($_GET['minPrice']) || !empty($_GET['maxPrice']) || !empty($_GET['cate - + + diff --git a/shop-list-left-sidebar.php b/shop-list-left-sidebar.php index 45a1cd1..8160167 100644 --- a/shop-list-left-sidebar.php +++ b/shop-list-left-sidebar.php @@ -104,7 +104,10 @@ $filteredProducts = []; - + + diff --git a/shop-list-left-sidebar2.php b/shop-list-left-sidebar2.php index 67ad455..dccc98c 100644 --- a/shop-list-left-sidebar2.php +++ b/shop-list-left-sidebar2.php @@ -33,7 +33,10 @@ if ($_SESSION["userId"] <> "") { - + + diff --git a/terms-condition.php b/terms-condition.php index 8ff6001..abc23d4 100644 --- a/terms-condition.php +++ b/terms-condition.php @@ -17,7 +17,10 @@ - + + diff --git a/user-history.php b/user-history.php index 022101f..f602828 100644 --- a/user-history.php +++ b/user-history.php @@ -33,7 +33,10 @@ if ($_SESSION["isVendor"] == true) { - + + diff --git a/user-profile.php b/user-profile.php index 4892afb..c525917 100644 --- a/user-profile.php +++ b/user-profile.php @@ -37,7 +37,10 @@ if ($_SESSION["isVendor"] == true) { - + + @@ -336,7 +339,7 @@ if ($_SESSION["isVendor"] == true) {
    - +
    diff --git a/user-refund-history.php b/user-refund-history.php index 3e74a3f..aed8a92 100644 --- a/user-refund-history.php +++ b/user-refund-history.php @@ -37,7 +37,10 @@ if ($_SESSION["isVendor"] == true) { - + + diff --git a/vendor-all-product-list.php b/vendor-all-product-list.php index 3f412aa..5d2ae26 100644 --- a/vendor-all-product-list.php +++ b/vendor-all-product-list.php @@ -53,7 +53,10 @@ $products = productList(); - + + diff --git a/vendor-dashboard-orders-edit.php b/vendor-dashboard-orders-edit.php index fad233d..8b8a672 100644 --- a/vendor-dashboard-orders-edit.php +++ b/vendor-dashboard-orders-edit.php @@ -45,7 +45,10 @@ $array = json_decode($result, true); - + + @@ -223,11 +226,11 @@ $array = json_decode($result, true); if ($array['status'] === 'TO SHIP' || $array['status'] === 'To Ship') { echo '
    - +
    '; echo '
    - +
    '; } elseif ($array['status'] === 'TO RECEIVE' || $array['status'] === 'To Receive') { echo '
    diff --git a/vendor-dashboard.php b/vendor-dashboard.php index 43e4cb9..87db16c 100644 --- a/vendor-dashboard.php +++ b/vendor-dashboard.php @@ -64,7 +64,10 @@ if ($_SESSION["isCustomer"] == true) { - + + @@ -326,42 +329,42 @@ if ($_SESSION["isCustomer"] == true) { $textColor = ''; $borderColor = ''; - switch ($status) { - case 'TO SHIP': - $borderColor = 'mint'; - $textColor = 'min'; // Change this to match the text color you prefer - break; - case 'TO PAY': - $borderColor = '#E0EA00'; - $textColor = '#E0EA00'; - break; - case 'TO RECEIVE': - $borderColor = '#20FF5A'; - $textColor = '#20FF5A'; - break; - case 'COMPLETED': - $borderColor = '#2098FF'; - $textColor = '#2098FF'; // Change this to match the text color you prefer - break; - case 'TO REFUND': - $borderColor = '#FF5320'; - $textColor = '#FF5320'; - break; - default: - // Default styles if the status doesn't match any case - $borderColor = '#464646'; - $textColor = '#464646'; - } + switch (strtoupper($status)) { + case 'TO SHIP': + $backgroundColor = '#8061ef'; + $textColor = 'white'; + break; + case 'TO PAY': + $backgroundColor = '#1E6E58'; + $textColor = 'white'; + break; + case 'TO RECEIVE': + $backgroundColor = '#FFD700'; + $textColor = 'black'; + break; + case 'COMPLETED': + $backgroundColor = '#4c84ff'; + $textColor = 'white'; + break; + case 'RETURNED': + $backgroundColor = '#ff7b7b'; + $textColor = 'white'; + break; + default: + $backgroundColor = '#464646'; + $textColor = 'white'; + } - // Generating style attribute based on the selected colors - $style = "display: flex; height: 15px;font-weight:400; width:90px; margin-top:10px; font-size:10px !important; justify-content:center; align-items:center; padding: 10px; border: 3px solid $borderColor; border-radius: 30px; color: $textColor;"; - - ?> + // Generating style attribute based on the selected colors + $style = "display: flex; height: 15px; font-weight: bold; + width: 90px; font-size: 10px !important; + justify-content: center; align-items: center; padding: 10px; + background-color: $backgroundColor; border-radius: 30px; color: $textColor;"; + ?>

    - diff --git a/vendor-list.php b/vendor-list.php index 25333d3..458c7b7 100644 --- a/vendor-list.php +++ b/vendor-list.php @@ -33,7 +33,10 @@ $products = productList(); - + + diff --git a/vendor-payments.php b/vendor-payments.php index 525d735..78b562e 100644 --- a/vendor-payments.php +++ b/vendor-payments.php @@ -45,17 +45,21 @@ if ($_SESSION["isCustomer"] == true) { oBanana B2B - Elevate Your Business - + - + - + + @@ -75,40 +79,41 @@ if ($_SESSION["isCustomer"] == true) { - + @@ -124,13 +129,16 @@ if ($_SESSION["isCustomer"] == true) { - + + + +
    @@ -153,7 +161,7 @@ if ($_SESSION["isCustomer"] == true) {
    - +