    

   <style type="text/css">
		 #printreceipt { font-size: 1.5em;         font-weight: bold;
}


  

    #printable { display: none; }

    #myprint { display: none; }
#print{  	


    background-repeat: no-repeat;
	font-size;12px;
  
    


}


#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:16; width:100%; }
		    	#myprint { display: block; font-size:16; width:100%; }

    }
    </style>


	
	
	
	
	
	
	
	
	
    </style>
	<script>

 

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

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


}
	</script>








<ul class="nav nav-tabs bordered" id="non-printable">
			<li class="active">
            	<a href="#list" data-toggle="tab"><i class="entypo-menu"></i> 
					
					<form name="print" method="post" action="">
<input type="submit" id="print"  accesskey="p" class="btn btn-primary"  name="print"onclick="printDiv('printableArea')" value="Click here to Print" />
</form>
                    	</a></li>
							<li>
            	<a href="#customer" data-toggle="tab"><i class="entypo-plus-circled"></i>
	
				 <a   class="btn btn-primary" href="<?php echo base_url(); ?>admin/viewpallmyplots">Next booking </a>
                    	</a></li>
			
						
						
						
		</ul>
    	<!------CONTROL TABS END------>
        
		<div class="tab-content">
            <!----TABLE LISTING STARTS-->
            <div class="tab-pane box active" id="list">
				
     


 <div class="panel panel-primary" data-collapsed="0" >
  <div id="printableArea">

  <?php 
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;
					}
									
 
    $postedtime = date('Y-m-d');
		$currenttime = date('h:i:sa');
 		$dateposted =  ($postedtime)." ".$currenttime ;	
 //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'];
      $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
$data['usertype'] = $session_data['usertype'];
   $usertype=$data['usertype'];

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

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

	 $symbol=$profile[0]["currencysymbol"];
$multicurrency=$profile[0]["currency"];

	 
	 
	 
	 
$ttfood=0;
$ttpaid=0;
$ttexpected=0;


			

  	//echo $this->session->flashdata('msg'); 
		if(validation_errors()):
		 endif;
 if(!is_array($mypayment)) 

 {




    
       echo '<div class="alert alert-warning text-center">There is no Payment found by now from system..Try again</div>';
   
    }else {
?>
    
             <?php 
  
  	foreach ($mypayment as $row): 

		$cash= $row->amount; 
				$mpesa= $row->mpesa; 
				$card= $row->card; 
							 $mpesa=$row->mpesa; 
							  $card=$row->card; 
								$voucher=$row->voucher; 
							 $credit=$row->credit; 
							  $cheque=$row->cheque; 
							  $points=$row->points; 
							  $roomtype=$row->roomtype; 
							    $total=$row->total;
							  $discount=$row->discount; 

							$totalpaid=$cash+$mpesa+$card+$voucher+$cheque+$points;

				$user=$row->userid; 
				
				
				
				
				
				
				
				
				
				
				
				
				
				

             ?>
	
 <table  align="center" width="100%" id="printreceipt" >

		<tr>
			<td colspan="2">
			<div style="text-align:center; " >
							
			

			<?php
$img1='uploads/';
	$url = base_url().$img1.$img;
	
if($photo!=""){
	
	?>
	
 <div>

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

</div>
<?php
 
 }
 ?>
 
 
			   <p>
			   <p style="margin-center;"><B>

<?php

if($row->paymentmode=="Credit"){
	//echo "HOUSE INVOICE";
	
}
	echo "HOUSE RECEIPT";
	

?>
							
							
							
							
							</B></p>
			
			
			  <center>
					<b>
						<?php 
																				 $countbranch=$this->usermodel->countbranches($companyid);

										 if( $countbranch>1){
									$mybranches= $this->usermodel->populateallarray('branch','id',$branchid);
									$branchdescription=$mybranches[0]['description']; if(isset($branchdescription)) {echo   $branchdescription; }


										}else{
									$bussinessname=$configuration[0]['businessname']; if(isset($bussinessname)) {echo   $bussinessname; }
 
											 
										 }
										?>
					</b>
				</center>
			  </p>

		

			</div></td>
			
		</tr>
		
		
		<tr>
			<td><B>RECEIPT NO:</B></td>
			<td >:<?php echo"RM".$row->id ; 
			
			
			?></td>
		</tr>
		
		
										 
										 <?php



 $roomsales = $this->usermodel->populatealldatanoarrayfour('roomsales','houseno', $houseno,'plotno', $plotno,'description', $row->id,'customerid', $row->tenantid);			   

				
				
				
				
				
 if(!is_array($roomsales)) 

 {


  		   $ttfood= 0;

    }else {
?>
    
			<tr>
			
			<td>Extra Charges</td>
				 <td>
             <?php 
  $mytotal=0;
  	foreach ($roomsales as $myrow){ 

		   $mytotal=$mytotal+$myrow->total;
		   $ttfood= $mytotal;
	}
	
		if(isset($mytotal)) {echo   formatMoney($mytotal, true); }
?>

				</td>
		</tr>
		
		  <?php 
	}
			?>		


			
		
		
		
			
							<tr>
							<td COLSPAN="2"><b>
							<hr  style="height:1px;border:none;margin:0;color:#333;background-color:#333;"/>
							
								</b></td>
							
							</tr>
							
						
		<tr> 
		<td colspan ="2"></br>
				<table>

											
  <table cellpadding="0" cellspacing="0" border="0" class="table  table-striped" id="example2" style="border-color:#CCCCCC; width:100%;"  >

             <thead>
         <tr>
   
     <th style="width:30%">Item Name</th>
	   
	<th>Cost</th>	
		<th>Disc</th>	
  <th>Days</th>	
    <th>Pax</th>	
  <th>Total</th>	

	  
	

                 </tr>
           
<?php



        		//$roomcharges = $this->usermodel->populateallstatus('dailycharges','transactioncode', $itemid,'id >', 0);

				
				
				
				
				
				
 if(!is_array($roomcharges)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='4'>";
    
       echo '<div class="alert alert-warning text-center">There no records found..</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    
             <?php 
  $ttamount=0;
   $ttdiscount=0;
  	foreach ($roomcharges as $c){

		 
$ttdiscount=$ttdiscount + $c->discount;
             ?>



             <tr>
                
            <?php 
$id=$c->id;


?>

              

  <td><?php 
  
  
  if($c->type=="room"){
		   $mycheckname = $this->usermodel->populateallarray('charges','id',$c->code);


if($mycheckname[0]["type"] !=""){
	echo $mycheckname[0]["type"];
}else{
	
	echo $c->name ;
}

  }else{
	  
	  //echo"---------". $c->type;

		   $checkname = $this->usermodel->populateallarray('products','code',$c->code);


if($checkname[0]["name"] !=""){
	echo $checkname[0]["name"];
}else{
	
	echo $c->name ;
}
  }


  $ttamount=$ttamount+$c->amount;

  ?></td>
     <td><?php echo $c->sprice ; ?></td>
		 
		 <td ><?php 
if($c->discount< 0){
	echo "0";
}else{
	echo $c->discount ; 
}



?></td>

     <td><?php echo $c->qty ; ?></td>
	  <td><?php echo $c->uomqty ; ?></td>
     <td><?php echo $c->amount ; ?></td>

		 

 
 
		
		 
             </tr>

	<?php
	}
	?>
	
	<tr>
<td colspan="5"> <b>Total amount:</b></td>
<td > 	<b>	 <?php echo $ttamount ?></b></td>
<td></td>
</tr>
	
	
	<?php
	
	} 
	
	?>
	
		</table>
		</td>
		</tr>
		
							
							
							
							
							
							
							
							
							
							
							
			
		
		
		
			<?php

		 $ttexpected=(($total)+$ttfood);
		if(isset($ttexpected)) {   formatMoney($ttexpected, true); }

								//$ttexpected=$total+$ttfood;





$taxtype=$plotnames[0]['taxtype'];


			if ($taxtype !="No")
							{
								
							?>
							
							
							
							
									<tr>
								
								<td><b>Sub Total</b></td>
								
								<td><b>:<?php 
								 $tax1rate=$configuration[0]['tax1rate'];
							
							$ttvat=($tax1rate*$ttexpected)/(100+$tax1rate);
									$SubTotal=$ttexpected-$ttvat;
						echo formatMoney($SubTotal , true);		
								?>
								
								
								</td></b>
							
							</tr>	
							
							
							
							
			
					
	
			<tr>
		
		
				
			
<td>Vat <?php


echo $tax1rate;     ?> %</td>

			<td>:<?php	 formatMoney($ttvat , true);
	echo formatMoney($row->tax1 , true);
			?></td>
		</tr>
	
					<tr>
		
		
				
			
<td>Cat .Levy <?php $tax2rate=$configuration[0]['tax2rate'];


echo $tax2rate;     ?> %</td>

			<td>:<?php	echo formatMoney($row->tax2 , true);

			?></td>
		</tr>					
							
							
					
							
							
							
							
						
								
							
						
							
							
							
							
							<?php 
							}
								
							?>
						
						
						
							<tr>
			
			<td><b>Grand Total </b></td>
			<td><b><b>:<?php   $row->currency."";
		if(isset($ttexpected)) {echo   formatMoney($ttexpected, true); }


			?></b></td>
		</tr>
						
						
						
						
						
						
						
						
							
							<?php if ($cash>0)
							{
								
							?>
								<tr>
								
								<td><b>Cash</b></td>
								
								<td><b>:<?php if(isset($cash)) {echo   formatMoney($cash, true); }

								
								?>
								</td></b>
							
							</tr>
							
							<?php 
							}
								
							?>
							
								<?php if ($card>0)
							{
								
							?>
								<tr>
								
								<td><b>Card</b></td>
								
								<td><b>:<?php echo$card?></b>
								</td>
							
							</tr>
							
							<?php 
							}
								
							?>
								<?php if ($cheque>0)
							{
								
							?>
								<tr>
								
								<td><b>Cheque</b></td>
								
								<td><b>:<?php echo$cheque?></b>
								</td>
							
							</tr>
							
							<?php 
							}
								
							?>	<?php if ($mpesa>0)
							{
								
							?>
								<tr>
								
								<td><b>Mpesa</b></td>
								
								<td><b>:<?php echo$mpesa?></b>
								</td>
							
							</tr>
							
							<?php 
							}
								
							?>	<?php if ($credit>0)
							{
								
							?>
								<tr>
								
								<td><b>Credit</b></td>
								
								<td><b>:<?php echo$credit?></b>
								</td>
							
							</tr>
							
							<?php 
							}
								
							?>	<?php if ($voucher>0)
							{
								
							?>
								<tr>
								
								<td><b>Voucher</b></td>
								
								<td><b>:<?php echo$voucher?></b>
								</td>
							
							</tr>
							
							<?php 
							}
								
							?>	<?php if ($points>0)
							{
								
							?>
								<tr>
								
								<td><b>L Points</b></td>
								
								<td><b>:<?php echo$points?></b>
								</td>
							
							</tr>
							
							<?php 
							}
								
							?>
							<tr>
		<td COLSPAN="2"><b>
							<hr  style="height:1px;border:none;margin:0;color:#333;background-color:#333;"/>
							
								</b></td>
							
							</tr>
							
							
									
			<?php
								 if(( $multicurrency=="yes")&& (trim($rooms[0]['othercurrencyamount']) !=0)){	
 $othercurrency=$rooms[0]['othercurrency'];


								 
							?>
								<tr>
								
								<td id="mytitle"><b>PAID IN  (Currency)</b></td>
								
								<td  id="myalltitle"><b>
								<?php 
								 if( $othercurrency!=""){  echo ":".$othercurrency ."(".$rooms[0]['othercurrencyamount'].")"; }else{ echo$rooms[0]['currency']; }

								?></b>
								</td>
							
							</tr>
							
							<?php 
							}
								
							?>					
										<?php if($discount>0){ ?>
		<tr>
			<tr>
			
			<td><b>Discount </b></td>
			<td><b>:<?php echo $discount; ?></b></td>
		</tr>	
			
		
		<?php  }?>
	
		
			<?php 
							$balance=($ttexpected-($totalpaid));

			
			if($balance!=0){ ?>
	
			<tr>
			
			<td><b>Balance </b></td>
			<td><b><?php
		if(isset($balance)) {echo   formatMoney($balance, true); }


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

   <?php 
   }
   

	
  ?>
 
  	
		
		
		
		
		
		
				<tr>
		
				<td colspan="2"></br></td>
		</tr>
		
		
		<!--
			<tr>
			<td >Date	Booked </td>
				<td>:<?php
												   	echo   $dateposted = date("d/m/Y H:i:a", strtotime($dateposted));


				?></td>
		</tr>
		
		-->
		
			<tr>
		<td COLSPAN="2"><b>
							<hr  style="height:1px;border:none;margin:0;color:#333;background-color:BLACK;"/>
							
								</b></td>
							
							</tr>
				<tr>
			
			<td>Customer Name</td>
						 		<td>: <?php  $tenantid=$row->tenantid ; 
				 
				 
					$tenantsid = $this->usermodel->populateallarray('people','id',$tenantid);



   echo $tenantsid[0]["firstname"]." ". $tenantsid[0]["lastname"]." ". $tenantsid[0]["company"]; 
    


				 
				 
				 
				 
				 
				 ?></td>
						
					
						
		</tr>
		
	<tr>
			<td>ID No </td>
				<td>:<?php 
   echo $tenantsid[0]["idno"];


				?></td>
		</tr>
		<tr>
			<td>Customer Pin </td>
				<td>:<?php 
   echo $tenantsid[0]["idnumber"];


				?></td>
		</tr>
	
		<tr>
			<td>Phone No</td>
				<td>:<?php 
 echo $tenantsid[0]["phone"];

				?></td>
		</tr>
		
			<tr>
	
			
			<td>Other customer /description </td>
			<td>:<?php echo $row->description; ?></td>
		</tr>
			<!--

			<tr>
			<td>Country </td>
				<td>:<?php 
									
										
					$country = $this->usermodel->populateallarray('nation','id',$tenantsid[0]["country"]);
	 echo $country[0]["name"];

				?></td>
		</tr>
	<tr>
			<td>County </td>
				<td>:<?php 
									
					$county = $this->usermodel->populateallarray('county','id',$tenantsid[0]["county"]);
	 echo $county[0]["name"];

				?></td>
		</tr>
	
			 -->  
					
		
		
		
	<tr>
			<td>Check In</td>
				<td>:<?php 
												   	echo   $createdat = date("d/m/Y H:i:a", strtotime($row->createdat));


				?></td>
		</tr>
	
	
	<tr>
			<td>Check out </td>
				<td>:<?php  
												   	echo   $checkoutdate = date("d/m/Y H:i:a", strtotime($row->checkoutdate));


				
				?></td>
		</tr>
		<!--
		<tr>
			
			<td>House Name </td>
			<td>:<?php echo $plotnames[0]['name'] ; ?></td>
		</tr>
		-->

		<tr>
			
			<td>Room No</td>
			<td>:<?php echo $row->houseno ; ?></td>
		</tr>
		
		
		
		<tr>
			
			<td>Days Booked</td>
			<td><?php  $row->number ; ?></td>
		</tr>
	
		
		
		
	
		
		
			<tr>
			
			<td>Status </td>
			<td>:<?php echo $row->paymentstatus; ?></td>
			
		</tr>
			

		
	
		

		<tr>
			
			<td><br><b>Served BY </b></td>
			<td><b><?php
        		$SERVEDBY = $this->usermodel->populateallarray('people','id',$user);
	$myname=$SERVEDBY[0]['firstname'];
			echo $myname; 
			
			
			?></b></td>
		</tr>
		
		
	


             <?php endforeach; ?>

              <?php }?>
			  	</table>
	<div style="text-align: left; text-size:16px ">
	<h3 style="padding:2px;margin:1px;">
		<?php $returnpolicy=$configuration[0]['returnpolicy']; if(isset($returnpolicy)) {echo   $returnpolicy; }?><br>

Developed by Robiseach LTD (0780655987)<br>
.............*******...............
</h3>
</div>

</div>
		</div>
		
		</div>
		</div>
		</div>	  
		
		<script type="text/javascript">


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

	