diff --git a/admin/.gitignore b/admin/.gitignore new file mode 100644 index 0000000..9b15ad2 --- /dev/null +++ b/admin/.gitignore @@ -0,0 +1,2 @@ +# ignore config.php +config.php diff --git a/admin/config.php b/admin/config.php index 2c49fab..d51d6b8 100644 --- a/admin/config.php +++ b/admin/config.php @@ -1,8 +1,9 @@
-
-
- - -
-
+
+
+ + +
+
diff --git a/admin/index.php b/admin/index.php index 814484e..21284dc 100644 --- a/admin/index.php +++ b/admin/index.php @@ -117,7 +117,7 @@ if($_SESSION["user_type"]!="admin"){ Setting diff --git a/admin/payout_deposit_action.php b/admin/payout_deposit_action.php new file mode 100644 index 0000000..c7f9339 --- /dev/null +++ b/admin/payout_deposit_action.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/admin/product-edit-action.php b/admin/product-edit-action.php index 62baaaf..09f9440 100644 --- a/admin/product-edit-action.php +++ b/admin/product-edit-action.php @@ -65,6 +65,7 @@ $response = editProduct( $color, $material, $size, + $priceMatrix, $token); $array = json_decode($response, true); $_SESSION['prodictId'] = $array['_id']; diff --git a/admin/product-edit.php b/admin/product-edit.php index 81cfeb2..1b25475 100644 --- a/admin/product-edit.php +++ b/admin/product-edit.php @@ -907,6 +907,33 @@ $vendorId = $_SESSION["vendorId"]; )
+ + +
+ + + + + + + + + + + $pair) : ?> + + + + + + + + +
QuantityPrice (PHP)
+ +
+ +
@@ -1021,6 +1048,100 @@ $vendorId = $_SESSION["vendorId"]; newquill.on('text-change', function() { document.getElementById('short-hidden-editor').value = newquill.root.innerHTML; }); + + // 3-20-24 raymart added function for price matrix + document.getElementById("add-row").addEventListener("click", function() { + var newRow = '' + + '' + + '' + + '' + + ''; + document.getElementById("price-matrix-body").insertAdjacentHTML('beforeend', newRow); + + var quantityInputs = document.querySelectorAll('.quantity-input'); + var lastIndex = quantityInputs.length - 1; + quantityInputs[lastIndex].addEventListener('blur', function(event) { + checkQuantity(event, lastIndex); + }); + }); + + document.getElementById("price-matrix-body").addEventListener("click", function(event) { + if (event.target.classList.contains("delete-row")) { + event.preventDefault(); + var rows = document.querySelectorAll("#price-matrix-body tr"); + if (rows.length > 1) { + event.target.closest("tr").remove(); + } else { + alert("At least one row is required."); + } + } + }); + + function checkQuantity(event, index) { + var currentInput = event.target; + var previousRow = currentInput.parentNode.parentNode.previousElementSibling; + var nextRow = currentInput.parentNode.parentNode.nextElementSibling; + + if (previousRow !== null) { + var previousQuantityInput = previousRow.querySelector('input[name="quantity[]"]'); + var currentQuantity = parseInt(currentInput.value); + var previousQuantity = parseInt(previousQuantityInput.value); + + if (currentQuantity <= previousQuantity) { + alert("Quantity must be greater than the previous row's quantity."); + currentInput.value = previousQuantity + 1; + } + } + + if (nextRow !== null) { + var nextQuantityInput = nextRow.querySelector('input[name="quantity[]"]'); + var nextQuantity = parseInt(nextQuantityInput.value); + + if (currentQuantity >= nextQuantity) { + alert("Quantity must be less than the next row's quantity."); + currentInput.value = nextQuantity - 1; + } + } + } + + function checkExistingQuantity(row) { + var currentInput = row.querySelector('input[name="quantity[]"]'); + var allRows = document.querySelectorAll("#price-matrix-body tr"); + var currentIndex = Array.from(allRows).indexOf(row); + + for (var i = currentIndex - 1; i >= 0; i--) { + var previousRow = allRows[i]; + var previousQuantityInput = previousRow.querySelector('input[name="quantity[]"]'); + var currentQuantity = parseInt(currentInput.value); + var previousQuantity = parseInt(previousQuantityInput.value); + + if (currentQuantity <= previousQuantity) { + alert("Quantity must be greater than the previous row's quantity."); + currentInput.value = previousQuantity + 1; + return; + } + } + + var nextRow = allRows[currentIndex + 1]; + if (nextRow !== undefined) { + var nextQuantityInput = nextRow.querySelector('input[name="quantity[]"]'); + var nextQuantity = parseInt(nextQuantityInput.value); + + if (currentQuantity >= nextQuantity) { + alert("Quantity must be less than the next row's quantity."); + currentInput.value = nextQuantity - 1; + return; + } + } + } + + document.getElementById("price-matrix-body").addEventListener("blur", function(event) { + if (event.target.tagName === "INPUT" && event.target.name === "quantity[]") { + checkExistingQuantity(event.target.closest("tr")); + } + }, true); + // 3-20-24 raymart added function for price matrix + - function renewToken(sessionToken, email, password, userId) { - // Add your logic here to renew the login token - login(email, password, sessionToken, function() { - // Callback function after renewing the token, e.g., show the modal - showTheModal(userId); - }); - } + + - function login(username, password, sessionToken, callback) { - fetch("https:///api/v1/login", { - method: "POST", - headers: { - "Content-Type": "application/json", - "X-Api-Key": "{{apiKey}}" - }, - body: JSON.stringify({ - username: username, - password: password - }) - }) - .then(response => { - if (response.ok) { - return response.json(); - } else { - throw new Error("Unable to login"); - } - }) - .then(data => { - // Update the session token on the server side - fetch("update-token-session.php", { - method: "POST", - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify({ - token: data.token - }) - }) - .then(response => response.json()) - .then(result => { - if (result.status === 'success') { - // Update the session token in the client-side variable - sessionToken = data.token; - console.log("New Token:", sessionToken); - callback(); - } else { - throw new Error("Unable to update session token"); - } - }); - }) - .catch(error => { - console.error("Error:", error.message); - }); - } - - function showTheModal(userId) { - // Add your logic here to show the modal - // You may need to trigger it manually if using Bootstrap modal - $('#modalContact-' + userId).modal('show'); - } - - -
- - - diff --git a/admin/vendor-card.php b/admin/vendor-card.php index 79fea72..f348835 100644 --- a/admin/vendor-card.php +++ b/admin/vendor-card.php @@ -80,564 +80,12 @@ $products = productList(); + + +
- - -
@@ -651,8 +99,16 @@ $products = productList();
- +
+
+
+ + +
+
No Vendor Found.

'; + } // $vendors = vendorList(); for ($x = $start; $x <= $end && $x < $totalVendors; $x++) { $vendor = $vendors[$x]; @@ -684,7 +161,7 @@ $products = productList(); if (isset($vendor['vendor_image']) && !empty($vendor['vendor_image'])) { echo 'Avatar Image '; } else { - echo 'Placeholder Image'; + echo 'Placeholder Image'; } ?>
@@ -694,15 +171,15 @@ $products = productList();
-
- -
+
+ +
- + @@ -418,14 +483,21 @@ $array = json_decode($vendor,true); + - ₱1,230 - EastWest - **** **** 1234 - Jon-Jon Manaay - Oct 20, 2018 + + + + + - Deposited + - - - - - ₱2,340 - EastWest - **** **** 1234 - Jon-Jon Manaay - Oct 27, 2018 - - Processing - - - - + @@ -533,7 +579,7 @@ $array = json_decode($vendor,true);
-
+
@@ -909,6 +955,12 @@ $array = json_decode($vendor,true);
+
+ + + + +
@@ -916,7 +968,23 @@ $array = json_decode($vendor,true);
-
+ + + + + + + + + + + + + + +
Bank Name
Account Number
Account Name
+ +
diff --git a/catalog-single-vendor.php b/catalog-single-vendor.php index b158760..d567c64 100644 --- a/catalog-single-vendor.php +++ b/catalog-single-vendor.php @@ -131,29 +131,6 @@ if (!empty($_GET['minPrice']) || !empty($_GET['maxPrice']) || !empty($_GET['cate - + +
diff --git a/vendor-payouts.php b/vendor-payouts.php index 40cd2fd..5b84f9c 100644 --- a/vendor-payouts.php +++ b/vendor-payouts.php @@ -3,24 +3,41 @@ include "functions.php"; if ($_SESSION["userId"] <> "") { $_SESSION["isLoggedIn"] = true; - // $customer_data = getCustomerbyLoginId($_SESSION["userId"]); - $vendorLoginId = searchVendorbyLoginId($_SESSION["userId"]); - $vendorLoginIdjson = json_decode($vendorLoginId, true); - if (isset($vendorLoginIdjson['results'][0])) { - $vendorData = $vendorLoginIdjson['results'][0]; - $vendorId = $vendorData['_id']; - $_SESSION["LoggedInVendorId"] = $vendorId; - } - // $vendor= getVendorbyId($vendorLoginIdjson['results'][0]['_id']); - // // var_dump($vendor); - // $array = json_decode($vendor,true); - // var_dump($array); - $response = getAllPayout($_SESSION['token']); - $vendorPayoutData = json_decode($response, true); } else { $_SESSION["isLoggedIn"] = false; header("location: login.php"); } + +// $customer_data = getCustomerbyLoginId($_SESSION["userId"]); +$vendorLoginId = searchVendorbyLoginId($_SESSION["userId"]); +$vendorLoginIdjson = json_decode($vendorLoginId, true); +if (isset($vendorLoginIdjson['results'][0])) { + $vendorData = $vendorLoginIdjson['results'][0]; + $vendorId = $vendorData['_id']; + $_SESSION["LoggedInVendorId"] = $vendorId; +} + +$token = $_SESSION["token"]; + +$token_parts = explode(".", $token); +$token_payload = base64_decode($token_parts[1]); +$token_data = json_decode($token_payload); + +$expiration_time = $token_data->exp; +$issued_at_time = $token_data->iat; + +$renewal_time = $issued_at_time + 3300; + + +if (time() >= $renewal_time) { + $token = loginRenew($_SESSION["email"], $_SESSION["password"], $token); + $_SESSION["token"] = $token; +} + +$authToken = $_SESSION['token']; +$response = getAllPayout($authToken); +$vendorPayoutData = json_decode($response, true); + ?> @@ -55,12 +72,32 @@ if ($_SESSION["userId"] <> "") { + + + + @@ -150,19 +187,42 @@ if ($_SESSION["userId"] <> "") {

+ $val) { + $paymentStatus = strtolower($val['payment']['status']); + $orderStatus = $val['status']; + $payoutStatus = empty($val['payout_status']); + if(( $paymentStatus == "paid") && ( $orderStatus == "COMPLETED") && ($payoutStatus == true)){ + $orderAmount = $val['total_amount']; + $payoutSum += $orderAmount; + } + } + + $finalPayoutSum = number_format($payoutSum, 2, '.', ','); + ?> - ₱ 0.00 + ₱

-
+
- Receipient: Philippine National Bank (PNB) Account ending in 6685 + + Receipient: Philippine National Bank (PNB) Account ending in
@@ -216,16 +276,16 @@ if ($_SESSION["userId"] <> "") { Receive Payout on or before: Wed, Mar 26, 2024
- Receipient: Philippine National Bank (PNB) Account ending in 6685 + Receipient: Philippine National Bank (PNB) Account ending in
-
Payout History
-
- +
Payout History
+
+
@@ -237,51 +297,46 @@ if ($_SESSION["userId"] <> "") { - + $val) { $vendorIdCheck = $val['vendor_details'][0]['vendor_id']; - if ((empty($vendorIdCheck) == false) && ($vendorIdCheck == $vendorId) && ($val['status'] == "DEPOSITED")) { - echo ""; - echo ""; - if (empty($val['bank_information'][0]['bank_name']) == false) { - echo ""; - // echo ""; - } else { - echo ''; - } - if (empty($val['bank_information'][0]['bank_account_number']) == false) { - echo ""; - // echo ""; - } else { - echo ''; - }; - echo ""; - echo ""; - echo ""; - echo ""; + $status = ucfirst(strtolower($val['status'])); + $payoutDate = date("F d, Y", strtotime($val['createdAt'])); + $payoutId = $val['_id']; + if ((empty($vendorIdCheck) == false) && ($vendorIdCheck == $vendorId) && ($status == "Deposited")) { ?> + + + + + + + + + + + + + + + + - + } ?>
Amount
" . $val['net_amount'] . "" . $val['bank_information'][0]['bank_name'] . "" . $val['bank_information'][0]['account_number'] . "N/A" . $val['bank_information'][0]['bank_account_number'] . "" . $val['bank_information'][0]['account_number'] . "N/ADecember 08, 2024" . $val['status'] . "" . - "" . - "
N/A N/A + + +
+
@@ -290,105 +345,27 @@ if ($_SESSION["userId"] <> "") { -