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

<?php   

 $sql = "SELECT * FROM eduportal_challan_fee_receiving as fee WHERE fee.branch_id=".$_SESSION['branch']. " ";


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


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

    

    } else {

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


    }

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

    

    } else {

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


    }    

    

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

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

  }



  if(isset($_REQUEST['from']) && isset($_REQUEST['to']) ){

     

      if($_REQUEST['from']!=" " && $_REQUEST['from']!=NULL ) {

        $from=date("Y-m-d",strtotime($_REQUEST['from']));  



      }else {

        $from=date("Y-m-01");  

      }

     

      if($_REQUEST['to']!=" " && $_REQUEST['to']!=NULL   ) {

        $to=date("Y-m-d",strtotime($_REQUEST['to']));

      }else {

        $to=date("Y-m-t");  

      } 

      

    

    $sql .= " AND (fee.paid_date BETWEEN '" .$from. "' AND '" .$to. "' )";

  }

  

// echo $sql;



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



}





  // getting branch details

  

  $branch=getBranch($m);



  // getting details of total records





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

      $branch_details = $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 Fee Collection 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:14px;}
tr td {border-bottom:1px solid gray;border-left:1px solid gray;font-size:14px;}
  
.border{border:1px solid black;}
.center{text-align:center;}
.alignment{padding-left:1%;text-align:left;}

</style>
</head>
<body style="font-size:12px;">


<br>

<div style="text-align:center;font-size:30px;font-weight:bold;"> Fee Collection Report </div>

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

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

<?php //echo $class[0]['Class_Name'];?> 

</div>

<div style="width:33%; float:left;font-size:20px; "> <b> Report Date:</b> <?php echo date("d-M",strtotime($_REQUEST['from']));?> to <?php echo date("d-M",strtotime($_REQUEST['to']));?> </div>

<!-- <div style="width:33%; float:right;font-size:20px; "> <a style="padding: 6px 8px; font-size:14px;float: right;" target="_blank" href="export_excel_expense_report.php?<?php echo session_id().session_id().session_id().session_id().session_id();?>&from=<?php echo $_REQUEST['from'] ;?>&to=<?php echo $_REQUEST['to'] ;?>&PiadBy=<?php echo $_REQUEST['PiadBy'] ;?>&category=<?php echo $_REQUEST['category'] ;?>" style="cursor:pointer;"  class="btn btn-success" class="btn btn-success  fa fa-download pull-right"> Export Excel </a> </div> -->


<br><br><br>
   
    <table style="width:100%;" cellspacing="0">
          
          

          <thead>

            <tr>

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

                <th width="20%">Student Name</th>

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

                <th width="10%" style="text-align:center;"> Class </th>

                <!-- <th width="8%" style="text-align:center;">  Month </th>  -->                           

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

                <th width="6%"> Date </th>

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

                <th width="6%">Paid by</th>

                

            </tr>

        </thead>

        <tbody>



     <?php 



     $count=1;

     $counter=0;

      foreach($WorkAssignListings as $WorkAssignListVal)

      { 



      $counter++;



           

    

      // getting students details 



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

        //$m->where("status", 0);

        $student=$m->get("edu_student_details");   


        if(count($student)<=0){

          continue;

        }

        if ($WorkAssignListVal['received']==0) {
                continue;
              }      



    $start_date = strtotime($WorkAssignListVal['challan_duedate']); 

    $end_date = strtotime(date("Y-m-d"));

    $datediffrence =($end_date - $start_date)/60/60/24;



$totalAmt+=$WorkAssignListVal['amount'];
$totalRecevidAmt+=$WorkAssignListVal['received'];

      ?>



<tr>

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

<td style="text-align:left;padding-left: 5px;<?php if($student[0]['status']=="1"){echo "background-color:#E26867;color:white;";}?>">  




<?php echo $student[0]['first_name'];?>



</td>



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

<td style="text-align:center;"> <?php echo getClassName($m,$student[0]['class_id']);?>  </td>



<!-- <td> <?php echo getMonthName($m,$WorkAssignListVal['month_id']);?> </td>  -->   

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


<td style="text-align:center;"><?php 


echo date("d-M",strtotime($WorkAssignListVal['paid_date']));


?></td>

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

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

</tr>



 <?php   $count++;      } ?>



<tr style="background-color:lightgray;font-size: 14px;">

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

  <td><?php echo number_format($totalAmt,1);?></td>  

  <td></td>

  <td><?php echo number_format($totalRecevidAmt,1);?></td>

  <td></td>


</tr>



           

            

           

        </tbody>

        

    </table>

</body>
</html>
