<?php
$ix = 1;
$messurement = $this->config->item('unit_measurement');
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($this->config->item('per_page'), 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-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">  
                    <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']; ?>"><?php echo $listVal['product_name']; ?></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 <?php echo $state; ?>, <?php echo $city; ?> --></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-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 services 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-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
}
?>
<script type="text/javascript">
    $('.getQuote').click(function () {
    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');
    $('#productQuoteImage').attr('src', productImage);
    $('#productQuoteImage').css({"border": "3px solid #CCC"});
    $('#companyProDetails').html('');
    $('#companyProDetails').html(productName);
    $('#companyProName').html(companyName);
    $('#productQuoteID').val(productID);
    $('#productCompID').val(companyID);
    $('.unitSize').html('/' + $(this).attr('data-unit'));
  });
    
    $(".getContactNo").click(function () {
    $('.pop-btn-rgstr').val('View Contact No.');
    $('.viewCompContact').val($(this).attr('data-companyID'));
  });
</script>