<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
      <div class="main my-0">
        <div class="row mt-3 mx-0">
          <div class="col-md-9">            
            <h3> Manage Products Price</h3>
          </div>
          <div class="col-md-3 text-right">
            <!--<a href="warehouse/<?php echo $mgmtname;?>/manage" class="btn btn-success">Add Product Price</a>//-->
          </div>
        </div>
        
        <div class="container_fluid mt-2 px-3">
		<form name="frmsearch" method="get" action="warehouse/<?php echo $mgmtname;?>">
         <table class="webforms sttbl bg-light my-0 table-responsive-sm">
          <tr>
           <td class="pr-0" width="20%"><input type="text" name="search" size="20" value="<?php echo $this->input->get("search");?>" placeholder="search name, barcode, price"></td>

          <td class="pr-0" width="20%">
		<select name="zoneid" id="zoneid" class="js-example-basic-single" >
		  <option value="">All Zones</option>
						<?php
						if(is_array($zonelist) && count(array_filter($zonelist))>0)
						{

							foreach($zonelist as $zonerow)
							{
								$sel_zone ="";
								if(decodeValue($this->input->get("zoneid"))==$zonerow->fld_id)
								{
									$sel_zone = 'selected="selected"';
								}				
									?>
											<option value="<?php echo encodeValue($zonerow->fld_id);?>" <?php echo $sel_zone;?>><?php echo $zonerow->fld_name;?></option>
									<?php
								
							}
						}
						?> 
		  </select>
		  </td>
          <td class="pr-0" width="20%">
		<select name="catid" id="catid" class="js-example-basic-single" >
		  <option value="">All Category</option>
						<?php
						if(is_array($catlist) && count(array_filter($catlist))>0)
						{

							foreach($catlist as $mcatrow)
							{
								$sel_mcat ="";
								if(decodeValue($this->input->get("catid"))==$mcatrow->fld_id)
								{
									$sel_mcat = 'selected="selected"';
								}				
									?>
											<option value="<?php echo encodeValue($mcatrow->fld_id);?>" <?php echo $sel_mcat;?>><?php echo $mcatrow->fld_name;?></option>
									<?php
								
							}
						}
						?> 
		  </select>
		  </td>
		<td class="pr-0" width="20%">
		<select name="productid" id="productid" class="js-example-basic-single" style="width:200px!important;">
		  <option value="">All Proudcts</option>
						<?php
						if(is_array($productlist) && count(array_filter($productlist))>0)
						{

							foreach($productlist as $productrow)
							{
								$sel_product ="";
								if(decodeValue($this->input->get("productid"))==$productrow->fld_id)
								{
									$sel_product = 'selected="selected"';
								}				
									?>
											<option value="<?php echo encodeValue($productrow->fld_id);?>" <?php echo $sel_product;?>><?php echo $productrow->fld_name;?></option>
									<?php
								
							}
						}
						?> 
		  </select>
		  </td>
		  
           <td class="pr-0" width="15%"><input type="number" name="fromprice" id="fromprice" value="<?php echo $this->input->get("fromprice");?>"   placeholder="From Price"  /></td>
           <td class="pr-0" width="15%"><input type="number" name="toprice" id="toprice"  value="<?php echo $this->input->get("toprice");?>" placeholder="To Price"/></td>	
           <td  width="10%">
           	<button class="btn btn-dark pt-0 pb-1 px-2">Go</button>
           </td>
          </tr>
         </table>
       </form>
         <?php
			if($this->session->flashdata("message")!="" && $this->session->flashdata("alerttype")!="")
			{
         ?>
         <div class="text-center my-4">
			 <span class="alert <?php echo $this->session->flashdata("alerttype");?>"><?php echo $this->session->flashdata("message");?></span>
         </div>
         <?php
			}
         ?>
         
         <table class="table mt-2 table-responsive-sm">
		
                <thead>
                	<tr>
                        <th width="10%" class="align-top">Zone</th>         	
                    	<th width="25%" class="align-top">Product</th>
                    	<th width="10%" class="align-top">Category</th>
                    	<th width="5%" class="align-top">MRP</th>
                    	<th width="5%" class="align-top">%</th>
                    	<th width="5%" class="align-top">Price<br> 1 Bottle</th>
                    	<th width="5%" class="align-top">Price<br> 3 Bottles</th>
                    	<th width="5%" class="align-top">Price<br> 6 Bottles</th>
                    	<th width="5%" class="align-top">Price<br> 9 Bottles</th>
                    	<th width="5%" class="align-top">Price<br> 12 Bottles</th>                   	
                    	<th width="5%" class="align-top">Price<br> 24 Bottles</th>                   	
                        
                        <!--<th width="5%" class="align-top text-center">Action</th>//-->
                    </tr>
                    </thead>
                    <tbody>
					<?php
					if(is_array($results) && count(array_filter($results))>0)
					{
						$rowindex = 0;
						foreach($results as $row)
						{
							$rowindex++;


					?>
                    <tr>
                       
                    	
						<td><a href="warehouse/outlets/?zoneid=<?php echo encodeValue($row->fld_zoneid);?>"><?php echo $row->zonename;?></a></td>
						<td><a href="warehouse/orders/product/<?php echo encodeValue($row->fld_productid);?>"><?php echo $row->productname;?></a></td>
						<td><a href="warehouse/orders/category/<?php echo encodeValue($row->fld_catid);?>"><?php echo $row->catname;?></a></td>
                    	<td><?php echo round($row->fld_mrp);?></td>
                    	<td><?php echo round($row->fld_discount);?></td>
	                   	<td><a href="warehouse/orders/product/<?php echo encodeValue($row->fld_productid);?>?price=<?php echo round($row->fld_price,2);?>"><?php echo round($row->fld_price);?></a></td>
	                   	<td><a href="warehouse/orders/product/<?php echo encodeValue($row->fld_productid);?>?price=<?php echo round($row->fld_price3bottles,2);?>"><?php echo round($row->fld_price3bottles,2);?></a></td>
	                   	<td><a href="warehouse/orders/product/<?php echo encodeValue($row->fld_productid);?>?price=<?php echo round($row->fld_price6bottles,2);?>"><?php echo round($row->fld_price6bottles,2);?></a></td>
	                   	<td><a href="warehouse/orders/product/<?php echo encodeValue($row->fld_productid);?>?price=<?php echo round($row->fld_price9bottles,2);?>"><?php echo round($row->fld_price9bottles,2);?></a></td>
	                   	<td><a href="warehouse/orders/product/<?php echo encodeValue($row->fld_productid);?>?price=<?php echo round($row->fld_price12bottles,2);?>"><?php echo round($row->fld_price12bottles,2);?></a></td>
						<td><a href="warehouse/orders/product/<?php echo encodeValue($row->fld_productid);?>?price=<?php echo round($row->fld_price24bottles,2);?>"><?php echo round($row->fld_price24bottles,2);?></a></td>
	                   
                    	
                        <!--<td align="center">
							<a href="warehouse/<?php echo $mgmtname;?>/manage/<?php echo encodeValue($row->fld_id);?>" class="text-success" title="Edit"><span class="fa fa-edit fa-lg"></span></a><span class="ml-2"></span></a>
						</td>//-->
                    </tr>
                    <?php
						}
							
					}
					else
					{
                    ?>
                    <tr><td colspan="11" style="text-align:center">Record not found!</td></tr>
                    <?php
					}
                    ?>
                    
                    
                    </tbody>
                </table>
                 
	         <div class="clearfix"></div>
          
        </div>
        <div id="paginate" class="row">
			<?php echo $this->ajax_pagination->create_links(); ?>
        </div>
            
        </div>

