<?php 
    if(isset($_GET["pid"])){
	    $product_id = $_GET["pid"]; $product_query = mysqli_query($conn, "SELECT * FROM aalierp_product WHERE product_id='".$product_id."'");
		$row = mysqli_fetch_assoc($product_query); 
		$query = mysqli_query($conn, "SELECT * FROM aalierp_catalogue WHERE catalogue_id='".$row["catalogue_id"]."'");$cat = mysqli_fetch_assoc($query);
    }
?>

<section class="single-banner inner-section" style="background: url(<?php echo $AaliLINK; ?>/assets/images/ds.png) no-repeat center;">
      <div class="container">
         <h2><?php echo $row["product_name"]; ?></h2>
         <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="<?php echo $AaliLINK; ?>">Home /</a></li>
            <li class="breadcrumb-item active" aria-current="page"><a href="#"><?php echo $cat["catalogue_name"]; ?></a></li>
        </ol>
    </div>
</section>
<section class="inner-section" style="margin-top: -45px;margin-bottom: 77px;">
    <div class="container">
         <div class="row">
            <div class="col-lg-6">
               <div class="details-gallery">
                  <ul class="details-preview">
                     <li><img id="zoom_04" class="img-fluid" src="<?php echo $AaliSYS; ?>/uploads/products/<?php echo $row["product_image"]; ?>" data-zoom-image="<?php echo $AaliSYS; ?>/uploads/products/<?php echo $row["product_image"]; ?>" alt="product"></li>
                  </ul>
                  <ul class="details-thumb mt-2" style="padding-bottom: 12px;">
                     <li><img src="<?php echo $AaliSYS; ?>/uploads/products/<?php echo $row["product_image"]; ?>" width="100" alt="product"></li>
                  </ul>
               </div>
            </div>
            <div class="col-lg-6">
               <div class="details-content">
                    <div id="detmsg"></div>
                    <form method="post" id="form_cart">
                        <h3 class="py-3"><a href="#" style="color:red;"><?php echo $row["product_name"]; ?></a></h3>
                        <div class="py-1">
                            <p>Category: <a href="#" style="color:red;"><?php echo $cat["catalogue_name"]; ?></a></p>
                        </div>
                        <h3 class="details-price py-3" id="setsalprice"><del style="color: grey;"><?php echo $cur."".$row["product_old_price"]; ?></del><span><?php echo $cur."".$row["product_price"]; ?></span></h3>
                        <label class="details-list-title">Description :</label>
                        <p><?php echo $row["product_desc"]; ?></p>
                        <div class="details-add-group">
                            <center>
                                <div class="product-action" style="display: block;margin-bottom:12px">
                                    <input class="action-input" type="number" name="qty" id="qty" style="width: 43%;" value="1" title="Quantity Number">
                                </div>
                            </center>
                        </div>
                        <input type="hidden" name="p_id" id="p_id" value="<?php echo $row["product_id"]; ?>" />
                        <div class="details-action-group">
                            <button type="submit" name="btn_cart" id="btn_cart" class="product-add addtocart2" style="display: block !imporant;background: linear-gradient(to right, #240b36, #c31432);color:white">
                                <i class="fas fa-shopping-basket"></i><span>Add to Cart</span>
                            </button>
                        </div>
                    </form>
               </div>
            </div>
        </div>
    </div>
</section>  

<section class="section recent-part">
    <div class="container">
         <div class="row">
            <div class="col-lg-12">
               <div class="section-heading">
                  <h2>Related <?php echo $cat["catalogue_name"]; ?> Products</h2><hr>
               </div>
            </div>
         </div>
         <div class="row row-cols-2 row-cols-md-3 row-cols-lg-4 row-cols-xl-4">
            <?php $product_query = mysqli_query($conn, "SELECT * FROM aalierp_product WHERE catalogue_id='".$row["catalogue_id"]."'");if(mysqli_num_rows($product_query) > 0){
            while($row = mysqli_fetch_array($product_query)){ ?>

                <div class="col">
                    <div class="product-card">
                        <div class="product-media">
                            <div class="product-label"><label class="label-text sale">Latest</label></div>
                            <a class="product-image" href="<?php echo $AaliLINK; ?>/product-detail?pid=<?php echo $row["product_id"]; ?>">
                                <img src="<?php echo $AaliSYS; ?>/uploads/products/<?php echo $row["product_image"]; ?>" alt="<?php echo $row["product_name"]; ?>">
                            </a>
                        </div>
                        <div class="product-content">
                            <h6 class="product-name"><a href="<?php echo $AaliLINK; ?>/product-detail?pid=<?php echo $row["product_id"]; ?>" style="text-transform: uppercase;"><?php echo $row["product_name"]; ?></a></h6>
                            <h6 class="product-price" style="float: right;font-weight: 700;"><span><?php echo $cur."".$row["product_price"]; ?></span></h6>
                            <a href="<?php echo $AaliLINK; ?>/product-detail?pid=<?php echo $row["product_id"]; ?>" style="background-color: #ED4B62;color: white;" class="product-add mb-1" title="View">
                                <i class="fas fa-clipboard"></i><span> Order Now</span>
                            </a>
                            <a href="#" pid="<?php echo $row["product_id"]; ?>" id="add_to_cart" style="background-color: #00A313;color: white;" class="product-add" title="Order By WhatsApp">
                                <i class="fas fa-whatsapp"></i><span> Order By WhatsApp</span>
                            </a>
                        </div>
                    </div>
                </div>

            <?php } }else{echo "No Product";} ?>
         </div>
    </div>
</section>