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

						$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']; 

					//$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(	$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 EXP</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;
	echo $this->session->flashdata('msg'); 
		if(validation_errors()):
		 endif;
 if(!is_array($invoice)) 

 {



 
    }else {
?>
    
             <?php 


   // $grandcommission=0;
   $totalinvoice=0;
      $totalpayment=0;
	   $balanacefoward=0;
	   $mybalanacefoward=0;
	   
		   $totaldeposite=0;
				   $totalcoparent=0;
		$totalpenalty=0;
		   $totalwater=0;
		     $totalpower=0;
			 		     $totalgarbage=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);
$myinvoice= $getallinvoices[0]["amount"];
						  $TTEXPECTED=$TTEXPECTED+$myinvoice;	
						  

             ?>



             <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.';
}
					

		$receipt= $this->usermodel->populateall('receipt', 'paymentcode',$c->paymentcode );
  if(is_array($receipt)) {
foreach ($receipt as $receiptrow){
	if($receiptrow->paymentcode!=""){
	
	//echo",". $receiptrow->paymentcode;		
	}
			   
  }
  
  }			


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


					    if(is_array($currentbalance)) {
					   foreach ($currentbalance as $ccurrentbalance){
						   ?>
					  <?php 
					   $mybalanacefoward=$ccurrentbalance->myamount-$ccurrentbalance->mypaid;
					   echo MyformatMoney($mybalanacefoward,true);
					  $balanacefoward= $balanacefoward+$mybalanacefoward;
					  
					  ?>
	
	                                  <?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  $cwater->myamount ;
						   
						   	if(($cwater->coparent > 0) && ($cwater->paid < $cwater->amount )){
							
							 $totalwater=$totalwater+($cwater->paid+$cwater->coparent);
							// echo MyformatMoney($cwater->paid+$cwater->coparent,true);
						}else{
						 $totalwater=$totalwater+$cwater->paid;	
							echo MyformatMoney($cwater->paid,true);
						}	
						   
						   
						  
						   	 //$totalwater= $totalwater+$totalwater;

					
					  
					  
					  ?>
	
	                                  <?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){
						   
						  
						   		if(($cmygarbage->coparent > 0) && ($cmygarbage->paid < $cmygarbage->amount )){
							
							 $totalgarbage=$totalgarbage+($cmygarbage->paid+$cmygarbage->coparent);
						echo MyformatMoney($cmygarbage->paid+$cmygarbage->coparent,true);	
						}else{
							 $totalgarbage=$totalgarbage+$cmygarbage->paid;
						echo MyformatMoney($cmygarbage->paid,true);	
						}	

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

 $totalpower=0;
					    if(is_array($mypower)) {
					   foreach ($mypower as $cmypower){
						   
						  
						   		if(($cmypower->coparent > 0) && ($cmypower->paid < $cmypower->amount )){
							
							 $totalpower=$totalpower+($cmypower->paid+$cmypower->coparent);
						echo MyformatMoney($cmypower->paid+$cmypower->coparent,true);	
						}else{
							 $totalpower=$totalpower+$cmypower->paid;
						echo MyformatMoney($cmypower->paid,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,$newfromdate,$newtodate,"6",$c->tenantid);

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

   
   
   
					  
					   
					   
					   	if(($cbf->coparent > 0) && ($cbf->paid < $cbf->amount )){
							
							echo MyformatMoney($cbf->paid+$cbf->coparent,true); 
							 $totalbf=$totalbf+($cbf->paid+$cbf->coparent);
							    $ppcommission= $ppcommission+($cbf->commission+$cbf->coparentcommission);
								$grandvat= $grandvat+($cbf->vat+$cbf->coparentvat);
								
								
								
							 
						}else{
							   $ppcommission= $ppcommission+$cbf->commission;
							$grandvat= $grandvat+$cbf->vat;
							echo MyformatMoney($cbf->paid,true); 
							 $totalbf=$totalbf+$cbf->paid;
						}	
					   
						  

						  
										}}
									?></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){


							 	if(($cmyelectricity->coparent > 0) && ($cmyelectricity->paid < $cmyelectricity->amount )){
							
							$totalelectricity=$totalelectricity+($cmyelectricity->paid+$cmyelectricity->coparent);

						 echo MyformatMoney($cmyelectricity->paid+$cmyelectricity->coparent,true);
						}else{
						$totalelectricity=$totalelectricity+$cmyelectricity->paid;

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

	
							  <?php
							   }
							   ?>



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

					    if(is_array($mydeposit)) {
					   foreach ($mydeposit as $cdeposit){
						
					if(($cdeposit->coparent > 0) && ($cdeposit->paid < $cdeposit->amount )){
							 $totaldeposite=$totaldeposite+($cdeposit->paid+$cdeposit->coparent);

						 echo MyformatMoney($cdeposit->paid+$cdeposit->coparent,true);	
							
						}else{
							 $totaldeposite=$totaldeposite+$cdeposit->paid;

						 echo MyformatMoney($cdeposit->paid,true);	
							
						}	
						    
										}}
									?>
					       </td> 
               
				       <td><?php 
					   	  
					   
											
					
				
		if(($c->coparent > 0) && ($c->paid < $c->amount )){
			
			 echo MyformatMoney($c->coparent+$c->paid ,true);
			    $mycoparentcommissioncommission=$c->coparentcommission;
					   
					   $grandvat=$grandvat + ($c->coparentvat+$c->vat);
					 $grandcommission=$grandcommission+($mycoparentcommissioncommission+$c->commission);
					
					   $grandtotal= $grandtotal + ($c->coparent+$c->paid) ;
			 
		}else{
			
					   $grandtotal= $grandtotal + $c->paid;
					     
					   $myvat=$c->vat;
					   
					   $mycommission=$c->commission;
					   
					   $grandvat=$grandvat + $myvat;
					 $grandcommission=$grandcommission+$mycommission;
			
				echo  MyformatMoney($c->paid,true);
		}
	//echo	$c->paymentcode;
						$receipt= $this->usermodel->populateall('receipt', 'paymentcode',$c->paymentcode );
  if(is_array($receipt)) {
foreach ($receipt as $receiptrow){
			

	if($receiptrow->paymentcode!=""){
	
	echo "<br>,". $receiptrow->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
								
								
					   echo MyformatMoney($myinvoice,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(	$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 >
					




                 </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 </b></td>
			<td width="58%"><?php  if(isset($grandtotal)) {echo   MyformatMoney($grandtotal,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+$grandtotal;
		
			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
			
			if(($grandvat)>1){
				
				
			
		
			?>
		<tr>
		
			<td width="42%">Total 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
		$finaltatalwithnocommission=$finaltatal-$TOTALCOMM;
		
			if(($finaltatalwithnocommission)>1){
				?>
		<tr>
			<td width="42%"><b>TOTAL RENT LESS COMMISSIONS </b></td>
			<td width="58%"><b><?php  if(isset($finaltatalwithnocommission)) {	echo MyformatMoney($finaltatalwithnocommission,true); }else{ echo "0";}?></b></td>
		</tr>
		
		<?php
			}
				?>
		
		
			
			
			         <?php 
				 	 if(!is_array($other)) 

 {
  
    }else {
		
		?>
			
			<tr>
			<td COLSPAN="2"><b> <br>ADDITONAL COLLECTIONS</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->coparent);	
													$otherspaid=($otherrow->paid+$otherrow->coparent);
														
	
								}
						}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 ;
														
														
	
								}
			
		
			
			?></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-$grandvat;
			echo MyformatMoney($totalgrand,true);

			?></b></td>
		</tr>
		
		
	<?php
	 if(!is_array($expenditure)) 

 {



  
    }else {
?>
    	<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>
	
	
		
		
		<tr>
			<td><b>TOTAL CASH PAYABLE </b></td>
			<td><b><?php 
			
			 $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>




			