
<!-- Header Wrap Starts -->
<?php include "common/header.php"; 
include "common/navbar.php"; 

if(isset($_GET['cid'])) { 
  $cid = htmlspecialchars(strip_tags(trim($_GET['cid'])), ENT_QUOTES, 'UTF-8');


  if(empty($cid)) {
    $redirectUrl = "index.php";
    echo "<script type=\"text/javascript\">";
    echo "window.location.href = '$redirectUrl'";
    echo "</script>";


  } else {
    $sql_cat = mysqli_query($conn, "SELECT * FROM sub_cat WHERE sub_cat_id='$cid'");
    $row_cat = mysqli_fetch_assoc($sql_cat);
    $cat = $row_cat['sub_cat'];

    ?> 

    <!-- Main Container Starts -->
    <div class="main-container" >
      <!-- Product Container Starts -->
      <div id="product-product" class="container" style="background-image: url(image/bg.jpg); ">

        <!-- Row Starts -->  
        <div class="row">

          <!-- <?php //include "common/sidebar.php"; ?>  -->

          <div id="content" class="col-sm-12">
            <h3 class="page-heading-1"><?php echo $cat ; ?></h3>
            <div class="product-sort-wrap hidden">
              <div class="row">
                <div class="col-md-2 col-sm-6 hidden-xs">
                  <div class="btn-group btn-group-sm">
                   <!--  <button type="button" id="list-view" class="btn btn-default" data-toggle="tooltip" title="List"><i class="fa fa-th-list"></i></button> -->
                    <button type="button" id="grid-view" class="btn btn-default" data-toggle="tooltip" title="Grid"><i class="fa fa-th"></i></button>
                  </div>
                </div>
              </div>
            </div>
            <div class="row">   
              <?php 
              $sql = mysqli_query($conn, "SELECT * FROM items WHERE sub_cat_id='$cid'");

              if(mysqli_num_rows($sql) == 0) {
                $redirectUrl = "index.php";
                echo "<script type=\"text/javascript\">";
                echo "window.location.href = '$redirectUrl'";
                echo "</script>";

              } else {
                while($row = mysqli_fetch_array($sql)){ 
                  ?>      
                  <!-- Product Col Starts -->
                  <div class="product-layout product-list col-xs-12">
                    <!-- Product Module Starts -->
                    <div class="product-thumb module-product animation clearfix">
                      <!-- Product Image Starts -->
                      <div class="module-product-image">
                        <a href="product-details?id=<?php echo $row['detail']; ?>">
                          <img src="backend/upload/item/<?php echo $row['item_code']; ?>/<?php echo $row['f_img']; ?>" alt="<?php echo $row['item_name']; ?>" title="<?php echo $row['item_name']; ?>" class="img-responsive img-center" />
                        </a>
                      </div>
                      <!-- Product Image Ends -->
                      <!-- Product Caption Starts -->
                      <div class="module-product-caption">
                        <!-- Product Name Starts -->
                        <h6 class="module-product-title"><a href="product-details?id=<?php echo $row['detail']; ?>"><?php echo $row['item_name']; ?></a></h6>
                        <!-- Product Name Ends -->
                        <!-- Product Description Starts -->
                        <div class="module-product-description">
                          <?php echo $row['discription']; ?>
                        </div>
                        <!-- Product Description Ends -->
                        <!-- Product Price Starts -->
                        <div class="module-product-price">
                          LKR <?php echo $row['price']; ?>
                          <span class="price-old">LKR<?php echo $row['ori_price']; ?></span>
                        </div>
                        <!-- Product Price Ends -->
                      </div>
                      <!-- Product Caption Ends -->
                      <!-- Product Buttons Starts -->
                      <div class="module-product-btns-wrap button-group">
                        <button type="button" id="button-cart" data-loading-text="Loading..." class="btn btn_cart" value="<?php echo $row['id']; ?>">
                          <i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md">Add to Cart</span></button>
                      <!-- <button type="button" class="btn rounded-0 animation" data-toggle="tooltip" title="Add to Wish List" onclick="wishlist.add('49');"><i class="fa fa-heart"></i></button>
                        <button type="button" class="btn rounded-0 animation" data-toggle="tooltip" title="Compare this Product" onclick="compare.add('49');"><i class="fa fa-exchange"></i></button> -->
                      </div>
                      <!-- Product Buttons Ends -->
                    </div>
                    <!-- Product Module Ends -->
                  </div>
                  <!-- Product Col Ends -->
                <?php } }?>
              </div>
              <hr>
              <div class="row">
                <div class="col-sm-6 text-left-lg text-left-md text-left-sm"></div>
                <div class="col-sm-6 text-right-lg text-right-md text-right-sm results">Showing 1 to 1 of 1 (1 Pages)</div>
              </div>
            </div>

          </div>
        </div>
      </div>
      <!-- Main Container Ends -->

    <?php  } } ?>


    <!-- Footer Starts -->
    <?php include "common/footer.php"; ?> 

    <!-- Footer Ends -->

  </body>
  </html> 
