%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64 User : ndkhermy ( 1200) PHP Version : 8.5.12 Disable Function : NONE Directory : /home1/ndkhermy/www/website_93b53270/ |
Upload File : |
<?php include('header.php');
error_reporting(0);
?>
<style>
#toggleBtn-132, .show-more-link{
color: black !important;
text-decoration: none !important;
padding: 10px;
}
</style>
<?php
$slug = isset($_REQUEST['prod_id']) ? $_REQUEST['prod_id'] : null;
$fet_slug = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM `product_product_sevice_tbl` WHERE slug='$slug'"));
$selected_service_id = $fet_slug['id'];
// Retrieve the first service ID to use as a fallback if no service ID is provided
$first_service_qry = mysqli_query($conn, "SELECT id FROM product_product_sevice_tbl WHERE status=1 ORDER BY sequence ASC LIMIT 1");
$first_service = mysqli_fetch_array($first_service_qry);
$first_service_id = $first_service['id'];
// Use the first service ID if no service ID is provided
if (is_null($selected_service_id)) {
$selected_service_id = $first_service_id;
}
?>
<section class="product-tabs">
<div class="container">
<div class="row">
<div class="col-md-12">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<?php
$service01Qry = mysqli_query($conn, "SELECT * FROM product_product_sevice_tbl WHERE status=1 ORDER BY sequence ASC");
while ($Servicerow0 = mysqli_fetch_array($service01Qry)) {
?>
<li class="nav-item" role="presentation">
<button
class="nav-link <?php if ($Servicerow0['id'] == $selected_service_id) {
echo "active";
} ?>"
id="home-tab<?= $Servicerow0['id'] ?>" data-bs-toggle="tab"
data-bs-target="#home<?= $Servicerow0['id'] ?>" type="button" role="tab"
aria-controls="home<?= $Servicerow0['id'] ?>" aria-selected="true">
<img src="<?= $base_url ?>images/Upload/service/<?= $Servicerow0['image1'] ?>" class="img-fluid"
alt="Service Image">
<p class="mb-0 mt-2"><?= $Servicerow0['title'] ?></p>
</button>
</li>
<?php
}
?>
</ul>
<div class="row">
<div class="col-md-7">
<div class="tab-content" id="myTabContent">
<?php
$service02Qry = mysqli_query($conn, "SELECT * FROM product_product_sevice_tbl WHERE status=1 ORDER BY sequence ASC");
while ($Servicerow02 = mysqli_fetch_array($service02Qry)) {
?>
<div class="tab-pane fade <?php if ($Servicerow02['id'] == $selected_service_id) {
echo "active show";
} ?>"
id="home<?= $Servicerow02['id'] ?>" role="tabpanel"
aria-labelledby="home-tab<?= $Servicerow02['id'] ?>">
<?php
$filter_sql = !empty($_SESSION['filter']) ? $_SESSION['filter'] : '';
$product02Qry = mysqli_query($conn, "SELECT * FROM product_tbl WHERE status=1 AND cat_id='" . $Servicerow02['id'] . "'" . $filter_sql);
while ($productrow02 = mysqli_fetch_array($product02Qry)) {
$productId = $productrow02['id'];
$isInCart = isset($_SESSION['cart'][$productId]);
?>
<div class="listing" id="find_pro_<?= $productrow02['id'] ?>">
<h6 class="fs-16"><?= $productrow02['title'] ?></h6>
<div class="listing-flex">
<div>
<img src="<?= $base_url ?>images/Upload/product/<?= $productrow02['image1'] ?>"
class="me-3"
style="width: 150px; height: 150px;object-fit:cover;border-radius:15px;"
alt="Product Image">
</div>
<div>
<div class="product-description"
style="max-height: 60px; overflow: hidden; position: relative;"
id="desc-<?= $productId ?>">
<?= $productrow02['short_description'] ?><br>
<?= $productrow02['about'] ?>
</div>
<br>
<a href="javascript:void(0);" class="text-primary show-more-link"
onclick="toggleDescription(<?= $productId ?>)"
id="toggleBtn-<?= $productId ?>">Show More</a>
</div>
</div>
<div class="rating-cart-flex">
<div></div>
<div class="merge-cart">
<a href="<?=$base_url?>contact.php?pro_id=<?= $productId ?>" style="text-decoration:none; color:inherit;"><span class="text-decoration-none">Enquiry</span></a>
<input type="hidden" name="pro_quantity" id="pro_quantity" value="1">
<?php if ($isInCart) { ?>
<!-- <a class="white-cart btn add_to_cart bg-warning" -->
<!-- data-id="</?= $productId ?>">Already in Cart</a> -->
<?php } else {
$Servicerow05 = mysqli_query($conn, "SELECT * FROM oil_pro_tbl WHERE status=1 AND cat_id='" . $productrow02['cat_id'] . "'");
$Servicerow06 = mysqli_query($conn, "SELECT * FROM part_pro_tbl WHERE status=1 AND cat_id='" . $productrow02['cat_id'] . "'");
if (mysqli_num_rows($Servicerow05) > 0 || mysqli_num_rows($Servicerow06) > 0) {
?>
<!-- <a class="white-cart" href="#" data-price="</?= $productrow02['price'] ?>" -->
<!-- data-id="</?= $productId ?>" data-catid="</?= $productrow02['cat_id'] ?>" -->
<!-- data-bs-toggle="modal" data-bs-target="#myModal"><i -->
<!-- class="bi bi-plus"></i> Add to Cart</a> -->
<?php
} else {
?>
<!-- <a class="white-cart add_to_cart" href="#"
data-price="<?= $productrow02['price'] ?>" data-id="<?= $productId ?>"
data-catid="<?= $productrow02['cat_id'] ?>"><i class="bi bi-plus"></i>
Add to Cart</a> -->
<?php
}
?>
<?php } ?>
</div>
</div>
</div>
<?php } ?>
</div>
<?php
}
?>
</div>
</div>
<div class="col-md-5">
<?php
if (isset($_SESSION['filter'])) {
include('choose-car-include.php');
} else {
include('choose-car-include.php');
}
?>
</div>
</div>
<?php include('faq-include.php'); ?>
<?php include('client-include.php'); ?>
</div>
</div>
</div>
</section>
<script>
function toggleDescription(id) {
const desc = document.getElementById('desc-' + id);
const btn = document.getElementById('toggleBtn-' + id);
if (desc.style.maxHeight === 'none') {
desc.style.maxHeight = '60px';
btn.innerText = 'Show More';
} else {
desc.style.maxHeight = 'none';
btn.innerText = 'Show Less';
}
}
</script>
<?php include('footer.php'); ?>
<script type="text/javascript">
$(document).ready(function () {
$('.white-cart').on('click', function () {
var price = $(this).data('price');
});
});
</script>
<!-- The Modal -->
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title fw-bold">Standard Service</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<!-- Modal body -->
<div class="modal-body">
<input type="hidden" id="catid">
<div class="row" id="oilContent">
<!-- Oil items will be loaded here -->
</div>
<div class="row">
<div class="col-md-12">
<h5 class="my-3 fw-bold">Boost Your Service</h5>
</div>
</div>
<div class="row y-scroll" id="partContent">
<!-- Part items will be loaded here -->
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer flex-justify-radio">
<div>
<h5 id="totalPrice">AED 0</h5>
</div>
<a class="btn btn-danger rounded-0 add_to_cart"><i class="bi bi-plus"></i>Add To Cart</a>
</div>
</div>
</div>
</div>
<!-- Add jQuery to handle dynamic content loading -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function () {
$('#myModal').on('show.bs.modal', function (e) {
var button = $(e.relatedTarget); // Button that triggered the modal
var catid = button.data('catid'); // Extract info from data-* attributes
$('#catid').val(catid); // Set the value of hidden input
// Load content dynamically based on catid
$.ajax({
url: 'fetch_oil_parts_pro.php', // PHP file to fetch data
method: 'GET',
data: { catid: catid },
success: function (response) {
var data = JSON.parse(response);
$('#oilContent').html(data.oilContent);
$('#partContent').html(data.partContent);
}
});
});
});
</script>
<script type="text/javascript">
$(document).ready(function () {
var price = 0;
var productId = 0;
var sevi_id = 0;
// Click handler for .white-cart elements
$('.white-cart').on('click', function () {
price = parseFloat($(this).data('price'));
productId = parseInt($(this).data('id'));
sevi_id = parseInt($(this).data('catid'));
calculateTotalPrice();
});
// Function to calculate the total price
function calculateTotalPrice() {
var total = 0;
// Add the price from .white-cart click
total += price;
// Get the selected oil price
const selectedOilPrice = $("input[name='oil']:checked").val();
if (selectedOilPrice) {
total += parseFloat(selectedOilPrice);
oil_id = parseInt($("input[name='oil']:checked").data('s_id'));
}else{
oil_id = '0';
}
// Get the selected additional services prices
$("input[name='check1[]']:checked").each(function () {
total += parseFloat($(this).data('ch'));
});
// Update the total price in the modal footer
$("#totalPrice").html("AED " + total.toFixed(2));
}
// Calculate the total price on document ready
calculateTotalPrice();
// Recalculate the total price on change of oil or additional services
$("body").on('change', "input[name='oil'], input[name='check1[]']", function () {
calculateTotalPrice();
});
// Add click handler for the "Add To Cart" button
$('.add_to_cart').on('click', function () {
// Recalculate the total price to make sure it's up to date
calculateTotalPrice();
// Get the value of the total price from the modal footer
let total = parseFloat($("#totalPrice").text().replace("AED ", ""));
// Get the value of the selected radio button with name 'oil'
var selectedOilPrice = parseFloat($("input[name='oil']:checked").val());
// Get the values of the checked checkboxes with name 'check1[]' and store them in an array
var parts = $("input[name='check1[]']:checked").map(function () {
return $(this).val();
}).get();
var quantity = 1;
addToCart(productId, quantity, total, selectedOilPrice, parts, sevi_id, oil_id, price);
});
function addToCart(productId, quantity, total, selectedOilPrice, parts, sevi_id, oil_id, price) {
$.ajax({
type: "POST",
url: "addToCart.php",
data: { id: productId, quantity: quantity, total: total, selectedOilPrice: selectedOilPrice, parts: parts, sevi_id: sevi_id, oil_id: oil_id, price: price },
dataType: 'json',
success: function (response) {
if (response.status === 'success') {
localStorage.setItem('addCartMessage', response.message);
window.location.href = "products.php";
} else if (response.status === 'error') {
localStorage.setItem('addCartMessage1', response.message);
window.location.href = "products.php";
}
},
error: function (xhr, status, error) {
// Handle errors, if any
console.error(error);
}
});
}
// Check if the flag is set in local storage
var addCartMessage = localStorage.getItem('addCartMessage');
var addCartMessage1 = localStorage.getItem('addCartMessage1');
if (addCartMessage) {
localStorage.removeItem('addCartMessage');
showAlert('success', addCartMessage);
}
if (addCartMessage1) {
localStorage.removeItem('addCartMessage1');
showAlert('danger', addCartMessage1);
}
function showAlert(type, message) {
$(".cart_add_success").html(`
<div class="alert alert-${type} alert-dismissible" id="alertClose">
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
${message}
</div>
`);
$("#shoppingCart").addClass("show");
setTimeout(function () {
$(".cart_add_success").html('');
}, 3000);
}
});
</script>