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

<?php  include("sessioncheck.php"); ?>

<?php





 $branch=$_SESSION['branch'];

 $month_id=$_REQUEST['month'];

 $year=$_REQUEST['year'];



 $sql = " select std.student_id,std.ref_no,std.first_name,std.last_name,std.cell_no,std.branch_id,std.class_id,std.candidate_roll_no,std.section_id,std.family_code,std.status, fee.* from  edu_student_details as std, eduportal_monthly_challan as fee where std.student_id=fee.student_id AND std.status='0' AND fee.month_id='$month_id' AND std.branch_id=".$_SESSION['branch'];



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

    

    } else {

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



    } 

  



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

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

  }else {

    $sql .= " AND fee.year = '" .date("Y"). "' ";

  }



  //print_r($sql);



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

 

     ?>





<!DOCTYPE html>

<html lang="en">

  <head>

    

    <title>Search Students with Fee | 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="" style="background-color: white;">



           <!--  <a href="<?php echo $_SESSION['dashboard'];?>" style="margin-left: 33px;">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp;



          <a href="multi_fee_reports.php">Fee Reports </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp;  



          Search Students With Fee

            -->

            

    <section class="add_sub_agent" id="table_sub_agent">

  <div class="container">



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

     

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

    </div>



<!-- <div style="overflow-x:auto;"> -->

      



<form class="form-style-7" action="arrear_reports.php" method="get"  enctype="multipart/form-data">



  <input type="hidden" id="year"  name="year" value="<?php echo $_GET['year']; ?>" />

  <input type="hidden" id="date"  name="date" value="<?php echo $_GET['date']; ?>" />



      

              


              <div class="col-md-2 col-xs-12" style="padding: 8px;">

                <div class="form-group ">

                  <label class="required">Year</label>

                    <select name="year" class="form-control" style="height:40px;">

                    <option value="All">All</option>

                    <?php

                    $match;

                    if(!isset($_REQUEST['year'])){

                    $match=date("Y");

                    }else { $match=$_REQUEST['year']; }

                    for($i=2018;$i<2031;$i++){ ?> 

                      <option <?php if($match==$i){echo 'selected';}?> value="<?php echo $i; ?>"><?php echo $i; ?></option>

                    <?php } ?>  

                 </select>

                  </div>

                </div>





              <div class="col-md-2 col-xs-12" style="padding: 8px;">



             <div class="form-group ">



                <label class="required">Month</label>

                    <select name="month" id="month" class="form-control" style="height:40px;">



                              <option value="">Select Month</option>

                        



                        <?php

                        $WorkAssignList = $m->get("eduportal_month_config");

                        foreach($WorkAssignList as $WorkAssignListVal)

                        { ?>



                           <option <?php if($_REQUEST['month']==$WorkAssignListVal['Month_Id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['Month_Id']; ?>"><?php echo $WorkAssignListVal['Month_Name']; ?></option>





                                <?php

                        } ?>



                    </select>

                </div>





        </div>





             

             <div class="col-md-2 col-xs-12" style="padding: 8px;">

                <div class="form-group ">

                  <label class="required">Class</label>

 

                  <select name="class_id" class="form-control" style="height:40px;">

                    <option value="All">All</option>



                    <?php

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

                    $WorkAssignList = $m->get("edu_class_config");

                    foreach($WorkAssignList as $WorkAssignListVal)

                    { ?>



                       <option <?php if($_REQUEST['class_id']==$WorkAssignListVal['class_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['class_id']; ?>"><?php echo $WorkAssignListVal['Class_Name']; ?></option>





                            <?php

                    } ?>



                </select> 

                </div>

              </div>



              <div class="col-md-2 col-xs-12" style="padding: 8px;">

                <div class="form-group ">

                  <label class="required">Choose Order</label>

                  <select name="orderByAmount" class="form-control" style="height:40px;" >



                    <option <?php if($_REQUEST['orderByAmount']=='above'){echo "Selected";} ?> value="above">Above Amount</option>



                    <option <?php if($_REQUEST['orderByAmount']=='below'){echo "Selected";} ?>value="below">Below Amount</option>                   



                </select> 

                </div>

              </div>





              <div class="col-md-2 col-xs-12" style="padding: 8px;">

                <div class="form-group ">

                  <label class="required">Enter Amount</label>

                

                  <input class="form-control" type="text" name="arrear"  id="arrear" style="height:40px;"  value="<?php echo $_GET['arrear'];?>" required>

                </div>

              </div>

 



              <div class="col-md-2 " style="padding:12px;">

    

        

                <div class="form-group " style="margin-top: -1em;">

                   

                <button type="submit" class="btn btn-primary" style="margin-top: 34px;">Search</button>

                     <?php 

           if( $_REQUEST['arrear']!=""){

          ?>



            <a target="_blank" title="Print Arrear Report" href="print_arrear_reports.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&year=<?php echo $_GET['year'];?>&month=<?php echo $_GET['month'];?>&class_id=<?php echo $_GET['class_id'];?>&orderByAmount=<?php echo $_GET['orderByAmount'];?>&arrear=<?php echo $_GET['arrear'];?>&8lqc1oclfi4llgnioo156a61oe8lqc1oclfi4llgnioo156a61oe8lqc1" class="fa fa-print btn btn-primary" style="margin-top: 34px;padding: 9px;">&nbsp;Print

              

            </a>



          <?php 

          }

          ?>

                </div>



           



        

              </div>

</form>

     <?php  if(!isset($_REQUEST['class_id'])){?>



        <div class="col-md-12">



          

           <div id="check_std_msg" style="color:white;font-size:18px;" class="alert alert-danger alert-dismissible">

                    <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>

                     <strong>Warning!</strong> Please select month, class, other parameters and search !!!

            </div>

    



        </div>



  <?php   }?>         



 <form class="form-style-7" action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post" enctype="multipart/form-data">



  

<input type="hidden" name="action_call" value="SendArrearFeeSMS"  />  



<?php if (isset($_REQUEST['month'])) { ?> 

<div class="col-md-2 pull-right" style="margin-bottom:1%;">

<?php if($brid[0]['sms_service']=="0") { ?>  



<input type="submit" name="detailed" style="padding:3%;"  onClick=" return confirmation()" class="pull-left btn btn-primary form-control"  value="Send Arrear Fee SMS"  />











<?php } else { ?>

<input disabled type="submit" name="detailed" style="padding:3%;"  onClick=" return confirmation()" class="pull-left btn btn-primary  form-control"  value="Send Arrear Fee SMS"  />

<?php } ?>

</div>

<?php } ?>



    <table id="" data-page-length='100' class="table table-striped table-bordered" style="width:100%">

          

         <thead>

            <tr>

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

                <th width="25%" class="center"> Name</th>

                <th width="25%" class="center"> F.Name</th>

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

                <th width="15%" class=" center"> Class / Sec</th>

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

                <th width="7%" class=" center" > Total Fee </th>  

                <th width="10%" class=" center"> Paid Fee </th>

                <th width="10%" class=" center"> Arrear </th>  

                <th width="5%">



              <label class="container1"><input  type="checkbox" id="checkAll"/><span style="margin-top: -20%;border: 1px solid gray;" class="checkmark" ></span></label>

              

               </th>

                

                

                 

            </tr>

        </thead>

        <tbody>

  <?php 

$count=1;

      foreach($WorkAssignListings as $WorkAssignListVal)

      { 

 

        $stdId=$WorkAssignListVal['student_id'];



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

        $section=$m->get("edu_adm_section_detail");

         

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

        $class=$m->get("edu_class_config");



  if ($WorkAssignListVal['paid_status']==0 && date("Y-m-d") > $WorkAssignListVal['challan_duedate']) {

    $stdFine=$brid[0]['late_fee_fine'];

  } else {

    $stdFine="0";

  }



$adm=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],1,$m);

$papr=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],2,$m);

$lib=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],3,$m);

$lab=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],4,$m);

$othr=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],5,$m);

$regfee=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],6,$m);

$secufee=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],7,$m);

$anualfee=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],8,$m);

$otherFee=$adm+$papr+$lib+$lab+$othr+$regfee+$secufee+$anualfee;

   

$total_fee=$WorkAssignListVal['tutionfee']+$WorkAssignListVal['transportfee']+$WorkAssignListVal['balance']+$WorkAssignListVal['misc_fee']+$otherFee+$stdFine-$WorkAssignListVal['disc_amount'];



$totalcollectedAmount=$WorkAssignListVal['collected_amount']+$WorkAssignListVal['paid_again_amount'];

$totalArrear=$total_fee-$totalcollectedAmount;



      if ($_REQUEST['orderByAmount']=='above') {

        

        if ($totalArrear<$_REQUEST['arrear']) {

         continue;

       }



      } else {



        if ($totalArrear>$_REQUEST['arrear']) {

         continue;

       }



      }



       

      $sumTotalFee+=$total_fee;

      $sumTotalCollectedAmount+=$totalcollectedAmount;

      $sumTotalArrear+=$totalArrear;

     ?>



<input type="hidden" name="total_fee<?php echo $stdId; ?>" value="<?php echo $total_fee;?>">

<input type="hidden" name="total_collected_fee<?php echo $stdId; ?>" value="<?php echo $totalcollectedAmount;?>">

<input type="hidden" name="total_arrear<?php echo $stdId; ?>" value="<?php echo $totalArrear;?>">

<input type="hidden" name="student_name<?php echo $stdId; ?>" value="<?php echo $WorkAssignListVal['first_name'];?>">

<input type="hidden" name="father_name<?php echo $stdId; ?>"  value="<?php echo $WorkAssignListVal['last_name'];?>">

<input type="hidden" name="std_cell<?php echo $stdId; ?>"  value="<?php echo $WorkAssignListVal['cell_no'];?>">

<input type="hidden" name="monthID" value="<?php echo $_REQUEST['month'];?>">

<input type="hidden" name="year" value="<?php echo $_REQUEST['year'];?>">

<input type="hidden" name="class_id" value="<?php echo $_REQUEST['class_id'];?>">

<input type="hidden" name="orderByAmount" value="<?php echo $_REQUEST['orderByAmount'];?>">

<input type="hidden" name="arrear" value="<?php echo $_REQUEST['arrear'];?>">



        <tr> 

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

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

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

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

                  <td style="padding-left:1%;"><?php echo  $class[0]['Class_Name']." / ".$section[0]['section_name'];  ?></td>

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

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

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



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



                    <td>

                   <label class="container1">

                   <input type="checkbox" name="checkboxes[]"  value="<?php echo $WorkAssignListVal['student_id']; ?>"  class="cb-element" /><span class="checkmark"></span>

                  </label>

                  </td>                  

                                 

              </tr>



       <?php } ?>



        <tr>

        <th colspan="6" class="center borderTop">Total</th>

        <th  class="center borderTop"><?php echo $sumTotalFee;?></th>

        <th  class="center borderTop"><?php echo $sumTotalCollectedAmount;?></th>

        <th  class="center borderTop"><?php echo $sumTotalArrear;?></th>

        



       </tr>

           

            

           

        </tbody>

        

    </table>



</form>

</div>



    <br><br>





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

        $(document).ready(function() {

        $('#listofstudents').DataTable();

        } 

        );



        $("#checkAll").change(function () {



      $("input:checkbox").prop('checked', $(this).prop("checked"));

  });

    </script>

  </body>

</html>

