mark_4 #83

Merged
MarkHipe merged 2 commits from mark_4 into main 2024-05-08 18:07:25 +08:00
11 changed files with 559 additions and 376 deletions
Showing only changes of commit 2c47485103 - Show all commits

View File

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

View File

@ -140,10 +140,10 @@
<div class="footer-bottom-social">
<span class="social-text text-upper">Follow us on:</span>
<ul class="mb-0">
<li class="list-inline-item"><a class="hdr-facebook" href="#"><i class="ecicon eci-facebook"></i></a></li>
<li class="list-inline-item"><a class="hdr-twitter" href="#"><i class="ecicon eci-twitter"></i></a></li>
<li class="list-inline-item"><a class="hdr-instagram" href="#"><i class="ecicon eci-instagram"></i></a></li>
<li class="list-inline-item"><a class="hdr-linkedin" href="#"><i class="ecicon eci-linkedin"></i></a></li>
<li class="list-inline-item"><a class="hdr-facebook" href="https://www.facebook.com/ObananaPH/"><i class="ecicon eci-facebook"></i></a></li>
<li class="list-inline-item"><a class="hdr-twitter" href="https://twitter.com/obananac?lang=en"><i class="ecicon eci-twitter"></i></a></li>
<li class="list-inline-item"><a class="hdr-instagram" href="https://www.instagram.com/obananaph/"><i class="ecicon eci-instagram"></i></a></li>
<li class="list-inline-item"><a class="hdr-linkedin" href="https://ph.linkedin.com/company/obananaph"><i class="ecicon eci-linkedin"></i></a></li>
</ul>
</div>
</div>

View File

@ -379,7 +379,6 @@ if ($_SESSION["userId"] <> "") {
} else {
?>
<li><a class="dropdown-item" href="register.php">Register</a></li>
<li><a class="dropdown-item" href="checkout.html">Checkout</a></li>
<li><a class="dropdown-item" href="login.php">Login</a></li>
<?php
}
@ -923,9 +922,15 @@ if ($_SESSION["userId"] <> "") {
<div class="row">
<div class="col-md-12 align-self-center">
<div class="ec-main-menu">
<a href="javascript:void(0)" class="ec-header-btn ec-sidebar-toggle">
<i class="fi fi-rr-apps"></i>
</a>
<?php
$currentFile = basename($_SERVER['PHP_SELF']);
if ($currentFile != 'login.php' && !isset($_SESSION["isVendor"])) { ?>
<a href="javascript:void(0)" class="ec-header-btn ec-sidebar-toggle">
<i class="fi fi-rr-apps"></i>
</a>
<?php
}
?>
<ul>
<li><a href="index.php">Home</a></li>
<!-- <li class="dropdown position-static"><a href="javascript:void(0)">Categories</a>

View File

@ -191,13 +191,13 @@ if ($_SESSION["userId"] <> "") {
<!-- Tab Start -->
<div class="col-md-12 text-center">
<ul class="ec-pro-tab-nav nav justify-content-center">
<li class="nav-item"><a class="nav-link active" data-bs-toggle="tab" href="#tab-pro-for-all">For
<li class="nav-item"><a class="nav-link active" data-bs-toggle="tab" href="#all-top-products">For
All</a></li>
<li class="nav-item"><a class="nav-link" data-bs-toggle="tab" href="#tab-pro-for-men">For
<li class="nav-item"><a class="nav-link" data-bs-toggle="tab" href="#electronics">For
Electronics</a></li>
<li class="nav-item"><a class="nav-link" data-bs-toggle="tab" href="#tab-pro-for-women">For
<li class="nav-item"><a class="nav-link" data-bs-toggle="tab" href="#smart-home">For
Smart Home</a></li>
<li class="nav-item"><a class="nav-link" data-bs-toggle="tab" href="#tab-pro-for-child">For
<li class="nav-item"><a class="nav-link" data-bs-toggle="tab" href="#e-vehicle">For
E-Vehicle</a></li>
</ul>
</div>
@ -207,7 +207,7 @@ if ($_SESSION["userId"] <> "") {
<div class="col">
<div class="tab-content">
<!-- 1st Product tab start -->
<div class="tab-pane fade show active" id="tab-pro-for-all">
<div class="tab-pane fade show active" id="all-top-products">
<div class="row">
<!-- Product Content -->
<?php
@ -331,7 +331,7 @@ if ($_SESSION["userId"] <> "") {
</div>
<!-- ec 1st Product tab end -->
<!-- ec 2nd Product tab start -->
<div class="tab-pane fade" id="tab-pro-for-men">
<div class="tab-pane fade" id="electronics">
<div class="row">
<!-- Product Content -->
<?php
@ -453,7 +453,7 @@ if ($_SESSION["userId"] <> "") {
</div>
<!-- ec 2nd Product tab end -->
<!-- ec 3rd Product tab start -->
<div class="tab-pane fade" id="tab-pro-for-women">
<div class="tab-pane fade" id="smart-home">
<div class="row">
<!-- Product Content -->
<?php
@ -573,7 +573,7 @@ if ($_SESSION["userId"] <> "") {
</div>
<!-- ec 3rd Product tab end -->
<!-- ec 4th Product tab start -->
<div class="tab-pane fade" id="tab-pro-for-child">
<div class="tab-pane fade" id="e-vehicle">
<div class="row">
<!-- Product Content -->
<?php

View File

@ -436,7 +436,7 @@ xhrVendors.onreadystatechange = function() {
</div>
<div class="card text-center" style="margin-left: auto; margin-right: 5px;">
<div class="card-body">
<h6>Seller Productsss</h6>
<h6>Seller Products</h6>
<p>${productCount}</p>
</div>
</div>
@ -783,49 +783,58 @@ maxPriceInput.addEventListener('input', function() {
<ul>
<li>
<div class="ec-sidebar-block-item">
<input type="checkbox" name="category[]" value="Electronics" <?php echo (isset($_POST['category']) && in_array('Electronics', $_POST['category'])) || (isset($_GET['category']) && in_array('Electronics', $_GET['category'])) ? 'checked' : ''; ?> /> <a>Electronics</a><span class="checked"></span>
<input type="checkbox" name="category[]" id="electronics_category" value="Electronics" <?php echo (isset($_POST['category']) && in_array('Electronics', $_POST['category'])) || (isset($_GET['category']) && in_array('Electronics', $_GET['category'])) ? 'checked' : ''; ?> />
<a><label for="electronics_category" style="cursor: pointer; margin: 0px;">Electronics</label></a><span class="checked"></span>
</div>
</li>
<li>
<div class="ec-sidebar-block-item">
<input type="checkbox" name="category[]" value="Solar" <?php echo (isset($_POST['category']) && in_array('Solar', $_POST['category'])) || (isset($_GET['category']) && in_array('Solar', $_GET['category'])) ? 'checked' : ''; ?> /> <a>Solar</a><span class="checked"></span>
<input type="checkbox" name="category[]" id="solar_category" value="Solar" <?php echo (isset($_POST['category']) && in_array('Solar', $_POST['category'])) || (isset($_GET['category']) && in_array('Solar', $_GET['category'])) ? 'checked' : ''; ?> />
<a><label for="solar_category" style="cursor: pointer; margin: 0px;">Solar</a></label><span class="checked"></span>
</div>
</li>
<li>
<div class="ec-sidebar-block-item">
<input type="checkbox" name="category[]" value="E-bike" <?php echo (isset($_POST['category']) && in_array('E-bike', $_POST['category'])) || (isset($_GET['category']) && in_array('E-bike', $_GET['category'])) ? 'checked' : ''; ?> /> <a>E-bike</a><span class="checked"></span>
<input type="checkbox" name="category[]" id="e-bike_category" value="E-bike" <?php echo (isset($_POST['category']) && in_array('E-bike', $_POST['category'])) || (isset($_GET['category']) && in_array('E-bike', $_GET['category'])) ? 'checked' : ''; ?> />
<a><label for="e-bike_category" style="cursor: pointer; margin: 0px;">E-bike</a></label><span class="checked"></span>
</div>
</li>
<li>
<div class="ec-sidebar-block-item">
<input type="checkbox" name="category[]" value="E-vehicle" <?php echo (isset($_POST['category']) && in_array('E-vehicle', $_POST['category'])) || (isset($_GET['category']) && in_array('E-vehicle', $_GET['category'])) ? 'checked' : ''; ?> /> <a>E-vehicle</a><span class="checked"></span>
<input type="checkbox" name="category[]" id="e-vehicle_category" value="E-vehicle" <?php echo (isset($_POST['category']) && in_array('E-vehicle', $_POST['category'])) || (isset($_GET['category']) && in_array('E-vehicle', $_GET['category'])) ? 'checked' : ''; ?> />
<a><label for="e-vehicle_category" style="cursor: pointer; margin: 0px;">E-vehicle</a></label><span class="checked"></span>
</div>
</li>
<li>
<div class="ec-sidebar-block-item">
<input type="checkbox" name="category[]" value="Appliance" <?php echo (isset($_POST['category']) && in_array('Appliance', $_POST['category'])) || (isset($_GET['category']) && in_array('Appliance', $_GET['category'])) ? 'checked' : ''; ?> /> <a>Appliance</a><span class="checked"></span>
<input type="checkbox" name="category[]" id="appliance_category" value="Appliance" <?php echo (isset($_POST['category']) && in_array('Appliance', $_POST['category'])) || (isset($_GET['category']) && in_array('Appliance', $_GET['category'])) ? 'checked' : ''; ?> />
<a><label for="appliance_category" style="cursor: pointer; margin: 0px;">Appliance</a></label><span class="checked"></span>
</div>
</li>
<li>
<div class="ec-sidebar-block-item">
<input type="checkbox" name="category[]" value="Smart Home" <?php echo (isset($_POST['category']) && in_array('Smart Home', $_POST['category'])) || (isset($_GET['category']) && in_array('Smart Home', $_GET['category'])) ? 'checked' : ''; ?> /> <a>Smart Home</a><span class="checked"></span>
<input type="checkbox" name="category[]" id="smart-home_category" value="Smart Home" <?php echo (isset($_POST['category']) && in_array('Smart Home', $_POST['category'])) || (isset($_GET['category']) && in_array('Smart Home', $_GET['category'])) ? 'checked' : ''; ?> />
<a><label for="smart-home_category" style="cursor: pointer; margin: 0px;">Smart Home</a></label><span class="checked"></span>
</div>
</li>
<li>
<div class="ec-sidebar-block-item">
<input type="checkbox" name="category[]" value="Home" <?php echo (isset($_POST['category']) && in_array('Home', $_POST['category'])) || (isset($_GET['category']) && in_array('Home', $_GET['category'])) ? 'checked' : ''; ?> /> <a>Home</a><span class="checked"></span>
<input type="checkbox" name="category[]" id="home_category" value="Home" <?php echo (isset($_POST['category']) && in_array('Home', $_POST['category'])) || (isset($_GET['category']) && in_array('Home', $_GET['category'])) ? 'checked' : ''; ?> />
<a><label for="home_category" style="cursor: pointer; margin: 0px;">Home</a></label><span class="checked"></span>
</div>
</li>
<li>
<div class="ec-sidebar-block-item">
<input type="checkbox" name="category[]" value="Apparel" <?php echo (isset($_POST['category']) && in_array('Apparel', $_POST['category'])) || (isset($_GET['category']) && in_array('Apparel', $_GET['category'])) ? 'checked' : ''; ?> /> <a>Apparel</a><span class="checked"></span>
<input type="checkbox" name="category[]" id="apparel_category" value="Apparel" <?php echo (isset($_POST['category']) && in_array('Apparel', $_POST['category'])) || (isset($_GET['category']) && in_array('Apparel', $_GET['category'])) ? 'checked' : ''; ?> />
<a><label for="apparel_category" style="cursor: pointer; margin: 0px;">Apparel</a></label><span class="checked"></span>
</div>
</li>
<li>
<div class="ec-sidebar-block-item">
<input type="checkbox" name="category[]" value="Heavy Equipment" <?php echo (isset($_POST['category']) && in_array('Heavy Equipment', $_POST['category'])) || (isset($_GET['category']) && in_array('Heavy Equipment', $_GET['category'])) ? 'checked' : ''; ?> /> <a>Heavy Equipment</a><span class="checked"></span>
<input type="checkbox" name="category[]" id="heavy-equipment_category" value="Heavy Equipment" <?php echo (isset($_POST['category']) && in_array('Heavy Equipment', $_POST['category'])) || (isset($_GET['category']) && in_array('Heavy Equipment', $_GET['category'])) ? 'checked' : ''; ?> />
<a><label for="heavy-equipment_category" style="cursor: pointer; margin: 0px;">Heavy Equipment</a></label><span class="checked"></span>
</div>
</li>
<li>

View File

@ -1297,7 +1297,7 @@ if ($_SESSION["isVendor"] == true) {
aria-label="Close">Close</a>
</div> -->
</form>
<button type="button" class="btn btn-primary btn-pill mt-3" onclick="editUser()">Upload</button>
<button type="button" class="btn btn-primary btn-pill mt-3" onclick="editUser()">Submit</button>
</div>
</div>
</div>

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@ $current_page = basename($_SERVER['PHP_SELF']);
<ul>
<li <?php if ($current_page == 'vendor-dashboard.php') echo 'class="active"'; ?>><a href="vendor-dashboard.php" id="vendor-dashboard-link">Dashboards</a></li>
<li <?php if ($current_page == 'vendor-uploads.php') echo 'class="active"'; ?>><a onclick="addProduct();" id="vendor-uploads-link">Uploads</a></li>
<li <?php if ($current_page == 'vendor-settings.php') echo 'class="active"'; ?>><a href="vendor-settings.php" id="vendor-settings-link">Settings (edit)</a></li>
<li <?php if ($current_page == 'vendor-settings.php') echo 'class="active"'; ?>><a href="vendor-settings.php" id="vendor-settings-link">Vendor Profile</a></li>
<li <?php if ($current_page == 'vendor-refund-history.php') echo 'class="active"'; ?>><a href="vendor-refund-history.php" id="vendor-refund-history-link">Vendor Refund History</a></li>
<li <?php if ($current_page == 'vendor-payments.php') echo 'class="active"'; ?>><a href="vendor-payments.php" id="vendor-payments-link">Payments</a></li>
<li <?php if ($current_page == 'vendor-payouts.php') echo 'class="active"'; ?>><a href="vendor-payouts.php" id="vendor-payouts-link">Payouts</a></li>

View File

@ -174,240 +174,244 @@ if ($_SESSION["isVendor"] == true) {
</div>
<div class="row margin-minus-b-30">
<?php foreach ($customer['favorites']['products'] as $product) {
// raymart added vendorproduct feb 14 2024
$vendorOfProduct = getVendorbyId($product['vendor_api_id']);
?>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-6 mb-6 pro-gl-content">
<div class="ec-product-inner">
<!-- raymart added style for checkboxes feb 19 2024 -->
<input type="checkbox" class="product-checkbox" style="width: 20px; height: 20px; "value="<?php echo $product["_id"]; ?>">
<div class="ec-pro-image-outer" style="max-width: 290px; height: 350px;">
<div class="ec-pro-image">
<a href="product-left-sidebar.php?id=<?php echo $product["_id"]; ?>" class="image">
<!-- <a href="shop-left-sidebar-col-4.php" class="image"> -->
<img loading="lazy" class="main-image" src="<?php echo $product["images"]; ?>" alt="Product" style="border: 1px solid #eeeeee; height: 330px; object-fit: cover;"/>
<!-- <img loading="lazy" class="hover-image" src="<?php echo $product["images"]; ?>" alt="Product" /> -->
</a>
<span class="ec-com-remove ec-remove-wishlist">
<a href="javascript:void(0)" class="remove-product" data-product-id="<?php echo $product["_id"]; ?>" id="removeItem<?php echo $product["_id"]; ?>">×</a>
</span>
<!-- raymart edit action feb 14 2024 -->
<div class="ec-pro-actions" style="bottom: -70px;">
<!-- <button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($product), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button> -->
<!-- <a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($product), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a> -->
<?php if (isset($product["sale_price"]) && $product["sale_price"] > 0) : ?>
<?php
if (empty($customer['favorites']['products'])) {
echo '<div class="col-12 text-center fs-2"><p>No wishlist</p></div>'; // Display "No wishlist" message if wishlist is empty
} else {
foreach ($customer['favorites']['products'] as $product) {
// raymart added vendorproduct feb 14 2024
$vendorOfProduct = getVendorbyId($product['vendor_api_id']);
?>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-6 mb-6 pro-gl-content">
<div class="ec-product-inner">
<!-- raymart added style for checkboxes feb 19 2024 -->
<input type="checkbox" class="product-checkbox" style="width: 20px; height: 20px; "value="<?php echo $product["_id"]; ?>">
<div class="ec-pro-image-outer" style="max-width: 290px; height: 350px;">
<div class="ec-pro-image">
<a href="product-left-sidebar.php?id=<?php echo $product["_id"]; ?>" class="image">
<!-- <a href="shop-left-sidebar-col-4.php" class="image"> -->
<img loading="lazy" class="main-image" src="<?php echo $product["images"]; ?>" alt="Product" style="border: 1px solid #eeeeee; height: 330px; object-fit: cover;"/>
<!-- <img loading="lazy" class="hover-image" src="<?php echo $product["images"]; ?>" alt="Product" /> -->
</a>
<span class="ec-com-remove ec-remove-wishlist">
<a href="javascript:void(0)" class="remove-product" data-product-id="<?php echo $product["_id"]; ?>" id="removeItem<?php echo $product["_id"]; ?>">×</a>
</span>
<!-- raymart edit action feb 14 2024 -->
<div class="ec-pro-actions" style="bottom: -70px;">
<!-- <button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($product), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button> -->
<!-- <a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($product), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a> -->
<?php if (isset($product["sale_price"]) && $product["sale_price"] > 0) : ?>
<button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($product), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
<?php elseif (isset($product["regular_price"]) && $product["regular_price"] != "") : ?>
<button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($product), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
<?php elseif (isset($product["regular_price"]) && $product["regular_price"] != "") : ?>
<button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($product), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
<?php else : ($product["regular_price"] == "" || $product["regular_price"] == null) ?>
<?php else : ($product["regular_price"] == "" || $product["regular_price"] == null) ?>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
</div>
</div>
<div class="ec-pro-content">
<h5 class="ec-pro-title"><a href="product-left-sidebar.php?id=<?php echo $product["_id"]; ?>"><?php echo $product["product_name"]; ?></a></h5>
<!-- <div class="ec-pro-rating">
<i class="ecicon eci-star fill"></i>
<i class="ecicon eci-star fill"></i>
<i class="ecicon eci-star fill"></i>
<i class="ecicon eci-star fill"></i>
<i class="ecicon eci-star"></i>
</div> -->
<!-- <div class="ec-pro-list-desc">Lorem Ipsum is simply dummy text of the
printing and typesetting industry. Lorem Ipsum is simply dutmmy text
ever since the 1500s, when an unknown printer took a galley.</div> -->
<?php if ($product['product_type'] === 'variable') {
$variation_products = getProductVariations($product['_id']);
if ($variation_products) {
$variation_details = json_decode($variation_products, true);
}
} ?>
<!-- <span class="ec-price">
<span class="old-price">$12.00 <?php echo $product["regular_price"]; ?></span>
<span class="new-price">$10.00</span>
</span> -->
<?php
if ($product['product_type'] === "simple") {
if (isset($product['sale_price']) && $product['sale_price'] > 0) {
echo '<span class="ec-price">';
echo '<span class="old-price">' . $product['regular_price'] . '</span>';
echo '<span class="new-price">' . $product['sale_price'] . '</span>';
echo '</span>';
} else {
echo '<span class="new-price">' . $product['regular_price'] . '</span>';
}
} elseif ($product['product_type'] === "variable") {
$lowest_regular_price = null;
$highest_regular_price = null;
$lowest_sale_price = null;
$highest_sale_price = null;
<div class="ec-pro-content">
<h5 class="ec-pro-title"><a href="product-left-sidebar.php?id=<?php echo $product["_id"]; ?>"><?php echo $product["product_name"]; ?></a></h5>
<!-- <div class="ec-pro-rating">
<i class="ecicon eci-star fill"></i>
<i class="ecicon eci-star fill"></i>
<i class="ecicon eci-star fill"></i>
<i class="ecicon eci-star fill"></i>
<i class="ecicon eci-star"></i>
</div> -->
<!-- <div class="ec-pro-list-desc">Lorem Ipsum is simply dummy text of the
printing and typesetting industry. Lorem Ipsum is simply dutmmy text
ever since the 1500s, when an unknown printer took a galley.</div> -->
<?php if ($product['product_type'] === 'variable') {
$variation_products = getProductVariations($product['_id']);
if ($variation_products) {
$variation_details = json_decode($variation_products, true);
}
} ?>
<!-- <span class="ec-price">
<span class="old-price">$12.00 <?php echo $product["regular_price"]; ?></span>
<span class="new-price">$10.00</span>
</span> -->
<?php
if ($product['product_type'] === "simple") {
if (isset($product['sale_price']) && $product['sale_price'] > 0) {
echo '<span class="ec-price">';
echo '<span class="old-price">' . $product['regular_price'] . '</span>';
echo '<span class="new-price">' . $product['sale_price'] . '</span>';
echo '</span>';
} else {
echo '<span class="new-price">' . $product['regular_price'] . '</span>';
}
} elseif ($product['product_type'] === "variable") {
$lowest_regular_price = null;
$highest_regular_price = null;
$lowest_sale_price = null;
$highest_sale_price = null;
if (isset($variation_details) && is_array($variation_details)) {
foreach ($variation_details as $index => $variation) {
$regular_price = isset($variation['regular_price']) ? $variation['regular_price'] : 0;
$sale_price = isset($variation['sale_price']) ? $variation['sale_price'] : 0;
if (isset($variation_details) && is_array($variation_details)) {
foreach ($variation_details as $index => $variation) {
$regular_price = isset($variation['regular_price']) ? $variation['regular_price'] : 0;
$sale_price = isset($variation['sale_price']) ? $variation['sale_price'] : 0;
// Update the minimum and maximum prices only if they are not null
if ($lowest_regular_price === null || $regular_price < $lowest_regular_price) {
$lowest_regular_price = $regular_price;
}
// Update the minimum and maximum prices only if they are not null
if ($lowest_regular_price === null || $regular_price < $lowest_regular_price) {
$lowest_regular_price = $regular_price;
}
if ($highest_regular_price === null || $regular_price > $highest_regular_price) {
$highest_regular_price = $regular_price;
}
if ($highest_regular_price === null || $regular_price > $highest_regular_price) {
$highest_regular_price = $regular_price;
}
if ($lowest_sale_price === null || $sale_price < $lowest_sale_price) {
$lowest_sale_price = $sale_price;
}
if ($lowest_sale_price === null || $sale_price < $lowest_sale_price) {
$lowest_sale_price = $sale_price;
}
if ($highest_sale_price === null || $sale_price > $highest_sale_price) {
$highest_sale_price = $sale_price;
if ($highest_sale_price === null || $sale_price > $highest_sale_price) {
$highest_sale_price = $sale_price;
}
}
}
}
// Display the range of prices based on the presence of sale prices
if ($lowest_sale_price !== null && $highest_sale_price !== null && $lowest_sale_price > 0 && $highest_sale_price > 0) {
echo '<span id="productPrice" class="new-price">' . '&#8369;' . $lowest_sale_price . ' - &#8369;' . $highest_sale_price . '</span>';
} elseif ($lowest_regular_price !== null && $highest_regular_price !== null) {
echo '<span id="productPrice" class="new-price">' . '&#8369;' . $lowest_regular_price . ' - &#8369;' . $highest_regular_price . '</span>';
// Display the range of prices based on the presence of sale prices
if ($lowest_sale_price !== null && $highest_sale_price !== null && $lowest_sale_price > 0 && $highest_sale_price > 0) {
echo '<span id="productPrice" class="new-price">' . '&#8369;' . $lowest_sale_price . ' - &#8369;' . $highest_sale_price . '</span>';
} elseif ($lowest_regular_price !== null && $highest_regular_price !== null) {
echo '<span id="productPrice" class="new-price">' . '&#8369;' . $lowest_regular_price . ' - &#8369;' . $highest_regular_price . '</span>';
}
}
}
?>
?>
</div>
</div>
</div>
</div>
<script>
customerId = '<?php echo $_SESSION['customerId']; ?>'
// Add event listener to remove button
document.addEventListener('DOMContentLoaded', function() {
var removeButtons = document.querySelectorAll('.remove-product');
removeButtons.forEach(function(removeButton) {
removeButton.addEventListener('click', function() {
var productId = removeButton.getAttribute('data-product-id');
removeProduct(productId);
<script>
customerId = '<?php echo $_SESSION['customerId']; ?>'
// Add event listener to remove button
document.addEventListener('DOMContentLoaded', function() {
var removeButtons = document.querySelectorAll('.remove-product');
removeButtons.forEach(function(removeButton) {
removeButton.addEventListener('click', function() {
var productId = removeButton.getAttribute('data-product-id');
removeProduct(productId);
});
});
var deleteButton = document.getElementById('delete-button');
deleteButton.addEventListener('click', function() {
var selectedProducts = [];
var checkboxes = document.querySelectorAll('.product-checkbox');
checkboxes.forEach(function(checkbox) {
if (checkbox.checked) {
selectedProducts.push(checkbox.value);
}
});
deleteProducts(selectedProducts);
});
});
var deleteButton = document.getElementById('delete-button');
deleteButton.addEventListener('click', function() {
var selectedProducts = [];
var checkboxes = document.querySelectorAll('.product-checkbox');
checkboxes.forEach(function(checkbox) {
if (checkbox.checked) {
selectedProducts.push(checkbox.value);
}
var selectAllButton = document.querySelector('#select-button');
selectAllButton.addEventListener('click', function() {
var selectedProducts = [];
var checkboxes = document.querySelectorAll('.product-checkbox');
// checkboxes.forEach(function(checkbox) {
// }
console.log('clicked')
for (let i = 0; i < checkboxes.length; i++ ) {
checkboxes[i].checked = selectAllButton.checked
// checkboxes[i].checked = true
}})
// Function to remove product
function removeProduct(productId) {
// Get all product IDs except the one to remove
var remainingProductIds = Array.from(document.querySelectorAll('.remove-product')).map(function(button) {
return button.getAttribute('data-product-id');
}).filter(function(id) {
return id !== productId;
});
deleteProducts(selectedProducts);
});
});
var selectAllButton = document.querySelector('#select-button');
selectAllButton.addEventListener('click', function() {
var selectedProducts = [];
var checkboxes = document.querySelectorAll('.product-checkbox');
// checkboxes.forEach(function(checkbox) {
// }
console.log('clicked')
for (let i = 0; i < checkboxes.length; i++ ) {
checkboxes[i].checked = selectAllButton.checked
// checkboxes[i].checked = true
}})
// Function to remove product
function removeProduct(productId) {
// Get all product IDs except the one to remove
var remainingProductIds = Array.from(document.querySelectorAll('.remove-product')).map(function(button) {
return button.getAttribute('data-product-id');
}).filter(function(id) {
return id !== productId;
});
// Make an AJAX request to update the favorites with the remaining products
var xhr = new XMLHttpRequest();
// xhr.open('PATCH', 'https://api.obanana.shop/api/v1/customers/' + customerId, true);
xhr.open('PATCH', 'https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/customers/' + customerId, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
// Product removed successfully, you can handle the UI update here if needed
console.log('Product removed successfully');
location.reload(); // Refresh the page after removing the product
} else {
// Handle error response
console.error('Error removing product:', xhr.responseText);
// Make an AJAX request to update the favorites with the remaining products
var xhr = new XMLHttpRequest();
// xhr.open('PATCH', 'https://api.obanana.shop/api/v1/customers/' + customerId, true);
xhr.open('PATCH', 'https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/customers/' + customerId, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
// Product removed successfully, you can handle the UI update here if needed
console.log('Product removed successfully');
location.reload(); // Refresh the page after removing the product
} else {
// Handle error response
console.error('Error removing product:', xhr.responseText);
}
}
}
};
// Construct data object with the remaining product IDs
var data = JSON.stringify({
favorites: {
products: remainingProductIds.map(function(id) {
// Find the product object with the corresponding ID
var remainingProduct = <?php echo json_encode($customer['favorites']['products']); ?>.find(function(product) {
return product['_id'] === id;
});
};
// Construct data object with the remaining product IDs
var data = JSON.stringify({
favorites: {
products: remainingProductIds.map(function(id) {
// Find the product object with the corresponding ID
var remainingProduct = <?php echo json_encode($customer['favorites']['products']); ?>.find(function(product) {
return product['_id'] === id;
});
// Return the entire product object
return remainingProduct;
})
}
});
xhr.send(data);
}
// Function to delete multiple products
function deleteProducts(productIds) {
var xhr = new XMLHttpRequest();
// xhr.open('PATCH', 'https://api.obanana.shop/api/v1/customers/' + customerId, true);
xhr.open('PATCH', 'https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/customers/' + customerId, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
console.log('Products removed successfully');
location.reload();
} else {
console.error('Error removing products:', xhr.responseText);
// Return the entire product object
return remainingProduct;
})
}
}
};
var remainingProductIds = Array.from(document.querySelectorAll('.remove-product')).map(function(button) {
return button.getAttribute('data-product-id');
}).filter(function(id) {
return !productIds.includes(id);
});
var data = JSON.stringify({
favorites: {
products: remainingProductIds.map(function(id) {
var remainingProduct = <?php echo json_encode($customer['favorites']['products']); ?>.find(function(product) {
return product['_id'] === id;
});
return remainingProduct;
})
}
});
xhr.send(data);
}
});
xhr.send(data);
}
// Function to delete multiple products
function deleteProducts(productIds) {
var xhr = new XMLHttpRequest();
// xhr.open('PATCH', 'https://api.obanana.shop/api/v1/customers/' + customerId, true);
xhr.open('PATCH', 'https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/customers/' + customerId, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
console.log('Products removed successfully');
location.reload();
} else {
console.error('Error removing products:', xhr.responseText);
}
}
};
var remainingProductIds = Array.from(document.querySelectorAll('.remove-product')).map(function(button) {
return button.getAttribute('data-product-id');
}).filter(function(id) {
return !productIds.includes(id);
});
var data = JSON.stringify({
favorites: {
products: remainingProductIds.map(function(id) {
var remainingProduct = <?php echo json_encode($customer['favorites']['products']); ?>.find(function(product) {
return product['_id'] === id;
});
return remainingProduct;
})
}
});
xhr.send(data);
}
</script>
<?php } ?>
<?php } }?>
</div>
</div>