<style>

table thead { font-size:14px;}
table td { border:none; padding:10px;}
table tr { border:1px solid #dddddd;}
.quantity {
  position: relative; width:100%; height:30px;
}

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button
{
  -webkit-appearance: none;
  margin: 0;
}

input[type=number]
{
  -moz-appearance: textfield;
}

.quantity input {
  width: 30px;
  height: 30px;
  line-height: 1.65;
  float: left;
  display: block;
  padding: 0;
  margin: 0;
  text-align:center;
  border: 1px solid #eee;
  margin-right:0px;
 
  
  
}

.quantity input:focus {
  outline: 0;
}

.quantity-nav {
  float: left;
  position: relative; display:none;
}

.quantity-button {
  position: relative;
  cursor: pointer;
  border: 1px solid #eee;
  width: 30px;
  height:30px;
  background-color:#ffffff;
  text-align: center;
  color: #333;
  font-size: 16px;
  font-family: "Trebuchet MS", Helvetica, sans-serif !important;
  line-height: 1.7;

}

.quantity .qur_1 { float:left;}
.quantity .qur_2 { float:left; }
.quantity input { float:left; }
.quantity .qur_1 .quantity-up { float:left;}
.quantity .qur_2 .quantity-down { float:left;}





.quantity-button.quantity-up {


  top: 0;
  border-bottom: 1px solid #eee;
}

.quantity-button.quantity-up:hover { background-color:#cccccc;}
.quantity-button.quantity-down:hover  { background-color:#cccccc;}

.quantity-button.quantity-down {

  bottom: -0px;

}
</style>
<div class="container padd_not marg_top ">




<div class="col-md-10   pull-right"   >
<div class="col-md-12 registor">
	<h3 class="sub_hd">Advanced Search</h3>
 <div class="col-md-12 tyos_us" > <!-- Home&nbsp; >> <?php echo $title; ?>--></div>
 
 <form method="post">
 
<div class="col-md-3"> 
	 <div>
     <?php echo $categories5;?> 
     
     
     <?php 
	 if($_GET["cid"] && $_GET["cid"]!="" ) {  $cid=$_GET["cid"]; } 
	 if($_GET["sid"] && $_GET["sid"]!="" ) {  $sid=$_GET["sid"]; } 
	 if($_GET["bid"] && $_GET["bid"]!="" ) {  $bid=$_GET["bid"]; } 
	 
	 
	 
	 
	 ?>
     
     
		 <label><b>Category *</b></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		 <select name="categories" id="categories" class="form-control"  >
			<option value="">-SELECT-</option>
<?php foreach($category as $value){?>
<option value="<?php echo $value['id'];?>"   ><?php echo $value['title'];?></option>
<?php }?>
		</select>
		<div id='category_error'  style="color:red;"></div>
	</div>
    </div>
    
<div class="col-md-3"> 

	<div>
		<label><b>Subcategory *</b></label>&nbsp;&nbsp;&nbsp;&nbsp;
		<select name="sub_categories" id="sub_categories"  class="form-control"  >
			<option value="">-SELECT-</option>	
		</select>
		<div id='subcategory_error' style="color:red;"></div>
	</div>
    
    </div>
    
<div class="col-md-3"> 

	<div>
		 <label><b>Brand </b></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		 <select name="brand" id="brand"  class="form-control" >
			<option value="">-SELECT-</option>
			<?php foreach($brand as $value){?>
			<option value="<?php echo $value['id'];?>"><?php echo $value['title'];?></option>
			<?php }?>
		</select>
	</div>
    
    </div>
    
    
    
    <div class="col-md-3"> 

	<div>
		<p align="center" >
         <label><b></b></label>
			<input name="submit" class="button-primary" style="float:none;" value="Submit" type="submit">
		</p>
	</div>
    </div>
    </form>
    
    
 
 
 
 <div class="col-md-12">&nbsp;</div>
 
 
 
 
 <?php
 
/*if($_GET["categories"] && $_GET["categories"]!='' ) { $categories=$_GET["id"];}
if($_GET["sub_categories"] && $_GET["sub_categories"]!='' ) { $sub_categories=$_GET["sub_categories"];}
if($_GET["brand"] && $_GET["brand"]!='' ) { $brand=$_GET["brand"];}*/
 


 

 
 ?>
 
 
 <div class="clr"></div>
 

 
 <table width="100%" border="0" cellspacing="0" cellpadding="10">
 <?php $i = 1; ?>
<?php if(!empty($product)){ foreach($product as $row_off):	?>
		
  
        
        
  <form method="post">      
  <tr>
  
  <td style="text-align:center;" valign="middle">
    
     <?php if($row_off['img']!=''): ?>
        <img src="<?php echo base_url('assets/images/'.$row_off['img']) ; ?>"   class="max-width" width="100"  />
        <?php else: ?>
        <img src="<?php echo base_url('assets/web_images/no_image.jpg') ; ?>"  class="max-width" width="100"  />
        <?php endif; ?>
    </td>
    <td><p><b><a href="<?php echo site_url( 'Product/view/'.$row_off['aid'].'/'.$row_off['category_id'].'/'.$row_off['unit_id'].'/'.url_title($row_off['title'], '-', TRUE) ) ; ?>" >
 <?=$row_off['title']?></a></b></p></td>
    <td width="20% "><p >



<?php if($row_off['uprice']!='') { ?> <span class="meroon2" >MRP  <i class="fa fa-inr" aria-hidden="true"></i><span class="text_over_line"> <?=$row_off['uprice']?> </span> </span><?php } ?>
<br />
<span class="meroon" >Selling Price  <span class="selling_price"> <i class="fa fa-inr" aria-hidden="true"></i> <?=$row_off['price']?> </span></span>
<br /><span class="for_text"> For <?php $uid=$row_off['unit_id']; 
$sql ="SELECT * FROM shop_unit where id=$uid";
$query = $this->db->query($sql);
if ($query->num_rows() > 0) {
  foreach ($query->result() as $row) {?>
<?php echo $row->title;?>
     
     
<?php }
}

	 
 ?>
</span>


</p></td>
    
    
<td align="left" width="25%">
   
<div class="clr"></div>
    
      
<?php
$sql ="SELECT * FROM shop_product where aid=".$row_off['aid']."";

$query = $this->db->query($sql);

if ($query->num_rows() > 0) {
foreach($query->result() as $row) {
$pro_quty=$row->stock2;
$defalut=0;
if( $pro_quty!=0) {$defalut=1;}
}
}
?>  

      
	  <div class="quantity">
      <div class="qur_2"><div class="quantity-button quantity-down">-</div></div>
      
<?php echo form_input(array('name' => $row_off['aid'], 'value' => $defalut, 'maxlength' => '3','id'=>'quantity', 'size' => '5','type' => 'number','min' => '0','max' => $pro_quty )); ?>
      
     <div class="qur_1"><div class="quantity-button quantity-up">+</div></div>
     
     
     
      </div>
      <?php echo form_input(array('name' => $i.'[id]', 'value' => $row_off['aid'], 'maxlength' => '3','id'=>'id', 'size' => '5','type' => 'hidden' )); ?>
      
      

<span style="font-size:10px; text-align:left;">Available product quantity : <?=$pro_quty?></span>
      </td>
    
    
    <td style="text-align:center;">
  
      <p> 
<?php  $currentURL = current_url(); 
$url=urlencode(base64_encode($currentURL));
?>
<!--<a href="<?php echo site_url('Cart/insert/'.$row_off['aid'].'/1/'.$row_off['price'].'/'.$row_off['unit_id'].'/'.$url.'/'.url_title($row_off->title,'-',true)); ?>" class="read_more5" > 
Add to Cart</a>-->




<input type="hidden" name="pro_id" value="<?=$row_off['aid']?>" />
<input type="hidden" name="price" value="<?=$row_off['price']?>" />
<input type="hidden" name="unit_id" value="<?=$row_off['unit_id']?>" />
<input type="hidden" name="url" value="<?=$url?>" />
<input type="hidden" name="title" value="<?=url_title($row_off->title,'-',true)?>" />

 
<input type="submit" name="addtocart" value="Add To Cart" class="read_more5" />


</form>

<!--<a href="<?php echo site_url( 'Product/view/'.$row_off['aid'].'/'.$row_off['category_id'].'/'.$row_off['unit_id'].'/'.url_title($row_off['title'], '-', TRUE) ) ; ?>" class="read_more5" >Read More</a>-->
</p>
    
    
    
    </td>
    
    
  </tr>

<?php $i++; ?>

<?php endforeach; }  ?>   


<?php

if($i==1 && ($_GET["cid"] || $_GET["sid"] || $_GET["bid"])) { echo "No Products in this Search. Kindky Try anthor Search.";}


?>

</table>
 
 

 
 
 
 
 
 
 
 <div class="clr"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
			<!--<div id="searched_products"></div>-->
</div>
</div>
<div class="clr2"></div>


<?php
  $this->load->view('website/side');
?>





</div>
<script>
$("#categories").change(function ()
	{  
		var categories=$('#categories').val();
	    $.ajax({
        url: '<?php echo base_url("search_product/subcategory"); ?>',
        type: 'POST',
        data: {categories:categories}, 
        dataType: 'json',      
        success: function(msg)
        {		
				$('#sub_categories').empty();
				for(var i=0;i<=msg.length;i++)
				{
					
					$('#sub_categories').append('<option value="'+msg[i].id+'">'+msg[i].title+'</option>');
           
				}
        }

      });
	});
	
	$('#form_id').submit(function(event) {

      /* Act on the event */

      event.preventDefault();
	  if($('#categories').val()=='')
	  {
		$('#category_error').html("Please select category");  
	  }
	  else if($('#sub_categories').val()=='')
	  {
		  $('#subcategory_error').html("Please select subcategory");  
	  }		
	  else
	  {	
		  $.ajax({

			url: '<?php echo base_url("search_product/search_product"); ?>',

			type: 'POST',

			data: $('#form_id').serialize(), 

			//dataType: 'json',      

			success: function(msg)
			{
			  $('#searched_products').replaceWith(msg);
			}
		  });
	  }
	 

    });
</script>




<!-------------------increment jquery----------------------->



<!--<script type="text/javascript" src="<?php echo base_url('assets/website/incre/jquery2.js');?>"></script>-->
<script>    jQuery('<div class="quantity-nav"><div class="quantity-button quantity-up">+</div><div class="quantity-button quantity-down">-</div></div>').insertAfter('.quantity input');
    jQuery('.quantity').each(function() {
      var spinner = jQuery(this),
        input = spinner.find('input[type="number"]'),
        btnUp = spinner.find('.quantity-up'),
        btnDown = spinner.find('.quantity-down'),
        min = input.attr('min'),
        max = input.attr('max');

      btnUp.click(function() {
        var oldValue = parseFloat(input.val());
        if (oldValue >= max) {
          var newVal = oldValue;
        } else {
          var newVal = oldValue + 1;
        }
        spinner.find("input").val(newVal);
        spinner.find("input").trigger("change");
      });

      btnDown.click(function() {
        var oldValue = parseFloat(input.val());
        if (oldValue <= min) {
          var newVal = oldValue;
        } else {
          var newVal = oldValue - 1;
        }
        spinner.find("input").val(newVal);
        spinner.find("input").trigger("change");
      });

    });
//# sourceURL=pen.js
</script>
<!-------------------increment jquery----------------------->