
	<script>
	var util = { };

document.addEventListener('keydown', function(e){

    var key = util.key[e.which];
    if( key ){
        e.preventDefault();
    }

   if( key === 'F5' ){        
  return  printDiv('printableArea');
    }
  if( key === 'F6' ){        
  window.location.href = "../user/viewexpenses";
    }

	 if( key === 'enter' ){        
return true;
    }
	
   
	
	
})


  
util.key = { 
  9: "tab",
  //13: "enter",
  16: "shift",
  12: "alt",
  27: "esc",
  33: "rePag",
  34: "avPag",
  35: "end",
  36: "home",
  37: "left",
  38: "up",
  39: "right",
  40: "down",
  112: "F1",
  113: "F2",
  114: "F3",
  115: "F4",
  116: "F5",
  117: "F6",
  112: "F7",
  119: "F8",
  120: "F9",
  121: "F10",
  122: "F11",
  123: "F12"
}
 

	</script>

  <style type="text/css">
  
  

    #printable { display: none; }
#print{  	


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


}

#sale{  	
background-image:url(images/add.png) ;

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


}
#printreceipt { font-size: 1.5em;         font-weight: bold;
}
    @media print
    {
    	#non-printable { display: none; }
    	#printableArea { display: block; font-size:18; width:100%; }
    }
    </style>
<?PHP

 echo $this->session->flashdata('imagemsg1'); 
		 
		    
$session_data = $this->session->userdata('logged_in');




$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
	 
	 $data['branchid'] = $session_data['branchid'];
	 $branchid = $data['branchid'];





$data['surname'] = $session_data['surname'];
$data['id'] = $session_data['id'];

$surname=$data['surname'];
   $userid=$data['id'];

   $myuser=$this->usermodel->geteuser($userid);
   $myname=$myuser[0]['firstname'];
    $postedtime = date('Y-m-d');
		$currenttime = date('h:i:sa');
 		$dateposted =  ($postedtime)." ".$currenttime ;	

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;
					}	

 $displaycode=$this->usermodel->populatuserpermissionsdataarray('config','productcode',$userid);
												 $countbranch=$this->usermodel->countbranches($companyid);
												 	$profile = $this->usermodel->populateallarray('smsconfig','id',$companyid);

$hscode=$profile[0]['hscode'];
									$photo=$profile[0]['logo'];
									$img=$profile[0]['logo'];
											$receiptlogo=$profile[0]['receiptlogo'];

					
?>
 
 <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 Sales</span>
						 
							<div class="print-hide"  >
<form name="print" method="post" action="">
 
 <div class="row">

 

   	<div class="col-md-6">
	
	
  			  <a class="btn btn-primary" id="next-btn" href="<?php echo base_url(); ?>user/viewproducts">Go back to mainstore </a>
			    			  <a class="btn btn-primary" id="next-btn" href="<?php echo base_url(); ?>user/viewproductlist">Go back to stocklist </a>

</div>
   	<div class="col-md-6">
<input type="submit" id="print"  accesskey="p" class="btn btn-primary"  name="print"onclick="printDiv('printableArea')" value="print receipt!" />
</form></div></div>
							</div> 
						 
						 

				
            	</div>
            </div>
				<div class="table-responsive">
			<div id="printableArea" style="width:100%" >
						<table  class="table table-bordered" border="0" width="100%" id="printreceipt">
						<thead>
					
						<?php
if(($receiptlogo=="yes") ||($receiptlogo=="yesbranch")) {
?>
								<tr>
								

					<td COLSPAN="6">
					<center>


			<?php
			
$img1='uploads/';
	
			if($receiptlogo=="yes") {
					$url = base_url().$img1.$img;

			}else{
				 $allbranches= $this->usermodel->populateallarray('branch','id',$branchid);
					$branchlogo=$allbranches[0]['logo']; 
											
				
					$url = base_url().$img1.$branchlogo;

			}

	
if($photo!=""){
	
	?>
	
 <div>
<img class="img-circle" src="<?php echo $url ?>" height="150" width="200" style="border-radius:4px;margin:0px  ">		 

</div>
<?php
 
 }
 ?>
		
						</center>	
						</td>
					
				
				</TR>
					<?php
}

						?>
					<TR>	
									
								<td colspan="6"><center>
								
								<span id="mytitle"><b>PRODUCTION FORMULA </b>	</span>	
								
								
										<?php 
										 if( $countbranch > 1){
										 $mybranches= $this->usermodel->populateallarray('branch','id',$branchid);
										$branchdescription=$mybranches[0]['description']; if(isset($branchdescription)) {
											
											//
											echo   strtoupper($branchdescription); }


										}else{
									$bussinessname=$configuration[0]['businessname']; if(isset($bussinessname)) {echo   $bussinessname; }
 
											 
										 }
										?>
										
											<?php $mypin= $configuration[0]['address']; 
if(	 $mypin!=""){
?>
			 <?php echo"<b> COMPANY PIN : &nbsp;&nbsp;&nbsp;&nbsp;        ". $mypin."</b>"; ?>

 
<?php
};			 

	$product = $this->usermodel->populateallarray('products','code', $itemid);	 
		


?>
	

								</center></td>
								
								
							</tr>
									
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						<tr>
						
						<td>
						<H3>PRODUCTION ITEM :
							<?php 	 echo$product[0]['name'];	;?><BR>
</H3>

						</td>
						<td colspan="2">
					
						<H3>
						   CODE:<?php 	 echo$product[0]['code'];	;?><BR>

						 PRICE:<?php 	 echo$product[0]['sellingprice'];	;?><BR>


				
						
						
						
						
						
						
						</td>
						
						
						
						
						
							</tr>
								
						
							<tr>
				
<td><b>Code</b></td>			


<td><b>Item Name</b></td>
	<td><b>Qty</b></td>

		<td><b>Uom</b></td>					

							</tr>
						</thead>
							<?php
					
 $totalcost=0;
 $ttqty=0;
 if(!is_array($child)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='5'>";
    
    echo "</td>";
   echo "</tr>";
    }else {


   $totaltax=0;
  	foreach ($child as $row): 

		 //$totalcost=$totalcost

             ?>
				            
									
										 
												
											<tr>
<td><b><?php echo $row->uom ;?></b><BR></td>
											
											
			
	 <td><b>
	 <?php
	 
	 	 $productname= $this->usermodel->populateallarray('products','code',$row->uom);
	 echo$productname[0]['name'];
 	 
	 ?>
		
				
</b>
		
	 </td>	

<td><b><?php echo $row->qty ;?></b><BR></td>
<td><b><?php echo $productname[0]['uom'] ;?></b><BR></td>
									
										
											</tr>
										<?php endforeach;} ?>
						
							
							
							
							
							
							<tr>
<td colspan="3"	>
</br>
 Name:-------------------------------------------------------------------------------------------</br></br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Signature:-------------------------------------------------------------------------------------


						</td>
									
							</tr>
							
							
				
									</tbody>
									
									
					</table>
	
					
					
					
					
				</div>
			</div>
			</div>
		</div>
  
  </div>
 </div>
 </div> 
			
			
		
			<script type="text/javascript">


$(window).load(function()
{
	 if( window.print()) {
         window.location.href = "../user/allinvoices";
 }else{
	  //       window.location.href = "../user/allinvoices";
 
 }
});
</script>	


















