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

<?php include('Sessioncheck.php');?>

<?php   

  
$year= $_REQUEST['year'];


 $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 std.class_id = '" .$_REQUEST['class_id']. "' ";



    }



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

    

    } else {

     $sql .= " AND std.section_id = '" .$_REQUEST['section']. "' ";



    }



   

  if($_REQUEST['year']!=NULL){

    $sql .= " AND fee.year = '" .$_REQUEST['year']. "' ";

  }



  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 std.section_id";

 //echo $sql;



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





  // getting branch details

  $branch=getBranch($m);



}



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



?>

<!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;}





</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 Fee List



 </div>



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

<!-- 

<div style="width:33%;float:left;font-size:16px;">  <b> Class Name:</b> 



<?php echo getClassName($m,$_REQUEST['class_id']); ?> 



</div>

 -->

<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> Year:</b> <?php echo $year;?> </div>



<br>

   

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

      

  <thead>

    <tr>



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

        <th width="15%" class="center"> Student </th>

        <th width="10%" class="center"> Cell No</th>

        <th width="8%" class=" center"> Class</th>

        <th width="5%" class=" center"> R.No / Adm </th>  



        <?php if($_GET['other']==1){?>

        <?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 ?> 

     <?php } // end display condition?>       



     <?php if($_GET['transport_fee']==1){?> 



    <th width="6%" class=" center"> <?php if ($brid[0]['transport_title']!=NULL){echo $brid[0]['transport_title'];}else {echo 'Transport Fee';} ?> </th>  



    <?php } ?>



       <?php if($_GET['miscellaneous']==1){?> 

        <th width="6%" class=" center"><?php if ($brid[0]['misc_title']!=NULL){echo $brid[0]['misc_title'];}else {echo 'Misc.';} ?></th>

       <?php } ?>



        <?php if($_GET['Balance']==1){?>

        <th width="6%" class=" center"> Balance </th>  

        <?php } ?>



        <?php if($_GET['Tuition']==1){?>

        <th width="6%" class=" center"> Tuition </th>  

        <?php } ?>



        <?php if($_GET['Disc']==1){?>

        <th width="6%" class=" center"> Disc. </th>  

        <?php } ?>



        <th width="6%" class=" center"> Total </th>  



        <?php if($_GET['Received']==1){?>

        <th width="6%" class=" center"> Received </th>  

        <?php } ?>



        <?php if($_GET['remainging']==1){?>

        <th width="6%" class=" center"> Balance </th>  

        <?php } ?>



        <?php if($_GET['paid_by']==1){?>

        <th width="6%" class=" center"> Paid </th>

        <?php } ?>



        <?php if($_GET['blank_column']==1){?>

        <th width="6%" class=" center" style="border-right:1px solid black;"> Blank </th>  

        <?php } ?>

        

        

                         

          </tr>

        </thead>

        <tbody>

  

   <?php 

      $count=1;

      $tf;

      $trf;

      $misc;

      $prof;

      $bal;

      $total_fees;

      $total_paid;

      $total_rem;

      $disc;

      $totalAllOtherFee;

      $collectedFine;

      

      

      foreach($WorkAssignListings as $WorkAssignListVal)

      { 





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

        $userName=$m->get("edu_user_config");

 

    // now getting the other fee parameters of student against current month



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



     // calculating students total fee 



      $tf+=$WorkAssignListVal['tutionfee'];

      $trf+=$WorkAssignListVal['transportfee'];

      $misc+=$WorkAssignListVal['misc_fee'];

      $bal+=$WorkAssignListVal['balance'];

      $disc+=$WorkAssignListVal['disc_amount'];

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

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



      

          //students whose fee is zero now going to be skip from the list

      /*  if($std_total==0 && $total_others==0 && $WorkAssignListVal['tutionfee']=="" || $WorkAssignListVal['tutionfee']==0){

          continue;

        }*/





         if($std_total==0 && $total_others==0){

          continue;

        }





        $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']);



        $total_fees+=$std_total+$total_others;

        $total_paid+=$paid_fee;

        $total_rem+=$remaining;



        

   ?>

        <tr> 

      <td class="center"> <?php echo $count; $count++;?> </td>

      <td style="padding-left:1%;"><?php echo $WorkAssignListVal['first_name']." / ".$WorkAssignListVal['last_name'];  ?></td>

      <td style="padding-left:1%;"><?php echo $WorkAssignListVal['cell_no'];  ?></td>

      <td style="padding-left:1%;">

<?php echo  getClassName($m,$WorkAssignListVal['class_id'])."-".getSectionName($m,$WorkAssignListVal['section_id']);  ?>              

      </td>

      <td class="center">  <?php echo $WorkAssignListVal['candidate_roll_no']." / ".$WorkAssignListVal['ref_no'];?>  </td>                  

          <?php if($_GET['other']==1){?>

          <?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 ?> 

          <?php }// ending display ?>  



                  <?php if($_GET['transport_fee']==1){?> 

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

                  <?php } ?>



                   <?php if($_GET['miscellaneous']==1){?>  

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

                   <?php } ?>



                   <?php if($_GET['Balance']==1){?>

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

                  <?php } ?>



                  <?php if($_GET['Tuition']==1){?>

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

                  <?php } ?>



                  <?php if($_GET['Disc']==1){?>

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

                  <?php } ?>



                  <td class="center" > 

                    <?php echo $std_total+$total_others+$WorkAssignListVal['collected_fine']-$WorkAssignListVal['disc_amount'];?> </td>



                    <?php if($_GET['Received']==1){?>

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

                   <?php } ?>



                    <?php if($_GET['remainging']==1){?>

                  <td class="center"> <?php echo $std_total+$total_others+$WorkAssignListVal['collected_fine']-$WorkAssignListVal['disc_amount']-($WorkAssignListVal['collected_amount']+$WorkAssignListVal['paid_again_amount']+$WorkAssignListVal['collected_fine']);?>  </td>

                   <?php } ?>



                   <?php if($_GET['paid_by']==1){?>

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

                   <?php } ?>



                  <?php if($_GET['blank_column']==1){?>

                  <td style="border-right:1px solid black;"></td>

                  <?php } ?>





  

                                 

              </tr>



       <?php $others_fee=""; 





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



   }



       // ending loop 





        ?>





        <tr> 

                

          <th colspan="5" style="padding-left:1%;">Total</th>

          <?php if($_GET['other']==1){?>

                   <?php 



          if($_REQUEST['others']==1){

          

           foreach ($fee_types as $type) {

            $fee=getAllotherUnPaidFeeWithType($_REQUEST['month'],$type['feetype_id'],0,$m);

          ?>              

          

          <th class="center">  <?php echo number_format($fee,2);?> </td>



          <?php }// ending loop



          }else{ ?>



          <th class="center">  <?php echo number_format($totalAllOtherFee,2);?> </td>



          <?php }  }?>

                  

                  <?php if($_GET['transport_fee']==1){?> 

                  <th class=" center">  <?php echo number_format($trf,2);?>  </th>

                  <?php } ?>



                  <?php if($_GET['miscellaneous']==1){?>

                  <th class=" center">  <?php echo number_format($misc,2);?>  </th>

                  <?php } ?>



                  <?php if($_GET['Balance']==1){?>

                  <th class=" center">  <?php echo number_format($bal,2);?>  </th>

                  <?php } ?>



                  <?php if($_GET['Tuition']==1){?>

                  <th class=" center">  <?php echo number_format($tf,2);?>  </th>   

                  <?php } ?>



                  <?php if($_GET['Disc']==1){?>               

                  <th class=" center">  <?php echo number_format($disc,2);?>  </th>   

                  <?php } ?>



                  <th class=" center"> <?php echo number_format($total_fees-$disc,1);?> </th>



                  <?php if($_GET['Received']==1){?>

                  <th class=" center"> <?php echo number_format($total_paid,2);?>  </th>  

                  <?php } ?>



                  <?php if($_GET['remainging']==1){?>  

                  <th class=" center"> <?php echo number_format($balbal,2);?>  </th> 

                  <?php } ?>



                  <?php if($_GET['paid_by']==1){?>   

                  <th class=" center">   </th>

                  <?php } ?>



                  <?php if($_GET['blank_column']==1){?> 

                  <th class=" center" style="border-right:1px solid black;">   </th>  

                  <?php } ?>  

                  

              </tr>













              <tr>

            

                <th class=" center" colspan="5"> Total </th>  

                <?php if($_GET['other']==1){?>

                <?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 ?> 

            <?php }// display else ?> 

                 

              <?php if($_GET['transport_fee']==1){?>           

              <th class=" center"> Transport </th> 

              <?php } ?> 



              <?php if($_GET['miscellaneous']==1){?>   

              <th class=" center"> <?php if ($branch[0]['misc_title']!=NULL){echo $branch[0]['misc_title'];}else {echo 'Misc.';} ?> </th>

              <?php } ?> 



                <?php if($_GET['Balance']==1){?>

                <th class=" center">  Balance </th>  

                <?php } ?>



                <?php if($_GET['Tuition']==1){?>

                <th class=" center"> Tuition </th> 

                <?php } ?>



                <?php if($_GET['Disc']==1){?>

                <th class=" center"> Disc. </th>  

                <?php } ?>

                

                <th class=" center" > Total </th>                



                <?php if($_GET['Received']==1){?>

                <th class=" center"> Received  </th> 

                 <?php } ?>



                 <?php if($_GET['remainging']==1){?>

                <th class=" center"> Balance  </th>   

                <?php } ?> 



                <?php if($_GET['paid_by']==1){?>

                <th class=" center" >   </th> 

                <?php } ?> 



                <?php if($_GET['blank_column']==1){?>

                <th class=" center" style="border-right:1px solid black;">   </th>

                <?php } ?> 



              </tr>       

              

       

            

           

        </tbody>

        

    </table>



</body>

</html>

