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

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



<?php

$branch=$_SESSION['branch'];

$year=$_REQUEST['year'];

$month=$_REQUEST['month'];







       

$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, fee.* from  edu_student_details as std, eduportal_monthly_challan as fee where std.student_id=fee.student_id AND fee.year='$year' AND std.status='0' AND fee.branch_id='$branch' and fee.month_id='$month' and fee.paid_status='1' group by std.family_code ";



 if ($_REQUEST['orderBy']=="alphabetic") {



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



    } else {



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



    }



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











 ?>



<!DOCTYPE html>

<html lang="en">

  <head>

   

    <title> Paid Family Repors | 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" style="background-color: white;">

  



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

  <div class="container">



<form action="family_reports.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>">



                

                

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

            
             

 <div class="col-md-2 col-sm-12 col-xs-12" style="padding:8px; float:left;"  id="col1">

                    <div class="form-group ">

                      <label class="required">Year</label>
                      <select name="year" class="form-control">

                        <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-sm-12 col-xs-12" style="padding:8px; float:left;"  id="col2">



                       <div class="form-group ">



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

                             <select name="month" id="month" class="form-control"  required>



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

                                  



                                  <?php

                                 

                                  $match;

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

                                    $match=date('m');

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

                                  

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

                                  foreach($WorkAssignList as $WorkAssignListVal)

                                  { ?>



                                     <option <?php if($match==$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-3 col-sm-12 col-xs-12" style="padding:8px; float:left;"  id="col2">



                       <div class="form-group ">

                        <?php 

                        $Code;

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

                                    

                                  }else { $Code=$_REQUEST['SearchBy']; }

                        ?>

                          <label class="required"> Search By</label>

                          <select id="SearchBy" required name="SearchBy" class="form-control">



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

                          <option <?php if($Code=="Paid"){echo "Selected";} ?> value="1">Paid</option>

                          <option <?php if($Code=="Unpaid"){echo "Selected";} ?> value="0">Unpaid</option>         

                                                              

                                                

                          </select>

                       

                          </div>

                  </div> -->

                  

                  

                  <div class="col-md-1 " style="padding:8px;">

                <div class="form-group ">

                   <input type="hidden" name="addaccountAdmin" value="1">

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

                </div>

              </div> 



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

              

            </a>

              

               

        </div>            

 </form>

    <br>



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





      <div class="alert alert-danger col-md-12" id="msg">

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

        <strong>Caution!</strong> Please select Cell/Family Code and click search!!!

      </div>



    <?php  } ?>





<div style="">



  

<h3>Family Report Paid List</h3>

<table id="listofstudents" class="table  table-bordered" style="width:100%">

 

        <thead>

            <tr>

              

                <th width="1%">S.No</th>

                <th width="10%">Father Name</th>

                <th width="8%">Students Name</th>

                <th width="8%">Class / Section</th>

                <th width="8%">Adm / Roll</th>

                <th width="8%">Cell No</th>  

                <th width="10%">Monthly Fee</th>            

                <th width="10%">Total</th>

                <th width="10%">Received</th>

                <th width="10%">Remaining</th>

                                

            </tr>

        </thead>

        <tbody>





   

     

     <?php 

$count=1;

      foreach($WorkAssignListings as $WorkAssignListVal)

      { 

  



  $m->where("Month_Id", $_REQUEST['month']);

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



  $cell=$WorkAssignListVal['family_code'];

  $StudId=$WorkAssignListVal['student_id'];



  $sqll = " 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 from  edu_student_details as std where std.status='0' AND std.branch_id='$branch' And std.family_code='$cell'";

  //print_r($sqll);

  $studentDatas = $m->query($sqll);



  

  $year=$_REQUEST['year'];

 



     

      ?>



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



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



          <td colspan="9"><a href="pay_fee.php?student=<?php echo $WorkAssignListVal['student_id'];?>"><b><?php echo $WorkAssignListVal['last_name']." (".$WorkAssignListVal['family_code'].")";?></b></a></td>



        </tr>



        

          <?php foreach ($studentDatas as $studentData) {



              $stdID=$studentData['student_id'];



             $qr22="SELECT * FROM eduportal_monthly_challan WHERE branch_id='$branch' and month_id='$month' and year='$year' and student_id='$stdID'";

            //print_r($qr);

              $Challandetails = $m->query($qr22);





$adm=getFeeOfOtherParameter($studentData['student_id'],$Challandetails[0]['challan_id'],1,$m);

$papr=getFeeOfOtherParameter($studentData['student_id'],$Challandetails[0]['challan_id'],2,$m);

$misc=getFeeOfOtherParameter($studentData['student_id'],$Challandetails[0]['challan_id'],3,$m);

$stati=getFeeOfOtherParameter($studentData['student_id'],$Challandetails[0]['challan_id'],4,$m);

$oth=getFeeOfOtherParameter($studentData['student_id'],$Challandetails[0]['challan_id'],5,$m);

$reg=getFeeOfOtherParameter($studentData['student_id'],$Challandetails[0]['challan_id'],6,$m);

$sec=getFeeOfOtherParameter($studentData['student_id'],$Challandetails[0]['challan_id'],7,$m);

$anual=getFeeOfOtherParameter($studentData['student_id'],$Challandetails[0]['challan_id'],8,$m);

$bokPack=getFeeOfOtherParameter($studentData['student_id'],$Challandetails[0]['challan_id'],9,$m);

$proFee=getFeeOfOtherParameter($studentData['student_id'],$Challandetails[0]['challan_id'],10,$m);



$other_totals=$adm+$papr+$misc+$stati+$oth+$reg+$sec+$anual+$bokPack+$proFee;









              $payableAmount=$Challandetails[0]['tutionfee']+$Challandetails[0]['transportfee']+$Challandetails[0]['collected_fine']+$Challandetails[0]['balance']+$Challandetails[0]['misc_fee']+$other_totals-$Challandetails[0]['disc_amount'];



              $totalReceived=$Challandetails[0]['collected_amount']+$Challandetails[0]['paid_again_amount'];



              $remaningAmount=$payableAmount-$totalReceived;



              



              $totalPayAbleAmount+=$payableAmount;

              $totalReceivedAmount+=$totalReceived;

              $totalRemaningAmount+=$remaningAmount;

              $totalMonthlyFee+=$Challandetails[0]['tutionfee'];



           ?>

          <tr>

          <td></td>

          <td></td>

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

          <td><?php echo getClassName($m,$studentData['class_id']);?> / <?php echo getSectionName($m,$studentData['section_id']);?></td>

          <td><?php echo $studentData['ref_no']." / ".$studentData['candidate_roll_no'];?></td>

          <td><?php echo $studentData['cell_no'];?></td>

          <td><?php echo $Challandetails[0]['tutionfee'];?></td>

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

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

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

          </tr>

          

          

        <?php } ?>



        <tr style="background-color:#F2F3F4;">

            <td colspan="6" style="text-align:center">Total</td>

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

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

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

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

          </tr>



          

        



   <?php $totalPayAbleAmount="";$totalReceivedAmount="";$totalRemaningAmount="";$totalMonthlyFee="";

      }  ?>

        

        </tbody>

        

    </table>



  </div>







    <br><br>





  </div>

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

</section>



        </div> 

        </div>





            </div>

          </div>

        </div>





     

        <!-- /page content -->





 <!-- jQuery -->

  <script src="js/ajax_functions.js"></script>

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

  <!-- Links for Datatable-->



 <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>

 <script>

        

  $(document).ready(function() {

    $('#listofstudents').DataTable({

      "pageLength": 100

    });

    } 

  );



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



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

  });



 </script>

  

  </body>

</html>

