<?php 
$this->load->view("top_application");
$messurement = $this->config->item('unit_measurement');
$QryStringArr = array();  // To store all Query Variables so to move to other view;
$QryStringArr = array_unique($QryStringArr);
if (isset($this->meta_info['entity_id']) && $this->meta_info['entity_id'] != '') {
  $QryStringArr['category_id'] = $this->meta_info['entity_id'];
}
if (isset($locationId) && $locationId!='') {
  $QryStringArr['locationId'] = $locationId;
}
if ($this->input->get_post('keyword') != '') {
  $QryStringArr['keyword'] = $this->input->get_post('keyword');
}
if ($this->input->get_post('sort') != '') {
  $QryStringArr['sort'] = $this->input->get_post('sort');
}

?>
<section class="dir-alp dir-pa-sp-top">
  <div class="container">
    <div class="row">
      <div class="dir-alp-tit mobile_padding">
        <h1><?php echo $heading_title; ?></h1>
        <ol class="breadcrumb">
          <li><a href="<?php echo site_url(); ?>">Home</a> </li>
          <?php echo category_breadcrumbs($categoryId); ?>
        </ol>
      </div>
    </div>
  <?php if($categoryId>0){ ?>
    <div id="second_bar">
      <div class=""><!-- container -->
        <div class="row">
          <ul class="second_bar_menu">
            <li>
              <a class="active" href="javascript:void(0);">
                <span><?php echo $title; ?> 
                  <?php
                  if (is_array($catList) && !empty($catList)) {
                    ?>
                    <!-- <i class="fa fa-angle-down"></i> -->
                    <?php
                  }
                  ?>
                </span>
              </a>
              <?php
              if (is_array($catList) && !empty($catList)) {
                ?>
              <!--  <div class="sub_menu01">
                  <div class="container">
                    <div class="full_menu02">
                      <ul class="row">
                        <?php
                        foreach ($catList as $val) {
                          ?>
                          <li><a href="<?php echo site_url($val['friendly_url']); ?>" title="<?php imagealtTitle('', $val['category_name'], 'Service Provider'); ?>"><?php echo $val['category_name']; ?></a></li>
                          <?php
                        }
                        ?>
                      </ul>
                    </div>
                  </div>
                </div> -->
                <?php
              }
              ?>
            </li>

            <?php
            if (is_array($result_cousin) && !empty($result_cousin)) {
              foreach ($result_cousin as $sVal) {
                $condtion_child = array('field' => "*,( SELECT COUNT(category_id) FROM wps_categories AS b WHERE b.parent_id=a.category_id ) AS total_subcategories", 'condition' => "AND parent_id = '" . $sVal['category_id'] . "' AND status='1' ", 'debug' => FALSE);
                $result_child = $this->category_model->getcategory($condtion_child);
                ?>
                <li>
                  <a href="<?php echo site_url($sVal['friendly_url']); ?>" title="<?php imagealtTitle('', $sVal['category_name'], 'Service Provider'); ?>">
                    <span><?php echo $sVal['category_name']; ?> 
                      <?php
                      if (is_array($result_child) && !empty($result_child)) {
                        ?>
                        <i class="fa fa-angle-down"></i>
                        <?php
                      }
                      ?>
                    </span>
                  </a>
                  <?php
                  if (is_array($result_child) && !empty($result_child)) {
                    ?>
                    <div class="sub_menu01">
                      <div class="container">
                        <div class="full_menu02">
                          <ul class="row">
                            <?php
                            foreach ($result_child as $cVal) {
                              ?>
                              <li><a href="<?php echo site_url($cVal['friendly_url']); ?>" title="<?php imagealtTitle('', $cVal['category_name'], 'Service Provider'); ?>"><?php echo $cVal['category_name']; ?></a></li>                 
                              <?php
                            }
                            ?>
                          </ul>
                        </div>
                      </div>
                    </div>
                    <?php
                  }
                  ?>
                </li>
                <?php
              }
            }
            ?>
            <li>
              <a href="javascript:void(0);"><span>More <i class="fa fa-angle-down"></i></span></a>
              <?php
              if (is_array($result_cousin_1) && !empty($result_cousin_1)) {
                ?>
                <div class="sub_menu01">
                  <div class="container">
                    <div class="full_menu02">
                      <ul class="row">
                        <?php
                        foreach ($result_cousin_1 as $cVal1) {
                          //trace($val);
                          ?>
                          <li><a href="<?php echo site_url($cVal1['friendly_url']); ?>" title="<?php imagealtTitle('', $cVal1['category_name'], 'Service Provider'); ?>"><?php echo $cVal1['category_name']; ?></a></li>                 
                          <?php
                        }
                        ?>
                      </ul>
                    </div>
                  </div>
                </div>
                <?php
              }
              ?>
            </li>
          </ul>        
        </div>      
      </div>
    </div>
  
    <div class="container">
      <div class="second_mobile hidden-lg hidden-md">
        <h3>Categories</h3>
        <button type="button" id="tab-top-menu" onclick="return OnMobileMenuClick()"><i class="fa fa-bars" aria-hidden="true"></i></button>
        <div id="m_navigation">
          <ul>
            <li><a class="active" href="javascript:void(0);"><?php echo $title; ?></a>
              <button type="button" onclick="return OnMobileSubMenuClick($(this));"><img src="<?php echo theme_url(); ?>images/drop-icon.png" title="<?php echo $title; ?>" alt="<?php echo $title; ?>"></button>
              <?php
              if (is_array($catList) && !empty($catList)) {
                ?>
                <ul>
                  <?php
                  foreach ($catList as $val) {
                    ?>
                    <li><a href="<?php echo site_url($val['friendly_url']); ?>" title="<?php imagealtTitle('', $val['category_name'], 'Service Provider'); ?>"><?php echo $val['category_name']; ?></a></li>
                    <?php
                  }
                  ?>
                </ul>
                <?php
              }
              ?>
            </li>

            <?php
            if (is_array($result_cousin) && !empty($result_cousin)) {
              foreach ($result_cousin as $sVal) {
                $condtion_child = array('field' => "*,( SELECT COUNT(category_id) FROM wps_categories AS b WHERE b.parent_id=a.category_id ) AS total_subcategories", 'condition' => "AND parent_id = '" . $sVal['category_id'] . "' AND status='1' ", 'debug' => FALSE);
                $result_child = $this->category_model->getcategory($condtion_child);
                ?>
                <li><a href="<?php echo site_url($sVal['friendly_url']); ?>" title="<?php imagealtTitle('', $sVal['category_name'], 'Service Provider'); ?>"><?php echo $sVal['category_name']; ?></a>
                  <button type="button" onclick="return OnMobileSubMenuClick($(this));"><img src="<?php echo theme_url(); ?>images/drop-icon.png" title="<?php echo $sVal['category_name']; ?>" alt="<?php echo $sVal['category_name']; ?>"></button>
                  <?php
                  if (is_array($result_child) && !empty($result_child)) {
                    ?>
                    <ul>
                      <?php
                      foreach ($result_child as $cVal) {
                        ?>
                        <li><a href="<?php echo site_url($cVal['friendly_url']); ?>" title="<?php imagealtTitle('', $cVal['category_name'], 'Service Provider'); ?>"><?php echo $cVal['category_name']; ?></a></li>               <?php
                      }
                      ?>
                    </ul>
                    <?php
                  }
                  ?>
                </li>
                <?php
              }
            }
            ?>
            <li><a href="javascript:void(0);">More</a>
              <button type="button" onclick="return OnMobileSubMenuClick($(this));"><img src="<?php echo theme_url(); ?>images/drop-icon.png" title="More" alt="More"></button>
              <?php
              if (is_array($result_cousin_1) && !empty($result_cousin_1)) {
                ?>
                <ul>
                  <?php
                  foreach ($result_cousin_1 as $cVal1) {
                    ?>
                    <li><a href="<?php echo site_url($cVal1['friendly_url']); ?>" title="<?php imagealtTitle('', $cVal1['category_name'], 'Service Provider'); ?>"><?php echo $cVal1['category_name']; ?></a></li>             <?php
                  }
                  ?>
                </ul>
                <?php
              }
              ?>
            </li>   
          </ul>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="dir-alp-con">

        <div class="col-md-9 dir-alp-con-right list-grid-rig-pad left_right_pad col-md-push-3">
          <!-- Start View Listing -->
          <div class="clearfix"></div>
          <div id="prodListingContainer">
            <?php
            if (is_array($listRes) && !empty($listRes)) {
              foreach ($listRes as $listKey => $listVal) {
                //trace($listVal);
                $userDets = get_db_single_row("wps_customers", "customers_id, website, company_name, state, city, locality, address, landmark, locality, is_manufacturer", "customers_id = '" . $listVal['customers_id'] . "'");
                $aboutCompany = get_db_field_value("wps_customers_factsheet", "about_company", "WHERE id = '" . $listVal['customers_id'] . "'");
                $companywebsiteUrl = get_db_field_value("wps_company_website_urls", "website_url", "WHERE customers_id = '" . $listVal['customers_id'] . "' ORDER BY id DESC LIMIT 0,1");
                $city = "";
                $state = "";
                $locality = "";
                if (is_array($userDets) && !empty($userDets)) {
                  $city = get_db_field_value("wps_cities_list", "city", "WHERE id = '" . $userDets['city'] . "'");
                  $state = get_db_field_value("wps_states_list", "name", "WHERE id = '" . $userDets['state'] . "'");
                  $locality = $userDets['locality'];
                }

                //more products
                $condtion = array();
                $condtion['status'] = '1';
                $condtion['customers_id'] = $userDets['customers_id'];
                $condtion['category_id'] = $categoryId;
                $condtion['leave_product_id'] = $listVal['products_id'];
                $productList = $this->product_model->get_products(4, 0, $condtion);
                $otherProductCount = get_found_rows();

                $location = $location1 = "";
                if ($state || $city) {
                  $location .= '<i class="fa fa-map-marker"></i> ';
                }
               
                if ($city) {
                  $location .= $city;
                  $location1 .= $city;
                }
                 if ($state){
                    $location .= ', ';
                  $location1 .= ', ';
                  $location .= $state;
                $location1 .= $state;
              }
                ?>
                <!--LISTINGS-->
                <div class="home-list-pop list-spac listpager">
                  <!--LISTINGS IMAGE-->
                  <?php
                  if ($listVal['youtube_id'] != '') {
                    
                  }
                  ?>
                  <div class="col-md-3 list-ser-img">
                    <a href="javascript:void(0);" title="<?php echo $listVal['product_name']; ?>" data-friendly_url="<?php echo site_url().$listVal['friendly_url']; ?>" data-productType="<?php echo $listVal['productType']; ?>" data-productID="<?php echo $listVal['products_id']; ?>" data-companyID="<?php echo $listVal['customers_id']; ?>" data-productName="<?php echo $listVal['product_name'] . ' <br> ' . $userDets['company_name'] . ' ' . $location1; ?>" data-companyName="<?php echo $userDets['company_name']; ?>" data-productImage="<?php echo get_image('product_images', $listVal['media'], '400', '600', 'R'); ?>" data-unit="<?php echo $messurement[$listVal['unit_measurement']]; ?>" class="getQuote" data-dismiss="modal" data-toggle="modal" data-target="#list-quo">
                    <div class="product_image_08"><img src="<?php echo get_image('product_images', $listVal['media'], '400', '350', 'R'); ?>" alt="" />
                        </div></a>
                    <div class="row">
                      <div class="col-md-12 col-lg-12 inn-list-pop-desc">
                        <span>
                          
                          <?php
                          if ($listVal['product_discounted_price'] > 0) {
                            echo '<i class="fa fa-rupee" aria-hidden="true"></i>';
                            echo display_price($listVal['product_discounted_price']);
                            ?> <span class="old-price"><i class="fa fa-rupee" aria-hidden="true"></i> <?php echo display_price($listVal['product_price']); ?></span>
                            <?php
                          } else if($listVal['product_price']>0){
                            echo '<i class="fa fa-rupee" aria-hidden="true"></i>';
                            echo display_price($listVal['product_price']);
                          }
                          ?> 
                          <?php if ($listVal['product_discounted_price'] > 0 || $listVal['product_price']>0) { ?>/ <?php echo $listVal['unit_value']; ?> <?php echo $unit_measurement[$listVal['unit_measurement']]; ?>
                        <?php } ?>
                          <?php if($listVal['moq']>0){ ?>
                            <br> <i class="fa fa-list" aria-hidden="true"></i>
                          MOQ : <?php echo $listVal['moq']; ?> <?php echo $unit_measurement[$listVal['unit_measurement']]; ?>
                          <?php } ?>
                        </span>
                      </div>
                    </div>
                  </div>
                  <!--LISTINGS: CONTENT-->
                  <div class="col-md-6 home-list-pop-desc inn-list-pop-desc heading_08">  
                    <div class="verified_badge">
                      <?php
                      if ($userDets['is_manufacturer'] == '1') {
                        ?>
                        <img src="<?php echo theme_url(); ?>images/verified.png">
                        <div class="info_02">
                          <p>Verified NTI Member.</p>
                        </div>
                        <?php
                      } else {
                        ?>
                        <div class="info_02">
                          <p>Unverified Member. Verification in Process.</p>
                        </div>
                        <img src="<?php echo theme_url(); ?>images/icon/unverified.png">
                        <?php
                      }
                      ?>
                    </div>                  
                    <h3><a href="<?php echo site_url() . $listVal['friendly_url']; ?>" title="<?php echo $listVal['product_name']; ?>"><span><?php echo $listVal['product_name']; ?></span></a></h3>
                    <div class="clearfix"></div>
                    <p><?php echo char_limiter($aboutCompany, 155); ?></p>

                    <div class="list-details">
                      <?php
                      if ($listVal['attribute_name']) {
                        $atrribute = explode(',', $listVal['attribute_name']);
                        $atrributeVal = explode(',', $listVal['attribute_value']);
                        ?>
                        <div class="row">
                          <?php
                          $it = 1;
                          foreach ($atrribute as $ak => $av) {
                            ?>
                            <div class="col-md-5"><?php echo $av; ?></div>
                            <div class="col-md-2">:</div>
                            <div class="col-md-5"><?php echo $atrributeVal[$ak]; ?></div>
                            <?php
                            $it++;
                            if ($it == 7)
                              break;
                          }
                          ?>                          
                        </div>
                        <?php
                      }
                      ?>
                    </div>
                    <?php
                    /*
                      <div class="list-enqu-btn">
                      <ul>
                      <li><a href="#!" data-productID="<?php echo $listVal['products_id']; ?>" data-companyID="<?php echo $listVal['customers_id']; ?>" data-productName="<?php echo $listVal['product_name'] . ' <br> ' . $userDets['company_name'] . ' ' . $location1; ?>" data-productImage="<?php echo get_image('product_images', $listVal['media'], '400', '600', 'R'); ?>" class="getQuote" data-dismiss="modal" data-toggle="modal" data-target="#list-quo">View Details</a> </li>
                      <li><a href="#!" data-productID="<?php echo $listVal['products_id']; ?>" data-companyID="<?php echo $listVal['customers_id']; ?>" data-productName="<?php echo $listVal['product_name'] . ' <br> ' . $userDets['company_name'] . ' ' . $location1; ?>" data-productImage="<?php echo get_image('product_images', $listVal['media'], '400', '600', 'R'); ?>" class="getQuote" data-dismiss="modal" data-toggle="modal" data-target="#list-quo"><i class="fa fa-rupee" aria-hidden="true"></i> Get a Quote</a></li>
                      </ul>
                      </div>
                     * 
                     */
                    ?>
                    <a class="view_more_btn" href="<?php echo site_url() . $listVal['friendly_url']; ?>" title="<?php echo $listVal['product_name']; ?>">View More Details <i class="fa fa-angle-double-right"></i></a>

                  </div>
                  <div class="col-md-3 home-list-pop-desc inn-list-pop-desc borderCompLeft right_sub">
                      
                    <a href="<?php echo ($companywebsiteUrl) ? base_url($companywebsiteUrl) : $listVal['friendly_url']; ?>" title="View More About <?php echo $userDets['company_name']; ?>">
                      <h4><?php echo $userDets['company_name']; ?> <!-- in New Delhi, India --></h4>
                    </a>
                    <div class="location"><?php echo $location; ?>
                       <div class="location_city">
                        <?php echo $userDets['address'];
                          echo ($userDets['locality']!='')?', '.$userDets['locality']:'';
                          echo ($userDets['landmark']!='')?', Near '.$userDets['landmark']:''; ?>, <?php echo $city; ?>, <?php echo $state; ?> 
                      </div>
                    </div>
                    <?php
                    if ($userDets['is_manufacturer'] == '1') {
                      ?>
                      <ul class="verified">
                        <!--<li><a href="javascript:void()"><i class="fa fa-gratipay"></i> Trust Verified</a></li>-->
                        <li><i class="fa fa-check-circle"></i> Verified Service Provider</li>
                        <!--<li><a href="javascript:void()"><i class="fa fa-youtube-play"></i> Company Video</a></li>-->
                      </ul>
                      <?php
                    }
                    ?>
                    <div class="">
                      <?php
                      if ($listVal['youtube_id'] != '' && $listVal['youtube_id'] != '0') {
                        ?>
                        <a href="javascript:void(0);" data-youtubeId="<?php echo $listVal['youtube_id']; ?>" data-companyFacName="<?php echo $userDets['company_name']; ?>" title="Video" class="youtube_btn" data-dismiss="modal" data-toggle="modal" data-target="#facVideo"><i class="fa fa-youtube-play"></i> Video</a>
                        <?php
                      }
                      ?>

                      <a href="javascript:void(0);" data-companyID="<?php echo $listVal['customers_id']; ?>" class="view_contact_number <?php echo ($this->session->userdata('user_id') <= 0) ? 'getContactNo' : 'viewContactNo'; ?>" <?php echo ($this->session->userdata('user_id') <= 0) ? 'data-dismiss="modal" data-toggle="modal" data-target="#regis-ter"' : ''; ?>>View Contact Number</a>

                      <a href="javascript:void(0);" data-friendly_url="<?php echo site_url().$listVal['friendly_url']; ?>" data-productType="<?php echo $listVal['productType']; ?>" data-productID="<?php echo $listVal['products_id']; ?>" data-companyID="<?php echo $listVal['customers_id']; ?>" data-productName="<?php echo $listVal['product_name'] . ' <br> ' . $userDets['company_name'] . ' ' . $location1; ?>" data-companyName="<?php echo $userDets['company_name']; ?>" data-productImage="<?php echo get_image('product_images', $listVal['media'], '400', '600', 'R'); ?>" data-unit="<?php echo $messurement[$listVal['unit_measurement']]; ?>" class="get_quotes_btn getQuote" data-dismiss="modal" data-toggle="modal" data-target="#list-quo"><i class="fa fa-rupee" aria-hidden="true"></i> Get a Quote</a>
                    </div>
                  </div>
                 <?php
                  if ($otherProductCount > 0) {
                    ?>
                    <div class="col-md-12 home-list-pop-desc inn-list-pop-desc borderExtProTop">
                      <div class="more_products01"><?php echo $otherProductCount; ?> more <?php echo ($isService=='1')?'services':'products'; ?> from this service provider</div>
                      <div class="clearfix"></div>
                      <div class="row">
                        <?php
                        foreach ($productList as $proVal) {
                          if ($proVal['media']) {
                            ?>

                            <div class="col-md-4">
                              <div class="list-customize more_item">
                                <div class="img-customize">
                                  <a href="<?php echo site_url() . $proVal['friendly_url']; ?>" title="<?php echo $proVal['product_name']; ?>">
                                   <div class="custimize_image09">
                                    <img src="<?php echo get_image('product_images', $proVal['media'], '120', '120', 'R'); ?>" alt="" height="100" width="100" />
                                      </div> </a>
                                </div>
                                <div class="list-enqu-btn width_auto">
                                  <h6><a href="<?php echo site_url() . $proVal['friendly_url']; ?>" title="<?php echo $proVal['product_name']; ?>"><span><?php echo char_limiter($proVal['product_name'],50); ?></span></a></h6>
                                <!--  <p>Rs: 999/Piece</p>-->
                                  <ul>
                                    <li><a href="javascript:void(0);" data-friendly_url="<?php echo site_url().$proVal['friendly_url']; ?>" data-productType="<?php echo $proVal['productType']; ?>" data-productID="<?php echo $proVal['products_id']; ?>" data-companyID="<?php echo $proVal['customers_id']; ?>" data-productName="<?php echo $proVal['product_name'] . ' <br> ' . $userDets['company_name'] . ' ' . $location1; ?>" data-companyName="<?php echo $userDets['company_name']; ?>" data-productImage="<?php echo get_image('product_images', $proVal['media'], '400', '600', 'R'); ?>" data-unit="<?php echo $messurement[$proVal['unit_measurement']]; ?>" class="getQuote" data-dismiss="modal" data-toggle="modal" data-target="#list-quo"><i class="fa fa-rupee" aria-hidden="true"></i> Get a Quote</a> </li>
                                  </ul>
                                </div>

                              </div>
                            </div>

                            <?php
                          }
                        }
                        ?>
                      </div>
                    </div>
                    <?php
                  }
                  ?>
                </div>
                <!--LISTINGS END-->
                <?php
              }
            } else {
              ?>
              <div class="alert alert-warning list-spac" role="alert">
                <strong>Oh snap!</strong> No Listing Found.<br>
                <p>Are You a <?php echo ($isService=='1')?'Service Provider':'Products Manufacturers'; ?>. List Your Business on <a href="<?php echo site_url(); ?>">naturaltherapyindia.com</a>. World's 1<sup>st</sup> specialized portal for Natural Health Products & Services.</p>
              </div>

              <!--<div class="manufacture list-spac">
                  <p>Are You a Service Provider List Your Business on <a href="javascript:void()">getmanufacturer.com</a>. India's 1<sup>st</sup> B2B Portal only for Service Provider.</p>
              </div>-->
              <div class="clearfix"></div>
              <div class="row">
                <div class="input-field s12 text-center">


                  <div class="row">
                    <div class="input-field s4 ">
                      <?php
                      if ($this->session->userdata('user_id') > 0) {
                        ?>
                        <a href="<?php echo site_url(); ?>members/add-product" class="waves-effect waves-light btn-large" >Are you a Service Provider?  List Your Business Now!</a>
                        <?php
                      } else {
                        ?>
                        <a href="#" data-dismiss="modal" data-toggle="modal" data-target="#regis-ter" class="waves-effect waves-light btn-large manufacturer_btn" >Are you a Service Provider?  List Your Business Now!</a>
                        <?php
                      }
                      ?>
                    </div>
                  </div>

                </div>
              </div>
              <div class="clearfix"></div>

              <?php
              if (is_array($result_cousin_1) && !empty($result_cousin_1)) {
                ?>
                <div class="list-spac"> 
                  <div class="com-title">
                    <div class="head_title2">New Businesses in<span> this month</span></div>
                    <p>Explore some of the best tips from around the world from our partners and friends.</p>
                  </div>    
                  <div class="row span-none">
                    <?php
                    foreach ($result_cousin_1 as $cVal1) {
                      //trace($cVal1);
                      ?>
                      <div class="col-md-4">
                        <a href="<?php echo site_url($cVal1['friendly_url']); ?>">
                          <div class="list-mig-like-com com-mar-bot-30 back_list">
                            <div class="list-mig-lc-img">
                            <div class="subcategory_image_08">
                              <img src="<?php echo get_image('category', $cVal1['category_image'], '295', '295', 'R'); ?>" title="<?php imagealtTitle('', $cVal1['category_name'], 'Service Provider'); ?>" alt="<?php imagealtTitle('', $cVal1['category_name'], 'Service Provider'); ?>" />
                            </div>
                            </div>
                            <div class="list-mig-lc-con">
                              <h5><?php echo $cVal1['category_name']; ?></h5>
                            </div>
                          </div>
                        </a>
                      </div>
                      <?php
                    }
                    ?>
                  </div>
                </div>
                <?php
              }
              ?>








              <?php
            }
            ?>
          </div>

          <!--LISTINGS END-->
        </div>
        <?php $this->load->view("category/category_left_view", array("title" => $title)); ?>
    
      </div>
    </div>
    <?php if (is_array($category_result) && !empty($category_result) && $category_result['category_description']) {
      ?>
      <div class="row">
        <div class="full_content">
          <?php echo $category_result['category_description']; ?>
        </div>
      </div>
      <?php
    } ?>
   <?php }else{ ?>
  <div class="row">
       <h3 class="cath3hd">Products</h3>
      <div class="dir-alp-con">
        <?php //$this->load->view("category/category_left_view"); ?>
        <div class="col-md-12 dir-alp-con-right list-grid-rig-pad padding_normal">
          <div class="dir-alp-con-right-1">
            <div class="row">
              <?php 
              if (is_array($catList) && !empty($catList)) {
                ?>
                <div class="row span-none" id="prodListingContainer">
                  <?php
                  foreach ($catList as $val) { 
                    $link_url = site_url($val['friendly_url']);
                    //$categoryCount = count_category(" AND parent_id = '" . $val['category_id'] . "' ");

                    //$productCount = count_products(" AND category_id = '" . $val['category_id'] . "' ");
                    //$productCount = count_products(" AND FIND_IN_SET('".$val['category_id']."', category_links) AND productType = '0' "); //wrong
                    //WHERE  AND wlp.productType = '1' AND FIND_IN_SET('42',wlp.category_id)

                    //$productCount = count_products(" AND FIND_IN_SET('".$val['category_id']."', category_id) AND productType = '0' ");
                    

                    /*$this->load->model('products/product_model');
                    if($val['catType']=='1'){
                      $condtion['productType'] = '1';
                    }else{
                      $condtion['productType'] = '0';
                    }
                    $condtion['status'] = '1';
                    $condtion['category_id'] = $val['category_id'];
                    $condtion['groupby'] = "wlp.customers_id";
                    $res_array = $this->product_model->get_products(20000, 0, $condtion);
                    //echo_sql(); die;
                    $productCount = get_found_rows();*/
        
                    /*if ($productCount > 0) {
                      $count = $productCount;
                      $catRes = array();
                      $catRes = $this->db->query("SELECT * FROM wps_categories WHERE parent_id = '" . $val['category_id'] . "' AND status = '1' LIMIT 0, 7")->result_array(); //3
                    } else {
                      $count = $categoryCount;
                      $catRes = $this->db->query("SELECT * FROM wps_categories WHERE parent_id = '" . $val['category_id'] . "' AND status = '1' LIMIT 0, 7")->result_array(); //3
                    }*/
                    $catRes = $this->db->query("SELECT * FROM wps_categories WHERE parent_id = '" . $val['category_id'] . "' AND status = '1' LIMIT 0, 7")->result_array(); //3

                    ?>
                    <div class="col-sm-4 col-md-3 listpager">
                      <div class="listing01">
                        <div class="box-img">
                          <div class="category_images">
                            <img src="<?php echo get_image('category', $val['category_image'], '415', '415', 'R'); ?>" alt="<?php imagealtTitle('', $val['category_name'], 'Service Provider'); ?>" title="<?php imagealtTitle('', $val['category_name'], 'Service Provider'); ?>">
                          </div>
                          <div class="caption">
                            <h2><a title="<?php imagealtTitle('', $val['category_name'], 'Service Provider'); ?>" href="<?php echo site_url($val['friendly_url']); ?>"><?php echo $val['category_name']; ?> <?php /*(<?php echo $count; ?>)*/ ?></a></h2>
                            <ul>
                              <?php
                              foreach ($catRes as $subCat) {
                                //$catCount = count_category(" AND parent_id = '" . $subCat['category_id'] . "' ");
                                //$proCount = count_products(" AND category_id = '" . $subCat['category_id'] . "' ");
                                //$proCount = count_products(" AND FIND_IN_SET('".$subCat['category_id']."', category_links) AND productType = '0' "); wrong
                                //$proCount = count_products(" AND FIND_IN_SET('".$subCat['category_id']."', category_id) AND productType = '0' ");
                                
                                /*if ($proCount > 0) {
                                  $subcount = $proCount;
                                } else {
                                  $subcount = $catCount;
                                }*/
                                ?>
                                <li><a href="<?php echo site_url($subCat['friendly_url']); ?>" title="<?php imagealtTitle('', $subCat['category_name'], 'Service Provider'); ?>"><?php echo $subCat['category_name']; ?> <?php /*(<?php echo $subcount; ?>) */ ?></a></li>
                                <?php
                              }
                              ?>

                            </ul>
                            <div class="listing-bottom">
                              <a href="<?php echo site_url($val['friendly_url']); ?>" class="btn btn-common float-right" title="<?php imagealtTitle('', $val['category_name'], 'Service Provider'); ?>">View All</a>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <?php
                  }
                  ?>

                </div>
                <div class="clearfix"></div>

                <?php
              } else {
                ?>
                <!-- <div class="alert alert-warning" role="alert">
                  <strong>Oh snap!</strong> No Listing Found.
                </div>
                <div class="row">
                  <div class="input-field s12 text-center">
                    <div class="row">
                      <div class="input-field s4 ">
                        <?php
                        if ($this->session->userdata('user_id') > 0) {
                          ?>
                          <a href="<?php echo site_url(); ?>members/add-product" class="waves-effect waves-light btn-large" >Are your a Service Provider? Add New Listing Now!</a>
                          <?php
                        } else {
                          ?>
                          <a href="#" data-dismiss="modal" data-toggle="modal" data-target="#regis-ter" class="waves-effect waves-light btn-large" >Are your a Service Provider? Add New Listing Now!</a>
                          <?php
                        }
                        ?>
                      </div>
                    </div>
                  </div>
                </div> -->
                <?php
              }
              ?>
                
                
                </div>
        </div>
      </div>
     </div>
          
                <h3 class="cath3hd">Services</h3>
                  <div class="dir-alp-con">
 <div class="col-md-12 dir-alp-con-right list-grid-rig-pad padding_normal">
          <div class="dir-alp-con-right-1">
            <div class="row">
              <?php 
              if (is_array($catListServices) && !empty($catListServices)) {
                ?>
                <div class="row span-none" id="prodListingContainer">

                  <?php
                  foreach ($catListServices as $val) {
                    $link_url = site_url($val['friendly_url']);
                    //$categoryCount = count_category(" AND parent_id = '" . $val['category_id'] . "' ");
                    //$productCount = count_products(" AND category_id = '" . $val['category_id'] . "' ");
                    //$productCount = count_products(" AND FIND_IN_SET('".$val['category_id']."', category_links) AND productType = '1' "); //wrong
                    //$productCount = count_products(" AND FIND_IN_SET('".$val['category_id']."', category_id) AND productType = '1' ");
                    /*if ($productCount > 0) {
                      $count = $productCount;
                      //$catRes = array();
                      $catRes = $this->db->query("SELECT * FROM wps_categories WHERE parent_id = '" . $val['category_id'] . "' AND status = '1' LIMIT 0, 7")->result_array(); //3
                    } else {
                      $count = $categoryCount;
                      $catRes = $this->db->query("SELECT * FROM wps_categories WHERE parent_id = '" . $val['category_id'] . "' AND status = '1' LIMIT 0, 7")->result_array(); //3
                    }*/
                    $catRes = $this->db->query("SELECT * FROM wps_categories WHERE parent_id = '" . $val['category_id'] . "' AND status = '1' LIMIT 0, 7")->result_array(); //3
                    
                    ?>
                    <div class="col-sm-4 col-md-3 listpager">
                      <div class="listing01">
                        <div class="box-img">
                          <div class="category_images">
                            <img src="<?php echo get_image('category', $val['category_image'], '415', '415', 'R'); ?>" alt="<?php imagealtTitle('', $val['category_name'], 'Service Provider'); ?>" title="<?php imagealtTitle('', $val['category_name'], 'Service Provider'); ?>">
                          </div>
                          <div class="caption">
                            <h2><a title="<?php imagealtTitle('', $val['category_name'], 'Service Provider'); ?>" href="<?php echo site_url($val['friendly_url']); ?>"><?php echo $val['category_name']; ?> <?php /*(<?php echo $count; ?>) */ ?></a></h2>
                            <ul>
                              <?php
                              foreach ($catRes as $subCat) {
                                /*$catCount = count_category(" AND parent_id = '" . $subCat['category_id'] . "' ");
                                //$proCount = count_products(" AND category_id = '" . $subCat['category_id'] . "' ");
                                //$proCount = count_products(" AND FIND_IN_SET('".$subCat['category_id']."', category_links) AND productType = '1' "); //wrong
                                $proCount = count_products(" AND FIND_IN_SET('".$subCat['category_id']."', category_id) AND productType = '1' ");
                                if ($proCount > 0) {
                                  $subcount = $proCount;
                                } else {
                                  $subcount = $catCount;
                                }*/
                                ?>
                                <li><a href="<?php echo site_url($subCat['friendly_url']); ?>" title="<?php imagealtTitle('', $subCat['category_name'], 'Service Provider'); ?>"><?php echo $subCat['category_name']; ?> <?php /*(<?php echo $subcount; ?>) */ ?></a></li>
                                <?php
                              }
                              ?>

                            </ul>
                            <div class="listing-bottom">
                              <a href="<?php echo site_url($val['friendly_url']); ?>" class="btn btn-common float-right" title="<?php imagealtTitle('', $val['category_name'], 'Service Provider'); ?>">View All</a>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <?php
                  }
                  ?>

                </div>
                <div class="clearfix"></div>

                <?php
              }  ?>
            </div>
          </div>
        </div>
      </div>
    </div> 
   <?php } ?>
    

 
  </div>
</section>
<!--MOBILE APP-->
<!-- <script type="text/javascript">
  var page = 1;
  var triggeredPaging = 0;

  $(window).scroll(function () {
    $('#loadingdiv').hide();
    var scrollTop = $(window).scrollTop();
    var scrollBottom = (scrollTop + $(window).height());
    var containerTop = $('#prodListingContainer').offset().top;
    var containerHeight = $('#prodListingContainer').height();
    var containerBottom = Math.floor(containerTop + containerHeight);
    var scrollBuffer = 0;
    if ((containerBottom - scrollBuffer) <= scrollBottom) {
      page = $('.listpager').length;
      var queryString = '?stOffSet=' + page;
<?php
if (count($QryStringArr)) {
  foreach ($QryStringArr as $qrykey => $qryval) {
    ?>
          queryString += "&<?php echo $qrykey; ?>=<?php echo $qryval; ?>";
    <?php
  }
}
?>
      var actual_count = <?php echo $total_rows; ?>;

      if (!triggeredPaging && page < actual_count) {
        triggeredPaging = 1;
        $.ajax({
          type: "POST",
          url: "<?php echo base_url(); ?>category/ajax_load_category_view" + queryString,
          error: function (res) {
            //alert('Error');
            triggeredPaging = 0;
            $('#loadingdiv').hide();
            //console.log(arguments);
          },
          beforeSend: function (jqXHR, settings) {
            $('#loadingdiv').show();

          },
          success: function (res) {
            $('#loadingdiv').hide();
            $("#prodListingContainer").append(res);
            triggeredPaging = 0;
            //console.log(res);
            $('.listpager').fadeTo(1000, 0.5, function () {
              $(this).fadeTo(1000, 1.0);
            });
          }
        });
      }
    }
  });
</script> -->

<script type="text/javascript">

  $('.getQuote').click(function () {
    var productType = $(this).attr('data-productType');
    var productID = $(this).attr('data-ProductID');
    var companyID = $(this).attr('data-companyID');
    var companyName = $(this).attr('data-companyName');
    var productName = $(this).attr('data-ProductName');
    var productImage = $(this).attr('data-ProductImage');
    var friendly_url = $(this).attr('data-friendly_url');
    if(productType==1){
      $('#productQuantity').val(1);
      $('.qhide').hide();
    }
    $('#productQuoteImage').attr('src', productImage);
    $('#productQuoteImage').css({"border": "3px solid #CCC"});
    $('#companyProDetails').html('');
    $('#companyProDetails').html(productName);
    $('#companyProName').html(companyName);
    $('#productQuoteID').val(productID);
    $('#productCompID').val(companyID);
    $('#post_url').val(friendly_url);
    $('.unitSize').html('/' + $(this).attr('data-unit'));
  });


  $(".getContactNo").click(function () {
    $('.pop-btn-rgstr').val('View Contact No.');
    $('.viewCompContact').val($(this).attr('data-companyID'));
  });

  var page = 1;
  var triggeredPaging = 0;
  $(window).scroll(function () {
    $('#loadingdiv').hide();
    var scrollTop = $(window).scrollTop();
    var scrollBottom = (scrollTop + $(window).height());
    var containerTop = $('#prodListingContainer').offset().top;
    var containerHeight = $('#prodListingContainer').height();
    var containerBottom = Math.floor(containerTop + containerHeight);
    var scrollBuffer = 0;
    if ((containerBottom - scrollBuffer) <= scrollBottom) {
      page = $('.listpager').length;
      var queryString = '?stOffSet=' + page;
<?php
if (count($QryStringArr)) {
  foreach ($QryStringArr as $qrykey => $qryval) {
    ?>
          queryString += "&<?php echo $qrykey; ?>=<?php echo $qryval; ?>";
    <?php
  }
}
?>
      var actual_count = <?php echo $total_list_rows; ?>;
      if (!triggeredPaging && page < actual_count) {
        triggeredPaging = 1;
        $.ajax({
          type: "POST",
          url: "<?php echo base_url(); ?>products/ajax_load_product_view" + queryString,
          error: function (res) {
            //alert('Error');
            triggeredPaging = 0;
            $('#loadingdiv').hide();
            //console.log(arguments);
          },
          beforeSend: function (jqXHR, settings) {
            $('#loadingdiv').show();

          },
          success: function (res) {
            $('#loadingdiv').hide();
            $("#prodListingContainer").append(res);
            triggeredPaging = 0;
            //console.log(res);
            $('.listpager').fadeTo(1000, 0.5, function () {
              $(this).fadeTo(1000, 1.0);
            });
          }
        });
      }
    }
  });

  $('.view_btn').click(function () {
    var text = $(this).html();
    //alert(text);
    if (text == '+ View More') {
      $(this).html('- View Less');
      $(this).parent().children('.full_item').children('.vm').removeClass('hidden');
    } else {
      $(this).html('+ View More');
      $(this).parent().children('.full_item').children('.vm').addClass('hidden');
    }
  });

</script>
<?php $this->load->view("bottom_application"); ?>
<script>
  window.onscroll = function () {
    myFunction()
  };
  var navbar = document.getElementById("second_bar");
  var sticky = navbar.offsetTop;

  function myFunction() {
    if (window.pageYOffset >= sticky) {
      navbar.classList.add("sticky")
    } else {
      navbar.classList.remove("sticky");
    }
  }
  function OnMobileMenuClick() {
    if ($("#m_navigation").is(":visible")) {
      $("#m_navigation").hide();
    } else {
      $("#m_navigation ul li ul").each(function () {
        $(this).hide();
      });
      $("#m_navigation").show();
    }
    return false;

  }
  function OnMobileSubMenuClick(objThis) {
    if (objThis.next("ul").is(":visible")) {
      objThis.next("ul").hide();
    } else {
      $("#m_navigation ul li ul li ul").each(function () {
        $(this).hide();
      });
      objThis.next("ul").show();
    }

    return false;
  }
</script>
