	<?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'];	
	 $data['branchid'] = $session_data['branchid'];
	 $branchid = $data['branchid'];		
						//	
//						
								?>	

								
								
						<script type="text/javascript2">
$(window).load(function()
{
	  var printing = document.getElementById('printing');

	   if( window.print()) {
		 		 //window.location.href = "../user/printreceiptcopy?invoice=<?php echo $invoiceid ?>";
 // return      window.location.href = "../login";
    }else {

	 		//return  window.location.href = "../user/printreceiptcopy?invoice=<?php echo $invoiceid ?>";

//return window.location.replace("../user/printreceiptcopy?invoice=<?php echo $invoiceid ?>");
		   <?php 
if($receipt=="One Without Automatic Logout"){
	?>
		    return      window.location.href = "../user/viewsales";


<?php 
}else if($receipt=="One With Automatic Logout"){
?>
   return      window.location.href = "../login";
<?php 
}else if($receipt=="both"){
?>
return window.location.replace("../user/printbill?invoice=<?php echo $invoiceid ?>");

   
   <?php 
}else{
	?>
			    return      window.location.href = "../user/viewsales";

	
<?php 	
}

?>
	

	}
	
});
</script>					
								
	
		

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

	 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;
  var printing = document.getElementById('printing');

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

	 if( window.print()) {
		 if(printing=true){
			 
			  window.location.href = "../user/logout";

		 }else{
			         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;10px;

    width:100%; height:50px;



}
.doted{
    border: dotted 3px #000000;
}
table { border-collapse: collapse; }
td { padding: 5px; }
tr { border-bottom:1px dashed #494949; }


table{
    border-collapse:collapse;/*This property collapses borders together*/
}

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

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


}
#myalltitle { font-size: 2em; }
#alltitle{ font-size: 1em; }
	#mytitle { font-size: 1.4em; }

    
    {
		
    	#non-printable { display: none; }
    	#printableArea { display: block; font-size:10; width:100%; }
		  margin:0; 
		#receipt{
	font-style: normal;font-size: 1.5em;
	
	padding:0px;
	
}
    }
    </style>
<?PHP

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

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

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

$surname=$data['surname'];
   $userid=$data['id'];
 $myuser=$this->usermodel->geteuser($viewreceipt[0]['userid']);
  // $myuser=$this->usermodel->geteuser($userid);
   $firstname=$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);
  $displaydiscount=$this->usermodel->populatuserpermissionsdataarray('sales','discount',$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'];


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

$total=$viewreceipt[0]['total']; if(isset($totalcost)) {echo   formatMoney($totalcost, true); }
								 $finalmaindiscount=$viewreceipt[0]['maindiscount'];
								 
						$display1=$configuration[0]['display1']; 
						$display2=$configuration[0]['display2']; 
	
	 
?>
 
 <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/viewsales">Add New Sales </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%;margin:0" >
<table    width="100%" >
						<thead>
<?php
if($receiptlogo=="yes"){
?>
								<tr>
								

					<td COLSPAN="6">
					<center>


			<?php
$img1='uploads/';
	$url = base_url().$img1.$img;
	
if($photo!=""){
	
	?>
	
 <div>
<img class="img-circle" src="<?php echo $url ?>" height="150" width="100%" style="border-radius:4px;margin:0px  ">		 

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

						?>	
					<TR>	
									
								<td colspan="6"><center>
								
								<span id="mytitle"><b>CASH SALE RECEIPT</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
};			 
				 

?>
	

								</center></td>
								
								
							</tr>
							
																					
 														
															
			
									<tr>
								
								<td colspan="3" id="myalltitle" ><?php  $viewreceipt[0]['type'];?>   
								
									<h4 style="padding:0; margin:0; "><b > RECEIPT NO :
																<?php 
																
																
																							 
															
															if($viewreceipt[0]['receiptno'] !==""){
																echo$viewreceipt[0]['receiptno'];
															}else{
																echo$viewreceipt[0]['id'];
																
															}
															
															
															
															 //$refno = $this->usermodel->populateallarray('sales','invoice',$invoiceid);

														//echo $viewreceipt[0]['id']; 
																
																
																?></b></h4>
																	
																	 
															

								
								</td>
								
								
						
								
								<td ><b>REF NO:<b></td>
								
								<td colspan="2" id="mytitle">	<h4 style="padding:0; margin:0"><b>
																<?php $invoiceid; if(isset($invoiceid)) {  echo $invoiceid; }?><b></h4>
																	
																	 
															

								
								</td>
								
								
								
							</tr>
							<tr>
								
									<td colspan="6" id="mytitle"><h4 style="padding:0; margin:0"><b> DATE: <?php  $myypostedtime= $viewreceipt[0]['dateposted']; echo date("d/m/Y", strtotime($myypostedtime));   
									echo "<br> TIME:" ;?> <?php echo date("H:i:a", strtotime($myypostedtime)) ;?>
									<b>
									<span class="pull-right"> 
													 <?php $mytable=$viewreceipt[0]['mytable']; if(($mytable!="")) {echo "Table No:".$mytable; }
													 
													 $customer=$viewreceipt[0]['customer'];
													 $mysupplier=$this->usermodel->populateallarray('people','id', $customer);
													 $customerpin= $mysupplier[0]['idnumber']; 
													 ?>
													 </span> 
													 
												
											
													 <?php 
if(	 $customerpin!=""){
?>	</BR> 
		CUSTOMER PIN:   <?php echo$customerpin;?>

 
<?php
};			 
?>
									
													 
													 
													 </h4></td>
								
							</tr>
						
							
							
							<?php 
							$customername=$viewreceipt[0]['name'];
						 if(($customer!=0)&&($customer!="")){
							 ?><tr><td>CUSTOMER:</td><td colspan="5"  id="mytitle"><b>
							<?php
							
						echo$myname=$mysupplier[0]['company'].' '.$mysupplier[0]['firstname'];
						?>
						</b></td></tr><?php
						 }else  if(($customername!=0)||($customername!="")){
							 	 ?><tr><td>CUSTOMER:</td><td colspan="5" id="mytitle"><b>
							<?php
						
						
						echo strtoupper($customername);
						?>
						</b></td></tr><?php
							 
						 }
							?>
								
									
							
								

							
							
							
						
							
							
							<tr>
							
																			<?php 
if($hscode=="yes"){
	 ?>

<td id="mytitle" width="5%"><b>Hs.C</b></td>
<?php
			
}			
											
?>
							
<?php 
if($displaycode==true){
	 ?>
<td id="mytitle"><b>Code</b></td>
<td id="mytitle"  ALIGN="LEFT"><b>Item</b></td>
	 	<?php
		}else{?>
	<td colspan="2" id="mytitle" ALIGN="LEFT"><b>Item</b></td>
 <?php
 }
 ?>

 <td id="mytitle" ALIGN="LEFT"><b>Qty</b></td>
  							<!--<td id="mytitle"><b>Price</b></td>
							-->	
							

 <?php 
if($displaydiscount==true){
	 ?>
								<td id="mytitle"><b>Dsc</b></td>
 <?php
 }
 ?>				
 					  								<td id="mytitle"><b>Price</b></td>

								<td id="mytitle"><b>Total</b></td>
							</tr>
						</thead>
						<?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;
  $totalvatcost=0;
    $vatable=0;
  $ttqty=0;
    $totalvatcost2=0;
    $myttvatable=0;
  $totalexemptedcost=0;
   $totaltax=0;
   
  	foreach ($viewsales as $c):

			$totalvatcost2=$totalvatcost2+$c->tax2;
			  $myttvatable=$myttvatable+$c->taxable;

	   $customer=$c->code;
  $ttqty= $ttqty+$c->qty ;
	  $productname = $this->usermodel->populatealldataarray('productlist','code', $customer,'branch', $c->branch);

		 
		    $sellingprice=strtoupper($productname[0]['sellingprice']);

             ?>
				                    <tbody>
									
										 
												
											<tr valign="top">
											
												<?php 
if($hscode=="yes"){
	 ?>

	<td id="mytitle"><?php echo $productname[0]['hscode'] ; ?></td>
<?php
			
}			
											
?>											
											
											
											<?php 
if($displaycode==true){
	 ?>
									<td id="mytitle"><?php echo $c->code ; ?></td>

													    <td id="mytitle">
														<B><?php ; 
	 $receiptdescription=$configuration[0]['receiptdescription'];
   if($customer!=""){
	  

     // $productname = $this->usermodel->geteproductbyid($customer);
  
     echo$name=strtoupper($productname[0]['name']); if($receiptdescription=="yes"){ echo"-".$description=strtoupper($productname[0]['description']) ;}

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

  ?></B></td>
	 	<?php
		}else{?>
	
	
													    <td  colspan="2" id="mytitle">
														<B>
														<?php ; 
	 $receiptdescription=$configuration[0]['receiptdescription'];
   $customer=$c->code;
   if($customer!=""){
	  
     // $productname = $this->usermodel->geteproductbyid($customer);
  	  //$productname = $this->usermodel->populatealldataarray('productlist','code', $customer,'branch', $c->branch);

     echo$name=strtoupper($productname[0]['name']); if($receiptdescription=="yes"){ echo"-".$description=strtoupper($productname[0]['description']) ;}

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

  ?></B></td>
 <?php
 }
 ?>
 		


		<td id="mytitle"><b><?php echo $c->qty ; ?></b></td>

									
		 	<!--
			
					<td id="mytitle"><b><?php echo $c->sprice ; ?></b></td>							 
			
			
							-->	
											 
											 
															
										 <?php 
if($displaydiscount==true){
	 ?>
	<td id="mytitle"><?php echo $c->discount ; ?></td>
 <?php
 }
 ?>	
 
 						 
											 
		 <td id="mytitle"><b>
												 
												 <?php 
											  $ttvat=$c->tax/$c->qty;
											  if($c->taxtype=="Exclusive"){
												  $sprice= $c->sprice * $c->qty; 
									 //echo   formatMoney($sprice, true); 

											  }else{
												  $sprice = (($c->sprice-$ttvat) * $c->qty); 
								// echo   formatMoney($sprice, true); 
  
											  }
												 
echo formatMoney($c->sprice, true);

											 
											 											 // echo $sellingprice; /  
																						 ?></b></td>

											 

									
										
										
											 	 <td id="mytitle"><b><?php 
												 									 echo formatMoney($c->amount, true);

												 $totalcost=$totalcost+$c->amount ;
												 $totaltax=$totaltax+$c->tax ;
												 $mytaxrate=$c->tax ;
												 
												 if(($mytaxrate!=0)||($mytaxrate!="")){
													 
													 $totalvatcost=$totalvatcost+$c->amount;
												 }
												  if(($mytaxrate==0)||($mytaxrate=="")){
													 
													 $totalexemptedcost=$totalexemptedcost+$c->amount;
												 }

												 ?></b></td>
											</tr>
										<?php endforeach;} ?>

              <?php }?>	
			  
			  	
							
						
							
								
							
							
							
							
							
							
							
							
							<?php
							 if($finalmaindiscount>0){
								 
							 
							?>
								<tr>
								
								<td colspan="6" id="mytitle"><b>GRAND DISCOUNT</b>
								
								<?php $maindiscount=$viewreceipt[0]['maindiscount']; if(isset($maindiscount)) {echo   formatMoney($maindiscount, true); }?>
								
								
								
								</td>
							
							</tr>
							
							<tr>
								
								<td colspan="6" id="mytitle"><b>GRAND TOTAL</b>
								
								
								<?php $discountedtotal=$viewreceipt[0]['discountedtotal']; if(isset($discountedtotal)) {echo   formatMoney($discountedtotal, true); }?>
								
								
								
								</td>
							
							</tr>
							
							
							
							
								<?php
							
								 
							 }
							 	 $mybalance=$viewreceipt[0]['balance']; 

							 $cash=$viewreceipt[0]['cash']; 
							 $mpesa=$viewreceipt[0]['mpesa']; 
							  $card=$viewreceipt[0]['card']; 
								$voucher=$viewreceipt[0]['voucher']; 
							 $credit=$viewreceipt[0]['credit']; 
							  $cheque=$viewreceipt[0]['cheque']; 
							  $points=$viewreceipt[0]['points']; 
 $creditnote=$viewreceipt[0]['creditnote']; 
							$totalcash=$cash+ $mpesa+$card+$voucher+$credit+$cheque+$points+$creditnote;


							?>
							
							
							<?php
				
						if(	$display1=="yes"){
						
						?>
						
							


								
									
								
									<?php 
						$display1=$configuration[0]['display1']; 
						$mydiscount=$viewreceipt[0]['discountedtotal'];
															
															$total=$viewreceipt[0]['total']; 
						if(	$display1=="yes"){
						
						?>
						
							<tr>
								
								<td colspan="4" id="mytitle"><b>SUB TOTAL :</b></td>
								
								<td colspan="2" id="myalltitle"><b>
								<?php 
										if(isset($totalcost)) {echo   formatMoney($totalcost-$totaltax-$totalvatcost2, true); }

								?></b>
								</td>
							
							</tr>

							
			


								<tr><td id="mytitle" colspan="4"><B>VAT 	<?php $tax1rate=$configuration[0]['tax1rate']; if(isset($tax1rate)) {echo  formatMoney($tax1rate, true) ;}?>%	: </B></td><td colspan="2" id="myalltitle"><b><?php if(isset($totaltax)) {  echo formatMoney($totaltax, true) ;}?></B></td>	</tr>
										<?php 
						if($display2=="yes"){
							?>
									
<tr><td id="mytitle" colspan="4"><B> CTL VAT  <?php $tax2rate=$configuration[0]['tax2rate']; if(isset($tax2rate)) {echo  round(formatMoney($tax2rate, true),1) ;}?>% :</B></td>
<td colspan="2" id="myalltitle"><b>															
<?php if(isset($totalvatcost2)) {  echo formatMoney($totalvatcost2, true) ;}?>
</B></td></tr>
<?php 
}
?>									
							<!--
								<tr><td colspan="3"><B>VATABLE AMT:</B></td><td align="right"><B><?php if(isset($totalvatcost)) { $vatable=($totalvatcost-$totaltax);echo formatMoney($vatable, true) ; }?></B></td>	</tr>

								<tr><td colspan="3"><B>EXEMPT  AMT:</B></td><td align="right"><B>	<?php if(isset($totalexemptedcost)) {  echo formatMoney($totalexemptedcost, true) ;}?></B></td>

-->
								</tr>

								
								<?php
									}
						}
									?>
								
		
		
							<tr>
								<td colspan="4" id="mytitle"> <B>TOTAL: </B></td>

								
								
<td colspan="4" id="myalltitle"><b><?php 

 $currency=$viewreceipt[0]['currency'];
 if( $currency!=""){   $currency.".";}

$mydiscount=$viewreceipt[0]['maindiscount'];  $total=$viewreceipt[0]['total']; if(isset($total)) {echo   formatMoney($total, true); }?></b></td>
											
							
							
							</tr>


							
							
							<?php if ($cash>0)
							{
								
							?>
								<tr>
								
								<td colspan="4" id="mytitle" ><b>CASH</b></td>
								
								<td colspan="2" id="myalltitle"><b>
							<?php
								if($mybalance > 0){
									 $ttcash=$cash+$mybalance;
									 echo formatMoney($ttcash, true);
								}else{
									// echo$cash;
									 echo formatMoney($cash, true);
								}
								
								
								?>
								</td></b>
							
							</tr>
							
							<?php 
							}
								
							?>
							
								<?php if ($card>0)
							{
								
							?>
								<tr>
								
								<td colspan="4" id="mytitle"><b>CARD</b></td>
								
								<td colspan="2" id="myalltitle"><b>
								<?php 
								 echo formatMoney($card, true);

								?></b>
								</td>
							
							</tr>
							
							<?php 
							}
								
							?>
								<?php if ($cheque>0)
							{
								
							?>
								<tr>
								
								<td colspan="4" id="mytitle"><b>CHEQUE</b></td>
								
								<td colspan="2" id="myalltitle"><b>
								<?php
				echo formatMoney($cheque, true);

								
								?></b>
								</td>
							
							</tr>
							
							<?php 
							}
								
							?>	<?php if ($mpesa>0)
							{
								
							?>
								<tr>
								
								<td colspan="4" id="mytitle"><b>MPESA: 		<?php echo $viewreceipt[0]['cashier'];?></b></td>
								
								<td colspan="2" id="myalltitle"><b>
								<?php 
								echo formatMoney($mpesa, true);
				
								
								?></b>
								</td>
							
							</tr>
							
							<?php 
							}
								
							?>	<?php if ($credit>0)
							{
								
							?>
								<tr>
								
								<td colspan="4" id="mytitle"><b>CREDIT</b></td>
								
								<td colspan="2" id="myalltitle"><b>
								<?php 
					echo formatMoney($credit, true);
		
								?></b>
								</td>
							
							</tr>
							
							<?php 
							}
								
							?>

	<?php if ($creditnote>0)
							{
								
							?>
								<tr>
								
								<td colspan="4" id="mytitle"><b>CREDIT NOTE</b></td>
								
								<td colspan="2" id="myalltitle"><b>
								<?php 
					echo formatMoney($creditnote, true);
		
								?></b>
								</td>
							
							</tr>
							
							<?php 
							}
								
?>



							<?php if ($voucher>0)
							{
								
							?>
								<tr>
								
								<td colspan="4" id="mytitle"><b>VOUCHER</b></td>
								
								<td colspan="2" id="myalltitle"><b>
								<?php
												echo formatMoney($voucher, true);
	
								
								?></b>
								</td>
							
							</tr>
							
							<?php 
							}
								
							?>	<?php if ($points>0)
							{
								
							?>
								<tr>
								
								<td colspan="4" id="mytitle"><b>L POINTS</b></td>
								
								<td colspan="2" id="myalltitle"><b>
								<?php
								
				echo formatMoney($points, true);

								?></b>
								</td>
							
							</tr>
							
							<?php 
							}
								
							?>
							
							
								<tr>
								
																<td colspan="4" id="mytitle" ><b>CHANGE</b></td>

								
								<td colspan="2" id="myalltitle"><b>
							<?php
								
									if(isset($mybalance)) {echo formatMoney($mybalance, true) ;}	
								?>
								</b></td>
							
							</tr>
								
									<?php
								
								$cashier=$viewreceipt[0]['cashier'];
								if($cashier !=""){
								?>
									<tr>
								
																<td colspan="4" id="mytitle" ><b>TRANSACTION CODE</b></td>

								
								<td colspan="2" id="mytitle"><b>
							<?php
								
									if(isset($cashier)) {echo $cashier ;}	
								?>
								</b></td>
							
							</tr>
								<?php
								}
								?>
								<?php
								
								$savedpoints=$viewreceipt[0]['savedpoints'];
								if($savedpoints !=0){
								?>
									<tr>
								
																<td colspan="4" id="mytitle" ><b>POINTS AWARDED</b></td>

								
								<td colspan="2" id="mytitle"><b>
							<?php
								
									if(isset($savedpoints)) {echo formatMoney($savedpoints, true) ;}	
								?>
								</b></td>
							
							</tr>
								<?php
								}
								?>
								
								
										<?php
								
								$savedcoins=$viewreceipt[0]['savedcoins'];
								if($savedcoins!=0){
								?>
									<tr>
								
																<td colspan="4" id="mytitle" ><b> SAVED COINS</b></td>

								
								<td colspan="2" id="mytitle"><b>
							<?php
								
									if(isset($savedcoins)) {echo formatMoney($savedcoins, true) ;}	
								?>
								</b></td>
							
							</tr>
								<?php
								}
								?>
								
								
								
								
								
								
	
							<?php
						
						if(	$display1=="yesS"){
						
						?>
							
								<tr>
								
								<td ><B>TAX RATE </B></td>
									<td ><B>VAT AMT 
							<?php 
						if($display2=="yes"){
							?>
							|| CTL
							<?php 
								}
							?>
									
									</B></td>
								
								
								<td colspan="2"><B>VATABLE AMT </B></td>
								
							<td colspan="2" ><B>EXMPT  AMT</B></td>
							
							</tr>
							
								<tr>
								<td id="mytitle"><b>
							<?php $tax1rate=$configuration[0]['tax1rate']; if(isset($tax1rate)) {echo round(formatMoney($tax1rate, true),1) ;}?>%
						<?php 
						if($display2=="yes"){
							?>
						||<?php $tax2rate=$configuration[0]['tax2rate']; if(isset($tax2rate)) {echo  round(formatMoney($tax2rate, true),1) ;}?>%

							<?php 
								}
							?>
						

								</b></td>
							
								
								<td id="mytitle"><b>
								<?php if(isset($totaltax)) {  echo formatMoney($totaltax, true) ;}?>
							
								

															<?php 
						if($display2=="yes"){
							?>
																||<?php if(isset($totalvatcost2)) {  echo formatMoney($totalvatcost2, true) ;}?>

							<?php 
								}
							?>
								</b>
								</td>
								<td colspan="2" id="mytitle"><b>
								
								
								
															<?php 
						if($display2=="yes"){
					if(isset($totalvatcost)) { $vatable=($totalvatcost-$totaltax-$totalvatcost2);echo formatMoney($vatable, true) ; }

								}else{
//echo formatMoney($myttvatable, true) ; 		
				echo formatMoney(($totalvatcost-$totaltax), true) ; 		
					
						}
							?>
						</b></td>
								<td colspan="2" id="mytitle"><b>
								<?php if(isset($totalexemptedcost)) {  echo formatMoney($totalexemptedcost, true) ;}?>
								
																<?php if(isset($totaltax)) {  ",". formatMoney(($totaltax+$vatable), true) ;}?>

								
								
								</b>
								</td>
							</tr>
								<?php
									}
										
									?>
									
								
								<?php
							 $mydescription=$viewreceipt[0]['description']; 
									if(	 $mydescription !=""){					 
							?>
								<tr>
								
								<td colspan="6" id="mytitle">
								<b>
								
							<?PHP
							 echo   $mydescription; 
							
							?>
							</b>
								</td>
								
							
							
							</tr>
										
							<?php
							 }
							 ?>
							
							
							
					
								
	





								</b>
							</td>
							
							</tr>
							
							
							
							
							
							
							
							
							
							
									
									
									
									
									
									
									
																					<tr><td colspan="6" id="mytitle" ><?php $tillno=$configuration[0]['tillno']; if(isset($tillno)) {echo   $tillno; }?></td></tr>

																<tr>	<td colspan="6"><H3>
																<?php 
															 if( $countbranch>1){
																 
																 
															


																		// $mytype=$c->type;

													 $branches= $this->usermodel->populateall('branch','id',$branchid);



								if(is_array($branches)) {

								   foreach($branches as $branches){

								  // echo "<b>(".strtoupper($branches->name).")</b>";
								 
								 
								}
								
								} else {
									
							echo '<b>( No  Branch )</b>';

								}
			 }
								
																										
																   
																   

																?></H3> </td></tr>

							
					  
								 
									</tbody>
									
									
					</table>
			<div style="text-align: left; margin-top: 8px; text-size:12px ">
			<p>
					 <?php
					 
						$barcode=$configuration[0]['barcode']; 
						
						
					
																	 if(isset($invoiceid) && ($barcode=="yes")) {  
																	 ?>
																	 <center>
								<img src="<?php echo base_url().'Systemusers/barcode/'.$invoiceid; ?>" alt="">
																	 </center>

																	 <?php
																	}

																	
																	?>
																
<?php $returnpolicy=$configuration[0]['returnpolicy']; if(isset($returnpolicy)) {echo   $returnpolicy; }?>

			<center style="text-align: center; text-size:16px ">
</br><b>
SERVED BY:
																<?php $myuserid=$viewreceipt[0]['userid']; $myuser=$this->usermodel->populateallarray('people','id', $myuserid);
								$myfirstname=$myuser[0]['firstname'];
							echo strtoupper($myfirstname);?>
																
								</b>	</center>								</p>
																	
																	
<b> <center>BY ROBISEARCH LTD(0780655987)<center></b><br>
.............*******...............
</div>
					
					
					
					
				</div>
			</div>
			</div>
		</div>
  
  </div>
 </div>
 </div> 
			

		
	<script type="text/javascript">


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

		
	
