

	<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/allpurchaseorder";
    }

	 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>
<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/viewsales";
		alert(" printing...........");
    }else {

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

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


}
    @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);
  $viewbprice=$this->usermodel->populatuserpermissionsdataarray('productlist','viewbprice',$userid);

					
?>
 
 <div class="row">

 

   	<div class="col-md-12">
	
  
        	
			
			<div class="table-responsive" id="printableArea" style="width:100%" >
						<table border="0" width="100%">
					
						<tr>
						<td colspan="2" valign="top">
<?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'];	

								$profile = $this->usermodel->populateall('smsconfig','id',$companyid);

	
		if(!is_array($profile)) 

 {
	 $this->session->set_flashdata('msg', '<div class="alert alert-danger fade in">
						 <a href="#" class="close" data-dismiss="alert">&times;</a><strong>Error!</strong>Upload photo</div>');
							

    }else {

    
          
  	foreach ($profile as $c): 
$photo= $c->logo;
		 	if($photo!=""){
		 
		 
		
		
	
			
		
		$img=$c->logo;
	
		$img1='uploads/';
	$url = base_url().$img1.$img;

 
 ?>
 <div >
<img class="img-circle" src="<?php echo $url ?>" height="100" width="100" style="border-radius:4px;  ">		 

</div>



	 <?php }else{
		 ?>

				<?php
	 }
		 endforeach; ?>

              <?php }?>
						
						
						
				
						<?php $description=$configuration[0]['description']; if(isset($description)) {echo   $description; }?>
							
						
						
						
						</td>
						
						<td colspan="4" valign="top">
					<h2>INTERNAL TRANSFER NOTE</h2>
					
<br><br>
					<b>	Invoice Date:  <?php echo$viewreceipt[0]['createdate'];?><BR>
						GRN No: <?php echo$viewreceipt[0]['id'];?><BR>


						Ref No:  <?php $invoiceid; if(isset($invoiceid)) {echo   $invoiceid; }?><BR></H3>
						</b></td>
						
						</tr>
						
					<TR>
					<td colspan="6">
					<hr style="border-top: 2px solid gray;">

					</td>
					</TR>
						<tr>
						
					
						<td colspan="3">
						<B>Goods From:</B><br><b>
					<?php $frombranch=$viewreceipt[0]['frombranch'];
$fromuserid=$viewreceipt[0]['userid'];
						 if($frombranch=="Main"){
							 echo "Main store";
							
						 }else{
														$frombranchxx=$this->usermodel->populateallarray('branch','id', $frombranch);
 
							 	echo$frombranchxx=$viewreceipt[0]['name'];
						 }
							
			$by=$this->usermodel->populateallarray('people','id', $fromuserid);

							echo "<br> Dispatched by :".$by[0]['firstname']." ".$by[0]['surname'];		 
						 
							?>
						
						
						
						</b>
						
						
						
						
						</td>
						
							<td colspan="3">
						<B>Shipped To:</B><br>
		<?php $tobranch=$viewreceipt[0]['tobranch'];

						 if($tobranch=="Main"){
							 echo "Main store";
							
						 }else{
							 
							if( $viewreceipt[0]['category']=="Customer"){
												$tobranchxx=$this->usermodel->populateallarray('people','id', $tobranch);
 
							 	echo$fromname=$tobranchxx[0]['firstname']; 
								 
							}else{
														$tobranchxx=$this->usermodel->populateallarray('branch','id', $tobranch);
 
							 	echo$fromname=$tobranchxx[0]['name'];
							}
						 }
							
						
						
							 
						 
							?>
	 
	 
	 
	 
	 
	 <BR>
						</td>
						
						
						
							</tr>
																				
																				
																				
																				</table >
<br><br>
										<div class="invoice-box">
													<table border="1" class="height2" height="100%" style="width:100%;">

					
						
							<tr  class="heading">
							
<?php 
if($displaycode==true){
	 ?>
<td><b>Code</b></td>
<td><b>Item Name</b></td>
	 	<?php
		}else{?>
	<td colspan="2"><b>Item Name</b></td>
 <?php
 }
 ?> <td><b>Qty Received</td>
	
	
	 
   	<?php

	
 if(trim($viewbprice) != TRUE){
	 ?>
	     <td><b>B Price</td>

	 	<?php	

 }
  ?>
  		     <td><b>TT B.price</td>

	
	
	
<!--
  <td><b>Qty Before</td>
  <td><b>Qty Total</td>
	 
					
		<td><b> S.price</td>
			-->	
					</tr>
					
						<?php
					
 if(!is_array($viewsales)) {
	 

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

 {


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

  $TTQTY=0;
  $totalvatcost=0;
  $totalexemptedcost=0;
   $totaltax=0;
  	foreach ($viewsales as $c): 

		 

             ?>
				                    <tbody >
									
										 
												
											<tr   valign="top">
											
											<?php 
if($displaycode==true){
	 ?>
									<td><?php echo $c->item_id ; ?></td>

													    <td><?php ; 
	 $receiptdescription=$configuration[0]['receiptdescription'];
   $customer=$c->item_id;
   if($customer!=""){
	  
      $productname = $this->usermodel->geteproductbyid($customer);
  
     echo$name=$productname[0]['name']; if($receiptdescription=="yes"){ echo"-".$description=$productname[0]['description'];}

	
   }else{
	    echo "No Product";  
   }
      if( $c->serial !=""){

echo " S/N: ".$c->serial;
  }	
  
  ?></td>
	 	<?php
		}else{?>
	
	
													    <td  colspan="2" ><?php ; 
	 $receiptdescription=$configuration[0]['receiptdescription'];
   $customer=$c->item_id;
   if($customer!=""){
	  
      $productname = $this->usermodel->geteproductbyid($customer);
  
     echo$name=$productname[0]['name']; if($receiptdescription=="yes"){ echo"-".$description=$productname[0]['description'];}

	
   }else{
	    echo "No Product";  
   }
      if( $c->serial !=""){

echo " S/N: ".$c->serial;
  }	
  
  ?></td>
 <?php
 }
 ?>
 <td><?php echo $c->total ;
$TTQTY=$TTQTY+ $c->total;
 $totalcost= $totalcost+($c->total * $c->buyingprice) ;
  $totalSELLING= $totalSELLING+($c->total * $c->sellingprice) ;

										?></td>
 
 
   	<?php

	
 if(trim($viewbprice) != TRUE){
	 ?>
	 <td>
										<?php if(isset($c->buyingprice)) {echo formatMoney($c->buyingprice, true);  }?>
										
		</td>
	 	<?php	

 }
  ?>
  
  
 
 
 
 		
										
		
										
<!--
																			<td><?php echo $c->item_id1 ; ?></td>
										
										
										<td><?php  $c->balance ; ?></td>
	
	-->	
	<td><?php  echo $c->total *$c->buyingprice  ; ?>
	
	</td>

		<!--	 
   <td>
										<?php if(isset($c->sellingprice)) {echo formatMoney($c->sellingprice, true);  }?>
										
		</td>
		
		-->
 								
									
											</tr>
										<?php endforeach;} ?>

              <?php }?>	
			  
			  
			  
					<tr>
					<td colspan="4"  height="50px"></td><td    height="50px"></td>
					
					</tr>
								
									
								
							
							
							
						<tr>
								
								
								<td colspan="2"> 

								<H3 class="pull-left">
															Name:-----------------------------------

															
							Signature:---------

											</H3>
											</td>
								
								<TD>
								<?php 
							if(isset($TTQTY)) {echo formatMoney($TTQTY, true);  }
							?>
</TD>
	<?php

	
 if(trim($viewbprice) != TRUE){
	 ?>
	 <td>
										
		</td>
	 	<?php	

 }
  ?>
 
<td> 

							<H3>
															
							<?php 
							if(isset($totalcost)) {echo formatMoney($totalcost, true);  }
							?>

											</H3>

							
							
							</td>
					
							</tr>
							
							
							
							
							
				
									</tbody>
									
									
					</table>
					</div>
			<div>

<br>

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



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




		
		
















