<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$addpmtr = "?warehouseid=".$this->input->get("warehouseid")."=&fromdate=".$fromdate."&todate=".$todate;
$previousstockdate = date('d-M-Y', strtotime('-1 day', strtotime($fromdate)));
?>
      <div class="main my-0">
        <div class="row mt-3 mx-0">
          <div class="col-md-9">
            <h3>Total Stock Status</h3>
          </div>
          <div class="col-md-3 text-right">
			<a href="account/<?php echo $mgmtname;?>/exportpdf<?php echo "/?" . $_SERVER['QUERY_STRING'];?>" class="btn btn-info">Export PDF</a>
          </div>
        </div>
        
        <div class="container_fluid mt-2 px-3">
		<form name="frmsearch" method="get" action="account/<?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 "></td>
         
		   <td>
           	<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="5%">SRNo.</th>                    	
                    	<th width="55%">Item</th>
                    	<th width="20%"  class="text-right">Stock In Hand (Bottles)</th>
                    	<th width="20%"  class="text-right">Stock In Hand (Cases)</th>
                    </tr>
                    </thead>
                    <tbody>
					<?php
					if(is_array($results) && count(array_filter($results))>0)
					{
						$rowindex = 0;
						$instock = 0;
						if($this->uri->segment("3")!="") $rowindex = ($this->uri->segment("3") - 1) * $this->perPage;
						foreach($results as $row)
						{
							$rowindex++;
							$minstockvalue = minstockStatus($row['minstockvalue'],$row['instock']);

					?>
                    <tr>
                    	<td class="text-center"><?php echo $rowindex;?>.</td>
                    	<td><a href="account/itemstock?productid=<?php echo encodeValue($row['id']);?>"><?php echo $row['name'];?></a></td>                    	              
						<td class="text-right "><strong><?php echo $row['instock'];?></strong></td>
						<td class="text-right "><strong><?php echo $row['instockcases'];?></strong></td>
                    </tr>
                    <?php
						}
							
					}
					else
					{
                    ?>
                    <tr><td colspan="4" 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>

