<ul class="nav nav-tabs bordered">
			<li class="active">
            	<a href="#list" data-toggle="tab"><i class="entypo-menu"></i> 
					New Coparent Applicants
                    	</a></li>
			
					
							<li>
            	<a href="#balance" data-toggle="tab"><i class="entypo-plus-circled"></i>
				All Coparent Applicants
                    	</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">
 
<table id="example"  cellspacing="1" class="table  table" width="100%">
             <thead>
			
         <tr>
    
    <th>House Number </th>
	<th>Plot Name</th>
    
	<th>Mode</th> 	
	<th>Tenant </th> 
	<th>Amount </th> 
	<th>Total Amount </th> 
	<th>Balance</th>
		<th>Type</th> 
		<th> Month </th> 
		<th> Year </th> 
	<th> Payment Date </th> 
	<th> Status: </th> 
 
	 
	




                 </tr>
             </thead>
<?php

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

 {



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

		 

             ?>



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


?>

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


  $paymentsectionbyid = $this->adminusermodel->getpaymentsectionid($c->paymentmode);
								


if(is_array($paymentsectionbyid)) {

   foreach($paymentsectionbyid as $paymentsectionbyidrow){

  echo $paymentsectionbyidrow->name ; 
    

}} else {
    echo 'Invoiced';
}







?></td> 
					

              
				 				         <td><?php 
					
   $tenantid=$c->tenantid;
				    $tenants = $this->adminusermodel->gettenantbyid($tenantid);
 if(is_array($tenants)) {
   foreach($tenants as $tenantsrow){

    $names=$tenantsrow->lastname. " ".$tenantsrow->firstname ; 
   
   ?>
   
                     <a class="btn btn-warning"  id="more" href="<?php echo base_url();?>admin/edittenant?randomitemidentifier=<?php   {echo  $tenantid;}  ?>"><?php   {echo  $names;}  ?>  </a>

   
   <?php
    

}
    } else {
    echo 'No tenant.';
}
?>
				 
				 
		</td>
				
				       <td><?php echo $c->amount ; ?></td>
					 <td><?php echo $c->totalamount ; ?></td> 
					   <td><?php echo $c->balance ; ?></td> 
					   <td><?php echo $c->paymentstatus ; ?></td> 
					          <td><?php echo $c->month ; ?></td>
							         <td><?php echo $c->year ; ?></td>
                     <td><?php echo $c->createdat; ?></td>
					     <td><?php  $approval=$c->approval;

if($approval=="new"){
	?>
  <a class="btn btn-warning" id="more" href="<?php echo base_url();?>admin/viewcoparent?randomitemidentifier=<?php   {echo  $id;}  ?>"><?php   {echo  $approval;}  ?> </a>
<?php
	
}else if($approval=="rejected"){
	?>
	  <a class="btn btn-danger" id="more" href="<?php echo base_url();?>admin/viewcoparent?randomitemidentifier=<?php   {echo  $id;}  ?>"><?php   {echo  $approval;}  ?> </a>
<?php	
	
}else if($approval=="approved"){
	
		?>
					  <a class="btn btn-success" id="more" href="<?php echo base_url();?>admin/viewcoparent?randomitemidentifier=<?php   {echo  $id;}  ?>"><?php   {echo  $approval;}  ?> </a>
<?php
}

						 ?>
						 
						 </td>
				
         				
          
             </tr>

             <?php endforeach; ?>

              <?php }?>

        </table>


</div>

</div>
		
   
   
   
   
   
   
   
   
      
   <div class="tab-pane box" id="balance" style="padding: 5px">
 <div class="panel panel-primary" data-collapsed="0">
 

<table id="example"  cellspacing="1" class="table  table" width="100%">
             <thead>
			
         <tr>
    
    <th>House Number </th>
	<th>Plot Name</th>
    
	<th>Mode</th> 	
	<th>Tenant </th> 
	<th>Amount </th> 
		<th>TT Amount</th> 
		<th>Balance</th>
		<th>Type</th> 
		<th> Month </th> 
		<th> Year </th> 
	<th> Payment Date </th> 
	<th> Status: </th> 
 	<th> Invoice </th> 
	 
	




                 </tr>
             </thead>
<?php

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

 {



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

		 

             ?>



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


?>

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


  $paymentsectionbyid = $this->adminusermodel->getpaymentsectionid($c->paymentmode);
								


if(is_array($paymentsectionbyid)) {

   foreach($paymentsectionbyid as $paymentsectionbyidrow){

  echo $paymentsectionbyidrow->name ; 
    

}} else {
    echo 'Invoiced';
}







?></td> 
					

           
				 
				 
				 
				 				         <td><?php 
					
   $tenantid=$c->tenantid;
				    $tenants = $this->adminusermodel->gettenantbyid($tenantid);
 if(is_array($tenants)) {
   foreach($tenants as $tenantsrow){

    $names=$tenantsrow->lastname. " ".$tenantsrow->firstname ; 
   
   ?>
   
                     <a class="btn btn-warning"  id="more" href="<?php echo base_url();?>admin/edittenant?randomitemidentifier=<?php   {echo  $tenantid;}  ?>"><?php   {echo  $names;}  ?>  </a>

   
   <?php
    

}
    } else {
    echo 'No tenant.';
}
?>
				 
				 
		</td>
				 
				 
				 
				 
				 
				 
				 
				 
				 
				 
				       <td><?php echo $c->amount ;
			$total=$total+$c->amount ;
					   ?></td>
					   <td><?php echo $c->totalamount ; ?></td> 
					   <td><?php //echo $c->balance ; 
					  $transactioncode= $c->transactioncode;
					   
					 $balance=0;
					$allpayment = $this->adminusermodel->displaycoparentbalance($transactioncode); 
					  
					if(is_array($allpayment)) {

   foreach($allpayment as $allpaymentrow){

    $balance=$balance + $allpaymentrow->amount ; 
    $balance1=$balance1 + $allpaymentrow->amount ; 
 
}

 echo $balance;
 //$grandtotal= $grandtotal+$total;

} else {
    echo 'Not Invoiced.';
}
					
					


?>
	</td>				   
					   
					   
					   
					   
					   
					   
					   
					     <td><?php echo $c->paymentstatus ; ?></td> 
					          <td><?php echo $c->month ; ?></td>
							         <td><?php echo $c->year ; ?></td>
                     <td><?php echo $c->createdat; ?></td>
					     <td><?php  $approval=$c->approval;

if($approval=="new"){
	?>
  <a class="btn btn-warning" id="more" href="<?php echo base_url();?>admin/viewcoparent?randomitemidentifier=<?php   {echo  $id;}  ?>"><?php   {echo  $approval;}  ?> </a>
<?php
	
}else if($approval=="rejected"){
	?>
	  <a class="btn btn-danger" id="more" href="<?php echo base_url();?>admin/viewcoparent?randomitemidentifier=<?php   {echo  $id;}  ?>"><?php   {echo  $approval;}  ?> </a>
<?php	
	
}else if($approval=="approved"){
	
		?>
					  <a class="btn btn-success" id="more" href="<?php echo base_url();?>admin/viewcoparent?randomitemidentifier=<?php   {echo  $id;}  ?>"><?php   {echo  $approval;}  ?> </a>
<?php
}

						 ?>
						 
						 </td>
				<td>
				<?php
				
				if($approval=="approved"){
					?>
					
									  <a class="btn btn-success" id="more" href="<?php echo base_url();?>admin/invoicecoparent?randomitemidentifier=<?php   {echo  $id;}  ?>">invoice </a>

					<?php
				}else{
					echo "Not Approved";
				}
					?>
				
				</td>
         				
          
             </tr>

             <?php endforeach; ?>

              <?php }?>
<tr>
    
    <th colspan="6">Total Balance</th>
	
	<th colspan="2"><?php 
	if(isset($balance1)) {echo  "KSHS  =" .$balance1; }
	 ?> </th> 
		 
	<th  colspan="5">  </th> 

 
	 
	




                 </tr>
        </table>


</div>

</div>
   </div>
   
</div>




			