
	<script>

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

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

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

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

		    // document.body.innerHTML = originalContents;

	}
}
	</script>
  <style type="text/css">
  
  	
  .invoice-box table tr.heading td {
        background: #eee;
        border-bottom: 1px solid #ddd;
        font-weight: bold;
		
		
    }
  
  #printable { display: none; }
  @media print
    {
		
    	#non-printable { display: none; }
    	#printableArea { display: block; font-size:18; width:100%; }
		  margin:0; 
		#printdive2{
	font-style: normal;font-size: 0.5em;
	
	padding:0px;
	
}
    }

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

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


}
    @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['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);

					
?>
 
 <div class="row">

 

   	<div class="col-md-12">
		 <div class="pull-right" id="non-printable"  >
<form name="print" method="post" action="">
 <input type="submit" id="print"  accesskey="p" class="btn btn-primary"  name="print"onclick="printDiv('printableArea')" value="Print Barcode!" />
                   
 
 </form>
<a href="<?php echo base_url();?>user/viewreceivedproducts?randomitemidentifier=<?php  if(isset($finalsalesid)) {echo   $finalsalesid; }?>" class="btn btn-info"> Back </a>



 </div>
  	
					
					

						<?php
 $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'];	

			
?>		
			<div class="table-responsive" id="printableArea" style="width:100%" >

					<table>

							
						
							<tr>
			


								
							</tr>
					
						<?php
					

 if(!is_array($viewserials)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='5'>";
    
    echo "</td>";
   echo "</tr>";
    }else {
 $counter=count($viewserials);
$i=0;
$finalname="";
while($i<$counter){
  	foreach ($viewserials as $c){ 
	
	
	
			 					 		$PRODUCTLIST = $this->usermodel->populateallarray('products','code',$c->code);
										$shortname=$PRODUCTLIST[0]["shortname"];
if($shortname==""){
	$finalname=$c->name;

}else{
		$finalname=$shortname;

	
}
		$i++;
		

             ?>
									
											
											

<tr>
		

	

	<?php
			if($i%2){
			 
			 ?>
			 	 <td rowspan="2" style="margin-bottom:1px;padding-bottom:1px">

			 <center> FB:<?php echo $c->serial; ?></center>
				<img style="margin:0px;margin-bottom:1px;  padding:0px;width:130% ; height:58%" src="<?php echo base_url().'Systemusers/barcode/'.$c->serial; ?>" alt=""></img>

										<center id="printdive"  style="margin-bottom:5px; padding:0px;">

											<span style="font-size: 0.6em;margin-bottom:0px;"><b><?php echo $shortname; ?></b></span>
											</center>
												
											
											 </td>

			 <?php
				}		
				?>
		

		 <?php		
     if($i % 2 == 0){ 
	 
	 ?>
				 <td >
				 <center> FB:<?php echo $c->serial; ?> </center>
				<img style="margin:0px;margin-left:10px; padding:0px;width:98%;height:60%" src="<?php echo base_url().'Systemusers/barcode/'.$c->serial; ?>" alt="">

										
											
										<center id="printdive"  style="margin-bottom:5px; ">

											<span style="font-size: 0.6em"><b><?php echo $shortname; ?></b></span>
											</center>
																					<br>
</td>
									<?php
									} 
										?>
		
			
		</tr>	

												
									

<?php }}}?>	
			  
		</table>	  
			  
			  
							
						
							
							
							
							
							
				
									
									
					</table>
			<div>
		
					
					
		
  </div>
 </div>
 </div> 
			
			
		
		<script type="text/javascript">
$(window).load(function()
{
	 if( window.print()) {
         window.location.href = "../user/viewpurchases";
 }
});
</script>

















