
      <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		    var plotno = $(this).data('plotno');
		   $("#plotno1").val(plotno); 
		     
		    var houseno = $(this).data('houseno');
		   $("#houseno1").val(houseno); 
		   
        });
		
		
		
    </script> 
<script>
	function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

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

	 if( window.print()) {
         window.location.href = "../admin/searchstatement";
		alert(" printing...........");
    }else {

	
		      return      window.location.href = "../admin/searchstatement";

		    // 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;
		height:auto;
		
		
    }
  

    #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; }
#maintable tr { border-bottom:1px dashed #494949; padding:0px;}


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('msg'); 
			 
	 $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'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
		echo $this->session->flashdata('deletemsg'); 
					 $data['branchid'] = $session_data['branchid'];
	 $branch = $data['branchid'];
					  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;
					}
					
			
	        		$configuration= $this->usermodel->populateallarray('smsconfig','id',$companyid);
					
					
					
					
					
					
					
					
					
			?>




<ul class="nav nav-tabs bordered">
			<li class="active">
            	<a href="#list" data-toggle="tab"><i class="entypo-menu"></i> 
					All Invoices for this House
                    	</a></li>
			
								<li>
            									 <a href="<?php echo base_url(); ?>admin/searchhouse">Search tenant statement </a>


							</li>
					
							<li>
            									 <a href="<?php echo base_url(); ?>admin/searchstatement">Search more statement </a>


							</li>
							
							<li>
            									 <a href="<?php echo base_url(); ?>admin/viewpallmyplots">Back Home </a>


							</li>
							
									<div class="pull-right" id="non-printable">
			 
<form name="print" method="post" action="">
 <input type="submit" id="print"  accesskey="p" class="btn btn-primary"  name="print"onclick="printDiv('printableArea')" value="Print" />
</form></div>
		</ul>
    	<!------CONTROL TABS END------>
        
		<div class="tab-content">
		<?php
					echo $this->session->flashdata('deletemsg'); 

			?>
            <!----TABLE LISTING STARTS-->
            <div class="tab-pane box active" id="list">
				
     


 <div class="panel panel-primary" data-collapsed="0">
 
 
 <div class="panel panel-primary" data-collapsed="0">
 	<div class="table-responsive">
			<div id="printableArea22">
			
			<table width="100%" id="printableArea">
           
			
			<tr>
				 	
	<td colspan="2" width="100%">
	<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=$configuration[0]['businessname']; if(isset($bussinessname)) {echo   $bussinessname; }
 
											 
										 }
										?>
					
					
					
					
					
					
		</center>	
		</td>

			</tr>
			<?php if(isset($fromdate)) {
			
				
				
			
			?>
		<tr>
				<td>

				<h4><b> Deposit refunds  between <?php echo $fromdate; ?> AND <?php echo $todate; ?>.</b></h4>	</td>
					<td><h4><b>Printed on <?php echo $date = date("H:s d/m/Y"); ?></b></h4></td>

		</tr>
			
			
				<?php 
				
				}
			
			?>
			
			
			
</table >
 
<table id="example"  cellspacing="1" class="table  table" width="100%" border="1">
             <thead>
			
         <tr>
      <th>Receipt No </th>
    <th>House No </th>
	<th>Plot Name</th>
    
	<th>Tenant </th> 
	<th> Amount Paid </th>

	<th> Mode  </th>

		<th> Code </th> 

	<th> Payment Date </th> 
	<th> Description</th> 
		<th> Staff</th> 


                 </tr>
             </thead>
<?php

		if(validation_errors()):
		 endif;
 if(!is_array($invoice)) 

 {



   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='10'>";
    
       echo '<div class="alert alert-warning text-center">There is no invoice found by now from system..</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    
             <?php 
    $totalbalance= 0;
  $totalinvoice=0;
    $totalpaid=0;
  	foreach ($invoice as $c): 

		 $confirm= $this->accomodationmodel->confirmrentpayments($c->companyid,$c->transactioncode);
$amount=$confirm[0]["amount"];
$paid=$confirm[0]["paid"];
$balance=$c->amount-$paid;
$totalpaid=$totalpaid+$paid;
		   $totalinvoice= $totalinvoice+$c->amount ;
   $totalbalance=  $totalinvoice-$totalpaid;
             ?>



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


?>
             <td><?php echo $c->receiptno ; ?></td> 

             <td><?php echo $c->houseno ; ?></td> 
				<td><?php 

	   
			        		$getplot = $this->usermodel->populateallarray('plot','id',$c->plotno);

						echo$plotname=$getplot[0]["name"];


				?></td> 

					

                 <td><?php  $tenantid=$c->tenantid ; 
				 
				 
				    $tenants = $this->accomodationmodel->gettenantbyid($tenantid);
								


if(is_array($tenants)) {

   foreach($tenants as $tenantsrow){

   echo $tenantsrow->lastname. "  ".$tenantsrow->firstname ; 
    

}} else {
    echo $c->tenantid;
}
				 
				 
				 
				 
				 
				 ?></td>
				   		       <td><?php echo formatMoney($c->amount,true) ; ?></td>
										   	
					      
						  
						  
						  
					  
			                     <td><?php echo $c->mode; ?></td>


		                     <td><?php echo $c->transactioncode; ?></td>

	


						  			  
                     <td><?php echo $c->createdat; ?></td>
					     <td><?php echo $c->description; ?></td>
								     <td><?php echo $c->description;
$people = $this->usermodel->populateallarray('people','id',$c->userid);

						echo$people=$people[0]["firstname"];


									 ?></td>

         
		 
            
             </tr>

             <?php endforeach; ?>

              <?php }?>
			  
				   <tfoot>
<th>
    <td colspan="3">Total Money paid out</td> 
 					   				 

	 <td colspan="1"><b><?php 
	if(isset($totalinvoice)) {echo formatMoney($totalinvoice,true) ; }
	 ?> </b></td > 
	
		     <td colspan="3"></td> 
		 
	

	

                 </th>
				  </tfoot>
        </table>



</div>

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




   </div>
</div>




			