-
-
+
- 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-profile.php b/admin/vendor-profile.php
index f923609..2c2df12 100644
--- a/admin/vendor-profile.php
+++ b/admin/vendor-profile.php
@@ -2,30 +2,91 @@
include "../functions.php";
if(isset($_SESSION["vendorId"])){
- if(isset($_GET["id"])){
- $_SESSION["vendorId"]=$_GET["id"];
- }
+ if(isset($_GET["id"])){
+ $_SESSION["vendorId"]=$_GET["id"];
+ }
} else {
- if(isset($_GET["id"])){
- $_SESSION["vendorId"]=$_GET["id"];
- } else {
- header("location: vendor-card.php");
- }
+ if(isset($_GET["id"])){
+ $_SESSION["vendorId"]=$_GET["id"];
+ } else {
+ header("location: vendor-card.php");
+ }
}
+
$_SESSION["url"] = $_SERVER['REQUEST_URI'];
+
+
if ($_SESSION["userId"] <> "") {
$_SESSION["isLoggedIn"] = true;
- //$customer_data = getCustomerbyLoginId($_SESSION["userId"]);
+
} else {
$_SESSION["isLoggedIn"] = false;
- header("location: login.php");
+ header("location: login.php");
}
+
if($_SESSION["user_type"]!="admin"){
- header("location: login.php?alert=Only admins allowed here!");
+ header("location: login.php?alert=Only admins allowed here!");
}
+
$vendor = getVendorbyId($_SESSION["vendorId"]);
$array = json_decode($vendor,true);
+
+$selectedBankAccount = null;
+foreach ($array['bank_acount_details'] as $bankAccount) {
+ if ($bankAccount['bank_payout']) {
+ $selectedBankAccount = $bankAccount;
+ break;
+ }
+}
+if ($selectedBankAccount === null && !empty($array['bank_acount_details'])) {
+ $selectedBankAccount = $array['bank_acount_details'][0];
+}
+$selectedBankAccountJSON = json_encode($selectedBankAccount);
+
+
+$shopOrders = getOrderbyVendorId($_SESSION["vendorId"]);
+$vendorOrderss = json_decode($shopOrders);
+if (is_array($vendorOrderss)) {
+ $vendorOrders = json_decode($shopOrders);
+} elseif (is_object($vendorOrderss) && property_exists($vendorOrderss, 'message')) {
+ $vendorOrders = [];
+} else {
+ echo "Unknown type or no 'message' property found.";
+}
+
+$allPayouts = getAllPayout($_SESSION["token"]);
+$vendorPayouts = json_decode($allPayouts,true);
+
+
+$filteredPayouts = [];
+foreach ($vendorPayouts as $payout) {
+ if ($payout['vendor_details'][0]['vendor_id'] == $_SESSION["vendorId"]) {
+ $filteredPayouts[] = $payout;
+ }
+}
+
+$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;
+}
+// $token = loginRenew($_SESSION["email"], $_SESSION["password"], $token);
+// $_SESSION["token"] = $token;
+
+
?>
+
@@ -128,6 +189,18 @@ $array = json_decode($vendor,true);