minor bugs, add +63 in contact at modal, pagination in admin #71

Merged
MarkHipe merged 1 commits from raymart_branch into main 2024-04-30 09:12:20 +08:00
8 changed files with 173 additions and 30 deletions

View File

@ -101,7 +101,7 @@ $users = getUsers();
<div class="row">
<?php
$totalUsers = count($users);
$usersPerPage = 20;
$usersPerPage = 15;
$totalPages = ceil($totalUsers / $usersPerPage);
$currentPage = isset($_GET['page']) ? $_GET['page'] : 1;
$start = ($currentPage - 1) * $usersPerPage;
@ -266,8 +266,31 @@ $users = getUsers();
<!-- Pagination Links -->
<div class="pagination">
<?php
for ($page = 1; $page <= $totalPages; $page++) {
/* for ($page = 1; $page <= $totalPages; $page++) {
echo '<a href="?page=' . $page . '">' . $page . '</a>';
} */
$maxPages = 5; // Maximum number of pages to display
$ellipsis = true; // Whether to show ellipsis if there are more pages
$startPage = max(1, $currentPage - floor($maxPages / 2));
$endPage = min($totalPages, $startPage + $maxPages - 1);
if ($ellipsis && $startPage > 1) {
echo '<a href="?page=1">1</a>';
if ($startPage > 2) {
echo '<span>...</span>';
}
}
for ($page = $startPage; $page <= $endPage; $page++) {
echo '<a href="?page=' . $page . '">' . $page . '</a>';
}
if ($ellipsis && $endPage < $totalPages) {
if ($endPage < $totalPages - 1) {
echo '<span>...</span>';
}
echo '<a href="?page=' . $totalPages . '">' . $totalPages . '</a>';
}
?>
</div>

View File

@ -814,11 +814,32 @@ function validateEmail(vendorId) {
// echo "<a href='?page=$i' class='" . ($currentpage == $i ? 'active' : '') . "'>$i</a>";
// }
if ($totalVendors >= $vendorsPerPage) {
/* if ($totalVendors >= $vendorsPerPage) {
for ($i = 1; $i <= $totalPages; $i++) {
echo "<a href='?page=$i' class='" . ($currentpage == $i ? 'active' : '') . "'>$i</a>";
}
}
} */
$start = max(1, $currentpage - 2);
$end = min($totalPages, $start + 4);
if ($start > 1) {
echo "<a href='?page=1'>1</a>";
if ($start > 2) {
echo "<span>&nbsp;...&nbsp;</span>";
}
}
for ($i = $start; $i <= $end; $i++) {
echo "<a href='?page=$i' class='" . ($currentpage == $i ? 'active' : '') . "'>$i</a>&nbsp;";
}
if ($end < $totalPages) {
if ($end < $totalPages - 1) {
echo "<span>&nbsp;...&nbsp;</span>";
}
echo "<a href='?page=$totalPages'>$totalPages</a>";
}
?>
</div>

View File

@ -389,7 +389,7 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
</div>
<div class="form-group">
<label for="addressContact" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
<input type="number" class="form-control" id="addressContact">
<input type="text" class="form-control" id="addressContact" value="+63 " oninput="preventErasePrefix(this)">
</div>
<div class="form-group">
<label for="addressBuilding" class="text-dark font-weight-medium pt-3 mb-2"> Building,Number </label>
@ -419,7 +419,7 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
</div>
<div class="form-group">
<label for="addressCountry" class="text-dark font-weight-medium pt-3 mb-2">Country</label>
<input type="text" class="form-control" id="addressCountry">
<input type="text" class="form-control" id="addressCountry" value="Philippines">
</div>
<button type="button" class="btn btn-primary" id="submitBtn">Submit</button>
</form>
@ -452,7 +452,7 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
<div class="form-group">
<label for="addressContact" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
<input type="text" class="form-control" id="addressContact2" value="<?php echo $address['phone']; ?>">
<input type="text" class="form-control" id="addressContact2" value="<?php echo $address['phone']; ?>" oninput="preventEraseThePrefix(this)">
<!-- <label for="addressContact" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
@ -512,6 +512,39 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
</div>
</div>
<script>
function preventErasePrefix(input) { /* secondmodal */
var numericValue = input.value.replace(/\D/g, '');
if (numericValue.startsWith('63')) {
input.value = "+63 " + numericValue.substring(2);
} else {
input.value = "+63 " + numericValue;
}
if (input.value.length > 14) {
input.value = input.value.slice(0, 14);
}
}
function preventEraseThePrefix(input) { /* thirdmodal */
var numericValue = input.value.replace(/\D/g, '');
if (numericValue.startsWith('63')) {
input.value = "+63 " + numericValue.substring(2);
} else {
input.value = "+63 " + numericValue;
}
if (input.value.length > 14) {
input.value = input.value.slice(0, 14);
}
}
</script>
<script>
// raymart/sir mark added function to show the addresses of the customer in the third modal march 04 2024
$('#thirdModal').on('shown.bs.modal', function (event) {

View File

@ -544,7 +544,7 @@ if (isset($_GET['id'])) {
onmouseover="this.style.color=\'#a15d00\'" onmouseout="this.style.color=\'#ffaa00\'">-</div>';
echo '<input class="qty-inputs" style="width:110px; height:40px" type="number" name="ec_qtybtn" value="';
echo (!empty($product_details['minimum_order'])) ? $product_details['minimum_order'] : "1";
echo '" id="qty-input" />';
echo '" id="qty-input" oninput="handleInput()" />';
echo '<div class="qty-btn" style="color:#ffaa00; font-size:25px; padding-left:5px; cursor: pointer;" onclick="increment()"
onmouseover="this.style.color=\'#a15d00\'" onmouseout="this.style.color=\'#ffaa00\'">+</div>';
echo '<div style="display:flex; margin-left:45px;"><button type="button" class="btn btn-primary" id="contactSellerButton" style="background:#ffaa00; width:190px;"
@ -559,7 +559,7 @@ if (isset($_GET['id'])) {
onmouseover="this.style.color=\'#a15d00\'" onmouseout="this.style.color=\'#ffaa00\'">-</div>';
echo '<input class="qty-inputs" style="width:100px; height:40px" type="number" name="ec_qtybtn" value="';
echo (!empty($product_details['minimum_order'])) ? $product_details['minimum_order'] : "1";
echo '" id="qty-input" />';
echo '" id="qty-input" oninput="handleInput()" />';
echo '<div class="qty-btn" style="color:#ffaa00; font-size:25px; margin-left:5px; cursor: pointer;" onclick="increment()"
onmouseover="this.style.color=\'#a15d00\'" onmouseout="this.style.color=\'#ffaa00\'">+</div>';
echo '<div> <div id="addToCartMessage" style="padding-left:45px;"></div> <button class="btn btn-primary" id="addToCartButton" style="text-wrap:nowrap;

View File

@ -111,7 +111,7 @@ $_SESSION["isVendor"] = false;
<label>Password*</label>
<input type="password" name="password" placeholder="Enter your password" required />
</span>
<p><input type="checkbox"> I accept this Terms & Conditions and Privacy Policy</p>
<p><input type="checkbox" required> I accept this Terms & Conditions and Privacy Policy </p>
<span class="ec-login-wrap ec-login-fp">
<label><a href="#">Forgot Password?</a></label>
</span>

View File

@ -513,7 +513,7 @@ function loadProducts(page,isFilter) {
let imageUrls = product.images.split(',');
let firstImageUrl = imageUrls[0].trim();
let img = document.createElement("img");
img.setAttribute("style", "width: 290px; height: 200px; object-fit: cover;");
img.setAttribute("style", "border: 1px solid #eeeeee; height: 330px; object-fit: cover;");
img.setAttribute("class", "main-image");
img.setAttribute("src", firstImageUrl);
img.setAttribute("alt", "Product");
@ -522,7 +522,7 @@ function loadProducts(page,isFilter) {
} else {
let img = document.createElement("img");
img.className = "main-image";
img.setAttribute("style", "width: 290px; height: 200px; object-fit: cover;");
img.setAttribute("style", "border: 1px solid #eeeeee; height: 330px; object-fit: cover;");
img.setAttribute("class", "main-image");
img.setAttribute("src", "https://api.obanana.com/images/storage/web_images/1709002636671-viber_image_2024-02-22_15-54-42-498.png");
@ -535,14 +535,21 @@ function loadProducts(page,isFilter) {
card.classList.add("col-lg-4", "col-md-6", "col-sm-6", "col-xs-6", "mb-6", "pro-gl-content", "width-100");
card.innerHTML = `
<div class="ec-product-inner">
<div class="ec-pro-image-outer" style="width: 290px; height: 200px;">
<div class="ec-pro-image-outer" style="max-width: 290px; height: 350px;">
<div class="ec-pro-image">
<a href="product-left-sidebar.php?id=${product._id}">
${imageContainer.innerHTML} <!-- Include the dynamically loaded image here -->
</a>
<div class="ec-pro-actions" style="bottom: -36px;">
<button title="Add To Cart" onclick="popupAddToCart('${encodeURIComponent(JSON.stringify(product))}','${encodeURIComponent(JSON.stringify(vendorOfProduct))}', '${token}', '${email}', '${password}', '${encodeURIComponent(JSON.stringify(customer_data))}');" 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('${encodeURIComponent(JSON.stringify(product))}', '${encodeURIComponent(JSON.stringify(customer_data))}');"><i class="fi-rr-heart"></i></a>
${
(product["sale_price"] && product["sale_price"] > 0) ?
`<button title="Add To Cart" onclick="popupAddToCart('${encodeURIComponent(JSON.stringify(product))}','${encodeURIComponent(JSON.stringify(vendorOfProduct))}', '${token}', '${email}', '${password}', '${encodeURIComponent(JSON.stringify(customer_data))}');" 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('${encodeURIComponent(JSON.stringify(product))}', '${encodeURIComponent(JSON.stringify(customer_data))}');"><i class="fi-rr-heart"></i></a>` :
(product["regular_price"] && product["regular_price"] != "") ?
`<button title="Add To Cart" onclick="popupAddToCart('${encodeURIComponent(JSON.stringify(product))}','${encodeURIComponent(JSON.stringify(vendorOfProduct))}', '${token}', '${email}', '${password}', '${encodeURIComponent(JSON.stringify(customer_data))}');" 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('${encodeURIComponent(JSON.stringify(product))}', '${encodeURIComponent(JSON.stringify(customer_data))}');"><i class="fi-rr-heart"></i></a>` :
`<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('${encodeURIComponent(JSON.stringify(product))}', '${encodeURIComponent(JSON.stringify(customer_data))}');"><i class="fi-rr-heart"></i></a>`
}
</div>
</div>
</div>

View File

@ -330,7 +330,7 @@ if ($_SESSION["isVendor"] == true) {
</div>
<div class="form-group">
<label for="addressContact" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
<input type="number" class="form-control" id="addressContact">
<input type="text" class="form-control" id="addressContact" value="+63 " oninput="preventErasePrefix(this)">
</div>
<div class="form-group">
<label for="addressBuilding" class="text-dark font-weight-medium pt-3 mb-2"> Building,Number </label>
@ -360,7 +360,7 @@ if ($_SESSION["isVendor"] == true) {
</div>
<div class="form-group">
<label for="addressCountry" class="text-dark font-weight-medium pt-3 mb-2">Country</label>
<input type="text" class="form-control" id="addressCountry" >
<input type="text" class="form-control" id="addressCountry" value="Philippines">
</div>
<button type="button" class="btn btn-primary mt-4" id="submitBtn">Submit</button>
@ -397,7 +397,7 @@ if ($_SESSION["isVendor"] == true) {
<div class="form-group">
<label for="addressContact" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
<input type="text" class="form-control" id="addressContact2" value="<?php echo $address['phone']; ?>">
<input type="text" class="form-control" id="addressContact2" value="<?php echo $address['phone']; ?>" oninput="preventEraseThePrefix(this)">
<!-- <label for="addressContact" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
@ -455,6 +455,54 @@ if ($_SESSION["isVendor"] == true) {
</div>
</div>
<script>
function preventErasePrefix(input) { /* secondmodal */
var numericValue = input.value.replace(/\D/g, '');
if (numericValue.startsWith('63')) {
input.value = "+63 " + numericValue.substring(2);
} else {
input.value = "+63 " + numericValue;
}
if (input.value.length > 14) {
input.value = input.value.slice(0, 14);
}
}
function preventEraseThePrefix(input) { /* thirdmodal */
var numericValue = input.value.replace(/\D/g, '');
if (numericValue.startsWith('63')) {
input.value = "+63 " + numericValue.substring(2);
} else {
input.value = "+63 " + numericValue;
}
if (input.value.length > 14) {
input.value = input.value.slice(0, 14);
}
}
function preventEraseInPrefix(input) { /* edit details */
var numericValue = input.value.replace(/\D/g, '');
if (numericValue.startsWith('63')) {
input.value = "+63 " + numericValue.substring(2);
} else {
input.value = "+63 " + numericValue;
}
if (input.value.length > 14) {
input.value = input.value.slice(0, 14);
}
}
</script>
<script>
// var myElement = document.getElementById('myElement');
// myElement.style.backgroundImage = 'red';
@ -1237,7 +1285,7 @@ if ($_SESSION["isVendor"] == true) {
</div>
<div class="form-group">
<label for="phone-" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
<input type="text" class="form-control" id="phone-" value="<?php echo $customer_data[0]['phone_number'] ?>">
<input type="text" class="form-control" id="phone-" value="<?php echo $customer_data[0]['phone_number'] ?>" oninput="preventEraseInPrefix(this)">
</div>
<!-- <div class="col-md-12 space-t-15">

View File

@ -182,20 +182,31 @@ if ($_SESSION["isVendor"] == true) {
<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">
<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["product_image"]; ?>" alt="Product" />
<!-- <img loading="lazy" class="hover-image" src="<?php echo $product["product_image"]; ?>" alt="Product" /> -->
<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">
<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>
<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 else : ($product["regular_price"] == "" || $product["regular_price"] == null) ?>
<?php endif; ?>
</div>
</div>
</div>
@ -227,7 +238,7 @@ if ($_SESSION["isVendor"] == true) {
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>';
echo '</span>';
} else {
echo '<span class="new-price">' . $product['regular_price'] . '</span>';
}
@ -335,7 +346,7 @@ if ($_SESSION["isVendor"] == true) {
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
location.reload(); // Refresh the page after removing the product
} else {
// Handle error response
console.error('Error removing product:', xhr.responseText);
@ -368,9 +379,9 @@ if ($_SESSION["isVendor"] == true) {
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
if (xhr.status === 0) {
console.log('Products removed successfully');
// location.reload();
location.reload();
} else {
console.error('Error removing products:', xhr.responseText);
}
@ -777,7 +788,7 @@ if ($_SESSION["isVendor"] == true) {
<!-- <script src="assets/js/tester10.js"></script> -->
<?php
if ($_SESSION["is_test"]==true) {
echo '<script src="assets/js/tester10.js"></script>';
echo '<script src="assets/js/tester11.js"></script>';
} else {
echo '<script src="assets/js/produc3.js"></script>';
}