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

				$configurationS = $this->usermodel->populateallarray('smsconfig','id',$companyid);

		$defaultcurrency = $configurationS[0]['currencysymbol'];
				
?>
 
 <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/viewproducts" 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>
					
						<?php
					

 if(!is_array($viewserials)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='5'>";
    echo "That code does not exist. Try gaian.";
    echo "</td>";
   echo "</tr>";
    }else {
		
					$finalname="";
			 					 		$PRODUCTLIST = $this->usermodel->populateallarray('products','code',$mycode);
										$shortname=$PRODUCTLIST[0]["shortname"];
										$name=$PRODUCTLIST[0]["name"];
										$sellingprice=$PRODUCTLIST[0]["sellingprice"];
										if(trim($shortname)==""){
											$finalname=$name;

										}else{
												$finalname=$shortname;

											
										}
  $counter=($myqty);

$i=0;

while($i<$counter){
 
	
	
	

		$i++;
		
if($columns=="1"){
	  ?>
	<tr>
		

	

	
			 
			
			 	 <td style="margin-bottom:1px;padding-bottom:1px">
			<center><b style="font-size:18"><?php echo $defaultcurrency;  ?>:<?php echo $sellingprice; echo",  ". $finalname; ?></b></center>

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

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

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

		
		

		
		
			
		</tr>
	


	
											
<?php											
}else{
?>
	
<tr>
		

	

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

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

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

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

			 <?php
				}		
				?>
		

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

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

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

<?php 

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

















