<?php include('parent/callMe.php');?>
<?php include('Sessioncheck.php');?>
<?php   

function check_in_range($start_date, $end_date, $date_from_user)
{
  // Convert to timestamp
  $start_ts = strtotime($start_date);
  $end_ts = strtotime($end_date);
  $user_ts = strtotime($date_from_user);

  // Check that user date is between start & end
  return (($user_ts >= $start_ts) && ($user_ts <= $end_ts));
}
  
 $sql = "SELECT * FROM eduportal_monthly_challan as fee, edu_student_details as std WHERE fee.student_id=std.student_id /*and std.status='0'*/ and std.branch_id=".$_SESSION['branch']. " ";


 if($_REQUEST['class_id']!=NULL){
      
    if($_REQUEST['class_id']=="All"){
    
    } else {
     $sql .= " AND fee.classs_id = '" .$_REQUEST['class_id']. "' ";

    }

    if($_REQUEST['section']=="All"){
    
    } else {
     $sql .= " AND std.section_id = '" .$_REQUEST['section']. "' ";

    }

   
  if($_REQUEST['session']!=NULL){
    $sql .= " AND fee.session_id = '" .$_REQUEST['session']. "' ";
  }

  if($_REQUEST['month']!=NULL){
    $sql .= " AND fee.month_id = '" .$_REQUEST['month']. "' ";
  }

 if($_REQUEST['fee']=="All"){

 } else {
  $sql .= " AND fee.paid_status = '" .$_REQUEST['fee']. "' ";
 }



  if(isset($_REQUEST['from']) && isset($_REQUEST['to']) && $_REQUEST['fee']==1){
    

    
      if($_REQUEST['from']!=" " && $_REQUEST['from']!=NULL ) {
        $from=date("Y-m-d",strtotime($_REQUEST['from']));  

      }else {
        $from=date("Y-m-01");  
      }
     
      if($_REQUEST['to']!=" " && $_REQUEST['to']!=NULL   ) {
        $to=date("Y-m-d",strtotime($_REQUEST['to']));
      }else {
        $to=date("Y-m-t");  
      } 
      
    
    $sql .= " AND (fee.paying_date BETWEEN '" .$from. "' AND '" .$to. "' OR fee.paid_again_date BETWEEN '" .$from. "' AND '" .$to. "' )";
  }

    $sql .= " ORDER BY fee.paying_date desc ";
 //echo $sql;

  $WorkAssignListings = $m->query($sql);


  // getting branch details
  $branch=getBranch($m);

}

$fee_types = $m->get("eduportal_fee_types");

$branchID=$_SESSION['branch'];

?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Print Fee Report </title>
<link rel="icon" type="image/png" href="img/favicon.png" sizes="32x32" />
<script type="text/javascript">
// window.print();
</script>
<style type="text/css">

tr th {border-top:1px solid gray;border-left:1px solid gray;border-bottom:1px solid gray;text-align:center;background-color:lightgray;font-size:12px;padding:0.5%;}
tr td {border-bottom:1px solid gray;border-left:1px solid gray;font-size:12px;padding:0.5%;}
  
.border{border:1px solid black;}
.center{text-align:center;}
.alignment{padding-left:1%;text-align:left;}


.centertable {
  margin-left: auto;
  margin-right: auto;
}

</style>
</head>
<body style="font-size:12px;">



<div style="text-align:center;font-size:24px;font-weight:bold;margin:0 auto;"><?php echo $branch[0]['Branch_Name'];?> 

</div>

<br>

<div style="text-align:center;font-size:18px;font-weight:bold;"> Students Paid Fee Report List

 </div>

<hr style="width:100%;">


<div style="width:50%; float:left;font-size:16px; "> <b> Report Month:</b> <?php echo date("F", mktime(0, 0, 0,$_REQUEST['month'], 10));?>  </div>

<div style="width:50%;text-align:center;float:left;font-size:16px;"> <b> Session:</b> <?php echo getSessionName($m,$_REQUEST['session']);?> </div>

<br>
   
<table style="width:100%;font-size:16px;" cellspacing="0">
      
  <thead>
    <tr>

        <th width="3%" class=" center"> S.No</th>

        <th width="12%" class=" alignment"><strong>Student Name</strong></th>
      

        <?php if($_GET['father_name']==1){?><th width="10%" class=" alignment"><strong>Father Name</strong></th><?php }?>

        <th width="10%" ><strong>Cell No</strong></th>

        <?php if($_GET['father_cellno']==1){?><th width="10%" ><strong>Father No</strong></th><?php }?>

        <?php if($_GET['mother_cell']==1){?><th width="10%" ><strong>Mother No</strong></th><?php }?>

        <?php if($_GET['home_number']==1){?><th width="10%" ><strong>Home No</strong></th><?php }?>

        <th width="8%" class=" alignment"><strong>Class/Sec</strong></th>

        <?php if($_GET['roll_no']==1){?><th width="10%" style="border-right:1px solid black" ><strong>Roll No</strong></th><?php }?>


        <?php if($_GET['adm_no']==1){?><th width="10%" style="border-right:1px solid black" ><strong>Adm No</strong></th><?php }?>


        <th width="6%" class=" center"> Paid </th>  
        
        <?php if($_REQUEST['others']==1){
      
         foreach ($fee_types as $type) {
          $branchId=$_SESSION['branch'];
          $query11="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchId' and fee_head_id=".$type['feetype_id'];
           $feeHeads = $m->query($query11);
        ?>              
             <th width="5%" class=" center"> <?php if ($feeHeads[0]['fee_head_title']!=NULL){echo $feeHeads[0]['fee_head_title'];}else {echo $type['feetype_name'];} ?> </th>
        <?php } // loop 
        }else{ ?>

         <th width="6%" class=" center"> Others Total </th>  
        <?php } // ending else ?> 
                    
        
        <th width="6%" class=" center"> Transport </th>  
        <th width="6%" class=" center"><?php if ($branch[0]['misc_title']!=NULL){echo $branch[0]['misc_title'];}else {echo 'Misc.';} ?></th>
        <th width="6%" class=" center"> Balance </th>
        <th width="6%" class=" center"> Fine </th>    
        <th width="6%" class=" center"> Tuition </th>  
        <th width="6%" class=" center"> Disc. </th>  
        <th width="8%" class=" center"> Total </th>    
        <th  width="8%" class="center"> Paid </th>
        <th  width="8%" class="center"> Paid Again </th>    
        <th width="10%" class="center" style=""> Rem. </th>
        <th width="10%" class="center" style="border-right:1px solid black;"> Paid By </th>              

                        
          </tr>
        </thead>
        <tbody>
   
       <?php 
      $count=1;
      $tf;
      $trf;
      $misc;
      $prof;
      $bal;
      $total_fees;
      $total_paid;
      $total_rem;
      $total_fine;
      $total_disc;
      
      
      foreach($WorkAssignListings as $WorkAssignListVal)
      { 


        $m->where("user_id", $WorkAssignListVal['paid_fee_user_id']);
        $userName=$m->get("edu_user_config");
 


    $total_others=0+getFeeAllOtherFee($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],$m);


     $std_total=intVal($WorkAssignListVal['balance'])+intVal($WorkAssignListVal['tutionfee'])+intVal($WorkAssignListVal['transportfee'])+intVal($WorkAssignListVal['misc_fee'])+intVal($WorkAssignListVal['collected_fine'])-$WorkAssignListVal['disc_amount'];



     // calculating students total fee 

      $tf+=$WorkAssignListVal['tutionfee'];
      $trf+=$WorkAssignListVal['transportfee'];
      $misc+=$WorkAssignListVal['misc_fee'];
      $bal+=$WorkAssignListVal['balance'];
      $total_fine+=$WorkAssignListVal['collected_fine'];
      $total_disc+=$WorkAssignListVal['disc_amount'];


       $Tadm+=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],1,$m);
      $Tpap+=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],2,$m);
      $Tuni+=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],3,$m);
      $Tstat+=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],4,$m);
      $Toth+=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],5,$m);
       $Tafund+=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],8,$m);
       $Rfee+=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],6,$m);
       $Sfee+=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],7,$m);
      
      
          //students whose fee is zero now going to be skip from the list
     /*   if($std_total==0 && $total_others==0){
          continue;
        }*/

        $paid_fee=0;
        $again_paid_fee=0;
        $paidAmountDate;

       $response_paying=check_in_range($_REQUEST['from'], $_REQUEST['to'], $WorkAssignListVal['paying_date']);

       if($response_paying==1){

       $paid_fee=intVal($WorkAssignListVal['collected_amount']+$WorkAssignListVal['collected_fine']);
       $paidAmountDate=$WorkAssignListVal['paying_date'];

         }

        $response_payagain=check_in_range($_REQUEST['from'], $_REQUEST['to'], $WorkAssignListVal['paid_again_date']);
 

      if($response_payagain==1){

         $again_paid_fee+=intVal($WorkAssignListVal['paid_again_amount']);
         $paidAmountDate=$WorkAssignListVal['paid_again_date'];

       }


        /*$paid_fee=intVal($WorkAssignListVal['collected_amount']+$WorkAssignListVal['collected_fine']+$WorkAssignListVal['paid_again_amount']);*/

        $remaining=intVal($std_total)+intVal($total_others)-intVal($WorkAssignListVal['collected_amount']+$WorkAssignListVal['collected_fine']+$WorkAssignListVal['paid_again_amount']);





        $total_fees+=$std_total+$total_others;
        $total_paid+=$paid_fee;
        $total_paidAgain+=$again_paid_fee;
        $total_rem+=$remaining;
   ?>
        <tr> 
                  <td class="center"> <?php echo $count; $count++;?> </td>
                  <td  class="alignment">
                    <a style="text-decoration: none;" href="pay_fee.php?student=<?php echo $WorkAssignListVal['student_id']; ?>">
                      <?php echo  $WorkAssignListVal['first_name']; ?>
                      </a></td>
                  <?php if($_GET['father_name']==1){?><td  class="alignment"><?php echo  $WorkAssignListVal['last_name']; ?></td><?php }?>
                  <td  class="center"> <?php echo  $WorkAssignListVal['cell_no']; ?></td>
                  <?php if($_GET['father_cellno']==1){?><td  class="center"> <?php echo  $WorkAssignListVal['father_cellno']; ?></td><?php }?>

                 <?php if($_GET['mother_cell']==1){?><td  class="center"> <?php echo  $WorkAssignListVal['mother_cell']; ?></td><?php }?>

                 <?php if($_GET['home_number']==1){?><td  class="center"> <?php echo  $WorkAssignListVal['home_number']; ?></td><?php }?>

                  <td style="padding-left:1%;">
                  <?php echo  getClassName($m,$WorkAssignListVal['class_id'])."-".getSectionName($m,$WorkAssignListVal['section_id']);  ?>              
                </td>

                  <?php if($_GET['roll_no']==1){?><td  class="center" ><?php echo  $WorkAssignListVal['candidate_roll_no']; ?></td><?php }?> 

                <?php if($_GET['adm_no']==1){?><td  class="center" ><?php echo  $WorkAssignListVal['ref_no']; ?></td><?php }?> 

                  <td class="center">  <?php echo date("d-M",strtotime($WorkAssignListVal['paying_date']));?> </td>                  
              
    
              <?php if($_REQUEST['others']==1){
            
           $others_fee;
           foreach ($fee_types as $type) {
            $fee=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],$type['feetype_id'],$m);
           // $others_fee+=$fee;
          ?>              
                <td class="center">  <?php echo 0+$fee;?> </td>

          <?php }// loop 
          }else{ ?>
           <td  class=" center"> <?php echo $total_others?> </td>  
          <?php }// ending else ?> 
              
                  <td class="center">  <?php echo 0+$WorkAssignListVal['transportfee'];?> </td>
                  <td class="center">  <?php echo 0+$WorkAssignListVal['misc_fee'];?> </td>

                  <td class="center">  <?php echo 0+$WorkAssignListVal['balance'];?> </td>
                  <td class="center">  <?php echo 0+$WorkAssignListVal['collected_fine'];?> </td>

                  <td class="center">  <?php echo 0+$WorkAssignListVal['tutionfee'];?> </td>
                  <td class="center">  <?php echo 0+$WorkAssignListVal['disc_amount'];?> </td>
                  <td class="center"> <?php echo $std_total+$total_others;?> </td>                   
                  <td class="center" style="font-weight:bold;"> 
                  <?php echo $paid_fee;?> </td>
                  <td class="center" style="font-weight:bold;"> 
                  <?php echo $again_paid_fee;?> </td>
                 
                  <td class="center" style="" > 
                  <?php   echo $remaining;?> </td>

                  <td class="center" style="border-right:1px solid gray;font-weight:bold;" > 
                  <?php   echo $userName[0]['user_fname'];?> </td>                   

                                 
              </tr>

       <?php $others_fee=""; } ?>


        <!-- <tr> 
                
                  <th colspan="10" style="padding-left:1%;">Total</th>
                  
                   <?php 

     

          if($_REQUEST['others']==1){ ?>
          
                  <th class=" center">  <?php echo number_format($Tadm,2);?>  </th>
                  <th class=" center">  <?php echo number_format($Tpap,2);?>  </th>
                  <th class=" center">  <?php echo number_format($Tuni,2);?>  </th>
                  <th class=" center">  <?php echo number_format($Tstat,2);?>  </th>
                  <th class=" center">  <?php echo number_format($Toth,2);?>  </th>
                  <th class=" center">  <?php echo number_format($Tafund,2);?>  </th>
                  <th class=" center">  <?php echo number_format($Rfee,2);?>  </th>
                  <th class=" center">  <?php echo number_format($Sfee,2);?>  </th>

        <?php } else { ?>

          <th class="center">  <?php echo number_format(getAllotherPaidFee($_REQUEST['month'],$from,$to,1,$m),2);?> </td>

          <?php } ?>
    
                  <th class=" center">  <?php echo number_format($trf,2);?>  </th>
                  <th class=" center">  <?php echo number_format($misc,2);?>  </th>
                  <th class=" center">  <?php echo number_format($bal,2);?>  </th>
                  <th class=" center">  <?php echo number_format($total_fine);?>  </th>                  
                  <th class=" center">  <?php echo number_format($tf,2);?>  </th>                  
                  <th class=" center"> <?php echo number_format($total_disc,1);?> </th>
                  <th class=" center"> <?php echo number_format($total_fees,1);?> </th>
                  
                  <th class=" center"> <?php echo number_format($total_paid,1);?> </th>
                  <th class=" center"> <?php echo number_format($total_paidAgain,1);?> </th>
                  <th class=" center" style="border-right:1px solid gray;font-weight:bold;" > <?php echo number_format($total_rem,1);?> </th>  
                  <th></th>             
              </tr> -->





            <!--   <tr>
            
                <th class=" center" colspan="10"> Total </th>  
                
                <?php if($_REQUEST['others']==1){
            
             foreach ($fee_types as $type) {
            ?>              
             <th class=" center"> <?php echo$type['feetype_name']; ?> </th>
              <?php }// loop 
              }else{ ?>
               <th class=" center"> Others Total </th>  
              <?php }// ending else ?> 
                            
              <th class=" center"> Transport </th>  
              <th class=" center"> <?php if ($branch[0]['misc_title']!=NULL){echo $branch[0]['misc_title'];}else {echo 'Misc.';} ?> </th><th class=" center">  Balance </th>  
                <th class=" center"> Fine </th>
                <th class=" center"> Tuition </th>  
                <th class=" center"> Disc. </th>  
                <th class=" center"> Total </th>  
                <th class=" center"> Paid </th>
                <th class=" center"> Paid Again </th>
                <th class=" center" style="border-right:1px solid black;"> Rem. </th>
                <th></th>
                
              </tr>  -->      
              
       
            
           
        </tbody>
        
    </table>


     <table class="centertable" style="border-collapse: collapse;width: 60%;margin-top: 15px;">
      <tr>
            <td width="1%" style="border-top: 1px solid gray;" class="text-center">1</td>
            <td width="10%" style="border-top: 1px solid gray;font-weight: bold;">Balance</td>
            <td width="10%" class="text-center" style="border-right: 1px solid gray;border-top: 1px solid gray;"><?php echo number_format($bal,0); ?></td>
                                    
      </tr>

      <tr>
            <td width="1%" class="text-center">2</td>
            <td width="10%" style="font-weight: bold;">Monthly Fee</td>
            <td width="10%" class="text-center" style="border-right: 1px solid gray;"><?php echo number_format($tf,0); ?></td>
                                    
      </tr>

      <tr>
            <td width="1%" class="text-center">3</td>
            <td width="10%" style="font-weight: bold;">Discount</td>
            <td width="10%" class="text-center" style="border-right: 1px solid gray;"><?php echo number_format($total_disc,0); ?></td>
                                    
      </tr>

      <tr>
            <td width="1%" class="text-center">4</td>
            <td width="10%" style="font-weight: bold;">Transport</td>
            <td width="10%" class="text-center" style="border-right: 1px solid gray;"><?php echo number_format($trf,0); ?></td>
                                    
      </tr>

      <tr>
            <td width="1%" class="text-center">5</td>
            <td width="10%" style="font-weight: bold;"><?php if ($branch[0]['misc_title']!=NULL){echo $branch[0]['misc_title'];}else {echo 'Misc.';} ?></td>
            <td width="10%" class="text-center" style="border-right: 1px solid gray;"><?php echo number_format($misc); ?></td>
                                    
      </tr>

      <tr>
            <td width="1%" class="text-center">6</td>
            <td width="10%" style="font-weight: bold;">Fine</td>
            <td width="10%" class="text-center" style="border-right: 1px solid gray;"><?php echo number_format($total_fine); ?></td>
                                    
      </tr>

      <?php 
            $query11="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='1'";     
               $feeHeads1 = $m->query($query11);
             ?>
      
      <tr>
            <td width="1%" class="text-center">7</td>
            <td width="10%" style="font-weight: bold;"><?php               
              if ($feeHeads1[0]['fee_head_title']!=NULL){echo $feeHeads1[0]['fee_head_title'];} else {echo "Admission Fee";} ?></td>           
          <td width="10%" class="text-center" style="border-right: 1px solid gray;">  <?php echo number_format($Tadm,0);?> </td>         
                                    
      </tr>

       <?php 
            $query11="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='2'";   

               $feeHeads2 = $m->query($query11);
           ?>

      <tr>
            <td width="1%" class="text-center">8</td>
            <td width="10%" style="font-weight: bold;"><?php               
              if ($feeHeads2[0]['fee_head_title']!=NULL){echo $feeHeads2[0]['fee_head_title'];} else {echo "Paper Fund";} ?></td>           
          <td width="10%" class="text-center" style="border-right: 1px solid gray;">  <?php echo number_format($Tpap,0);?> </td>         
                                    
      </tr>

      <?php 
            $query11="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='3'";     
               $feeHeads3 = $m->query($query11);
           ?>

      <tr>
            <td width="1%" class="text-center">9</td>
            <td width="10%" style="font-weight: bold;"><?php               
              if ($feeHeads3[0]['fee_head_title']!=NULL){echo $feeHeads3[0]['fee_head_title'];} else {echo "Uniform/Card Fee";} ?>	</td>           
          <td width="10%" class="text-center" style="border-right: 1px solid gray;">  <?php echo number_format($Tuni,0);?> </td>         
                                    
      </tr>

        <?php 
            $query11="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='4'";     
               $feeHeads4 = $m->query($query11);
           ?>

      <tr>
            <td width="1%" class="text-center">10</td>
            <td width="10%" style="font-weight: bold;"><?php               
              if ($feeHeads4[0]['fee_head_title']!=NULL){echo $feeHeads4[0]['fee_head_title'];} else {echo "Stationery";} ?></td>           
          <td width="10%" class="text-center" style="border-right: 1px solid gray;">  <?php echo number_format($Tstat,0);?> </td>         
                                    
      </tr>

      <?php 
            $query11="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='5'";     
               $feeHeads5 = $m->query($query11);
            ?>

      <tr>
            <td width="1%" class="text-center">11</td>
            <td width="10%" style="font-weight: bold;"><?php               
              if ($feeHeads5[0]['fee_head_title']!=NULL){echo $feeHeads5[0]['fee_head_title'];} else {echo "Other Fee";} ?></td>           
          <td width="10%" class="text-center" style="border-right: 1px solid gray;">  <?php echo number_format($Toth,0);?> </td>         
                                    
      </tr>

      <?php 
            $query11="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='8'";     
               $feeHeads8 = $m->query($query11);
            ?>

      <tr>
            <td width="1%" class="text-center">12</td>
            <td width="10%" style="font-weight: bold;"><?php               
              if ($feeHeads8[0]['fee_head_title']!=NULL){echo $feeHeads8[0]['fee_head_title'];} else {echo "Annual Fund";} ?>	</td>           
          <td width="10%" class="text-center" style="border-right: 1px solid gray;">  <?php echo number_format($Tafund,0);?> </td>         
                                    
      </tr>

       <?php 
            $query11="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='6'";     
               $feeHeads6 = $m->query($query11);
            ?>

      <tr>
            <td width="1%" class="text-center">13</td>
            <td width="10%" style="font-weight: bold;"><?php               
              if ($feeHeads6[0]['fee_head_title']!=NULL){echo $feeHeads6[0]['fee_head_title'];} else {echo "Registration Fee";} ?>	</td>           
          <td width="10%" class="text-center" style="border-right: 1px solid gray;">  <?php echo number_format($Rfee,0);?> </td>         
                                    
      </tr>
     
     <?php 
            $query11="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='7'";     
               $feeHeads7 = $m->query($query11);
            ?>

      <tr>
            <td width="1%" class="text-center">14</td>
            <td width="10%" style="font-weight: bold;"><?php               
              if ($feeHeads7[0]['fee_head_title']!=NULL){echo $feeHeads7[0]['fee_head_title'];} else {echo "Security Fee";} ?>	</td>           
          <td width="10%" class="text-center" style="border-right: 1px solid gray;">  <?php echo number_format($Sfee,0);?> </td>         
                                    
      </tr>
      

          
      
      <tr style="background-color: lightgray;">
            <td width="1%" class="text-center">15</td>
            <td width="10%" style="font-weight: bold;">Total</td>
            <td width="10%" class="text-center" style="border-right: 1px solid gray;"><?php echo number_format($total_fees-$disc,0); ?></td>                                    
      </tr>

      <tr style="background-color: lightgray;">
            <td width="1%" class="text-center">16</td>
            <td width="10%" style="font-weight: bold;">Paid</td>
            <td width="10%" class="text-center" style="border-right: 1px solid gray;"><?php echo number_format($total_paid,0); ?></td>                                    
      </tr>

      <tr style="background-color: lightgray;">
            <td width="1%" class="text-center">17</td>
            <td width="10%" style="font-weight: bold;">Paid Again</td>
            <td width="10%" class="text-center" style="border-right: 1px solid gray;"><?php echo number_format($total_paidAgain,0); ?></td>                                    
      </tr>

      <tr style="background-color: lightgray;">
            <td width="1%" class="text-center">18</td>
            <td width="10%" style="font-weight: bold;">Total Paid</td>
            <td width="10%" class="text-center" style="border-right: 1px solid gray;"><?php echo number_format($total_paidAgain+$total_paid,0); ?></td>                                    
      </tr>

       <tr style="background-color: lightgray;">
            <td width="1%" class="text-center">19</td>
            <td width="10%" style="font-weight: bold;">Remaining</td>
            <td width="10%" class="text-center" style="border-right: 1px solid gray;"><?php echo number_format($total_rem,0); ?></td>                                    
      </tr>

    </table>

</body>
</html>
