Merge pull request 'louie_branch' (#81) from louie_branch into main
Reviewed-on: #81
This commit is contained in:
commit
bf27328ec3
|
@ -29,17 +29,17 @@ if($_SESSION["user_type"]!="admin"){
|
|||
}
|
||||
|
||||
$vendor = getVendorbyId($_SESSION["vendorId"]);
|
||||
$array = json_decode($vendor,true);
|
||||
$vendorData = json_decode($vendor,true);
|
||||
|
||||
$selectedBankAccount = null;
|
||||
foreach ($array['bank_acount_details'] as $bankAccount) {
|
||||
foreach ($vendorData['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];
|
||||
if ($selectedBankAccount === null && !empty($vendorData['bank_acount_details'])) {
|
||||
$selectedBankAccount = $vendorData['bank_acount_details'][0];
|
||||
}
|
||||
$selectedBankAccountJSON = json_encode($selectedBankAccount);
|
||||
|
||||
|
@ -114,22 +114,6 @@ date_default_timezone_set('Asia/Manila');
|
|||
<!-- FAVICON -->
|
||||
<link href="assets/img/favicon.png" rel="shortcut icon" />
|
||||
|
||||
<!-- <script>
|
||||
function renewToken() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "token-renew.php", true);
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
setInterval(function() {
|
||||
var currentTime = <?php // echo time(); ?>;
|
||||
var renewalTime = <?php // echo $renewal_time; ?>;
|
||||
var expirationTime = <?php // echo $expiration_time; ?>;
|
||||
if (currentTime >= renewalTime || currentTime >= expirationTime) {
|
||||
renewToken();
|
||||
}
|
||||
}, 60000);
|
||||
</script> -->
|
||||
<script>
|
||||
|
||||
var token_parts = "<?php echo $_SESSION["token"]; ?>".split(".");
|
||||
|
@ -201,7 +185,8 @@ function renewToken() {
|
|||
<div class="content">
|
||||
<div class="breadcrumb-wrapper breadcrumb-contacts">
|
||||
<div>
|
||||
<h1><?php echo $array["first_name"]; ?></h1>
|
||||
<?php $vendorFullName = "{$vendorData['first_name']} {$vendorData['last_name']}"; ?>
|
||||
<h1><?php echo $vendorFullName ?></h1>
|
||||
<p class="breadcrumbs"><span><a href="index.php">Home</a></span><span><i class="mdi mdi-chevron-right"></i></span><span><a href="vendor-card.php">Vendors</a></span>
|
||||
<span><i class="mdi mdi-chevron-right"></i></span>Profile
|
||||
</p>
|
||||
|
@ -218,8 +203,8 @@ function renewToken() {
|
|||
<div class="text-center widget-profile px-0 border-0">
|
||||
<div class="card-img mx-auto rounded-circle">
|
||||
<img loading="lazy" src="<?php
|
||||
if($array["vendor_image"]!=""){
|
||||
echo $array["vendor_image"];
|
||||
if($vendorData["vendor_image"]!=""){
|
||||
echo $vendorData["vendor_image"];
|
||||
} else {
|
||||
echo "assets/img/vendor/u1.jpg";
|
||||
}
|
||||
|
@ -227,13 +212,13 @@ function renewToken() {
|
|||
?>" alt="user image" class="img-fluid rounded-circle" alt="Avatar Image" style="width: 100px; height: 100px; object-fit: cover; border-radius: 50%;">
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h4 class="py-2 text-dark"><?php echo $array["first_name"]; ?></h4>
|
||||
<p><?php echo $array["user_email"]; ?></p>
|
||||
<a class="btn btn-primary my-3" href="#">Follow</a>
|
||||
<h4 class="py-2 text-dark"><?php echo $vendorFullName ?></h4>
|
||||
<p><?php echo $vendorData["user_email"]; ?></p>
|
||||
<!-- <a class="btn btn-primary my-3" href="#">Follow</a> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between ">
|
||||
<!-- <div class="d-flex justify-content-between ">
|
||||
<div class="text-center pb-4">
|
||||
<h6 class="text-dark pb-2">1703</h6>
|
||||
<p>Friends</p>
|
||||
|
@ -248,49 +233,58 @@ function renewToken() {
|
|||
<h6 class="text-dark pb-2">1150</h6>
|
||||
<p>Following</p>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<hr class="w-100">
|
||||
|
||||
<div class="contact-info pt-4">
|
||||
<h5 class="text-dark">Contact Information</h5>
|
||||
<?php
|
||||
//echo date('Y-m-d H:i:s', $issued_at_time) . "<br>";
|
||||
//echo date('Y-m-d H:i:s', $expiration_time) . "<br>";
|
||||
//echo date('Y-m-d H:i:s', $renewal_time) . "<br>";
|
||||
//echo date('Y-m-d H:i:s', time()) . "<br>";
|
||||
|
||||
|
||||
?>
|
||||
<?php echo $_SESSION["token"] ?><br>
|
||||
<?php $real_time = date('Y-m-d H:i:s', $expiration_time); echo $real_time?>
|
||||
<?php // echo $_SESSION["email"] ?> <br>
|
||||
<?php // echo "Updated token: " . $token; ?>
|
||||
<?php // echo $_SESSION["password"] ?>
|
||||
<!-- <php echo $_SESSION["token"] ?><br>
|
||||
<php $real_time = date('Y-m-d H:i:s', $expiration_time); echo $real_time?>
|
||||
<php // echo $_SESSION["email"] ?> <br>
|
||||
<php // echo "Updated token: " . $token; ?>
|
||||
<php // echo $_SESSION["password"] ?> -->
|
||||
<p class="text-dark font-weight-medium pt-24px mb-2">Email address</p>
|
||||
<p><?php echo $array["user_email"]; ?></p>
|
||||
<p><?php echo $vendorData["user_email"]; ?></p>
|
||||
<p class="text-dark font-weight-medium pt-24px mb-2">Phone Number</p>
|
||||
<p>+00 1234 5678 91</p>
|
||||
<p class="text-dark font-weight-medium pt-24px mb-2">Birthday</p>
|
||||
<p>Dec 10, 1991</p>
|
||||
<p class="text-dark font-weight-medium pt-24px mb-2">Social Profile</p>
|
||||
<p class="social-button">
|
||||
<a href="#" class="mb-1 btn btn-outline btn-twitter rounded-circle">
|
||||
<i class="mdi mdi-twitter"></i>
|
||||
</a>
|
||||
<p>
|
||||
<?php
|
||||
if (!empty($vendorData["phone"])) {
|
||||
echo $vendorData["phone"];
|
||||
} else {
|
||||
echo "NONE";
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
<p class="text-dark font-weight-medium pt-24px mb-2">Vendor Since</p>
|
||||
<p>
|
||||
<?php
|
||||
if (!empty($vendorData["createdAt"])) {
|
||||
$createdAt = new DateTime($vendorData["createdAt"]);
|
||||
echo $createdAt->format('F j, Y');
|
||||
} else {
|
||||
echo "Unknown";
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
<!-- <p class="text-dark font-weight-medium pt-24px mb-2">Social Profile</p>
|
||||
<p class="social-button">
|
||||
<a href="#" class="mb-1 btn btn-outline btn-twitter rounded-circle">
|
||||
<i class="mdi mdi-twitter"></i>
|
||||
</a>
|
||||
|
||||
<a href="#" class="mb-1 btn btn-outline btn-linkedin rounded-circle">
|
||||
<i class="mdi mdi-linkedin"></i>
|
||||
</a>
|
||||
<a href="#" class="mb-1 btn btn-outline btn-linkedin rounded-circle">
|
||||
<i class="mdi mdi-linkedin"></i>
|
||||
</a>
|
||||
|
||||
<a href="#" class="mb-1 btn btn-outline btn-facebook rounded-circle">
|
||||
<i class="mdi mdi-facebook"></i>
|
||||
</a>
|
||||
<a href="#" class="mb-1 btn btn-outline btn-facebook rounded-circle">
|
||||
<i class="mdi mdi-facebook"></i>
|
||||
</a>
|
||||
|
||||
<a href="#" class="mb-1 btn btn-outline btn-skype rounded-circle">
|
||||
<i class="mdi mdi-skype"></i>
|
||||
</a>
|
||||
</p>
|
||||
<a href="#" class="mb-1 btn btn-outline btn-skype rounded-circle">
|
||||
<i class="mdi mdi-skype"></i>
|
||||
</a>
|
||||
</p> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -327,8 +321,7 @@ function renewToken() {
|
|||
<div class="row">
|
||||
<div class="col-12">
|
||||
<!-- Recent Order Table -->
|
||||
<div class="card card-default card-table-border-none ec-tbl"
|
||||
id="recent-orders">
|
||||
<div class="card card-default card-table-border-none ec-tbl"id="recent-orders">
|
||||
<div class="card-header justify-content-between">
|
||||
<h2>Payments</h2>
|
||||
|
||||
|
@ -353,60 +346,59 @@ function renewToken() {
|
|||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php
|
||||
$totalOrders = count($vendorOrders);
|
||||
for ($i = 0; $i < $totalOrders; $i++) {
|
||||
$order = $vendorOrders[$i];
|
||||
$orderArray = json_encode($order, true);
|
||||
$orderItems = json_decode($orderArray, true);
|
||||
|
||||
if ($orderItems['payment']['status'] === 'PAID') {
|
||||
foreach ($orderItems['items'] as $item) {
|
||||
$displayDate = date('m-d-Y, g:i A', strtotime($orderItems['updatedAt']));
|
||||
$isPayoutCompleted = !empty($orderItems['payout_status']);
|
||||
?>
|
||||
<tr>
|
||||
<td><input type="checkbox" <?php echo $isPayoutCompleted ? 'disabled' : ''; ?>></td>
|
||||
<td><?php echo $orderItems['payment_method']; ?></td>
|
||||
<td><?php echo $orderItems['total_amount']; ?></td>
|
||||
<td>
|
||||
<span class="badge badge-success"><?php echo $orderItems['payment']['status']; ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge badge-warning"><?php echo $isPayoutCompleted ? 'Yes' : 'No'; ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<a class="text-dark" href=""><?php echo $item['product']['name']; ?></a>
|
||||
</td>
|
||||
<td><?php echo $displayDate; ?></td>
|
||||
<td hidden><?php echo $orderItems['_id']; ?></td>
|
||||
<td class="text-right">
|
||||
<div class="dropdown show d-inline-block widget-dropdown">
|
||||
<a class="dropdown-toggle icon-burger-mini" href="" role="button" id="dropdown-recent-order1" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-display="static"></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdown-recent-order1">
|
||||
<li class="dropdown-item">
|
||||
<a href="#">Details</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
<?php
|
||||
$totalOrders = count($vendorOrders);
|
||||
for ($i = 0; $i < $totalOrders; $i++) {
|
||||
$order = $vendorOrders[$i];
|
||||
$orderArray = json_encode($order, true);
|
||||
$orderItems = json_decode($orderArray, true);
|
||||
|
||||
if (strtoupper($orderItems['payment']['status']) === 'PAID') {
|
||||
foreach ($orderItems['items'] as $item) {
|
||||
$displayDate = date('m-d-Y, g:i A', strtotime($orderItems['updatedAt']));
|
||||
$isPayoutCompleted = !empty($orderItems['payout_status']);
|
||||
?>
|
||||
<tr>
|
||||
<td><input type="checkbox" <?php echo $isPayoutCompleted ? 'disabled' : ''; ?>></td>
|
||||
<td><?php echo $orderItems['payment_method']; ?></td>
|
||||
<td><?php echo $orderItems['total_amount']; ?></td>
|
||||
<td>
|
||||
<span class="badge badge-success"><?php echo $orderItems['payment']['status']; ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge badge-warning"><?php echo $isPayoutCompleted ? 'Yes' : 'No'; ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<a class="text-dark" href=""><?php echo $item['product']['name']; ?></a>
|
||||
</td>
|
||||
<td><?php echo $displayDate; ?></td>
|
||||
<td hidden><?php echo $orderItems['_id']; ?></td>
|
||||
<td class="text-right">
|
||||
<div class="dropdown show d-inline-block widget-dropdown">
|
||||
<a class="dropdown-toggle icon-burger-mini" href="" role="button" id="dropdown-recent-order1" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-display="static"></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdown-recent-order1">
|
||||
<li class="dropdown-item">
|
||||
<a href="#">Details</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-end mt-5">
|
||||
<button type="button" class="btn btn-primary mb-2 btn-pill" onclick="createPayout()">Create Payout from Selected</button>
|
||||
</div>
|
||||
<div class="d-flex justify-content-end mt-5">
|
||||
<button type="button" class="btn btn-primary mb-2 btn-pill" onclick="createPayout()">Create Payout from Selected</button>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
<script>
|
||||
function createPayout() {
|
||||
var rows = document.querySelectorAll("#recent-orders tbody tr");
|
||||
var selectedBank = JSON.parse('<?php echo $selectedBankAccountJSON; ?>');
|
||||
|
@ -416,8 +408,8 @@ function renewToken() {
|
|||
var feesDeductionAdjustment = <?php echo $_SESSION["transfer_fee"] ?>;
|
||||
var feesPercentage = (feesDeductionAdjustment * 100) + '%';
|
||||
const token = '<?php echo $_SESSION["token"] ?>';
|
||||
const vendorId = '<?php echo ($array['_id']); ?>';
|
||||
const vendorName = '<?php echo ($array['user_login']); ?>';
|
||||
const vendorId = '<?php echo ($vendorData['_id']); ?>';
|
||||
const vendorName = '<?php echo ($vendorData['user_login']); ?>';
|
||||
rows.forEach(function(row) {
|
||||
var checkbox = row.querySelector("input[type=checkbox]");
|
||||
if (checkbox && checkbox.checked) {
|
||||
|
@ -456,10 +448,10 @@ function renewToken() {
|
|||
selectedBank
|
||||
],
|
||||
transaction_logs: selectedOrders,
|
||||
vendor_details: [
|
||||
{ vendor_id: vendorId,
|
||||
vendor_name: vendorName}
|
||||
],
|
||||
vendor_details: [{
|
||||
vendor_id: vendorId,
|
||||
vendor_name: vendorName
|
||||
}],
|
||||
status: "PENDING",
|
||||
created_by: "Sample User",
|
||||
};
|
||||
|
@ -588,7 +580,7 @@ function renewToken() {
|
|||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -420,6 +420,7 @@ $products = productList();
|
|||
} else {
|
||||
console.error("Product row with ID " + productId + " not found in the DOM.");
|
||||
}
|
||||
location.reload();
|
||||
} else {
|
||||
throw new Error("Error deleting product with ID " + productId + ": " + response.statusText);
|
||||
}
|
||||
|
@ -429,10 +430,7 @@ $products = productList();
|
|||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
<!-- End Vendor dashboard section -->
|
||||
|
|
|
@ -295,13 +295,13 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 03-19-24 Jun Jihad Bank Information -->
|
||||
<div class="col-md-12 col-sm-12" style="display:flex; justify-content: space-between">
|
||||
<h5>Bank Information </h5>
|
||||
<button type="button" class="btn btn-primary" id="vendorBankModalBtn" data-bs-toggle="modal" data-bs-target="#vendorBankModal">My Banks</button>
|
||||
</div>
|
||||
<!-- 03-19-24 Jun Jihad Bank Information -->
|
||||
<div class="col-md-12 col-sm-12" style="display:flex; justify-content: space-between">
|
||||
<h5>Bank Information </h5>
|
||||
<button type="button" class="btn btn-primary" id="vendorBankModalBtn" data-bs-toggle="modal" data-bs-target="#vendorBankModal">My Banks</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-sm-12">
|
||||
<div class="py-3 col-md-12 col-sm-12">
|
||||
<?php foreach ($vendorData['bank_acount_details'] as $bank_acount_details) : ?>
|
||||
<?php if ($bank_acount_details['bank_payout']) : ?>
|
||||
<table style="width:100%; border-collapse: collapse;">
|
||||
|
@ -544,7 +544,6 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Bank -->
|
||||
<div class="modal fade" id="vendorBankModal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-sm" role="document" style="max-width: 800px;">
|
||||
|
@ -561,19 +560,34 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
<div class="card-body">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12 mx-auto">
|
||||
<div class="form-check" style="display: flex; align-items: center;">
|
||||
<label class="form-check-label" for="address_<?php echo $vendor_index; ?>_<?php echo $bank_index; ?>">
|
||||
<strong style="font-weight: bold;">Bank Name: </strong><?php echo $bank['bank_name']; ?> <br>
|
||||
<strong style="font-weight: bold;">Bank Account Number: </strong><?php echo $bank['bank_account_number']; ?> <br>
|
||||
<strong style="font-weight: bold;">Bank Account Name: </strong><?php echo $bank['bank_account_name']; ?>
|
||||
</label>
|
||||
<div class="selectWrap" style="margin-left: auto; display: flex; align-items: center;">
|
||||
<input type="radio" style="height:15px !important; width: 15px !important;" name="payout_bank" id="payout_bank_<?php echo $vendor_index; ?>_<?php echo $bank_index; ?>" value="<?php echo $vendor_index; ?>_<?php echo $bank_index; ?>" onchange="setPayoutBank('<?php echo $vendor['_id']; ?>', <?php echo $bank_index; ?>, true)" <?php echo $bank['bank_payout'] ? 'checked' : ''; ?>>
|
||||
<label for="payout_bank_<?php echo $vendor_index; ?>_<?php echo $bank_index; ?>" style="margin-bottom: 0; margin-left: 5px;">Set as Payout Bank</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-10 mx-auto">
|
||||
<div class="form-check" style="display: flex; align-items: center;">
|
||||
<label class="form-check-label" for="address_<?php echo $vendor_index; ?>_<?php echo $bank_index; ?>">
|
||||
<strong style="font-weight: bold;">Bank Name: </strong><?php echo $bank['bank_name']; ?> <br>
|
||||
<strong style="font-weight: bold;">Bank Account Number: </strong><?php echo $bank['bank_account_number']; ?> <br>
|
||||
<strong style="font-weight: bold;">Bank Account Name: </strong><?php echo $bank['bank_account_name']; ?>
|
||||
</label>
|
||||
<div class="selectWrap" style="margin-left: auto; display: flex; align-items: center;">
|
||||
<input type="radio" style="height:15px !important; width: 15px !important;" name="payout_bank" id="payout_bank_<?php echo $vendor_index; ?>_<?php echo $bank_index; ?>" value="<?php echo $vendor_index; ?>_<?php echo $bank_index; ?>" onchange="setPayoutBank('<?php echo $vendor['_id']; ?>', <?php echo $bank_index; ?>, true)" <?php echo $bank['bank_payout'] ? 'checked' : ''; ?>>
|
||||
<label for="payout_bank_<?php echo $vendor_index; ?>_<?php echo $bank_index; ?>" style="margin-bottom: 0; margin-left: 5px;">Set as Payout Bank</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2 mx-auto">
|
||||
<div id="editDelete" style="display:flex; float:right; width:20px; margin-right:-10px;" >
|
||||
<?php
|
||||
$bank['id'] =$bank_index;
|
||||
$jsonBank = json_encode($bank)?>
|
||||
<a href="javascript:0" data-bs-toggle="modal" data-value=' <?php echo $jsonBank; ?>' data-bs-target="#editBankModal">
|
||||
<i class="fa-regular fa-pen-to-square" style="font-size:15px; float:right;"></i></a>
|
||||
<!-- <i class="fa-regular fa-trash-can" style="font-size:15px; float:right;"></i> -->
|
||||
</div>
|
||||
<div id="editDelete" style="display:flex; float:right; width:20px; margin-top:20px; margin-right:-20px; margin-top:30px;">
|
||||
<!-- <i class="fa-solid fa-pen" style="font-size:15px; float:right;"></i></a> -->
|
||||
<i onclick="deleteBank('<?php echo $vendor['_id']; ?>', <?php echo $bank_index; ?>, true)"
|
||||
class="fa-regular fa-trash-can" style="font-size:15px; float:right;"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -603,7 +617,6 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
<label for="bankAccountName" class="text-dark font-weight-medium pt-3 mb-2">Bank Account Name</label>
|
||||
<input type="text" class="form-control" id="bankAccountName">
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-primary mt-4" id="submitBankBtn">Add Bank</button>
|
||||
|
||||
</form>
|
||||
|
@ -613,6 +626,45 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Louie Added Edit Bank Modal -->
|
||||
<div class="modal fade" id="editBankModal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-sm" role="document" style="max-width: 800px;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body" style="overflow-y: auto; max-height: 90vh;">
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<label for="bankName" class="text-dark font-weight-medium pt-3 mb-2">Bank Name</label>
|
||||
<input type="text" class="form-control"
|
||||
id="bankName2"
|
||||
value="<?php echo $bank['bank_name']; ?>">
|
||||
<!-- <label for="addressFirstName" class="text-dark font-weight-medium pt-3 mb-2">First Name</label>-->
|
||||
<input type="hidden" class="form-control" id="bankId" >
|
||||
<input type="hidden" class="form-control" id="bankPayoutStatus" >
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="bankAccNum" class="text-dark font-weight-medium pt-3 mb-2">Bank Account Number</label>
|
||||
<input min="0" type="number" class="form-control" id="bankAccNum" value="<?php echo $bank['bank_account_number']; ?>">
|
||||
<!-- <label for="addressLastName" class="text-dark font-weight-medium pt-3 mb-2">Last Name</label>
|
||||
<input type="text" class="form-control" id="addressLastName"> -->
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="bankAccName" class="text-dark font-weight-medium pt-3 mb-2">Bank Account Name</label>
|
||||
<input type="text" class="form-control" id="bankAccName" value="<?php echo $bank['bank_account_name']; ?>" >
|
||||
<!-- <label for="addressContact" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
|
||||
<input type="number" class="form-control" id="addressContact"> -->
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-primary mt-4" id="editBankBtn">Submit</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
function preventErasePrefix(input) { /* secondmodal */
|
||||
|
||||
|
@ -915,6 +967,8 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
const vendorid = `<?php echo $_SESSION["LoggedInVendorId"]; ?>`;
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
@ -947,7 +1001,6 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
}
|
||||
})
|
||||
.then(provincesData => {
|
||||
|
||||
provincesData.forEach(province => {
|
||||
const option = new Option(province.name, province.code);
|
||||
provinceSelect.append(option);
|
||||
|
@ -1185,7 +1238,6 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
const bankName = $('#bankName').val();
|
||||
const bankAccountNumber = $('#bankAccountNumber').val();
|
||||
const bankAccountName = $('#bankAccountName').val();
|
||||
|
||||
const newBank = {
|
||||
bank_name: bankName,
|
||||
bank_account_number: bankAccountNumber,
|
||||
|
@ -1218,7 +1270,7 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
<script>
|
||||
async function updateAddressBilling(vendorid, addressIndex, isBilling) {
|
||||
try {
|
||||
const apiUrl = `https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/vendors/${vendorid}`;
|
||||
|
@ -1417,6 +1469,129 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<!-- Script added by Louie for Dynamic Edit Modal Box. May 08, 2024 -->
|
||||
<script>
|
||||
const vendorid = `<?php echo $_SESSION["LoggedInVendorId"]; ?>`;
|
||||
$('#editBankModal').on('shown.bs.modal', function (event) {
|
||||
var jsonString = $(event.relatedTarget).data('value');
|
||||
var jsonObject = JSON.parse(jsonString);
|
||||
console.log("This is the data", jsonObject)
|
||||
// shows inputed data by the vendor
|
||||
document.querySelector('input[id="bankName2"]').value = jsonObject.bank_name;
|
||||
document.querySelector('input[id="bankAccNum"]').value = jsonObject.bank_account_number;
|
||||
document.querySelector('input[id="bankAccName"]').value = jsonObject.bank_account_name;
|
||||
document.querySelector('input[id="bankPayoutStatus"]').value = jsonObject.bank_payout;
|
||||
document.querySelector('input[id="bankId"]').value = jsonObject.id;
|
||||
})
|
||||
|
||||
$('#editBankBtn').on('click', function() {
|
||||
|
||||
console.log(vendorid)
|
||||
// function updateAddress(){
|
||||
// Retrieve existing addresses from the API
|
||||
// fetch('https://api.obanana.shop/api/v1/customers/65482e8d209ff8d348bd30fd')
|
||||
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/vendors/' + vendorid)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
// Get the existing addresses array
|
||||
const existingBankDetails = data.bank_acount_details || [];
|
||||
|
||||
|
||||
console.log("This is the existing data", existingBankDetails)
|
||||
// Get the new bank details
|
||||
const editedbankName = $('#bankName2').val();
|
||||
const editedAccNum = $('#bankAccNum').val();
|
||||
const editedAccName = $('#bankAccName').val();
|
||||
const editedPayout = $('#bankPayoutStatus').val() === "true";
|
||||
const id = $('#bankId').val();
|
||||
console.log('this is the bank id '+ id)
|
||||
console.log(typeof editedPayout);
|
||||
console.log(editedPayout);
|
||||
|
||||
// Create a new address object
|
||||
let bankDetails = existingBankDetails
|
||||
|
||||
bankDetails[id]={
|
||||
bank_name: editedbankName,
|
||||
bank_account_number: editedAccNum,
|
||||
bank_account_name: editedAccName,
|
||||
bank_payout: editedPayout,
|
||||
};
|
||||
console.log( bankDetails[id])
|
||||
// Make a PATCH request to update the addresses array
|
||||
return fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/vendors/' + vendorid, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
bank_acount_details: bankDetails
|
||||
}),
|
||||
});
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
// Handle success (e.g., show a success message)
|
||||
location.reload();
|
||||
} else {
|
||||
// Handle error
|
||||
console.error('Failed to submit data');
|
||||
alert('Failed to submit data');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
// Handle network or other errors
|
||||
console.error('Error:', error);
|
||||
alert('Error submitting data');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Script added by Louie for Deleting Bank Information. May 08, 2024 -->
|
||||
<script>
|
||||
const vendorid = `<?php echo $_SESSION["LoggedInVendorId"]; ?>`;
|
||||
function deleteBank(vendorid, bankIndex) {
|
||||
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/vendors/' + vendorid)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
let existingBank = data.bank_acount_details || [];
|
||||
if (bankIndex >= 0 && bankIndex < existingBank.length) {
|
||||
existingBank.splice(bankIndex, 1);
|
||||
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/vendors/' + vendorid, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
bank_acount_details: existingBank
|
||||
}),
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
location.reload();
|
||||
// filter the delete action
|
||||
document.getElementById('form-check-' + bankIndex).remove();
|
||||
} else {
|
||||
console.error('Failed to submit data');
|
||||
alert('Failed to submit data');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('Error submitting data');
|
||||
});
|
||||
} else {
|
||||
console.log("Invalid address index.");
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('Error fetching vendor data');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
<!-- End Vendor setting section -->
|
||||
|
||||
|
|
|
@ -278,11 +278,11 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label for="inputEmail4" class="form-label">Product name</label>
|
||||
<input type="text" class="form-control slug-title" id="inputEmail4" name="product_name" value="<?php echo $array['product_name']; ?>">
|
||||
<input type="text" class="form-control slug-title" id="inputEmail4" name="product_name" value="<?php echo $array['product_name']; ?>" required>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Product Type</label>
|
||||
<select id="Categories" class="form-select" name="product_type" onchange="variables()">
|
||||
<select id="Categories" class="form-select" name="product_type" onchange="variables()" >
|
||||
<option value="simple" <?php if ($array['product_type'] == 'simple') {
|
||||
echo 'selected';
|
||||
} ?>>Simple</option>
|
||||
|
@ -467,7 +467,7 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
</div> -->
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Product Category</label>
|
||||
<select class="form-select" name="product_category" id="product_category">
|
||||
<select class="form-select" name="product_category" id="product_category" required>
|
||||
<option value="">Select Category</option>
|
||||
<option value="Electronics" <?php echo ($array['product_category'] === 'Electronics') ? 'selected' : ''; ?>>Electronics</option>
|
||||
<option value="Solar" <?php echo ($array['product_category'] === 'Solar') ? 'selected' : ''; ?>>Solar</option>
|
||||
|
@ -486,7 +486,7 @@ if ($_SESSION["isCustomer"] == true) {
|
|||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Product Status</label>
|
||||
<select class="form-select" name="status" id="status">
|
||||
<select class="form-select" name="status" id="status" required>
|
||||
<option value="">Select Product Status</option>
|
||||
<option value="Active" <?php echo ($array['status'] === 'Active') ? 'selected' : ''; ?>>Active</option>
|
||||
<option value="Inactive" <?php echo ($array['status'] === 'Inactive') ? 'selected' : ''; ?>>Inactive</option>
|
||||
|
|
Loading…
Reference in New Issue