 			
       <?php
       
       $mid = $_GET["mid"];
$sql_user_billrecord= "SELECT SUM(amount) as billspaidbalances FROM tbl_payments where payment_type = 'WB' and unique_id = '$mid'";
$result_user_billpay= mysqli_query($conn, $sql_user_billrecord);
$row_user_billpay_summary = mysqli_fetch_assoc($result_user_billpay);

$sql_user_readings1 = "SELECT sum(billing_amount) as totalbills FROM tbl_members_report where account_no = '$mid' ";
$result_user_details2 = mysqli_query($conn, $sql_user_readings1);
$row_user_readings_summary = mysqli_fetch_assoc($result_user_details2);
$totalwbbills = $row_user_readings_summary['totalbills'];

$sql_user_bklogs = "SELECT sum(amount) as bklogtotal FROM tbl_backlogs_collection where account_no = '$mid' ";
$result_bl_details2 = mysqli_query($conn, $sql_user_bklogs);
$row_user_bklogread = mysqli_fetch_assoc($result_bl_details2);
$bklog = $row_user_bklogread['bklogtotal'];

$remainingbalance_summary = $totalwbbills  + $bklog;

$billspayment_summary = $row_user_billpay_summary['billspaidbalances'];

$totalunpaidbill_wbhistory = $remainingbalance_summary - $billspayment_summary;

?>		
<p><b>Summary</b> <br>
Total  Waterbills: <? echo number_format($totalwbbills);?> <br>
Total Paid Water Bills <?php echo number_format($billspayment_summary); ?>
<hr>
<H4>Remaining Balance: <b style="color:#fd0000">&#8369;<?php echo number_format(($totalunpaidbill_wbhistory));?> </b> </h4>  
   
  
<table id="example1" class="table table-bordered table-hover">

<thead>
  <tr>
  <th width="5%">ID </th> 
  <th width="5%">Type </th> 
   <th width="10%" >Reading</th>
  <th  width="10%">Paid</th>  
  <th  width="10%">MOP</th>  
                   
  <th width="10%" >Payment </th>
  <?php if (($_SESSION['username'] == 'MainAdmin')) {?>
  <th width="10%" >Action </th>
  <?php }else { ?>
   <?php }?>
 
</tr>
</thead>
<tbody>

<?php


// $acctno = "this. document.getElementById('id_u').value"
$result = mysqli_query($conn,"SELECT * FROM tbl_payments where unique_id = '$mid' and payment_type='WB'");
$i=1;
while($row = mysqli_fetch_array($result)) {
?>
<tr id="<?php echo $row["id"]; ?>" >
                  <td>
                     <?php echo $row["id"]; ?>
               </td>
                <td> <?php echo $row["payment_type"]; ?>    </td>
              <td>
              <div class='edit_paymenttype'> <?php echo $row["reading_date"]; ?></div> 
              </td>
               <td>
               <div class='edit_paymenttype'>  <?php echo  '&#8369;'. $row["amount"]; ?></div> 
               
              
      
      </td>
                    
               </td>
               <td>
              
               <div class='edit_paymenttype'>  <?php echo $row["payment_option"]; ?></div> 

                  

               </td>
               <td>
                     <?php echo $row["payment_date"]; ?>
               </td>
               <?php if (($_SESSION['username'] == 'MainAdmin')) {
                     ?>  <td> 
           
       
           <div class="hidebutton" id="hidebutton">   <a href="#deletebillspay" class="deletebillspay btn btn-danger btn-radius" data-id="<?php echo $row["id"]; ?>" data-toggle="modal">
		 <i class="fas fa-trash-alt" data-toggle="tooltip" 
			  title="Delete"></i></a>
               </div>

          
                </td>
                <?php } else { ?>

<?php } ?>
               


</tr>
<?php
$i++;
}
?>
</tbody>
</table>
<!---END payment history RECORD -->
 
<?php include 'edit_billspayment.php';?>
 