
<script>
	function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

    // document.body.innerHTML = printContents.fontsize(12);
     window.print();

	 if( window.print()) {
         window.location.href = "../user/viewlowstore";
		alert(" printing...........");
    }else {

	
		      return      window.location.href = "../user/viewlowstore";

		    // document.body.innerHTML = originalContents;

	}
}
	</script>

         <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
		
		
		
    </script>   
  <style type="text/css">
  
  

    #printable { display: none; }
#print{  	


    background-repeat: no-repeat;
	font-size;20px;
  
    width:100%; 


}

#sale{  	


    background-repeat: no-repeat;
  
    width:100px; height:50px;


}
    @media print
    {
    	#non-printable { display: none; }
    	#printableArea { display: block; font-size:16; width:100%; }
    }
    </style>
 
 <div class="row">
  
   	

   	<div class="col-md-12">

  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading" id="non-printable">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
				 <span class="pull-right"> View salesreport</span>
                        <a  id="more" target="blank" class="btn btn-primary" href="<?php echo base_url();?>user/viewlowstore">back  </a>
				 		 	<div class="pull-right"  >
<form name="print" method="post" action="">
 <input type="submit" id="print"  accesskey="p" class="btn btn-primary"  name="print"onclick="printDiv('sortable_table')" value="print receipt!" />
</form></div>
            	</div>
            </div>
			<div class="panel-body">

			
	<div class="widget-content nopadding table_holder table-responsive" >				
				<?PHP
function formatMoney($number, $fractional=false) {
						if ($fractional) {
							$number = sprintf('%.2f', $number);
						}
						while (true) {
							$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
							if ($replaced != $number) {
								$number = $replaced;
							} else {
								break;
							}
						}
						return $number;
					}
 $session_data = $this->session->userdata('logged_in');

   
 	 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	    $addproductaction=$this->usermodel->populatuserpermissionsdataarray('reports','add',$userid);

	 $updateaction=$this->usermodel->populatuserpermissionsdataarray('reports','update',$userid);
  $updatebuyingpriceaction=$this->usermodel->populatuserpermissionsdataarray('reports','update',$userid);
  $deleteaction=$this->usermodel->populatuserpermissionsdataarray('reports','delete',$userid);
	 				echo $this->session->flashdata('deletemsg'); 

				echo $this->session->flashdata('msg'); 
								?>	
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">

									
			<table class="tablesorter table table-bordered  table-hover" id="sortable_table">			

             <thead>
			 
    <tr>
		 
		 	 	 <?php  if(isset($viewwarningproducts)) {
				
			 ?>
		 
		  	  <tr>
			 <th colspan="8"><center>
			 
			 
			 <?php  if(isset($configuration[0]['businessname'])) {echo   $configuration[0]['businessname']; 
			 
			echo " </BR>";
			 }
			   $TIMEOFREPORT=date("d/m/Y H:i:s a");
			
			 if(isset($branchdata)) {echo   $branchdata; } 
			 ?>

			 <B><?PHP if(isset($reporttype)) {echo   $reporttype; } ?><BR> 
			 Report was run on <?php echo  date("d/m/Y H:i:s");?>
									<br>Name----------------------Date--------------------Signature----------------</span>

			</th>
	
			 </center>
			 </tr>
		 	 <?php 
				 }				
			 ?>
		 			 
			 
			 
			 
            <tr>
     <th id="non-printable">Code</th>
     <th>Product Name</th>
<th id="non-printable">Qty Available</th>
<th>Qty to Order</th>


 
		  <th id="non-printable">B.price</th> 
		   <th  id="non-printable">Total</th> 





			  </tr>
             </thead>
<?php
 $updateaction=$this->usermodel->populatuserpermissionsdataarray('products','update',$userid);
  $addstockaction=$this->usermodel->populatuserpermissionsdataarray('products','addstock',$userid);
  $deleteaction=$this->usermodel->populatuserpermissionsdataarray('products','delete',$userid);
  $moreaction=$this->usermodel->populatuserpermissionsdataarray('products','more',$userid);



 if(!is_array($viewwarningproducts)) {
				    echo '<div class="alert alert-danger text-center">There was no products found in the system</div>';

			 }else{
 if(!is_array($viewwarningproducts)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='1'>";
    
       echo '<div class="alert alert-warning text-center">There no records found..</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    
             <?php 
  $TOTAL=0;
   $TTAMOUNT=0;
  	foreach ($viewwarningproducts as $c): 

		$id=$c->id;
$qty1=$c->qty ;
	$reorder=$c->reorderevel; 
	
		 if($qty1<=$reorder){

$TOTAL=$TOTAL+1;
             ?>



             <tr>
                
            <?php 



?>

              
  <td id="non-printable"><?php echo $c->code ; ?></td>
    <td><?php echo $c->name."-".$c->description ; ?></td>

  <td id="non-printable"><b>
			<?php 
			
			if($qty1>$reorder){
			
			?>
			<div style="background-color:green">
			<?php  echo $c->qty ; 	?>
			</div>
			<?php
			}else if($qty1<=$reorder){
		?>
			<div style="background-color:orange">
			<?php  echo $c->qty ; 	?>
			</div>
			<?php
			
			}else if($qty1==0){
			?>
			<div style="background-color:red">
			<?php  echo $c->qty ; 	?>
			</div>
			<?php
			}
			
		
			?>
			
		</b>
		
		
					  <td>
					  
					  <div class="btn-danger">
			<?php  
			
			if($c->reorderquantity !=""){
	$difference=($c->reorderquantity-$c->qty);
 //echo $difference;
				
			}else{
 $difference=($c->reorderevel-$c->qty);
 //echo $difference;
			}
			
					echo	$c->reorderquantity;

			?>
			</div>
 </td>

		
		</td>


  <td id="non-printable"><?php echo $c->buyingprice ; ?></td>
          <td ><?php echo $tt=( $difference * $c->buyingprice) ;


   $TTAMOUNT=$TTAMOUNT+$tt;
		  ?></td> 
  
	
		<td id="non-printable"><b>
			<?php 
			$mycode=$c->code;
			$mystock=$this->usermodel->populateallarray('store','code', $mycode);
			$myreorder=$mystock[0]['reorderevel'];
			$myqty1=$mystock[0]['qty']; 			
	 
			if($myqty1>$myreorder){
			
			?>
			<div style="background-color:green">
			<?php  echo $myqty1 ; 	?>
			</div>
			<?php
			}else if($myqty1<=$myreorder){
		?>
			<div style="background-color:orange">
			<?php  echo $myqty1 ; 	?>
			</div>
			<?php
			
			}else if($myqty1==0){
			?>
			<div style="background-color:red">
			<?php  echo $myqty1 ; 	?>
			</div>
			<?php
			}
			
		
			?>
			
		</b></td>
          
             </tr>

		 <?php }
		
		 
		 
		 endforeach;} 
		
		 ?>


<TR>
<TH  colspan="2">
Total
</TH>
<TH  id="non-printable">
</TH>
<TH  id="non-printable">
</TH>

<TH id="non-printable">
<?php echo $TTAMOUNT;    ?>
</TH>
</TR>



              <?php }?>

        </table>
		
	</div>

			<div id="deleteModel" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Delete</h4>
      </div>
      <div class="modal-body">
        <h3>Are you sure you want to delete this item? </h3>
      </div>
      <div class="modal-footer">
	  	

     
		<?PHP
				$session_data = $this->session->userdata('logged_in');
 echo $this->session->flashdata('deletemsg'); 

		
                 echo form_open('user/deletebyid' , array('class' => 'form-horizontal ', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
 <input type="hidden" id="table"name="table" class="table" placeholder="view" value="sales_order">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/startsales">
 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
 <button type="button" class="btn btn-success" data-dismiss="modal">No</button>
 		  	         <button type="submit" name="btn_delete" value="deletebyid" class="btn btn-danger"> Delete  </button>

	<?php echo form_close();?>
      </div>
    </div>

  </div>

  </div>		
	
	
	
	
	
	
	
	
	
	

			
			</div>
		</div>
  
  </div>
			
			
			
		
		
  

 
</div>


















