<?php include('parent/callMe.php');?>
<?php include('Sessioncheck.php');?>
<?php
$branch=$_SESSION['branch'];
$sessionID=$_REQUEST['session'];
$month=$_REQUEST['month'];



       
$sql = " select std.*, fee.* from  edu_student_details as std, eduportal_student_fee_structure as fee where std.student_id=fee.student_id AND std.session_id='$sessionID' AND std.status='0' AND std.branch_id='$branch' group by std.cell_no order by std.last_name asc";

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


$m->where("branch_id", $_SESSION['branch']);
$branchDetail=$m->get("edu_branch_config");

 ?>

<!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 Un-Paid Family List</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-left:1px solid black;border-top: 1px solid black;border-bottom: 1px solid black;text-align:center;background-color:lightgray;font-size:14px;}
tr td {border-bottom:1px solid black;border-left:1px solid black;font-size:16px;}
  
.border{border:1px solid black;}
.center{text-align:center;}
.alignment{padding-left:1%;text-align:left;}



@media print {
    #Header, #Footer { display: none !important; }
}
@media screen
   {
      p.bodyText {font-family:verdana, arial, sans-serif;}
   }

   @media print
   {
      p.bodyText {font-family:georgia, times, serif;}
   }
   @media screen, print
   {
      p.bodyText {font-size:10pt}
   }
   @media print {
  a[href]:after {
    content: none !important;
  }
}
.center{text-align:center;}
</style>
</head>

<body style="font-size:12px;padding-right:1%;padding-left:1%;padding-top:3%;padding-bottom:1%;">

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

<br>

<div style="text-align:center;font-size:20px;font-weight:bold;"> PAID FAMILY LIST

 </div>

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


<br>
   


    <table id="listofstudents" class="table table-striped table-bordered" style="width:100%">
 
        <thead>
            <tr>
              
                <th width="1%">S.No</th>
                <th width="10%">Father Name</th>
                <th width="8%">Students Name</th>
                <th width="8%">Cell No</th>              
                <th width="10%">Total</th>
                <th width="10%">Received</th>
                <th width="10%">Remaining</th>
                                
            </tr>
        </thead>
        <tbody>


   
     
     <?php 
$count=1;
      foreach($WorkAssignListings as $WorkAssignListVal)
      { 
  

  $m->where("Month_Id", $_REQUEST['month']);
  $months=$m->get("eduportal_month_config");

  $cell=$WorkAssignListVal['cell_no'];

  $sqll = " select std.* from  edu_student_details as std where std.status='0' AND std.branch_id='$branch' And std.cell_no='$cell'";
  //print_r($sqll);
  $studentDatas = $m->query($sqll);

  
  $sessionID=$_REQUEST['session'];
  $qr="SELECT SUM(fee.tutionfee) as tution,SUM(fee.transportfee) as trans,SUM(fee.total_fine) as fine, SUM(fee.disc_amount) as disc, SUM(fee.balance) as balance,SUM(fee.misc_fee) as misc,SUM(fee.collected_amount) as received,SUM(fee.paid_again_amount) as againreceived FROM eduportal_monthly_challan as fee, edu_student_details as std WHERE fee.branch_id='$branch' and std.status='0' and fee.month_id='$month' and std.session_id='$sessionID' and std.student_id=fee.student_id AND std.cell_no='$cell'";
//print_r($qr);
  $details = $m->query($qr);

  foreach ($studentDatas as $studentIds) {
    
    $stdID=$studentIds['student_id'];

    $qr1="SELECT * FROM eduportal_monthly_challan WHERE branch_id='$branch' and month_id='$month' and session_id='$sessionID' and student_id='$stdID'";
//print_r($qr1);
  $monthlChallan = $m->query($qr1);


   $adm=getFeeOfOtherParameter($studentIds['student_id'],$monthlChallan[0]['challan_id'],1,$m);
  $papr=getFeeOfOtherParameter($studentIds['student_id'],$monthlChallan[0]['challan_id'],2,$m);
  $misc=getFeeOfOtherParameter($studentIds['student_id'],$monthlChallan[0]['challan_id'],3,$m);
  $stati=getFeeOfOtherParameter($studentIds['student_id'],$monthlChallan[0]['challan_id'],4,$m);
  $oth=getFeeOfOtherParameter($studentIds['student_id'],$monthlChallan[0]['challan_id'],5,$m);
  $reg=getFeeOfOtherParameter($studentIds['student_id'],$monthlChallan[0]['challan_id'],6,$m);
  $sec=getFeeOfOtherParameter($studentIds['student_id'],$monthlChallan[0]['challan_id'],7,$m);
  $anual=getFeeOfOtherParameter($studentIds['student_id'],$monthlChallan[0]['challan_id'],8,$m);

$other_totals=$adm+$papr+$misc+$stati+$oth+$reg+$sec+$anual;

  }

  



  

$payableAmount=$details[0]['tution']+$details[0]['trans']+$details[0]['fine']+$details[0]['balance']+$details[0]['misc']+$other_totals-$details[0]['disc'];

$totalReceived=$details[0]['received']+$details[0]['againreceived'];

$remaningAmount=$payableAmount-$totalReceived;

  
if ($remaningAmount>0) {
  continue;
}


     
      ?>

        <tr>

          <td style="text-align:center; padding: 2px;"><?php echo $count++;?></td>
          <td><a href="pay_fee.php?student=<?php echo $WorkAssignListVal['student_id'];?>"><?php echo $WorkAssignListVal['last_name'];?></a></td>
          <td><?php foreach ($studentDatas as $studentData) {
            echo $studentData['first_name'].",";  } ?></td>      
          <td><?php echo $WorkAssignListVal['cell_no'];?></td>
          <td><?php echo $payableAmount;?></td>
          <td><?php echo $totalReceived;?></td>
          <td><?php echo $remaningAmount;?></td>

        </tr>

              <?php
      }  ?>
 
        </tbody>
        
    </table>

    

</body>
</html>
