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

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

<?php   

/*

error_reporting(E_ALL);

ini_set('display_errors', '1');*/



$paidStatus=0;

  

 $sql = "SELECT fee.*,std.student_id,std.ref_no,std.first_name,std.last_name,std.cell_no,std.status,std.branch_id,std.class_id,std.section_id,std.session_id,std.family_code,std.father_cellno,std.mother_cell,std.home_number 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['year']!=NULL){

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

  }



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

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

  }



/*if (isset($_REQUEST['fee'])) {

  

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



 } else {*/

  $sql .= " AND fee.paid_status = '" .$paidStatus. "' ";

/* }



 }*/







  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. "'";



    

  }



if($_REQUEST['orderBy']=='asc'){

$sql .= "order by std.first_name asc";

}



if($_REQUEST['orderBy']=='desc'){

$sql .= "order by std.last_name asc";

}



if($_REQUEST['orderBy']=='RollNoWise'){

$sql .= "order by std.candidate_roll_no asc";

}



if($_REQUEST['orderBy']=='AdmNoWise'){

$sql .= "order by CAST(std.ref_no as unsigned)  asc";

}



if($_REQUEST['orderBy']=='ClassWise'){

$sql .= "order by fee.classs_id desc";

}



   //$sql .= " ORDER BY fee.classs_id desc ";

 //echo $sql;



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





  // getting branch details

  $branch=getBranch($m);



}



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



?>

<input type="hidden" name="" value="<?php print_r($sql);?>">

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

<?php include('RootMe/css_links.php');?>

<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:15px;padding:0.5%;}

tr td {border-bottom:1px solid gray;border-left:1px solid gray;font-size:15px;padding:0.5%;font-weight: bold;}

  

.border{border:1px solid black;}

.center{text-align:center;}

.alignment{padding-left:1%;text-align:left;}





.centertable {

  margin-left: auto;

  margin-right: auto;

}



</style>



<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css">

  <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.slim.min.js"></script>

  <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>

  <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js"></script>



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



 </div>



<!--   <a target="_blank" class="btn btn-success fa fa-print pull-right" style="height: 34px;padding: 6px;margin-top: -50px;font-size: 14px;" title="Print Fee Report" data-toggle="modal" data-target="#Modal<?php echo $_GET['class_id'];?>-<?php echo $_GET['section'];?>">

    Print Customize

  </a>  -->







   <!-- Modal -->

            <div id="Modal<?php echo $_GET['class_id'];?>-<?php echo $_GET['section'];?>" class="modal fade" role="dialog">





              <div class="modal-dialog">



                <!-- Modal content-->

                <div class="modal-content">



                   

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



                  <input type="hidden" name="action" value="PrintFeeParameter">

                  <input type="hidden" name="recevabl" value="PrintList">

             

                  <div class="modal-header">

                    <button type="button" class="close" data-dismiss="modal">&times;</button>

                    <h4 class="modal-title" style="font-size:20px;">Choose the parameters to display in print. </h4>

                  </div>





                  <div class="modal-body">



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

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

                  <!-- <input type="hidden" name="session" value="</?php echo $_GET['session'];?>" /> -->

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

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

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

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

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

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

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

                  <input type="hidden" name="checkboxes[]"  value="1"  class="cb-element" />

                 

               

                  <br> 

            

                                    

                  <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="student_name" checked value="1"/>

                    Student Name

                    <span class="checkmark"></span>

                  </label>



                  <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="father_name" checked value="1"/>

                    Father Name

                    <span class="checkmark"></span>

                  </label>



                   <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="class_sec" checked value="1"/>

                    Class/Sec

                    <span class="checkmark"></span>

                  </label>



                  <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="roll_no" checked value="1"/>

                    Roll No

                    <span class="checkmark"></span>

                  </label>



                  <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="adm_no" checked value="1"/>

                    Admission No

                    <span class="checkmark"></span>

                  </label>



                  <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="cell_no" checked value="1"/>

                    SMS Reporting Number

                    <span class="checkmark"></span>

                  </label>                  



                  <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="father_cellno" checked value="1"/>

                    Father Contact No

                    <span class="checkmark"></span>

                  </label>              



                  <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="mother_cell" checked value="1"/>

                    Mother Contact No

                    <span class="checkmark"></span>

                  </label>



                  <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="home_number" checked value="1"/>

                    Home Contact No

                    <span class="checkmark"></span>

                  </label>



                      <label class="container1" style="text-align: left;">



                       Display Fee Heads in Print

                      

                        <select name="others" style="height: 34px;" class="form-control col-md-12" >



                           <option <?php if($_GET['others']=="0"){echo 'selected';}?> value='0'>NO</option>

                           <option <?php if($_GET['others']=="1"){echo 'selected';}?> value='1'>YES</option>

                      

                          </select>



                        </label>





                        <label class="container1" style="text-align: left;">



                       Order By

                      

                        <select name="orderBy" style="height: 34px;" class="form-control col-md-12" >



                        <option <?php if($_REQUEST['orderBy']=='asc'){echo "Selected";}?> value="asc">Ascending Name</option>



                       <option <?php if($_REQUEST['orderBy']=='desc'){echo "Selected";}?> value="desc">Descending Name</option>



                       <option <?php if($_REQUEST['orderBy']=="AdmNoWise"){echo "Selected";}?>  value="AdmNoWise">Adm No Wise</option>



                       <option <?php if($_REQUEST['orderBy']=="RollNoWise"){echo "Selected";}?> value="RollNoWise">Roll No Wise</option>



                       <option <?php if($_REQUEST['orderBy']=="ClassWise"){echo "Selected";}?> value="ClassWise">Class Wise</option>

                      

                        </select>



                        </label>

                   





                  </div>



                

 



                  <div class="modal-footer" style="text-align: right;">

                    <input type="submit" style="font-size:15px;" class="btn btn-primary" checked value="Print" />

                  </div>



                   </form>

                </div>



              </div>

            </div>

            <!-- Modal -->



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

<?php $year=$_REQUEST['year']; ?>

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



        <?php if($_GET['student_name']==1){?><th width="12%" class=" alignment"><strong>Student Name</strong></th><?php }?>



        <?php if($_GET['father_name']==1){?><th width="10%" class=" alignment"><strong>Father Name</strong></th><?php }?>



        <?php if($_GET['cell_no']==1){?><th width="10%" ><strong>Cell No</strong></th><?php }?>



        <?php if($_GET['father_cellno']==1){?><th width="10%" ><strong>Father Cell No</strong></th><?php }?>



      <?php if($_GET['mother_cell']==1){?><th width="10%" ><strong>Mother Cell No</strong></th><?php }?>



      <?php if($_GET['home_number']==1){?><th width="10%" ><strong>Home Cell No</strong></th><?php }?>



        <?php if($_GET['class_sec']==1){?><th width="8%" class=" alignment"><strong>Class/Sec</strong></th><?php }?>



        <?php if($_GET['roll_no']==1){?><th width="10%" style="border-right:1px solid black" ><strong>Roll No</strong></th><?php }?>  



        <?php if($_GET['adm_no']==1){?><th width="10%" style="border-right:1px solid black" ><strong>Adm No</strong></th><?php }?>

        

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

      

     foreach ($fee_types as $type) {

    ?>              

         <th width="5%" class=" center"> <?php echo$type['feetype_name']; ?> </th>

    <?php }// loop 

    }else{ ?>

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

    <?php }// ending else ?> 

                

  <!--   <th width="6%" class=" center"> Transport </th>  

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

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

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

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

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

        

                         

          </tr>

        </thead>

        <tbody>

  

   <?php 

      $count=1;

      $tf;

      $trf;

      $misc;

      $prof;

      $bal;

      $total_fees;

      $total_paid;

      $total_rem;

      $disc;

      

      

      foreach($WorkAssignListings as $WorkAssignListVal)

      { 

 

    // 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'];

      

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



      $stdtotalwithDisc=$std_total-$WorkAssignListVal['disc_amount'];

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

        if($stdtotalwithDisc<=0 && $total_others<=0){

          continue;

        }





        $paid_fee=intVal($WorkAssignListVal['collected_amount']+$WorkAssignListVal['collected_fine']);

        $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;



        /*$sumOtherTotals+=$total_others;

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

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

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

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

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

        $sumTotal+=$std_total+$total_others-$WorkAssignListVal['disc_amount'];*/

   ?>

   <!-- href="pay_fee.php?student=<?php echo $WorkAssignListVal['student_id']; ?>" -->

        <tr> 

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



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

        <td  class="alignment">  

      <a style="text-decoration: none;" href="#">      

      <?php echo  $WorkAssignListVal['first_name']; ?></a></td>



      <?php }?>



      <?php if($_GET['father_name']==1){?><td  class="alignment"><?php echo  $WorkAssignListVal['last_name']; ?></td><?php }?>



      <?php if($_GET['cell_no']==1){?><td  class="center"> <?php echo  $WorkAssignListVal['cell_no']; ?></td><?php }?>



      <?php if($_GET['father_cellno']==1){?><td  class="center"> <?php echo  $WorkAssignListVal['father_cellno']; ?></td><?php }?>



      <?php if($_GET['mother_cell']==1){?><td  class="center"> <?php echo  $WorkAssignListVal['mother_cell']; ?></td><?php }?>



      <?php if($_GET['home_number']==1){?><td  class="center"> <?php echo  $WorkAssignListVal['home_number']; ?></td><?php }?>



      <?php if($_GET['class_sec']==1){?><td style="padding-left:1%;">

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

      </td><?php }?>



      <?php if($_GET['roll_no']==1){?><td  class="center" ><?php echo  $WorkAssignListVal['candidate_roll_no']; ?></td><?php }?> 



      <?php if($_GET['adm_no']==1){?><td  class="center" ><?php echo  $WorkAssignListVal['ref_no']; ?></td><?php }?>                 

              

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

              

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

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



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

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

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

                  <td class="center" style="border-right:1px solid gray;font-weight:bold;"> 

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

                 

                                 

              </tr>



       <?php $others_fee=""; 



   }



       // ending loop 





        ?>



        <tr style="background-color: lightgray;">



          <td colspan="6">Total</td>

          <td><?php echo $sumOtherTotals;?></td>

          <!-- <td><?php echo $sumTranportFee;?></td>

          <td><?php echo $sumMiscFee;?></td> -->

          <td><?php echo $sumBalance;?></td>

       <!--    <td><?php echo $sumTutionFee;?></td>

          <td><?php echo $sumDiscAmount;?></td> -->

          <td><?php echo $sumTotal;?></td>          

        </tr> 



    </tbody>

        

    </table>



   <br>







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

        dom: 'Bfrtip',

              buttons: [

                  'print'

              ]

          } );

      } );

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



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

      });

    </script>



</body>

</html>

