From cffda7e9e55f0c278b66228b72dbe7544f5cd069 Mon Sep 17 00:00:00 2001 From: jouls Date: Wed, 22 May 2024 15:46:15 +0800 Subject: [PATCH 1/8] edited vendor payouts breadcrumbs --- vendor-payouts.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor-payouts.php b/vendor-payouts.php index 228fd3a..e078b15 100644 --- a/vendor-payouts.php +++ b/vendor-payouts.php @@ -137,13 +137,13 @@ $vendorPayoutData = json_decode($response, true);
-

Vendor Settings

+

Vendor Payouts

  • Home
  • -
  • Settings
  • +
  • Payouts
From 4620fde33db1abea125ccd7f0251ab33e7454218 Mon Sep 17 00:00:00 2001 From: jouls Date: Wed, 22 May 2024 15:46:35 +0800 Subject: [PATCH 2/8] fixed vendor name and customer name on index --- header.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/header.php b/header.php index 4df2f85..6a8c53b 100644 --- a/header.php +++ b/header.php @@ -1802,7 +1802,7 @@ if ($_SESSION["userId"] <> "") {
- + From f616306a45512b51b2670137648762b28359805e Mon Sep 17 00:00:00 2001 From: jouls Date: Wed, 22 May 2024 18:46:36 +0800 Subject: [PATCH 3/8] added pagination admin vendor payments and payouts table --- admin/vendor-product-search.php | 278 ++++++------ admin/vendor-profile.php | 777 +++++++++++++++++--------------- 2 files changed, 564 insertions(+), 491 deletions(-) diff --git a/admin/vendor-product-search.php b/admin/vendor-product-search.php index 07b2977..51a96ae 100644 --- a/admin/vendor-product-search.php +++ b/admin/vendor-product-search.php @@ -93,7 +93,7 @@ $vendorSearchResult = $_SESSION["vendorSearchResult"]; - +
@@ -648,22 +648,22 @@ $vendorSearchResult = $_SESSION["vendorSearchResult"]; - - -
-
-
Vendor Search Results
-
- -
-
-
-
-
+ + +
+
+
Vendor Search Results
+
+ +
+
+
+
+ +
+
+ "> + + +
+
+
+
+
Seller Products
+ +

-
-
- "> - - -
-
-
-
-
Seller Products
+
+
+
+
Seller since
+

-

-
-
-
-
-
Seller since
-

-
+

-
-
-
- -
-
-
- - - - -
-
-
- $productListVendor) { - // echo "$product .":" . $productListVendor"; - // $vendorOfProduct = getVendorbyId($product['vendor_api_id']); - $products = productListVendor($vendorId); - $totalProducts = count($products); - - - for ($i = 0; $i <= $totalProducts - 1; $i++) { - $product = $products[$i]; - ?> -
-
-
-
-
- - edit - - edit - -
-
-
-

-

-
-
-
-
-
-
- -
+ $count++; + } + ?>
- - - - + - - - - + @@ -860,6 +866,6 @@ $vendorSearchResult = $_SESSION["vendorSearchResult"]; - + \ No newline at end of file diff --git a/admin/vendor-profile.php b/admin/vendor-profile.php index b112fa0..f4706ec 100644 --- a/admin/vendor-profile.php +++ b/admin/vendor-profile.php @@ -1,45 +1,44 @@ "") { - $_SESSION["isLoggedIn"] = true; - + $_SESSION["isLoggedIn"] = true; } else { - $_SESSION["isLoggedIn"] = false; - header("location: login.php"); + $_SESSION["isLoggedIn"] = false; + header("location: login.php"); } -if($_SESSION["user_type"]!="admin"){ - header("location: login.php?alert=Only admins allowed here!"); +if ($_SESSION["user_type"] != "admin") { + header("location: login.php?alert=Only admins allowed here!"); } $vendor = getVendorbyId($_SESSION["vendorId"]); -$vendorData = json_decode($vendor,true); +$vendorData = json_decode($vendor, true); $selectedBankAccount = null; foreach ($vendorData['bank_acount_details'] as $bankAccount) { - if ($bankAccount['bank_payout']) { - $selectedBankAccount = $bankAccount; - break; - } + if ($bankAccount['bank_payout']) { + $selectedBankAccount = $bankAccount; + break; + } } if ($selectedBankAccount === null && !empty($vendorData['bank_acount_details'])) { - $selectedBankAccount = $vendorData['bank_acount_details'][0]; + $selectedBankAccount = $vendorData['bank_acount_details'][0]; } $selectedBankAccountJSON = json_encode($selectedBankAccount); @@ -47,22 +46,22 @@ $selectedBankAccountJSON = json_encode($selectedBankAccount); $shopOrders = getOrderbyVendorId($_SESSION["vendorId"]); $vendorOrderss = json_decode($shopOrders); if (is_array($vendorOrderss)) { - $vendorOrders = json_decode($shopOrders); + $vendorOrders = json_decode($shopOrders); } elseif (is_object($vendorOrderss) && property_exists($vendorOrderss, 'message')) { - $vendorOrders = []; + $vendorOrders = []; } else { - echo "Unknown type or no 'message' property found."; + echo "Unknown type or no 'message' property found."; } $allPayouts = getAllPayout($_SESSION["token"]); -$vendorPayouts = json_decode($allPayouts,true); +$vendorPayouts = json_decode($allPayouts, true); $filteredPayouts = []; foreach ($vendorPayouts as $payout) { - if ($payout['vendor_details'][0]['vendor_id'] == $_SESSION["vendorId"]) { - $filteredPayouts[] = $payout; - } + if ($payout['vendor_details'][0]['vendor_id'] == $_SESSION["vendorId"]) { + $filteredPayouts[] = $payout; + } } // if (isset($_SESSION["token"])) { @@ -114,55 +113,82 @@ date_default_timezone_set('Asia/Manila'); - + setInterval(function() { + 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()); + if (currentTime >= renewalTime || currentTime >= expirationTime) { + console.log("Renewing token..."); + renewToken(); + } + }, 60000); + @@ -202,13 +228,14 @@ function renewToken() {
- " alt="user image" class="img-fluid rounded-circle" alt="Avatar Image" style="width: 100px; height: 100px; object-fit: cover; border-radius: 50%;">
@@ -245,28 +272,28 @@ function renewToken() { -->

Email address

-

+

Phone Number

-

- -

+

+ +

Vendor Since

-

- format('F j, Y'); - } else { - echo "Unknown"; - } - ?> -

+

+ format('F j, Y'); + } else { + echo "Unknown"; + } + ?> +

-
+

Payments

@@ -331,7 +349,7 @@ function renewToken() {
- +
@@ -345,19 +363,22 @@ function renewToken() { - + + ?> @@ -384,7 +405,7 @@ function renewToken() { -
>
+ + +
- + fetch('https:///api/v1/payouts/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + "Authorization": "Bearer " + token, + }, + body: JSON.stringify(postData) + }) + .then(response => { + if (response.ok) { + return response.json(); + } else { + throw new Error('Failed to create payout'); + } + }) + .then(data => { + console.log('Payout created successfully'); + selectedOrders.forEach(order => { + var orderId = order.orderId; + fetch(`https:///api/v1/orders/${orderId}`, { + method: 'PATCH', + headers: { + 'Content-Type': 'application/json', + "Authorization": "Bearer " + token, + }, + body: JSON.stringify({ + payout_status: { + payout_id: data._id, + status: "Processing" + } + }) + }) + .then(response => { + // if (!response.ok) { + // console.error(`Failed to update payout status for order ${orderId}`); + // } + if (!response.ok) { + console.error(`Failed to update payout status for order ${orderId}`); + } else { + location.reload(); + } + }) + .catch(error => { + console.error(`Error updating payout status for order ${orderId}:`, error); + }); + }); + }) + .catch(error => { + console.error('Error:', error); + }); + } +
-
+
-
+

Payouts

@@ -541,57 +613,99 @@ function renewToken() { - - + - - - - - - - - - - - - - - + $reversedPayouts = array_reverse($filteredPayouts); + for ($i = 0; $i < $totalPayoutOrders; $i++) { + $order_payouts = $reversedPayouts[$i]; + $displayPayoutDate = date('m-d-Y, g:i A', strtotime($order_payouts['createdAt'])); + ?> + + + + + + + + + + + + + +
+
+
-
+
@@ -796,8 +910,7 @@ function renewToken() {
-
+

Recent Orders

@@ -831,22 +944,13 @@ function renewToken() { Oct 20, 2018 $230 - Completed + Completed -