diff --git a/admin/index.php b/admin/index.php index 2eee72d..43f9ce7 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1056,6 +1056,9 @@ $allSignups = array_merge($all_customers, $all_vendors);

Recent Orders

+
- +
@@ -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..0dc168d 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"; - } - ?> -

+

+ +

+

Account Created on

+

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

-
+

Payments

-
+
-
+
@@ -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 -