
      <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
			 $(document).on("click", "#managebtndelete2", function()
        {
          var itemid2 = $(this).data('id');
		  $("#itemid2").val(itemid2); 
		  
		    var plotno2 = $(this).data('plotno');
		   $("#plotno2").val(plotno2); 
		     
		    var houseno2 = $(this).data('houseno');
		   $("#houseno2").val(houseno2); 
		   
        });
		
		
		
    </script> 

<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 id="non-printable"  class=" btn-info" href="<?php echo base_url(); ?>admin/viewpallmyplots">Back home</a></li>

			 OVER PAYMENTS

					
		</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>Plot No</th>
    <th>Hs No </th>

    
	<th>Mode</th> 	
	<th>Tenant </th> 
	<th>Invoce </th> 
		<th>Code </th> 
			<th>Exra </th> 

					<th>Balance </th> 
	<th> Payment Date </th> 
	<th> Uploaded Date </th> 
	<th> Paid By: </th> 
		<th> Added By: </th> 
 <th> Pay: </th> 
	 

	 <th> More: </th> 


                 </tr>
                </thead>
<?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['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
				echo $this->session->flashdata('msg'); 
 				echo $this->session->flashdata('deletemsg'); 
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;
					}
		if(validation_errors()):
		 endif;
 if(!is_array($payment)) 

 {



  
    }else {
?>
    
             <?php 
  
  	foreach ($payment as $c): 

		 

             ?>



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


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


  $paymentsectionbyid = $this->accomodationmodel->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->accomodationmodel->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->paymentcode ; ?></td>
					      <td><?php echo $c->overpayment ; ?></td>
						  
						  	<td>
					   <?php
					     $currentbalance = $this->accomodationmodel->getplothouseinvoicewithbalance($c->plotno,$c->houseno,$c->tenantid, $c->exactime,"all" );
			$mybalanacefoward=0;

					    if(is_array($currentbalance)) {
					   foreach ($currentbalance as $ccurrentbalance){
						   ?>
					  <?php 
					  
					   $mybalanacefoward=$ccurrentbalance->myamount-$ccurrentbalance->mypaid;
					   echo MyformatMoney($mybalanacefoward,true);
					  
					  
					  ?>
	
	                                  <?php  
										}}else{
												$mybalanacefoward=0;
											  echo MyformatMoney($mybalanacefoward,true);
										}
									?></td>
				 
					         <td><?php echo $c->exactime; ?></td>
                     <td><?php echo $c->createdat; ?></td>
					     <td><?php echo $c->paidby; ?></td> 
						 
						 
						 

<td><?php  $customer=$c->userid ;

$mycustomer=$this->usermodel->populateallarray('people','id', $customer);
			echo$myname=$mycustomer[0]['firstname'];

 ?></td>
						 
						 
						 
						 
						 
				
         			
						
			
							<td>
						<?php
						
					
						if ($mybalanacefoward>0){
							?>

									 <a class="btn btn-warning"  target="_blank" id="more" href="<?php echo base_url();?>admin/receivepayment?randomitemidentifier=<?php   {echo  $c->houseno;}  ?>&randomitemidentifier1=<?php   {echo  $c->plotno;}  ?>&paymentid=<?php   {echo  $c->id;}  ?>&myoriginalamount=<?php   {echo  $c->overpayment;}  ?>">Pay  </a>

						

				
						
						<?php
						}
						?>
				
				</td>
				
					
 		<td>
					<div class="btn-group">
                                    <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">
                                        More <span class="caret"></span>
                                    </button>
									<?php
										if($usertype=="admin"){
											
											?>
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        
                                        <!-- teacher EDITING LINK -->
                                      
										
											  <li> 
										 <a class="btn btn-danger managebtn" id="managebtndelete2"	 data-amount='<?php echo  $c->amount;?>'	 data-id='<?php echo  $c->id;?>'   data-plotno='<?php echo  $c->plotno;?>'  data-toggle='modal' data-target='#deleteModal<?php  $c->id; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Cancel
                                                </a>
                                                        </li>
									
									
                                        <li class="divider"></li>
                                        
                              <li> 
							
							<?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
						}
						?>
				
                                <i class="glyphicon glyphicon-pencil"></i>
																Print
                                                </a>
                                                        </li>           
                                    </ul>
											<?php
										}
										?>
                                </div>
							</td>
          
             </tr>

             <?php endforeach; ?>

              <?php }?>

        </table>

 	
<div id="deleteModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Cancel Payment</h4>
      </div>
      <div class="modal-body">
        <h3>Are you sure you want to cancel this payment? </h3>
      </div>
      <div class="modal-footer">
	  	

     
		<?PHP
				$session_data = $this->session->userdata('adminlogged_in');
 echo $this->session->flashdata('deletemsg'); 

		
                 echo form_open('user/deleteallbyid' , array('class' => 'form-horizontal ', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
 <input type="hidden" id="table"name="table" class="table" placeholder="view" value="receipt">

 
 
  <input type="hidden" id="view"name="view" class="view" placeholder="view" value="admin/dailypayment">
  <input type="hidden" id="view2"name="view2" class="view2" placeholder="view" value="">
 
 
 
 
 
 
 <input type="hidden" id="houseno2"name="houseno" class="houseno" placeholder="houseno" value=""><br>

 <input type="hidden" id="itemid2"name="itemid" class="itemid" placeholder="itemid" value=""><br>
          <input type="hidden" id="plotno4"name="plotno" class="form-control" placeholder="plotno"  value="">
 <button type="button" class="btn btn-success" data-dismiss="modal">No</button>
 		  	         <button type="submit" name="btn_delete" value="deletebyid" class="btn btn-danger"> Cancel Payment  </button>

	<?php echo form_close();?>
      </div>
    </div>

  </div>

  </div>

</div>
		
   
   
   
   

</div>

</div>



</div>




			