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





  // getting branch details



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

  $branch=$m->get("edu_branch_config");



 ?>



<!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 Arrear Sheet</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 {padding:1%;border-bottom:1px solid gray;border-top:1px solid gray;border-left:1px solid gray;text-align:center;background-color:lightgray;font-size:14px;}

tr td {border-bottom:1px solid gray;border-left:1px solid gray;font-size:16px;}

  

.border{border:1px solid black;}

.center{text-align:center;}

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







@media print {

    #Header, #Footer { display: none !important; }

}

@media screen

   {

      p.bodyText {font-family:verdana, arial, sans-serif;}

   }



   @media print

   {

      p.bodyText {font-family:georgia, times, serif;}

   }

   @media screen, print

   {

      p.bodyText {font-size:10pt}

   }

   @media print {

  a[href]:after {

    content: none !important;

  }

}

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



<?php if ($_REQUEST['orderByAmount']=='above') { ?>

    

    <div style="text-align:center;font-size:18px;font-weight:bold;"> Students Arrear Report with Above "<?php echo $_GET['arrear']; ?>" Arrear

    </div>

<?php } else { ?>



    <div style="text-align:center;font-size:18px;font-weight:bold;"> Students Arrear Report with Less Then "<?php echo $_GET['arrear']; ?>" Arrear

 </div>



<?php } ?>





 



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



<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="16%" class="center"> Name</th>

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

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

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

                <th width="10%" class=" center"> Class</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" style="border-right:1px solid black;"> Arrear </th>

             

                

                 

            </tr>

        </thead>

    

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

      

     ?>

        <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 style="padding-left:1%;"><?php echo $WorkAssignListVal['cell_no'];  ?></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" style="border-right:1px solid black;">  <?php echo $totalArrear;?>   </td>                  

                                 

              </tr>



       <?php } ?>



      <tr>

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

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

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

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

        



       </tr>

                 

       

            

           

        </tbody>

        

    </table>



</body>

</html>

