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

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

$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("d-m-Y",strtotime($_REQUEST['from']));  

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

$sql.=" order by fee.challan_id desc limit 1200";
 //echo $sql;

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

}


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

  // getting details of total records



     ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Fee Reporting | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
<style>

.thStyle{background-color:lightgray;text-align:center;}

</style>   
  </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="" style="background-color: white;">
           
<section class="add_sub_agent" id="table_sub_agent">
  <div class="container">

 <div class="" style="margin-top:10px;">
      
      
      <div class="clearfix"></div>
    </div>
   

     
<table id="excelexpo" class="table table-striped table-bordered" style="width:100%">
  
          <thead>
            <tr>

              
                <th width="">S.No</th>
                <th width="">FEEMONTH</th>
                <th width="">CAMPUS</th>
                <th width="">ROLLNUMBER</th>
                <th width="">CHALLANNUMBER</th>
                <th width="">STUDENTNAME</th>
                <th width="">FATHERNAME</th>
                <th width="">STANDARDCLASS</th>
                <th width="">MONTHLYQUARTERLY</th>
                <th width="">TUTIONFEE</th>
                <th width="">BALANCE</th>
                <th width="">LATEPAYCHARGES</th>
                <th width="">MISCCHARGES</th>
                <th width="">OTHERS</th>
                <th width="">TAXAMOUNT</th>
                <th width="">FEEBEFOREDUEDATE</th>
                <th width="">DUEDATE</th>
                <th width="">FEEAFTERDUEDATE</th>
                <th width="">CELLNUMBER</th>
                <th width="">FATHERNUMBER</th>
                <th width="">MOTHERNUMBER</th>
                <th width="">HOMENUMBER</th>
                <th width="">WHATSAPPNUMBER</th>
              
               
            </tr>
        </thead>
        <tbody>


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

        $m->where("class_id", $WorkAssignListVal['class_id']);
        $class=$m->get("edu_class_config");

        $m->where("section_id", $WorkAssignListVal['section_id']);
        $section=$m->get("edu_adm_section_detail");

        $m->where("session_id", $WorkAssignListVal['session_id']);
        $session=$m->get("edu_session_config");


         $totalAmount= $WorkAssignListVal['tutionfee']+$WorkAssignListVal['transportfee']+$WorkAssignListVal['balance']+$WorkAssignListVal['misc_fee']+$others_fee-$WorkAssignListVal['disc_amount'];
              
          if($totalAmount==0 ||  $totalAmount=="0"){
          
          continue;
        } 

  $fee_fine;
  if(date("Y-m-d")>$WorkAssignListVal['challan_duedate']){

  $fee_fine=$branch1[0]['late_fee_fine'];
   }
   else {

  $fee_fine=0;

   }
        
      ?>

         <tr>

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

          <td style="padding: 2px;" > <?php echo getMonthName($m,$_REQUEST['month']);?></td>
          <td style="padding: 2px;" > <?php echo $_SESSION['branch_name']; ?> </td>
                  
          <td style="padding: 2px; text-align: center;"> <?php 
                  
        if($_SESSION['branch']!=25){
         echo $WorkAssignListVal['candidate_roll_no'];
       }else {
         echo $WorkAssignListVal['ref_no'];
       }  
         ?> </td>
          <td style="text-align:center; padding: 2px;"> <?php echo $WorkAssignListVal['challan_id'];?> </td>
          <td style="text-align:center; padding: 2px;"> <?php echo $WorkAssignListVal['first_name'];?> </td>
          <td style="padding: 2px;" > <?php echo $WorkAssignListVal['last_name'];?></td>
           <td style="padding: 2px;" > <?php echo getClassName($m,$WorkAssignListVal['class_id']);?></td>
           <td style="padding: 2px;" > <?php echo $WorkAssignListVal['tutionflle'];?></td>
           <td style="padding: 2px;" > <?php echo $WorkAssignListVal['tutionfee'];?></td>
           <td style="padding: 2px;" > <?php echo $WorkAssignListVal['balance'];?></td>
           <td style="padding: 2px;" > <?php echo $fee_fine;?> </td>
           <td style="padding: 2px;" > <?php echo $fee_fine22;?> </td>
           <td style="padding: 2px;" > <?php echo $others_fee;?></td>
           <td style="padding: 2px;" > <?php echo $others_fe555e;?></td>
           <td style="padding: 2px;" > <?php echo $totalAmount;?> </td>
           <td style="padding: 2px;" > <?php echo date("d-M",strtotime($WorkAssignListVal['challan_duedate']));?></td>
           <td style="padding: 2px;" > <?php echo $totalAmount+$fee_fine;?> </td>
           <td style="padding: 2px;" > <?php echo $WorkAssignListVal['cell_no'];?> </td>
           <td style="padding: 2px;" > <?php echo $WorkAssignListVal['father_cellno'];?> </td>
           <td style="padding: 2px;" > <?php echo $WorkAssignListVal['mother_cell'];?> </td>
           <td style="padding: 2px;" > <?php echo $WorkAssignListVal['home_number'];?> </td>
           <td style="padding: 2px;" > <?php echo $WorkAssignListVal['whatsapp_number'];?> </td>
         </tr>

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








  </div>
  <div class="clearfix"></div>
</section>            
    

           
          </div>
        </div>

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

    
  <?php include('RootMe/js_linksscript.php');?>
  <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
   
   <script src="js/FileSaver.min.js" type="text/javascript"></script>
  <script src="js/tableexport.min.js" type="text/javascript"></script>

  <script type="text/javascript">
    $('#excelexpo').tableExport();
  </script>
  </body>
</html>
