<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); 

$branch=$_SESSION['branch'];
$WorkAssignListings = $m->query("SELECT sec.*, cls.* FROM edu_adm_section_detail as sec LEFT JOIN edu_class_config as cls ON sec.class_id = cls.class_id where cls.class_id!='' and cls.branch_id='$branch' and sec.branch_id='$branch' group by cls.class_id");

?>

<!DOCTYPE html>
<html lang="en">
  <head>
   
    <title> Classwise Fee Status | EduPortal </title>
    <?php include('RootMe/css_links.php');?>
   
  </head>
 
  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
     
            <?php include('RootMe/sidebar.php');?>

              <?php include('RootMe/header.php');?>
     
        <!-- page content -->
         
            <div class="right_col" role="main">
            <div class="row">
        <h3 style="float: left;">Class Wise Fee Reports </h3>

          <a target="_blank" class="btn btn-success pull-right" title="Print Students List" href="print_students_report.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&class_id=<?php echo $_GET['class_id'];?>&section=<?php echo $_GET['section'];?>">
          <i class="fa fa-print m-right-xs" target="_blank"></i> &nbsp; Print Report
        </a>

        <a target="_blank" class="btn btn-warning pull-right" title="Print Students List" data-toggle="modal" data-target="#Modal<?php echo $_GET['class_id'];?>-<?php echo $_GET['section'];?>" style=""><i class="fa fa-print m-right-xs" target="_blank"></i>&nbsp;Print All Students List
            
          </a>

  
  <table  class="table table-striped table-bordered" style="width:100%;background-color:#FFFFFF;">
        <thead>
            <tr>

                <th width="10%" style="text-align:center;"> S.No </th>
                <th width="25%"> Class </th>
                <th width="20%" style="text-align:center;"> Expected Fee </th>
                <th width="20%" style="text-align:center;">Fee Received </th>
                <th width="20%" style="text-align:center;">Remaining </th>
                
            </tr>
        </thead>
        <tbody>


   
     
     <?php 

   
     $count=1;
     $std=0;
      foreach($WorkAssignListings as $WorkAssignListVal)
      { 

        
      $cls=$WorkAssignListVal['class_id'];
      $section=$WorkAssignListVal['section_id'];
      $curr_session=$_SESSION['current_session'];
      $monthID=date('m');

      $qr="SELECT SUM(fee.tutionfee) as tution,SUM(fee.transportfee) as trans,SUM(fee.total_fine) as fine, SUM(fee.balance) as balance,SUM(fee.misc_fee) as misc, SUM(fee.disc_amount) as disc FROM eduportal_monthly_challan as fee WHERE fee.branch_id='$branch' AND fee.session_id='$curr_session' AND fee.month_id='$monthID' AND fee.classs_id='$cls'";
//print_r($qr);
  $amount = $m->query($qr);
  echo $amount[0]['tution'];
  $total_expectedFee=$amount[0]['tution']+$amount[0]['trans']+$amount[0]['fine']+$amount[0]['balance']+$amount[0]['misc']-$amount[0]['disc'];
      
       // getting strength of students 
       
      $m->where("section_id", $section);
      $m->where("class_id", $cls);
      $m->where("status", 0);
      $m->where("branch_id", $_SESSION['branch']);
      /*$m->where("session_id", $_SESSION['current_session']);*/
      $total=$m->get("edu_student_details");
      $std+=count($total);
//echo $std;
      ?>

        <tr>


                  
                  <td style="text-align:center;"> <?php echo $count; $count++;?> </td>

                  <td> <?php echo  $WorkAssignListVal['Class_Name']." - ".$WorkAssignListVal['section_name']; ?> </td>

                  <td  style="text-align:center;"> <?php echo count($total_expectedFee);?> </td>
                  
                  <td style="text-align:center;">  <?php echo count($total);?> </td>

                  <td style="text-align:center;">  <?php echo count($total);?> </td>

              </tr>

              <?php
      }   ?>

  
           
        </tbody>
        
    </table>

        </div> 
        </div>

            </div>
          </div>
        </div>
        <!-- /page content -->
  

        <?php include('RootMe/js_linksscript.php');?>
  
  </body>
</html>
