<?php
include_once("include/main.inc.php");

@extract($_REQUEST);



if (preg_match('webpulse\.co$/', $_SERVER['HTTP_HOST'], $match)) {

  $match1 = $match[1];

  $vanity_url = 'http://' . $_SERVER['HTTP_HOST'];
}

$actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

$ee = explode('/', $actual_link);

$loc_url = $ee[3];

$cat_url = $_REQUEST['pid'];

$cats = ucwords(str_replace("-", " ", $_REQUEST['pid']));

$cat_s = "select catName, catID from category_tbl where catName='$cats' or catUrl='$cat_url'";

$cat_q = mysqli_query($GLOBALS['dbconn'], $cat_s);



if (mysqli_num_rows($cat_q) > 0) {
} else {

  header("Location: " . site_url);

  exit;
}

$num = mysqli_num_rows($cat_q);

$cat_r = mysqli_fetch_array($cat_q);

$category_id = $cat_r['catID'];

$hover = 'category';

$catn = $cat_r['catName'];

$cat_sql = "select catImage, catName, displayName, catDesc, catID, catDesc1, parentID,catUrl,alt, title from category_tbl where parentID='$category_id' and status='Y'";

$cat_qry = mysqli_query($GLOBALS['dbconn'], $cat_sql);

$cccnum = mysqli_num_rows($cat_qry);

$cat_sql1 = "select catName, displayName, catID, parentID,catImage,catDesc1,catBanner,keyword1,keyword2,keyword3,catHeading1, catHeading2,alt,pageTitle,pageKeywords,pageDescription,multi_image,catDesc2 from category_tbl where catID='$category_id'";

$cat_qry1 = mysqli_query($GLOBALS['dbconn'], $cat_sql1);

$cat_res = mysqli_fetch_array($cat_qry1);

$pageTitles = $cat_res['catName'];

$disTitles = $cat_res['displayName'];



$parent = $cat_res['parentID'];

$cat_sql2 = "select catName, displayName, catID, parentID from category_tbl where catID='$parent'";

$cat_qry2 = mysqli_query($GLOBALS['dbconn'], $cat_sql2);

$num2 = mysqli_num_rows($cat_qry2);

$cat_res2 = mysqli_fetch_array($cat_qry2);

$mparent = $cat_res2['parentID'];

$cat_sql3 = "select catName, displayName, catID, parentID from category_tbl where catID='$mparent'";

$cat_qry3 = mysqli_query($GLOBALS['dbconn'], $cat_sql3);

$num3 = mysqli_num_rows($cat_qry3);

$cat_res3 = mysqli_fetch_array($cat_qry3);

$mmparent = $cat_res3['parentID'];

$cat_sql4 = "select catName, displayName, catID, parentID from category_tbl where catID='$mmparent'";

$cat_qry4 = mysqli_query($GLOBALS['dbconn'], $cat_sql4);

$num4 = mysqli_num_rows($cat_qry4);

$cat_res4 = mysqli_fetch_array($cat_qry4);

$mobile = $admin_res['mobile'];

$city = $admin_res['city'];

$state = $admin_res['state'];

$country = $admin_res['country'];

$companyName = $admin_res['companyName'];

$address = $admin_res['address'];

$multi_image = explode(',', $cat_res['multi_image']);



if ($cat_res['catImage'] != '') {

  $imglink = getImage($cat_res[catImage], 500, 500, $cat_res[catName], "/uploaded-files/category/images/");
} else {

  $imglink = getImage("noimage (10).jpg", 500, 500, "noimage", "/uploaded-files/category/images/");
}

$loc_sql = mysqli_query($GLOBALS['dbconn'], "select locationID,locationName,loc_url from location_tbl where loc_url='$loc_url' and status='Y'");

$location = mysqli_fetch_array($loc_sql);

$locationName = $location['locationName'];

$location_id = $location['locationID'];

$category_sub_general = mysqli_query($dbconn, "select location_ids,meta_title,meta_keyword,meta_description,description,short_description,subheadingtwo,description2 from location_content_tbl where category_id='$category_id' AND location_id='0'");

$content_count = mysqli_num_rows($category_sub_general);

if ($content_count > 0) {

  while ($categorysubdomain = mysqli_fetch_array($category_sub_general)) {

    $locati = explode(",", $categorysubdomain['location_ids']);

    if (in_array($location_id, $locati)) {

      if ($categorysubdomain['meta_title'] != '') {

        $page_metatitle = $categorysubdomain['meta_title'];
      }

      if ($categorysubdomain['meta_keyword'] != '') {

        $page_metakey = $categorysubdomain['meta_keyword'];
      }

      if ($categorysubdomain['meta_description']) {

        $page_metadesc = $categorysubdomain['meta_description'];
      }

      $page_desc = $categorysubdomain['description'];

      $page_desc2 = $categorysubdomain['description2'];
    }
  }

  //    specific location content

}



if ($cat_res['keyword1'] != '' && $cat_res['keyword2'] != '' && $cat_res['keyword3'] != '') {
  $m_title = "hotkeyword1 Suppliers in location, hotkeyword2 Distributors Franchise in location";
  $page_metatitle = str_replace('hotkeyword1', $cat_res[keyword1], str_replace('hotkeyword2', $cat_res[keyword2], str_replace('location', $locationName, $m_title)));
  $m_keyword = "hotkeyword1 in location, hotkeyword2 in location, hotkeyword1 Suppliers in location, hotkeyword2 Distributors in location, hotkeyword2 Franchise in location, hotkeyword1 Distributors in location, hotkeyword1 Suppliers in location, hotkeyword2 Suppliers in location";
  $page_metakey = str_replace('hotkeyword1', $cat_res[keyword1], str_replace('hotkeyword2', $cat_res[keyword2], str_replace('hotkeyword3', $cat_res[keyword3], str_replace('location', $locationName, $m_keyword))));
  $meta_des = "companyName leading hotkeyword1 Suppliers in location, Since 2024. Premium Quality hotkeyword2 Distributors, Franchise in location, Get latest factory price for hotkeyword3. ✓Fast Delivery ✓Good Price";
  $page_metadesc = str_replace('hotkeyword1', $cat_res[keyword1], str_replace('hotkeyword2', $cat_res[keyword2], str_replace('hotkeyword3', $cat_res[keyword3], str_replace('companyName', $admin_res['companyName'], str_replace('phone', $admin_res['mobile_meta'], str_replace('location', $locationName, $meta_des))))));
} else if ($cat_res['keyword1'] != '' && $cat_res['keyword2'] != '') {
  $m_title = "hotkeyword1 Suppliers in location, hotkeyword2 Distributors Franchise in location";
  $page_metatitle = str_replace('hotkeyword1', $cat_res[keyword1], str_replace('hotkeyword2', $cat_res[keyword2], str_replace('location', $locationName, $m_title)));
  $m_keyword = "hotkeyword1 in location, hotkeyword2 in location, hotkeyword1 Suppliers in location, hotkeyword2 Distributors in location, hotkeyword2 Franchise in location, hotkeyword1 Distributors in location, hotkeyword1 Suppliers in location";
  $page_metakey = str_replace('hotkeyword1', $cat_res[keyword1], str_replace('hotkeyword2', $cat_res[keyword2], str_replace('location', $locationName, $m_keyword)));
  $meta_des = "companyName leading hotkeyword1 Suppliers in location, Since 2014. Premium Quality hotkeyword2 Distributors, Franchise in location, Get latest factory price for hotkeyword1. ✓Fast Delivery ✓Good Price";
  $page_metadesc = str_replace('hotkeyword1', $cat_res[keyword1], str_replace('hotkeyword2', $cat_res[keyword2], str_replace('companyName', $admin_res[companyName], str_replace('phone', $admin_res['mobile_meta'], str_replace('location', $locationName, $meta_des)))));
} else if ($cat_res['keyword1'] != '') {
  $m_title = "hotkeyword1 Suppliers in location, hotkeyword1 Distributors Franchise in location";
  $page_metatitle = str_replace('hotkeyword1', $cat_res[keyword1], str_replace('location', $locationName, $m_title));
  $m_keyword = "hotkeyword1 in location, hotkeyword1 Suppliers in location, hotkeyword1 Distributors in location, hotkeyword1 Franchise in location";
  $page_metakey = str_replace('hotkeyword1', $cat_res[keyword1], str_replace('location', $locationName, $m_keyword));
  $meta_des = "companyName leading hotkeyword1 Suppliers in location, Since 2014. Premium Quality hotkeyword1 Distributors, Franchise in location, Get latest factory price for hotkeyword1. ✓Fast Delivery ✓Good Price";
  $page_metadesc = str_replace('hotkeyword1', $cat_res[keyword1], str_replace('companyName', $admin_res[companyName], str_replace('phone', $admin_res['mobile_meta'], str_replace('location', $locationName, $meta_des))));
} else {
  $page_metatitle = $page_metatitle1;
  $page_metakey = $page_metakey1;
  $page_metadesc = $page_metadesc1;
}

$page_desc = str_replace('countryname', $locationName, $page_desc);

$page_desc = str_replace('catname', $pid, $page_desc);

$page_desc = str_replace('{location}', $locationName, $page_desc);

$page_desc = str_ireplace('{companyName}', $admin_res['companyName'], $page_desc);

// for second description

$page_desc2 = str_replace('countryname', $locationName, $page_desc2);

$page_desc2 = str_replace('catname', $pid, $page_desc2);

$page_desc2 = str_replace('{location}', $locationName, $page_desc2);

$page_desc2 = str_ireplace('{companyName}', $admin_res['companyName'], $page_desc2);

// meta keywords

$page_metatitle = str_replace('countryname', $locationName, $page_metatitle);

$page_metatitle = str_replace('catname', $pid, $page_metatitle);

$page_metatitle = str_replace('{location}', $locationName, $page_metatitle);

$page_metakey = str_replace('countryname', $locationName, $page_metakey);

$page_metakey = str_replace('catname', $pid, $page_metakey);

$page_metakey = str_replace('{location}', $locationName, $page_metakey);

$page_metadesc = str_replace('countryname', $locationName, $page_metadesc);

$page_metadesc = str_replace('catname', $pid, $page_metadesc);

$page_metadesc = str_replace('{location}', $locationName, $page_metadesc);

// if location not checked in admin

$category_sub_uncheck_loc = mysqli_query($GLOBALS['dbconn'], "select description,subheadingtwo,meta_title,meta_keyword,meta_description,short_description,description2 from location_content_tbl where category_id='$category_id' AND location_id='0'");

$category_sub_uncheck_res = mysqli_fetch_array($category_sub_uncheck_loc);



// // For metatitle 1 (uncheck location)

// $page_metatitle = $category_sub_uncheck_res['meta_title'];

// $page_metatitle= str_replace('{location}', $locationName,  $page_metatitle);

// $page_metatitle= str_ireplace('{companyName}', $admin_res['companyName'], $page_metatitle);



// // For metadescription 1 (uncheck location)

// $page_metadesc = $category_sub_uncheck_res['meta_description'];

// $page_metadesc= str_replace('{location}', $locationName,  $page_metadesc);

// $page_metadesc= str_ireplace('{companyName}', $admin_res['companyName'], $page_metadesc);





// // For metakeyword 1 (uncheck location)

// $page_metakey = $category_sub_uncheck_res['meta_keyword'];

// $page_metakey= str_replace('{location}', $locationName,  $page_metakey);

// $page_metakey= str_ireplace('{companyName}', $admin_res['companyName'], $page_metakey);





// For description 1 (uncheck location)

$page_descUncheck = $category_sub_uncheck_res['description'];

$page_descUncheck = str_replace('{location}', $locationName,  $page_descUncheck);

$page_descUncheck = str_ireplace('{companyName}', $admin_res['companyName'], $page_descUncheck);

// For description 2 (uncheck location)

$page_desc2Uncheck = $category_sub_uncheck_res['description'];

$page_desc2Uncheck = str_replace('{location}', $locationName,  $page_desc2Uncheck);

$page_desc2Uncheck = str_ireplace('{companyName}', $admin_res['companyName'], $page_desc2Uncheck);

$page_desc = $page_desc != '' ? $page_desc : $page_descUncheck;

$page_desc2 = $page_desc2 != '' ? $page_desc2 : $page_desc2Uncheck;







// if ($cat_res['catHeading1'] != '') {

//   $heading1 = $cat_res['catHeading1'] . ' Services in ' . $locationName;

// } else {

//   $heading1 = $disTitles . ' Services in ' . $locationName;

// }



if ($cat_res['catHeading1'] != '') {

  $heading1 = $cat_res['catHeading1'] . ' Suppliers in ' . $locationName;
} else {

  // Join array into a string

  $heading1 = $disTitles . ' Suppliers in ' . $locationName;
}



if ($cat_res['catHeading2'] != '') {

  $heading2 = $cat_res['catHeading2'] . ' in ' . $locationName;
} else {

  $heading2 = $disTitles . ' in ' . $locationName;
}



// if ($cat_res['alt'] != '') {

//   $alttag = $cat_res['alt'] . ' Services in ' . $locationName;

// } else {

//   $alttag = $disTitles . ' Services in ' . $locationName;

// }



if ($cat_res['alttag'] != '') {

  $alttag = $cat_res['alttag'] . ' in ' . $locationName;
} else {

  if ($cat_res['catID'] == '8') {

    $alttag = $cat_res['displayName'] . ' Suppliers in ' . $locationName;
  } else {

    $alttag = $disTitles . ' Suppliers in ' . $locationName;
  }
}





if (mysqli_num_rows($loc_sql) > 0) {
} else {

  header("Location: " . site_url);

  exit;
}


?>
<!DOCTYPE html>
<html lang="en">

<head>

  <?php include 'app_top.php'; ?>
</head>

<body>
  <?php include 'app_header_sub.php'; ?>
  <div class="breadcum-sec" style="background-image: url(<?= site_url; ?>/designer/images/category-banner.jpg);">
    <div class="container">
      <h1 class="main-tt"><?= $heading1; ?></h1>
      <ul>
        <li><a href="<?= site_url; ?>" title="Home">Home</a></li>
        <?php if ($num4 > 0) { ?>
          <li><a href="<?= site_url; ?>/<?= getValidFileName($loc_url); ?>/<?= getValidFileName($cat_res4['catName']); ?>.htm"
              title="<?php echo $cat_res4['catName']; ?> "><?php echo $cat_res4['catName']; ?></a>
          </li>
        <?php } ?>
        <?php if ($num3 > 0) { ?>
          <li><a href="<?= site_url; ?>/<?= getValidFileName($loc_url); ?>/<?= getValidFileName($cat_res3['catName']); ?>.htm"
              title="<?php echo $cat_res3['catName']; ?>"><?php echo $cat_res3['catName']; ?></a>
          </li>
        <?php } ?>
        <?php if ($num2 > 0) { ?>
          <li>
            <?php if ($cat_res2['catID'] == '1') { ?>
              <a href="javascript:void(0);"
                title="<?php echo $cat_res2['catName']; ?>"><?php echo $cat_res2['catName']; ?></a>
            <?php } else {  ?>
              <a href="<?= site_url; ?>/<?= getValidFileName($loc_url); ?>/<?= getValidFileName($cat_res2['catName']); ?>.htm"
                title="<?php echo $cat_res2['catName']; ?>"><?php echo $cat_res2['catName']; ?></a>
            <?php } ?>
          </li>
        <?php  }  ?>
        <li><?php echo $cat_res['catName']; ?></li>
      </ul>
    </div>
  </div>
  <div class="category-page bg-light">
    <div class="container">
      <a href="#productEnquiry" class="cate-img" data-bs-toggle="modal" data-bs-target="#productEnquiry" onclick="$('.catID').val('<?php echo $cat_res['catID']; ?>');
                                     $('.catName').html('<?php echo $cat_res['catName']; ?>'); $('.catImg').attr('src','<?= $imglink; ?>');  $('.catImg').attr('alt','<?= $alttag; ?>'); $('.catImg').attr('title','<?= $alttag; ?>');" title="Enquire Now">
        <img src="<?= $imglink; ?>" alt="<?= $alttag; ?>"
          title="<?= $alttag; ?>">
      </a>
      <div class="cate-tx">
        <!-- <h2 class="main-tt"><?= $heading2; ?></h2> -->
        <?php echo html_entity_decode($page_desc); ?>
        <div class="btn-bx mt-4 d-flex gap-2">
          <button class="main-btn" type="button" data-bs-toggle="modal" data-bs-target="#productEnquiry" onclick="$('.catID').val('<?php echo $cat_res['catID']; ?>');
                                     $('.catName').html('<?php echo $cat_res['catName']; ?>'); $('.catImg').attr('src','<?= $imglink; ?>');  $('.catImg').attr('alt','<?= $alttag; ?>'); $('.catImg').attr('title','<?= $alttag; ?>');" title="Get A Quote"><svg
              xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-envelope"
              viewBox="0 0 16 16">
              <path
                d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2zm2-1a1 1 0 0 0-1 1v.217l7 4.2 7-4.2V4a1 1 0 0 0-1-1zm13 2.383-4.708 2.825L15 11.105zm-.034 6.876-5.64-3.471L8 9.583l-1.326-.795-5.64 3.47A1 1 0 0 0 2 13h12a1 1 0 0 0 .966-.741M1 11.105l4.708-2.897L1 5.383z" />
            </svg> Get a Quote</button>
          <button class="w-btn" type="button" data-bs-toggle="modal" data-bs-target="#whatsappEnquiry" title="Chat With Us">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
              <path
                d="M13.601 2.326A7.854 7.854 0 0 0 7.994 0C3.627 0 .068 3.558.064 7.926c0 1.399.366 2.76 1.057 3.965L0 16l4.204-1.102a7.933 7.933 0 0 0 3.79.965h.004c4.368 0 7.926-3.558 7.93-7.93A7.898 7.898 0 0 0 13.6 2.326zM7.994 14.521a6.573 6.573 0 0 1-3.356-.92l-.24-.144-2.494.654.666-2.433-.156-.251a6.56 6.56 0 0 1-1.007-3.505c0-3.626 2.957-6.584 6.591-6.584a6.56 6.56 0 0 1 4.66 1.931 6.557 6.557 0 0 1 1.928 4.66c-.004 3.639-2.961 6.592-6.592 6.592zm3.615-4.934c-.197-.099-1.17-.578-1.353-.646-.182-.065-.315-.099-.445.099-.133.197-.513.646-.627.775-.114.133-.232.148-.43.05-.197-.1-.836-.308-1.592-.985-.59-.525-.985-1.175-1.103-1.372-.114-.198-.011-.304.088-.403.087-.088.197-.232.296-.346.1-.114.133-.198.198-.33.065-.134.034-.248-.015-.347-.05-.099-.445-1.076-.612-1.47-.16-.389-.323-.335-.445-.34-.114-.007-.247-.007-.38-.007a.729.729 0 0 0-.529.247c-.182.198-.691.677-.691 1.654 0 .977.71 1.916.81 2.049.098.133 1.394 2.132 3.383 2.992.47.205.84.326 1.129.418.475.152.904.129 1.246.08.38-.058 1.171-.48 1.338-.943.164-.464.164-.86.114-.943-.049-.084-.182-.133-.38-.232z">
              </path>
            </svg>
            Chat with us</button>
        </div>
      </div>
      <div class="clearfix"></div>
      <?php
      $whr = ' FIND_IN_SET(' . $cat_res['catID'] . ', product_cat)';
      // $totalcount = mysqli_num_rows(mysqli_query($GLOBALS['dbconn'], "select product_id from product_tbl where   " . $whr . "  order by product_id desc"));
      $totalcount = mysqli_num_rows(mysqli_query($GLOBALS['dbconn'], "SELECT product_id FROM product_tbl WHERE product_status='1' AND " . $whr . " ORDER BY product_id DESC"));
      $product_s = mysqli_query($GLOBALS['dbconn'], "select product_image,product_title,catalog,product_id,product_video,product_specfi from product_tbl WHERE product_status='1' AND " . $whr . " order by product_id desc limit 6");
      $num = mysqli_num_rows($product_s);
      if ($num > 0) {    ?>
        <div class="you_may mt-4 mb-3">Products Related To <?= $disTitles; ?></div>
        <div class="row g-3 product-container">

          <?php $i = 1;
          while ($product_r = mysqli_fetch_array($product_s)) {
            $pro_image =  explode(',', $product_r['product_image']);
            $probig_img = $pro_image[0];
            $imgname = explode('.', $pro_image[0]);
            $prod_img = getImage($probig_img, 600, 600, $product_r['product_title'] . $imgname[0], "/uploaded-files/product-images/");
            $prod_imgsmall = getImage($probig_img, 150, 150, $product_r['product_title'], "/uploaded-files/product-images/");
          ?>
            <div class="col-12 pr_view productlist">
              <div class="pr-li">
                <div class="row g-0">
                  <div class="col-lg-4 col-md-5 col-12 g_col">
                    <div class="img_bx">
                      <a class="main-img" href="#productEnquiry" data-bs-toggle="modal" data-bs-target="#productEnquiry" onclick="var src = $(this).find('img.clickable-image').attr('src');$('.catID').val('<?php echo $product_r['product_id']; ?>');$('.catName').html('<?php echo $product_r['product_title']; ?>');  $('.catImg').attr('src', src); $('.catImg').attr('alt','<?= $product_r['product_title']; ?> Suppliers, Distributors, Franchise in <?= $locationName; ?>'); $('.catImg').attr('title','<?= $product_r['product_title']; ?> Suppliers, Distributors, Franchise in <?= $locationName; ?>');" title="<?= $product_r['product_title']; ?> Suppliers, Distributors, Franchise in <?= $locationName; ?>">
                        <img id="mainImage<?= $product_r['product_id']; ?>" src="<?= $prod_img; ?>" class="clickable-image" alt="<?= $product_r['product_title']; ?> Suppliers, Distributors, Franchise in <?= $locationName; ?>"
                          title="<?= $product_r['product_title']; ?> Suppliers, Distributors, Franchise in <?= $locationName; ?>">
                      </a>
                      <?php
                      if (!empty($pro_image[1]) || !empty($product_r['product_video'])) {
                      ?>
                        <div class="multi-imgs">
                          <?php
                          if (!empty($pro_image[1])) {
                            $snn = 1;
                            foreach ($pro_image as $pro_imag_vals) { ?>
                              <div class="imgs <?= $snn == 1 ? 'active' : ''; ?>" onclick="imgMulti(<?= $product_r['product_id']; ?>, '<?= getImage($pro_imag_vals, 600, 600, $product_r['product_title'] . $product_r['product_id'] . $snn, '/uploaded-files/product-images/'); ?>', this)">
                                <img src="<?= getImage($pro_imag_vals, 150, 150, $product_r['product_title'] . $product_r['product_id'] . $snn, '/uploaded-files/product-images/'); ?>" alt="<?= $product_r['product_title']; ?> Suppliers, Distributors, Franchise in <?= $locationName; ?>" title="<?= $product_r['product_title']; ?> Suppliers, Distributors, Franchise in <?= $locationName; ?>">
                              </div>
                          <?php $snn++;
                            }
                          } ?>

                          <?php if ($product_r['product_video'] != '') { ?>
                            <div class="imgs youTube">
                              <a data-fancybox="" href="https://www.youtube.com/watch?v=<?= $product_r['product_video']; ?>">
                                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
                                  <path d="m11.596 8.697-6.363 3.692c-.54.313-1.233-.066-1.233-.697V4.308c0-.63.692-1.01 1.233-.696l6.363 3.692a.802.802 0 0 1 0 1.393z">
                                  </path>
                                </svg>
                              </a>
                            </div>
                          <?php } ?>
                        </div>

                      <?php } ?>

                    </div>
                  </div>

                  <div class="col-lg-8 col-md-7 col-12 g_col">
                    <div class="tx-bx">
                      <h4 class="title"><?= $product_r['product_title']; ?> in <?= $locationName; ?></h4>
                      <?php if ($product_r['catalog'] != '') { ?>
                        <div class="bt_bx mb-2">
                          <div class="productBrochureandvideo">
                            <a href="<?= site_url; ?>/uploaded-files/pdf/<?= $product_r['catalog']; ?>" title="Product Brochure" target="_blank">
                              <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-filetype-pdf" viewBox="0 0 16 16">
                                <path fill-rule="evenodd" d="M14 4.5V14a2 2 0 0 1-2 2h-1v-1h1a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5ZM1.6 11.85H0v3.999h.791v-1.342h.803c.287 0 .531-.057.732-.173.203-.117.358-.275.463-.474a1.42 1.42 0 0 0 .161-.677c0-.25-.053-.476-.158-.677a1.176 1.176 0 0 0-.46-.477c-.2-.12-.443-.179-.732-.179Zm.545 1.333a.795.795 0 0 1-.085.38.574.574 0 0 1-.238.241.794.794 0 0 1-.375.082H.788V12.48h.66c.218 0 .389.06.512.181.123.122.185.296.185.522Zm1.217-1.333v3.999h1.46c.401 0 .734-.08.998-.237a1.45 1.45 0 0 0 .595-.689c.13-.3.196-.662.196-1.084 0-.42-.065-.778-.196-1.075a1.426 1.426 0 0 0-.589-.68c-.264-.156-.599-.234-1.005-.234H3.362Zm.791.645h.563c.248 0 .45.05.609.152a.89.89 0 0 1 .354.454c.079.201.118.452.118.753a2.3 2.3 0 0 1-.068.592 1.14 1.14 0 0 1-.196.422.8.8 0 0 1-.334.252 1.298 1.298 0 0 1-.483.082h-.563v-2.707Zm3.743 1.763v1.591h-.79V11.85h2.548v.653H7.896v1.117h1.606v.638H7.896Z">
                                </path>
                              </svg>
                              <span>Product Brochure</span>
                            </a>
                          </div>
                        </div>
                      <?php } ?>
                      <div class="info">
                        <?= html_entity_decode($product_r['product_specfi']); ?>
                      </div>
                      <div class="d-flex gap-2 align-items-center">
                        <button class="main-btn" data-bs-toggle="modal" data-bs-target="#productEnquiry" onclick="$('.catID').val('<?php echo $product_r['product_id']; ?>');$('.catName').html('<?php echo $product_r['product_title']; ?>');  $('.catImg').attr('src','<?= site_url; ?>/uploaded-files/product-images/<?= $probig_img; ?>'); $('.catImg').attr('alt','<?= $product_r['product_title']; ?> Suppliers, Distributors, Franchise in <?= $locationName; ?>'); $('.catImg').attr('title','<?= $product_r['product_title']; ?> Suppliers, Distributors, Franchise in <?= $locationName; ?>');" title="Get Best Quote"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
                            <path d="M.05 3.555A2 2 0 0 1 2 2h12a2 2 0 0 1 1.95 1.555L8 8.414.05 3.555ZM0 4.697v7.104l5.803-3.558L0 4.697ZM6.761 8.83l-6.57 4.027A2 2 0 0 0 2 14h12a2 2 0 0 0 1.808-1.144l-6.57-4.027L8 9.586l-1.239-.757Zm3.436-.586L16 11.801V4.697l-5.803 3.546Z"></path>
                          </svg> Get Best Quote</button>
                        <button class="w-btn" type="button" data-bs-toggle="modal" data-bs-target="#whatsappEnquiry" title="Chat With us">
                          <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
                            <path
                              d="M13.601 2.326A7.854 7.854 0 0 0 7.994 0C3.627 0 .068 3.558.064 7.926c0 1.399.366 2.76 1.057 3.965L0 16l4.204-1.102a7.933 7.933 0 0 0 3.79.965h.004c4.368 0 7.926-3.558 7.93-7.93A7.898 7.898 0 0 0 13.6 2.326zM7.994 14.521a6.573 6.573 0 0 1-3.356-.92l-.24-.144-2.494.654.666-2.433-.156-.251a6.56 6.56 0 0 1-1.007-3.505c0-3.626 2.957-6.584 6.591-6.584a6.56 6.56 0 0 1 4.66 1.931 6.557 6.557 0 0 1 1.928 4.66c-.004 3.639-2.961 6.592-6.592 6.592zm3.615-4.934c-.197-.099-1.17-.578-1.353-.646-.182-.065-.315-.099-.445.099-.133.197-.513.646-.627.775-.114.133-.232.148-.43.05-.197-.1-.836-.308-1.592-.985-.59-.525-.985-1.175-1.103-1.372-.114-.198-.011-.304.088-.403.087-.088.197-.232.296-.346.1-.114.133-.198.198-.33.065-.134.034-.248-.015-.347-.05-.099-.445-1.076-.612-1.47-.16-.389-.323-.335-.445-.34-.114-.007-.247-.007-.38-.007a.729.729 0 0 0-.529.247c-.182.198-.691.677-.691 1.654 0 .977.71 1.916.81 2.049.098.133 1.394 2.132 3.383 2.992.47.205.84.326 1.129.418.475.152.904.129 1.246.08.38-.058 1.171-.48 1.338-.943.164-.464.164-.86.114-.943-.049-.084-.182-.133-.38-.232z">
                            </path>
                          </svg>
                          Chat with us</button>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <script>
              $('#small<?= $i; ?> .item').click(function() {
                $('#bigImage<?= $i; ?> img').attr('src', $(this).attr('src').replace('thumb',
                  'large'));
                if ($(this).hasClass("active")) {
                  $("#small<?= $i; ?> .item").removeClass("active");
                } else {
                  $("#small<?= $i; ?> .item").removeClass("active");
                  $(this).addClass("active");
                }
              });
            </script>
          <?php $i++;
          } ?>



        </div>
        <?php if ($totalcount > $num) { ?>
        <?php echo '<div class="mt-2 text-center" id="loadmore" data-id="' . $whr . '"><i class="fa fa-spinner fa-spin"></i> Loading...</div>';
        } ?>
      <?php } ?>

      <div class="you_may mt-4 mb-3">All Category Range</div>
      <div class="row g-3">
        <!-- loop starts -->
        <?php
        if (mysqli_num_rows($cat_qry) > 0) {

          $subcat_sql = $cat_qry;
        } else {

          $sqlsub2 = mysqli_query($GLOBALS['dbconn'], "select catImage, catName, displayName, catDesc, catID, catDesc1, parentID from category_tbl where parentID ='$parent' and status='1' and catID!='$category_id' order by catOrder Asc");

          if (mysqli_num_rows($sqlsub2) > 1) {



            $subcat_sql = $sqlsub2;
          } else {



            $subcat_sql = mysqli_query($GLOBALS['dbconn'], "select catImage, catName, displayName, catDesc, catID, catDesc1, parentID from category_tbl  where parentID ='0' and status='1' and catID!='$category_id' order by catOrder Asc");
          }
        }

        while ($sub_res = mysqli_fetch_array($subcat_sql)) {



          if ($sub_res['catImage'] != '') {

            $img_link = getImage($sub_res[catImage], 395, 395, $sub_res[catName], "/uploaded-files/category/images/");

            $img_link1 = getImage($sub_res[catImage], 395, 395, $sub_res[catName], "/uploaded-files/category/images/");
          } else {

            $img_link = getImage("noimage.jpg",  395, 395, "noimages", "/uploaded-files/category/images/");

            $img_link1 = getImage("noimage.jpg", 395, 395, "noimages", "/uploaded-files/category/images/");
          }

          $caturls1 = !empty($sub_res['catUrl']) ? $sub_res['catUrl'] : $sub_res['catName'];
          $catIdss = $sub_res['catID'];
          $sql_content = mysqli_query($GLOBALS['dbconn'], "select subheadingtwo,short_description,meta_title,meta_keyword,meta_description from location_content_tbl where category_id ='$catIdss'");

          $res_content = mysqli_fetch_array($sql_content);

          $subcontent_descc = html_entity_decode($res_content['short_description']);

          $subcontent_desccc = str_replace('{location}', $locationName, $subcontent_descc);

          $subcontent_descccc = str_replace('catname', $res_cat['catName'], $subcontent_desccc);

          $subcontent_descccc = str_ireplace('{companyName}', $admin_res['companyName'], $subcontent_descccc);

        ?>
          <div class="col-12 pr_view">
            <div class="pr-li">
              <div class="row g-0">
                <div class="col-lg-4 col-md-5 col-12 g_col">
                  <div class="img_bx">
                    <a class="main-img" href="<?= site_url; ?>/<?= getValidFileName($loc_url); ?>/<?= getValidFileName($caturls1); ?>.htm" title="<?= $sub_res['displayName']; ?> Suppliers in <?= $locationName; ?>">
                      <img src="<?= $img_link; ?>" alt="<?= $sub_res['displayName']; ?> Suppliers in <?= $locationName; ?>" title="<?= $sub_res['displayName']; ?> Suppliers in <?= $locationName; ?>">
                    </a>
                  </div>
                </div>
                <div class="col-lg-8 col-md-7 col-12 g_col">
                  <div class="tx-bx">
                    <h4 class="title" title="<?= $sub_res['displayName']; ?> Suppliers in <?= $locationName; ?>"><a href="<?= site_url; ?>/<?= getValidFileName($loc_url); ?>/<?= getValidFileName($caturls1); ?>.htm"><?= $sub_res['displayName']; ?></a></h4>
                    <div class="info">
                      <p><?= $subcontent_descccc; ?>
                      </p>
                    </div>
                    <div class="d-flex gap-2 align-items-center">
                      <a href="<?= site_url; ?>/<?= getValidFileName($loc_url); ?>/<?= getValidFileName($caturls1); ?>.htm" class="main-btn" title="Read More">Read More</a>
                      <button class="main-btn light dark" data-bs-toggle="modal" data-bs-target="#productEnquiry" onclick="$('.catID').val('<?php echo $sub_res['catID']; ?>');$('.catName').html('<?php echo $sub_res['catName']; ?>');$('.catImg').attr('src','<?= $img_link1; ?>'); $('.catImg').attr('alt','<?= $sub_res['displayName']; ?> Suppliers in <?= $locationName; ?>'); $('.catImg').attr('title','<?= $sub_res['displayName']; ?> Suppliers in <?= $locationName; ?>');" title="Get Best Quote"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
                          <path d="M.05 3.555A2 2 0 0 1 2 2h12a2 2 0 0 1 1.95 1.555L8 8.414.05 3.555ZM0 4.697v7.104l5.803-3.558L0 4.697ZM6.761 8.83l-6.57 4.027A2 2 0 0 0 2 14h12a2 2 0 0 0 1.808-1.144l-6.57-4.027L8 9.586l-1.239-.757Zm3.436-.586L16 11.801V4.697l-5.803 3.546Z"></path>
                        </svg> Get Best Quote</button>
                    </div>
                  </div>
                </div>
              </div>




            </div>
          </div>
        <?php } ?>
        <!-- loop ends -->






      </div>


    </div>
  </div>

  <?php include 'app_footer_sub.php'; ?>
  <?php include 'app_bottom.php'; ?>

  <script>
    var loading = false;
    $(window).scroll(function() {
      var offset = $("#loadmore").offset().top;
      if ($(window).scrollTop() >= offset - 500) {
        let whr = $("#loadmore").data('id');
        let start = $('.productlist').length;
        if (loading === false) {
          loading = true;
          $.ajax({
            url: '<?= site_url ?>/ajaxloadcategorysub.php',
            data: {
              whr: whr,
              start: start,
              loadmores: '<?= $locationName; ?>'
            },
            type: 'post',
            success: function(r) {
              $('.product-container').append(r);
              if (r.length > 5) {
                loading = false;
              } else {
                $("#loadmore").remove();
              }

              if (start == <?= $totalcount; ?>) {
                $("#loadmore").remove();
              }
            }
          });
        }
      }
    })
  </script>
  <script>
    function imgMulti(id, url, elm) {
      document.getElementById(`mainImage${id}`).src = url;
      $(elm).addClass('active').siblings().removeClass('active');
    }
  </script>
</body>

</html>