
    <html moznomarginboxes mozdisallowselectionprint>

   <style type="text/css" media="print">
@media print {
    a {
        display:none;
    }
 }

 @media screen and projection {
    a {
        display:inline;
    }
  }  @media print
    {
		
		    	#logo { width:100%";font-size:12;margin-top:0; margin-bottom:0;}

		
    	#non-printable { display: none; }
		 	#href{ display: none; }
    	#printableArea { display: block; font-size:12;margin-top:0; margin-bottom:0;


    margin: 0 ;
    overflow: hidden;  
		}
		
	
	a[href]:after {
        content: none !important;
    }
    }
    </style>
	<script>

 

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


}
	</script>





<ul class="nav nav-tabs bordered" id="non-printable">
			<li class="active">
            	<a href="#add" data-toggle="tab"><i class="entypo-menu"></i> 
			View House Details
                    	</a></li>
						
							<li>
            	<a href="#list" data-toggle="tab"><i class="entypo-plus-circled"></i></a>
			
				 <a href="<?php echo base_url(); ?>user/searchstatement">	Go back
                    	</a></li>
			
				<li>
            	<a href="#print" data-toggle="tab"><i class="entypo-plus-circled"></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>
		</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">
<table cellspacing="1" border="0" width="100%" >
 
	<tr>
	<td width="10%">
		
			<div id="non-printable">
				<?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['branchid'] = $session_data['branchid'];
	 $branchid = $data['branchid'];
   		
  // $todate = "1998-08-14";

      	$businessconfiguration = $this->usermodel->populateallarray('smsconfig', 'id',$companyid);
  // $today->modify('-1 month');
   	$configuration = $this->usermodel->populateallarray('plot', 'id',$plotno);



$servicedeposit=$configuration[0]['servicedeposit']; 

$displaylease=$configuration[0]['lease']; 
						$displayservices=$configuration[0]['service']; 

						$displayareas=$configuration[0]['areas']; 
						$displaycoparent=$configuration[0]['coparent']; 
												$displaywater=$configuration[0]['water']; 

												$displaygarbage=$configuration[0]['garbage']; 

												$displaypower=$configuration[0]['power']; 
												$displaypartial=$configuration[0]['partial']; 

   						$displaypenalty=$configuration[0]['showpenalty']; 
					$maintax=$configuration[0]['tax']; 

					//$profile= $this->usermodel->populateimages($userid);
					
					
					 $session_data = $this->session->userdata('logged_in');

   

								//$profile = $this->usermodel->populateall('smsconfig','id',$companyid);
					
					
					
					
		
				$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  id="non-printable"  style="margin:0px; width:100%" ><center>
<img  src="<?php echo $url ?>" width="150px" id="logo" style="border-radius:4px;margin:0px;  ">		 
</center>
</div>



	 <?php }else{
		 ?>

				<?php
	 }
		 endforeach; ?>

              <?php }?>
			  </div>
			</td>
			
	
		
	<td width="10%">
	<center>
					
					
				<?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=$businessconfiguration[0]['businessname']; if(isset($bussinessname)) {echo   $bussinessname; }
 
											 
										 }
										?>	
					
					
		</center>	
		</td>
		</tr>
		</table>
		<table cellspacing="1" border="0" width="100%" >

		
		
		<tr>
			<td >				
			<p style="font-size:12px;"><B>OFFICIAL STATEMENT FOR  <?php echo strtoupper($plotnames[0]['name']) ." ( ". $plotno ." )"; ?></B></p>
</td>
			<td></td>
		</tr>
		
		
			
		<tr>
			<td style="font-size:12px;"><B>RENT REMITTANCE FOR THE MONTH OF  <?php  	$month = date("F",strtotime($todate));  echo strtoupper($month); ?> <?php  echo $YEAR = date("Y",strtotime($todate));; ?></B></td>
					<td style="font-size:12px;" width="20%"><B>DATE PRINTED: <?php echo $date = date("Y-m-d"); ?> </B></td>
			
		</tr>
		
				
		
		
		
	
 
 
 
 
 
 
 </table>
 
 
<table cellspacing="1"  border="1" width="100%">
             <thead>
			
         <tr>
		    <th>S/N</th>
		   <th>ROOM NO </th>
    	<th>NAME OF TENANT </th> 
  		
			<?php
						
						if(	$displayareas=="yes"){
							?>
	<th>ARREAS</th> 
							  <?php
							   }
							?>
		
			<?php
	if(	$servicedeposit=="yes"){
							?>
	<th>S.CH.Dep</th> 
			 <?php
			 }
			?>
				<?php
	if(	$displayservices=="yes"){
							?>
	<th>S.CH</th> 
			 <?php
			 }
			?>
	<?php
	if(	$displaylease=="yes"){
							?>
	<th>LEASE</th> 
			 <?php
			 }
			?>
			
						<?php
			if(	$displaywater=="yes"){
							?>
	<th>WATER</th> 
							  <?php
							   }
							   ?>
							
							
							
						<?php
			if(	$displaygarbage=="yes"){
							?>
	<th>GARBAGE</th> 
							  <?php
							   }
							   ?>
							
							
							
								<?php
						
						if(	$displaypower=="yes"){
							?>
		<th> POWER</th> 							  <?php
							   }
							?>	
							
								
								<?php
						
						if(	$displaypartial=="yes"){
							?>
		<th>PARTIAL PAYMENT</th> 
		
		<?php
							   }
							?>	
								
	


						<?php
			if(	$displaywater=="yes"){
							?>
	<th>WATER/P DEPOSIT</th> 
							  <?php
							   }
							   ?>
		<th> HOUSE DEPOSIT </th> 
 
	 	<th>MONTHLY RENT </th> 
		
					<?php
						
						if(	$displaycoparent=="yes"){
							?>
	<th>COPARENT</th> 
							  <?php
							   }
							?>
					<?php
						
						if(	$displaypenalty=="yes"){
							?>
	<th>PENALTY</th> 
							  <?php
							   }
							?>
							<th>TT BILL</th> 
					<th>TT PAID</th> 

								<th>TT BAL</th> 

                 </tr>
             </thead>
<?php
			function MyformatMoney($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;
					}	


		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;
					}
				  $grandtotal=0;
				  $TOTALCOMM=0;		
				  				  $TTEXPECTED=0;		

   $totalbf=0;
     $grandvat=0;
	   $ppgrandvat=0;
    $grandcommission=0;
	    $ppcommission=0;
		 $ttareas=0;
		  $ttpaid=0;
	echo $this->session->flashdata('msg'); 
		if(validation_errors()):
		 endif;
 if(!is_array($invoice)) 

 {



 
    }else {
?>
    
             <?php 

		   		   $totalservicesdeposit=0;
		   		   $totallease=0;

 $totalbalance=0;
   $totalinvoice=0;
      $totalpayment=0;
	   $balanacefoward=0;
	
	    $totaldeposites=0;
		   $totaldeposite=0;
				   $totalcoparent=0;
		$totalpenalty=0;
		   $totalwater=0;
		   		   $totalcservices=0;

		     $totalpower=0;
			 		     $totalgarbage=0;
$myinvoice=0;
		  	$counter = 0;  	 
			//$myfinaltotal2=++$counter;
		   $totalelectricity=0;
		 
  	foreach ($invoice as $c): 
		$totalinvoice=$totalinvoice +  $totalinvoice=$c->amount;
		$totalpayment=$totalpayment +	$totalpayment=$c->paid;
		
							     $getallinvoices = $this->accomodationmodel->getallinvoices($c->plotno,$c->houseno,$fromdate,$todate,$c->tenantid,$displaytype);

						  

             ?>



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

?>
<td><?php echo $counter ; ?></td>
<td><?php echo $c->houseno ; ?></td> 
                	         <td><?php 
					$tenantavalable = $this->accomodationmodel->tenantavailable($c->plotno,$c->houseno); 
					  $total=0;
					if(is_array($tenantavalable)) {

   foreach($tenantavalable as $tenantavalablerow){
	   $tenantid= $tenantavalablerow->tenantid ; 
				    $tenants = $this->accomodationmodel->gettenantbyid($tenantid);
 if(is_array($tenants)) {
   foreach($tenants as $tenantsrow){

  $names=$tenantsrow->lastname. " ".$tenantsrow->firstname ; 
   							echo strtoupper($names);?>

   

   

   
   <?php
    

}
    } else {
 
}

}



} else {
    echo 'vacant.';
}
					

	$myttpaid=0;
								//
															     $getallreceipts = $this->accomodationmodel->getallpayments($c->plotno,$c->houseno,$fromdate,$todate,$c->tenantid);

								  if(is_array($getallreceipts)) {
					   foreach ($getallreceipts as $cgetallreceipts){
						   
						   $myttpaid=$myttpaid+$cgetallreceipts->amount;
						if($cgetallreceipts->paymentcode !=""){
							echo ",".$cgetallreceipts->paymentcode;
						}
					  
					  
					  
	
	                                 
										}
								// echo MyformatMoney($ttpaid,true);
	
										
										}
										


?>
				 
				 
		</td>
		
		
			<?php
						$mybalanacefoward=0;
						if(	$displayareas=="yes"){
							?>
								<td>
					   <?php
					     $currentbalance = $this->accomodationmodel->getplothouseinvoicewithbalance($c->plotno,$c->houseno,$c->tenantid, $fromdate,$displaytype);


					    if(is_array($currentbalance)) {
					   foreach ($currentbalance as $ccurrentbalance){
						   ?>
					  <?php 
					  
					  // $mybalanacefoward=$ccurrentbalance->myamount;
					  
					    $totalpaid = $this->accomodationmodel->getallpaid($c->plotno,$c->houseno,$fromdate,$c->tenantid);
						$allpaid=$totalpaid[0]["amount"];
					   $mybalanacefoward=$ccurrentbalance->myamount-$allpaid;
					    echo MyformatMoney($mybalanacefoward,true);
					  
					  ?>
	
	                                  <?php  
										}}
									?></td>
							  <?php
							   }else{
								   					 

								$mybalanacefoward=0;   
								   
							   }
					  $balanacefoward= $balanacefoward+$mybalanacefoward;
							   
							   
							?>	
		
		
		
		
 	   <?php  
	if(	$servicedeposit=="yes"){
?>         
<td>
					   <?php
					     $myservicesdeposit = $this->accomodationmodel->getstatementbytype($c->plotno,$c->houseno,$fromdate,$todate,'18',$c->tenantid);


					    if(is_array($myservicesdeposit)) {
					   foreach ($myservicesdeposit as $cmyservicesdeposit){
					
						   
					
						   							echo MyformatMoney($cmyservicesdeposit->amount,true);

						  
						   	$totalservicesdeposit= $totalservicesdeposit+$cmyservicesdeposit->amount;

					
					  
					  
					  ?>
	
	                                  <?php  
										}}
										 
 				
									?>
									
									
									</td>
									<?php  
										}
 				
									?>
		
		
 	   <?php  
	if(	$displayservices=="yes"){
?>         
<td>
					   <?php
					     $myservices = $this->accomodationmodel->getstatementbytype($c->plotno,$c->houseno,$fromdate,$todate,'19',$c->tenantid);


					    if(is_array($myservices)) {
					   foreach ($myservices as $cservices){
					
						   
					
						   							echo MyformatMoney($cservices->amount,true);

						  
						   	$totalcservices= $totalcservices+$cservices->amount;

					
					  
					  
					  ?>
	
	                                  <?php  
										}}
										 
 				
									?>
									
									
									</td>
									<?php  
										}
 				
									?>
		
		
 	   <?php  
	if(	$displaylease=="yes"){
?>         
<td>
					   <?php
					     $myleases = $this->accomodationmodel->getstatementbytype($c->plotno,$c->houseno,$fromdate,$todate,'9',$c->tenantid);


					    if(is_array($myleases)) {
					   foreach ($myleases as $cmyleases){
					
						   
					
						   							echo MyformatMoney($cmyleases->amount,true);

						  
						   	$totallease= $totallease+$cmyleases->amount;

					
					  
					  
					  ?>
	
	                                  <?php  
										}}
										 
 				
									?>
									
									
									</td>
									<?php  
										}
 				
									?>
		
		
 	   <?php   if(	$displaywater=="yes"){
							?>         
<td>
					   <?php
					     $mywater = $this->accomodationmodel->getstatementbytype($c->plotno,$c->houseno,$fromdate,$todate,'5',$c->tenantid);


					    if(is_array($mywater)) {
					   foreach ($mywater as $cwater){
					
						   
					
						   							echo MyformatMoney($cwater->amount,true);

						  
						   	$totalwater= $totalwater+$cwater->amount;

					
					  
					  
					  ?>
	
	                                  <?php  
										}}
										 $newtodate
 				
									?>
									
									
									</td>
									<?php  
										}
 				
									?>
									
													<?php
			if(	$displaygarbage=="yes"){
							?>

							
										<td>
					   <?php
					     $mygarbage = $this->accomodationmodel->getstatementbytype($c->plotno,$c->houseno,$fromdate,$todate,'7',$c->tenantid);

					    if(is_array($mygarbage)) {
					   foreach ($mygarbage as $cmygarbage){
						   
						
						   
	 $totalgarbage=$totalgarbage+$cmygarbage->amount;
echo MyformatMoney($cmygarbage->amount,true);	
										}}
										 
 				
									?></td>
									
									  <?php
							   }
							   ?>
									
									
									
									
									
									
									
												<?php
					
						if(	$displaypower=="yes"){
							?>
								
									
									
									<td>
					   <?php
					     $mypower = $this->accomodationmodel->getstatementbytype($c->plotno,$c->houseno,$fromdate,$todate,'10',$c->tenantid);


					    if(is_array($mypower)) {
					   foreach ($mypower as $cmypower){
						   
						  
					
						   	 $totalpower=$totalpower+$cmypower->amount;
						echo MyformatMoney($cmypower->amount,true);
										}}
										 
 				
									?></td>
									
										  <?php
							   }
							?>	
									
									
											<?php
						
						if(	$displaypartial=="yes"){
							?>

									<td>
					   <?php
					   
					  
					   $mynewtodate = strtotime ( '-1 month' , strtotime ( $todate ) ) ;
					$newtodate = date ( 'Y-m-d' , $mynewtodate );
 
$mynewfromdate = strtotime ( '-1 month' , strtotime ( $fromdate ) ) ;
$newfromdate = date ( 'Y-m-d' , $mynewfromdate );

					   					     $BF = $this->accomodationmodel->getstatementbytype($c->plotno,$c->houseno,$fromdate,$todate,'6',$c->tenantid);


					    if(is_array($BF)) {
					   foreach ($BF as $cbf){

   
   
   
					    $ppcommission= $ppcommission+$cbf->commission;
							$grandvat= $grandvat+$cbf->vat;
							echo MyformatMoney($cbf->amount,true); 
							 $totalbf=$totalbf+$cbf->amount;
					   
					   
					
					   
						  

						  
										}}
									?></td>

		
		
		<?php
							   }
							?>	
					









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

								<td>
					   <?php
					     $myelectricity = $this->accomodationmodel->getstatementbytype($c->plotno,$c->houseno,$fromdate,$todate,'3',$c->tenantid);

					    if(is_array($myelectricity)) {
					   foreach ($myelectricity as $cmyelectricity){


							 
							 $totalelectricity=$totalelectricity+$cmyelectricity->amount;

						 echo MyformatMoney($cmyelectricity->amount,true);
						
										}}
									?></td>

	
							  <?php
							   }
							   ?>



									<td>
					   <?php
					   $deposites=0;
					     
					 $mydeposit = $this->accomodationmodel->getstatementbytype($c->plotno,$c->houseno,$fromdate,$todate,'2',$c->tenantid);

					    if(is_array($mydeposit)) {
					   foreach ($mydeposit as $cdeposit){
						
					
						     $totaldeposite=$totaldeposite+$cdeposit->amount;
					   $deposites=$cdeposit->amount;

						 echo MyformatMoney($cdeposit->amount,true);
										}}else{
											
									$deposites=0;		
										}
										
										
										 $totaldeposites=$totaldeposites+$deposites;
									?>
					       </td> 
               
				       <td><?php 
					   	  
					   $rental=0;
							 $myrent = $this->accomodationmodel->getstatementbytype($c->plotno,$c->houseno,$fromdate,$todate,'1',$c->tenantid);

					    if(is_array($myrent)) {
					   foreach ($myrent as $cmyrent){
						
					
						   	$grandtotal= $grandtotal + $cmyrent->amount;
					     
					   $myvat=$cmyrent->vat;
					   
					   $mycommission=$cmyrent->commission;
					   
					   $grandvat=$grandvat + $myvat;
					 $grandcommission=$grandcommission+$mycommission;
				   $rental=$cmyrent->amount;

						 echo MyformatMoney($cmyrent->amount,true);
										}}					
	
		
	
			
		
		
	//echo	$c->paymentcode;
	
					   ?></td> 
					<?php
						
						if(	$displaycoparent=="yes"){
							?>
							<td>
	<?php 
	
	
	
	
	
	
	
	
					$totalcoparent=$totalcoparent+$c->coparent;
							 echo MyformatMoney($c->coparent,true);
							?>
	</td>
							  <?php
							   }
							?>
         				<?php
						
						if(	$displaypenalty=="yes"){
							?>
							<td>
	   <?php
					     $mypenalty = $this->accomodationmodel->getstatementbypenalty($c->plotno,$c->houseno,$fromdate,$todate,'4',$c->tenantid);

					    if(is_array($mypenalty)) {
					   foreach ($mypenalty as $cmypenalty){
						   
						   $totalpenalty=$totalpenalty+$cmypenalty->amount;
						   	 //$totalwater= $totalwater+$totalwater;

						   ?>
					  <?php echo MyformatMoney($cmypenalty->amount,true);
					  
					  
					  
	
	                                 
										}}
										?>
									</td>
	
	
	
							  <?php
							   }
							?>
								

								<td>
								<?PHP
								//$myinvoice= $getallinvoices[0]["amount"];
				if($displaytype !="all"){
								$myinvoice=$rental+$deposites+$mybalanacefoward;

	
					}else{
														//$myinvoice=$ $rental+$balanacefoward;

																	$myinvoice=$getallinvoices[0]["amount"]+$mybalanacefoward;

			
					}
								
 $TTEXPECTED=$TTEXPECTED+$myinvoice;	
								   echo MyformatMoney($myinvoice,true);	
					 
								?>
								
								
								</tD> 
								
							
										<td>
								<?PHP
								
							
								
							$ttpaid=$ttpaid+$myttpaid;
								 echo MyformatMoney($myttpaid,true);
								?>
								
								
								</tD> 
									
									
									
									
										<td>
								<?PHP
								
								$TTBALANCE=$myinvoice-$myttpaid;
								
								
								if($TTBALANCE<0){
																	$TTBALANCE=0;

								}else{
																$TTBALANCE=$TTBALANCE;
	
									
								}
								$totalbalance=$totalbalance+$TTBALANCE;
				  echo MyformatMoney($TTBALANCE,true);
								?>
								
								
								</tD> 
									
									

            
             </tr>

     <?php endforeach; ?>       
	
 

              <?php }?>
			  
			  <tr>
      <td colspan="2"></td>
    <td><B>Total</B> </td>
	
		<?php
						
						if(	$displayareas=="yes"){
							?>
		<td><B><?php 
	if(isset($balanacefoward)) {echo MyformatMoney($balanacefoward,true); }
	 ?></B></td >
							  <?php
							   }
							?>
							
							
							<?php
	if(	$servicedeposit=="yes"){
							?>
	
		<td><B><?php 
			 	if(isset($totalservicesdeposit)) {echo MyformatMoney($totalservicesdeposit,true);}
	 ?></B></td >
			 <?php

			 }
			?>
				
			<?php
	if(	$displayservices=="yes"){
							?>
	
		<td><B><?php 
			 	if(isset($totalcservices)) {echo MyformatMoney($totalcservices,true);}
	 ?></B></td >
			 <?php

			 }
			?>



			<?php
	if(	$displaylease=="yes"){
							?>
	
		<td><B><?php 
			 	if(isset($totallease)) {echo MyformatMoney($totallease,true);}
	 ?></B></td >
			 <?php

			 }
			?>			
							
							
							<?php
						
						if(	$displaywater=="yes"){
							?>
	<td><B><?php 
	if(isset($totalwater)) {echo MyformatMoney($totalwater,true);}
	 ?></B></td >
	 
						<?php
						}
							?>
							
							
							
							
							
							<?php
						
						if(	$displaygarbage=="yes"){
							?>
	<td><B><?php 
	if(isset($totalgarbage)) {echo MyformatMoney($totalgarbage,true);}
	 ?></B></td >
	 
						<?php
						}
							?>
							
							
								<?php
						
						if(	$displaypower=="yes"){
							?>
 <td><B><?php 
	if(isset($totalpower)) {echo MyformatMoney($totalpower,true);}
	 ?></B></td >


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

	 
	 <td><B><?php 
	if(isset($totalbf)) {echo MyformatMoney($totalbf,true);   }
	 ?></B></td > 
 
								  <?php
							   }
							   ?>
	
	 	<?php
			if(	$displaywater=="yes"){
							?>
 <td><B><?php 
	if(isset($totalelectricity)) {echo  MyformatMoney($totalelectricity,true);  }
	 ?></B></td >
								  <?php
							   }
							   ?>
	
		  
	  
	 
	  <td><B><?php 
	if(isset($totaldeposite)) {echo MyformatMoney($totaldeposite,true); };
	 ?></B></td >
	  <td><B><?php 
	if(isset($grandtotal)) {echo      MyformatMoney($grandtotal,true);  }
	

	 ?></B></td > 

 
	 	<?php
						
						if(	$displaycoparent=="yes"){
							?>
		<td><B><?php 
	if(isset($totalcoparent)) {echo MyformatMoney($totalcoparent,true); }
	 ?></B></td >
							  <?php
							   }
							?>
			<?php
						
						if(	$displaypenalty=="yes"){
							?>
		<td><B><?php 
	if(isset($totalpenalty)) {echo MyformatMoney($totalpenalty,true); }
	 ?></B></td >
							  <?php
							   }
							?>
								<td><B><?php 
	if(isset($TTEXPECTED)) {echo MyformatMoney($TTEXPECTED,true); }
	 ?></B></td >
					
				<td><B><?php 
	if(isset($ttpaid)) {echo MyformatMoney($ttpaid,true); }
	 ?></B></td >
					

	<td><B><?php 
	if(isset($totalbalance)) {echo MyformatMoney($totalbalance,true); }
	 ?></B></td >

                 </tr>
        </table>
		<br>	<br>	
		
<table cellspacing="1"  border="1" width="100%">
             <thead>
			
      
<?php

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

 {
	 }else {
?>

			<tr>
		 
		  <th colspan="3"><center>Vacant Rooms/Houses Report</center>
		  </th>
		  
		  
		</tr>



   <tr>
		     <th>S/N</th>
		  <th width="40%">Room No </th>
		   <th width="58%"> Status</th> 
		</tr>
             </thead>
    
             <?php 
	$counter = 0; 
  	foreach ($vacant as $c): 
		 

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

	$counter = ++$counter;
  
?>
<td><?php echo $counter ; ?></td> 
<td><?php echo $c->houseno ; ?></td> 
      <td><?php echo $c->status ; ?></td> 
               
				
         				
            
             </tr>

     <?php endforeach; ?>       
	
 

              <?php }?>
        </table>
		<br>
		<br>
		
		
<table cellspacing="1" border="1" width="100%">

			<tr>
			<td width="42%"><b>TOTAL RENT EXPECTED </b></td>
			<td width="58%"><?php  if(isset($grandtotal)) {echo   MyformatMoney($grandtotal,true);  }else{ echo "0";}?></td>
		</tr>
			<tr>
			<td width="42%"><b>TOTAL MONEY COLLECTED </b></td>
			<td width="58%"><?php  if(isset($ttpaid)) {echo   MyformatMoney($ttpaid,true);  }else{ echo "0";}?></td>
		</tr>
		<?php
		
			if(($totalbf)>1){
				?>
		<tr>
			<td width="42%">TOTAL PARTIAL PAYMENT </td>
			<td width="58%"><?php  if(isset($totalbf)) {echo  MyformatMoney($totalbf,true);  }else{ echo "0";}?></td>
		</tr>
			<?php
			}
				?>
		
		
		
		<?php
		$finaltatal=$totalbf+$ttpaid;
		
			if(($totalbf)>1){
				?>
		<tr>
			<td width="42%"><b>TOTAL RENT & PARTIAL PAYMENT </b></td>
			<td width="58%"><b><?php  if(isset($finaltatal)) {echo  MyformatMoney($finaltatal,true); }else{ echo "0";}?></b></td>
		</tr>
		
		<?php
			}
				?>
		
		
		
		
		
		
		<?php
									$taxtype= trim($plotnames[0]['taxtype']);

			if(($grandvat)>1){
				
				//
	if(($taxtype == "Landlord") || ($taxtype == "Both")){
		
			?>
		<tr>
		
			<td width="42%">Total House VAT (<?php echo$plotnames[0]['tax']; ?> )%</td>
			<td width="58%"><?php 
			if(isset($grandvat)) { $grandvat=$grandvat+$ppgrandvat;  echo MyformatMoney($grandvat,true);}else{echo  MyformatMoney($grandvat,true);}
			?></td>
		</tr>	
			
			
			
			
			<?php
			
			}
		}
		
		
			?>
			
			
			
			<?php
		if($grandcommission>1){
			?>

			<tr>
		
			<td width="42%">Total Commission (<?php echo$plotnames[0]['commission']; ?> )%</td>
			<td width="58%"><?php 
			if(isset($grandcommission)) { $TOTALCOMM=$grandcommission+$ppcommission;
			echo MyformatMoney($TOTALCOMM,true);
			}
			?></td>
		</tr>
			<?php
		}
		
		
			?>
			
					<?php

	if(($taxtype == "Agent") || ($taxtype == "Both")){
			?>

			<tr>
		
			<td width="42%">VAT on Commission (<?php echo$maintax ?> )%</td>
			<td width="58%"><?php 
			$totalagentvat=(($maintax /100)* ($TOTALCOMM));
			$totalagentvat=MyformatMoney($totalagentvat,true);
			
			echo MyformatMoney($totalagentvat,true);
		
			?></td>
		</tr>
		
		
			<tr>
		
			<td width="42%"><b>Total Commission and VAT</b></td>
			<td width="58%"><b><?php 
			$totalVATandcommission=(($totalagentvat)+ ($TOTALCOMM));
			$totalVATandcommission=MyformatMoney($totalVATandcommission,true);
			
			echo MyformatMoney($totalVATandcommission,true);
		
			?></b></td>
		</tr>
			<?php

		}
		
		
		
	if($taxtype == "Agent"){
					$finaltatalwithnocommission=$finaltatal-$TOTALCOMM-$totalagentvat;

	}else  if($taxtype == "Landlord"){	
						$finaltatalwithnocommission=$finaltatal-$TOTALCOMM-$grandvat;

		
	}else  if($taxtype == "Both"){	
	
							$finaltatalwithnocommission=$finaltatal-$TOTALCOMM-$grandvat-$totalagentvat;

	}else{
		
								$finaltatalwithnocommission=$finaltatal-$TOTALCOMM;
	
		
	}
		
			?>
			
		<?php
		
		
		
		
			if(($finaltatalwithnocommission)>1){
				?>
		<tr>
			<td width="42%"><b>TOTAL RENT LESS COMMISSIONS AND VAT</b></td>
			<td width="58%"><b><?php  if(isset($finaltatalwithnocommission)) {	echo MyformatMoney($finaltatalwithnocommission,true); }else{ echo "0";}?></b></td>
		</tr>
		
		<?php
			}
				?>
		
		
			
			
			         <?php 
					 if($displaytype=="all"){
					 
				 	 if(!is_array($other)) 

 {
  
    }else {
		
		?>
			
			<tr>
			<td COLSPAN="2"><b> <br>SUMMARY OF ALL CHARGES EXCEPT RENT</b></td>
		
		</tr>
		<?PHP

  $mytotal=0;
    $tt=0;
		$otherspaid=0;
  	foreach ($other as $otherrow){ 
	$mytype= $otherrow->type;
	
 

	
	if(isset($mytotal)) { $mytotal; }else{ echo "0"; }
	
		if(($otherrow->coparent > 0) && ($otherrow->paid < $otherrow->amount )){
							
								if(($displaywater=="no")&& ($mytype =="5") ){
															$mytotal= $mytotal+0;	
														
															

								}else{
														$mytotal= $mytotal+($otherrow->paid+$otherrow->paid);	
													$otherspaid=($otherrow->paid+$paid->paid);
														
	
								}
						}else{
								
						
						
							if(($displaywater=="no")&& ($mytype =="5") ){
														$otherspaid=0;
												$mytotal= $mytotal+0;
															

								}else{
														$otherspaid=$otherrow->paid;
						$mytotal= $mytotal+($otherrow->paid);
														
	
								}
						
						
						
						
						
						
						
						
						}	
	
	?>
	
	
	<tr>
	
			<td width="42%"><?php 
							if(($displaywater=="no")&& ($mytype =="5") ){
													
															

								}else{
														//echo$otherrow->type ;
														$charges = $this->usermodel->populateallarray('charges','id',$otherrow->type);

						echo$charges[0]["type"];		
														
	
								}
			
		
			
			?></td>
			<td width="58%"><?php 
			if(($displaywater=="no")&& ($mytype =="5") ){
													
															

								}else{
													echo MyformatMoney($otherspaid,true); 
														
	
								}
			
			?></td>
		</tr>
	
	<?php
	} }?>

		
			
		<tr>
			<td width="42%"><b>TOTAL ADDITONAL COLLECTIONS</b></td>
			<td width="58%"><b><?php if(isset($mytotal)) {echo MyformatMoney($mytotal,true);}else{ $mytotal=0;echo "0"; }?></b></td>
		</tr>
		



			<tr>
			<td width="42%"><b>GRAND TOTAL </b></td>
			<td width="58%"><b><?php $totalgrand= $finaltatalwithnocommission+$mytotal;
			$totalgrand= $finaltatalwithnocommission;
			echo MyformatMoney($totalgrand,true);

			?></b></td>
		</tr>
				
	<?php
	}else{
		?>
		
		
			<tr>
			<td width="42%"><b>GRAND TOTAL </b></td>
			<td width="58%"><b><?php $totalgrand= $finaltatalwithnocommission;
			$totalgrand= $finaltatalwithnocommission;
			echo MyformatMoney($totalgrand,true);

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

	?>

		
		
		
	<?php
	 if(is_array($expenditure)) 

 {



?>
    	<tr>
			<td COLSPAN="2"><b>  <br>OTHER EXPENSES </b></td>
		
		</tr>
		
             <?php 
  $mygrandtotal=0;
 
  
  	foreach ($expenditure as $row): 
	if(isset($mygrandtotal)) { $mygrandtotal; }else{ echo "0"; }
	$mygrandtotal= $mygrandtotal+($row->amount);
	
	?>
	<tr>
	
			<td width="42%"><?php echo$row->description ?></td>
			<td width="58%"><?php 		echo MyformatMoney($row->amount,true); ?></td>
		</tr>
	
	<?php
	endforeach; }?>
	
	
		<tr>
			<td width="42%"><b>TOTAL EXPENSES</b></td>
			<td width="58%"><b><?php if(isset($mygrandtotal)) {	echo MyformatMoney($mygrandtotal,true); }else{ $mygrandtotal=0; }?></b></td>
	
		</tr>
		
		
		
		<tr>
			<td COLSPAN="2"><br></td>
		
		</tr>
	<?php 
	if($displaytype !="all"){
	?>
		<tr>
			<td width="42%"><b>TOTAL DEPOSIT</b></td>
			<td width="58%"><b><?php if(isset($totaldeposites)) {	echo MyformatMoney($totaldeposites,true); }else{ $totaldeposites=0; }?></b></td>
	
		</tr>
			<?php 
	}
	
	?>
		
		
		
		<?php
	 if(is_array($depositrefunds)) 

 {



?>
    	<tr>
			<td COLSPAN="2"><b>  <br> DEPOSITS REFUNDED</b></td>
		
		</tr>
		
             <?php 
  $mygranddepositetotal=0;
 
  
  	foreach ($depositrefunds as $rows){ 
	if(isset($mygranddepositetotal)) { $mygranddepositetotal; }else{ echo "0"; }
	$mygranddepositetotal= $mygranddepositetotal+($rows->amount);
	
	?>
	<tr>
			<td width="32%"><?php echo$rows->description ."-HS NO.".$rows->houseno ?></td>
			<td width="58%"><?php 		echo MyformatMoney($rows->amount,true); ?></td>
		</tr>
	
	<?php
	}
	?>
	
	<tr>
			<td width="42%"><b>TOTAL REFUNDS</b></td>
			<td width="58%"><b><?php if(isset($mygranddepositetotal)) {	echo MyformatMoney($mygranddepositetotal,true); }else{ $totaldeposites=0; }?></b>
			
		
			</td>
	
		</tr>
	
		<?php
	}?>
	
		
		<tr>
			<td COLSPAN="2"> </BR></BR></td>
		
		</tr>
		
		
		
		
		
		
		
		<tr>
			<td><b>TOTAL CASH PAYABLE </b></td>
			<td><b><?php 
			
			if($displaytype !="all"){
 $payable= ($totalgrand+ $totaldeposites)-  $mygrandtotal;
	
					}else{
												

			 $payable= $totalgrand-  $mygrandtotal;
					}
			
			
			

			
			
			
			
			
			echo MyformatMoney($payable,true);
			?>
			</b></td>
		</tr>
	
 	<tr>
			<td><b>Bank Name </b></td>
			<td ><b><?php echo $plotnames[0]['accountname']	?> </b></td>
		</tr>
  	<tr>
			<td><b>Bank Account Number </b></td>
			<td><b><?php echo $plotnames[0]['accountno']	?> </b></td>
		</tr>

 
 
 
 </table>



</div>
</div>

</div>
		<!----CREATION FORM STARTS---->
	
</div>




			