<ul class="nav nav-tabs bordered">
			<li class="active">
            	<a href="#list" data-toggle="tab"><i class="entypo-menu"></i> 
					All Payment for this House
                    	</a></li>
			
						<li>
            	<a href="#thirdtab" data-toggle="tab"><i class="entypo-plus-circled"></i>
					Add  Payment  
                    	</a></li>
							<li>
            	<a href="#balance" data-toggle="tab"><i class="entypo-plus-circled"></i>
					ALL BALANCE 
                    	</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>Reason </th> 
		<th>Type</th> 
		<th> Month </th> 
		<th> Year </th> 
	<th> Payment Date </th> 
	<th> Paid By: </th> 
 	<th>Print </th> 
	 
	 	<th>Monthly </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" target="_blank" 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->type ; ?></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 echo $c->userid; ?></td>
						<td>
						<?php
						
						$typs=$c->paymentstatus ;
						if ($typs=="receipt"){
							?>
			 <a class="btn btn-primary"  target="_blank" id="more" href="<?php echo base_url();?>admin/housereceiptbyno?randomitemidentifier=<?php   {echo  $c->id;}  ?>&plotno=<?php   {echo  $c->plotno;}  ?>&houseno=<?php   {echo  $c->houseno;}  ?>">Print  </a>

						
						

				
						
						<?php
						}
						?>
				
				</td>
				
							<td>
						<?php
						
						$typs=$c->paymentstatus ;
						if ($typs=="receipt"){
							?>

						
						
				                     <a class="btn btn-primary" target="_blank"  id="more" href="<?php echo base_url();?>admin/allhousereceiptbyno?randomitemidentifier1=<?php   {echo  $c->id;}  ?>&plotno=<?php   {echo  $c->plotno;}  ?>&houseno=<?php   {echo  $c->houseno;} ?>&nyumbaid=<?php   {echo  $c->tenantid;} ?>&year=<?php   {echo  $c->year;} ?>&month=<?php   {echo  $c->month;} ?>">Print (Month)  </a>

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

             <?php endforeach; ?>

              <?php }?>

        </table>


</div>

</div>
		
   
   
   <div class="tab-pane box" id="thirdtab" style="padding: 5px">
			
			



		
<div class="row">
	<div class="col-md-12">
		<div class="panel panel-primary" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" >
            		<i class="entypo-plus-circled"></i>
				Add new Payment
            	</div>
            </div>
			<div class="panel-body">





				<?PHP
				echo $this->session->flashdata('msg'); 
		 $date = Date('Y-m-d') ;
		 	 $year = Date('Y') ;
		  $month = Date('m') ;
                 echo form_open('addpayment' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
					
  <div class="form-group">

    <label for="inputhouseno" class="col-sm-2 control-label">House Number</label>
    <div class="col-sm-7">
			  		<input type="text" name="houseno" value="<?php  echo $houseno ; ?>"id="Paymentno" class="form-control" required placeholder="Enter Payment number">
  		<input type="hidden" name="action" value="<?php echo set_value('action','insert'); ?>"id="action" class="form-control" required >


     <span class="text-danger"><?php echo form_error('houseno'); ?></span>
   </div>
  </div>
  <div class="form-group">

    <label for="inputplotno" class="col-sm-2 control-label">Plot Number</label>
    <div class="col-sm-7">
	<input type="text" name="plotno" value="<?php  echo $plotno  ; ?>"id="plotno" class="form-control" required placeholder="Enter Payment number">


     <span class="text-danger"><?php echo form_error('plotno'); ?></span>
   </div>
  </div>
  
 <div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">Tenant Name</label>
    <div class="col-sm-7">
       	<input type="hidden" name="tenantid" value="<?php echo set_value('tenantid',$tenant[0]['tenantid']); ?>" id="idno" class="form-control" required placeholder="Enter Name">
 
		
		<?php 
		$tenantid=$tenant[0]['tenantid'];
		$tenantsdetails = $this->adminusermodel->gettenantbyid($tenantid);
								


if(is_array($tenantsdetails)) {

   foreach($tenantsdetails as $tenantsdetailsrow){

    $names=$tenantsdetailsrow->lastname. " ".$tenantsdetailsrow->firstname ; 
    ?>

	<input type="text" name="mytenantid" value="<?php echo set_value('tenantid',$names); ?>" id="idno" class="form-control" required placeholder="Enter Name">

	<?php

}} else {
  
  
         echo '<div class="alert alert-warning text-center">There is no tenant  found for this house.</div>';


	
}
				 
		
	?>	
		
		<span class="text-danger"><?php echo form_error('tenantid'); ?></span>
	</div>
  </div>
  
   <div class="form-group">
    <label for="inputamount" class="col-sm-2 control-label">Amount</label>
    <div class="col-sm-7">
				<input type="text" name="amount" value="<?php echo set_value('amount'); ?>" id="amount" class="form-control" required placeholder="Enter amount">
        <span class="text-danger"><?php echo form_error('amount'); ?></span>
	</div>
  </div>
  
  
  
		 		  <div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">Payment for?:</label>
    <div class="col-sm-7">
				    	
			  	<select name="type" class="form-control" required>
<option value="" >---Select charges type---</option>

		<?php 

//$nation = $this->nationmodel->populatenation();


if(is_array($charges)) {

   foreach($charges as $chargesrow){

   $chargeid=$chargesrow->chargeid;
   $chargesbyid = $this->adminusermodel->getchargesbyid($chargeid);
								


if(is_array($chargesbyid)) {

   foreach($chargesbyid as $chargesbyidrow){

  
   ?>
	    <option value="<?php echo set_value('amount',$chargesbyidrow->type); ?> "><?=$chargesbyidrow->type?></option>

   
    <?php   

}} else {
    echo 'There is no charge in the system.... try again.';
}
   
   
  

}} else {
    echo 'There is no other  charges for this house.... PLease add charges first.';
}

?>
	</select>
		(Should bethe same as expected amount type )		

	  <span class="text-danger"><?php echo form_error('amount'); ?></span>
	</div>
  </div>	
		 
  
  
  
  
  
  
  
  
  
  
  
  
  
 <div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">Paid By:</label>
    <div class="col-sm-7">
				<input type="text" name="userid" value="<?php echo set_value('userid'); ?>" id="idno" class="form-control" required placeholder="Paid by (Name)">
        <span class="text-danger"><?php echo form_error('year'); ?></span>
	</div>
  </div>  
    <div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">Month of Payment</label>
    <div class="col-sm-7">
				<input type="text" name="month" value="<?php echo set_value('month',$month); ?>" id="idno" class="form-control" required placeholder="Enter month">
        <span class="text-danger"><?php echo form_error('year'); ?></span>
	</div>
  </div>
  <div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">Year of Payment</label>
    <div class="col-sm-7">
				<input type="text" name="year" value="<?php echo set_value('year',$year); ?>" id="idno" class="form-control" required placeholder="Enter year">
        <span class="text-danger"><?php echo form_error('year'); ?></span>
	</div>
  </div>

   <div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">Created Date</label>
    <div class="col-sm-7">
				<input type="text" name="createdat" value="<?php echo set_value('createdat',$date); ?>" id="idno" class="form-control" required placeholder="Enter Start Date">
        <span class="text-danger"><?php echo form_error('createdat'); ?></span>
	</div>
  </div>
		  <div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">Payment Mode</label>
    <div class="col-sm-7">
				    	
			  	<select name="paymentmode" class="form-control" required>
<option value="" >---Select Payment Mode---</option>

		<?php 

//$nation = $this->nationmodel->populatenation();


if(is_array($methode)) {

   foreach($methode as $methoderow){

    ?>
	    <option value="<?php echo set_value('mode',$methoderow->id); ?> "><?=$methoderow->name?></option>

   
    <?php

}} else {
    echo 'There is no other  payment mode for this house.... PLease add charges first.';
}

?>
	</select>
				

	  <span class="text-danger"><?php echo form_error('paymentmode'); ?></span>
	</div>
  </div>			
  
    	 
	   <div class="form-group">
    <label for="inputpaymentcode" class="col-sm-2 control-label">Payment Code</label>
    <div class="col-sm-7">
				<input type="text" name="paymentcode" value="<?php echo set_value('paymentcode'); ?>" id="idno" class="form-control"  placeholder="Enter paymentcode">
        <span class="text-danger"><?php echo form_error('paymentcode'); ?></span>
	</div>
  </div>	 
		 
		 
		 
		 
		 
		 
   <div class="form-group">
    <label for="inputphone3" class="col-sm-2 control-label">Description </label>
    <div class="col-sm-7">
	<textarea name="description" id="ttt" rows="5" placeholder="add Description" class="form-control"></textarea>
    <span class="text-danger"><?php echo form_error('description'); ?></span>
   </div>
  </div>
    
  
  
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-7">
     
	       <button type="submit" name="btn_payment" value="payment" class="btn btn-primary">Add Payment</button>

    </div>
  </div>
                    
                <?php echo form_close();?>
            </div>
        </div>
    </div>
</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>Reason</th> 
		<th>Type</th> 
		<th> Month </th> 
		<th> Year </th> 
	<th> Payment Date </th> 
	<th> Paid By: </th> 
 
	 	<th> Print: </th> 
<th> Monthly: </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;
  	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" target="_blank"  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->type ; ?></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 echo $c->userid; ?></td>
				
         					<td>
						<?php
						
						$typs=$c->paymentstatus ;
						if ($typs=="receipt"){
							?>
			 <a class="btn btn-primary"  target="_blank" id="more" href="<?php echo base_url();?>admin/housereceiptbyno?randomitemidentifier=<?php   {echo  $c->id;}  ?>&plotno=<?php   {echo  $c->plotno;}  ?>&houseno=<?php   {echo  $c->houseno;}  ?>">Print  </a>

						
						

				
						
						<?php
						}
						?>
				
				</td>
				
							<td>
						<?php
						
						$typs=$c->paymentstatus ;
						if ($typs=="receipt"){
							?>

						
						
				                     <a class="btn btn-primary" target="_blank"  id="more" href="<?php echo base_url();?>admin/allhousereceiptbyno?randomitemidentifier1=<?php   {echo  $c->id;}  ?>&plotno=<?php   {echo  $c->plotno;}  ?>&houseno=<?php   {echo  $c->houseno;} ?>&nyumbaid=<?php   {echo  $c->tenantid;} ?>&year=<?php   {echo  $c->year;} ?>&month=<?php   {echo  $c->month;} ?>">Print (Month)  </a>

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

             <?php endforeach; ?>

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

 
	 
	




                 </tr>
        </table>


</div>

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




			