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

//getting branch details 


$branch=getBranch($m);

$month_id=$_REQUEST['month'];
$monthid=date("m");
$branchID=$_SESSION['branch'];
$sessionID=$_SESSION['current_session'];

$m->where("Month_Id", $month_id);
$month_name=$m->get("eduportal_month_config");


$sql = " select std.*, 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']!=NULL) { 

if ($_REQUEST['session']!=NULL) {
    $sql .= " AND fee.session_id =" . $_REQUEST['session']. " ";
}

if ($_REQUEST['class_id']!=NULL){
    $sql .= " AND fee.classs_id =" . $_REQUEST['class_id']. " ";
}

if($_REQUEST['section']=="All"){
      $sql;
    } else {
    $sql .= " AND std.section_id =" . $_REQUEST['section']. " ";

    }

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

  else {
   $sql .= " AND paid_status = '" .$_REQUEST['fee']. "' ";
    }

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

} else {

  $sql = " select std.*, 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='$monthid' AND std.branch_id='$branchID' AND fee.session_id='$sessionID' order by fee.classs_id asc";

 $WorkAssignListings = $m->query($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">
<!-- Favicons-->
<link rel="icon" type="image/png" href="img/favicon.png" sizes="32x32" />
<title>Print Voucher</title>
<!-- Favicons-->
<link rel="icon" type="image/png" href="img/favicon.png" sizes="32x32" />
<script type="text/javascript">
 window.print();
</script>
<style> 

.section{width:95%; height:auto;float:left;border-right: 2px solid black;border-right-style:dotted;padding-right:2.5%;margin-left:2%;}
.box{
  width:48%;float:left;height:14.5cm;padding:0.5%;
}  
   
tr th {background-color:gray; text-align:center;font-size:14px;border:1px solid gray;}
tr td {border-bottom:1px solid gray;border-left:1px solid gray;padding:.7%;}



.tdalign{text-align:center;border:1px solid black;}
  

body {
  background: rgb(204,204,204);
  font-weight:bold; 
}
page {
  background: white;
  display: block;
  margin: 0 auto;
  margin-bottom: 0.5cm;
  border:1px solid black;
  box-shadow: 0 0 0.5cm rgba(0,0,0,0.5);
  /*padding:1%;*/
  height: 21cm; 
}
page[size="A4"] {  
  width: 21cm;
  height: 29.7cm; 
}
page[size="A4"][layout="landscape"] {
  width: 29.7cm;
  height: 21cm;  
}
page[size="A3"] {
  width: 29.7cm;
  height: 42cm;
}
page[size="A3"][layout="landscape"] {
  width: 42cm;
  height: 29.7cm;  
}
page[size="A5"] {
  width: 14.8cm;
  height: 21cm;
}
page[size="A5"][layout="landscape"] {
  width: 21cm;
  height: 14.8cm;  
}
@media print {
  body, page {
    margin: 0;
    box-shadow: none;
    border:none;
  }
}
  </style>

</head>
<body>

<?php 
$WorkAssignValue=$WorkAssignListings;

for($k=0;$k<count($WorkAssignValue);$k++){



  $fee_fine;
  if(date("Y-m-d")>$WorkAssignValue[$k]['challan_duedate']){

  $fee_fine=$branch[0]['late_fee_fine'];
   }
   else {

  $fee_fine=0;

   }



  $total_fee=intVal($other_fee)+intVal($WorkAssignValue[$k]['tutionfee'])+intVal($WorkAssignValue[$k]['transportfee'])+intVal($WorkAssignValue[$k]['balance'])+intVal($WorkAssignValue[$k]['misc_fee']);


         $m->where("student_id", $WorkAssignValue[$k]['student_id']);
         $discount=$m->get("eduportal_student_fee_structure");


$m->where("session_id", $WorkAssignValue[$k]['session_id']);
 $sessionName=$m->get("edu_session_config");

?>

<page size="A4">

<div style="float:left;width:100%;">
<?php 

 $array1=array("Institute Copy","Student Copy");

for($i=0;$i<2;$i++){ ?>

<div class="box" >

<div class="section" style="<?php if($i==1){echo 'border-right:none;';}?>">
   
   <div style="width:100%; text-align:center; height:auto;font-size:12px;">
            <?php echo $array1[$i];?>

   </div>


  <div style="">
        
        <div style="width: 15%;float: left;">
            <img src="<?php echo DOMAIN.AgentDirectory;?>img/<?php echo $branch[0]['logo']; ?>" style="height:65px;width:65px;" />    
        </div>
        <div style="width:85%;font-size:18px;float: right;margin-top: 25px;text-align:center;"><?php echo $branch[0]['Branch_Name'];?></div>

      </div>
      <div style="font-size:10px; text-align:center;">  <?php echo $branch[0]['Branch_Location'];?> </div>
 <!-- <br>
     <div style="font-size:12px;text-align:center;">  <strong> <u> Due Date <?php echo date("d-M-Y",strtotime($WorkAssignValue[$k]['challan_duedate']));?> </u>  </strong> </div> -->

<br>
   <div style="width:33%; font-size:10px;text-align:left; height:25px; float:left;">

         Month : <?php echo $month_name[0]['Month_Name'];?>

   </div>

   <div style="width:31%;font-size:13px;text-align:center;height:25px;float:left;margin-top: -6px;">

        <span style="border: 1px solid black;padding: 3px;"> Adm No : <?php echo $WorkAssignValue[$k]['ref_no'];?></span>

   </div>


   <div style="width:33%;font-size:10px; text-align:right; height:25px; float:left;">

        Due Date <?php echo date("d-M-Y",strtotime($WorkAssignValue[$k]['challan_duedate']));?>

   </div>



   <table width="100%" style="font-size:11px;" cellspacing="0">  
   
   
      <tr>  
         <td width="20%" style="border:none;"> Name   </td>
         <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo $WorkAssignValue[$k]['first_name'];?>  </td>
         
         <td width="20%" style="border:none;"> Father   </td>
         <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo $WorkAssignValue[$k]['last_name'];?>  </td>

      </tr>
 
    
  <tr>  
     <td width="20%" style="border:none;"> Class </td>
     <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;"> <?php 
      if($_REQUEST['class_id']!=NULL) {
     echo getClassName($m,$_GET['class_id']);
       } else {
     echo getClassName($m,$WorkAssignValue[$k]['class_id']);
       }?></td>
     
     <td width="20%" style="border:none;"> Section  </td>
     <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo getSectionName($m,$WorkAssignValue[$k]['section_id']);?>  </td>

  </tr>

  
       
  <tr>  

   
     <td width="20%" style="border:none;">  Roll No  </td>
     <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo $WorkAssignValue[$k]['candidate_roll_no'];?>  </td>

     <td width="20%" style="border:none;">  Session  </td>
     <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo $sessionName[0]['session_year'];?>
      </td>
  
  </tr>

     
      

   
   </table>


   <table width="100%" style="font-size:11px;margin-top:2%;" cellspacing="0">  
   

      <tr>  
         <th width="70%"> Particulars    </td>
         <th width="30%" style="text-align:center;border-right:1px solid gray;">  Amount </td>
      </tr>


      <!-- <tr style="background-color: lightgray;">  
         <td width="70%"> Standard Fee   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php 
           
          $m->where("class_id", $WorkAssignValue[$k]['classs_id']);
          $class_fee = $m->get("eduportal_class_fee_details");
          $class_standerd_fee=$class_fee[0]['tution_fee'];
          echo $class_standerd_fee;
          ?> </td>
      </tr> -->


      <tr>  
         <td width="70%"> Balance   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo $WorkAssignValue[$k]['balance'];?> </td>
      </tr>
      
         
      <tr>  
         <td width="70%"> Monthly Fee   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo $WorkAssignValue[$k]['tutionfee'];?>  </td>
      </tr>
    <?php if($WorkAssignValue[$k]['transportfee']>0){ ?>
      <tr>  
         <td width="70%"> Transport Fee   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo $WorkAssignValue[$k]['transportfee'];?>  </td>
      </tr>
    <?php } ?>

    <?php if($WorkAssignValue[$k]['misc_fee']>0){ ?>
      <tr>  
         <td width="70%"> <?php if ($branch[0]['misc_title']!=NULL){echo $branch[0]['misc_title'];}else {echo 'Miscellaneous';} ?>  </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo $WorkAssignValue[$k]['misc_fee'];?>  </td>
      </tr>
      <?php } ?>
   <?php 

      $fee_types = $m->get("eduportal_fee_types");
      $other_fee=0;
      foreach ($fee_types as $type) {
        $fees=getFeeOfOtherParameter($WorkAssignValue[$k]['student_id'],$WorkAssignValue[$k]['challan_id'],$type['feetype_id'],$m);
        if($fees!=""){
       
   ?>
     <tr>  
         <td width="70%"> <?php echo $type['feetype_name']; ?>   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;"> 
          <?php 
          $other_fee+=$fees;
          echo $fees;  ?> </td>
      </tr>

    <?php } else continue; } ?>
        
<!-- <?php if($fee_fine>0){ ?>
      <tr>  
         <td width="70%"> Fine   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  
         
               <?php  echo $fee_fine;?>
  
         
           </td>
      </tr>
<?php } ?> -->

<?php if($WorkAssignValue[$k]['disc_amount']>0){ ?>
      <tr>  
         <td width="70%"> Fee Discount   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">
  <?php  

  echo ($WorkAssignValue[$k]['disc_amount']/$WorkAssignValue[$k]['tutionfee']*100)."% (".$WorkAssignValue[$k]['disc_amount'].")";?>        
           </td>
      </tr>
<?php } ?>
      
      <tr>  
         <th width="70%" style="text-align:left;"> Total   </th>
         <th width="30%" style="text-align:center;">  <?php echo $total_fee+$other_fee-$WorkAssignValue[$k]['disc_amount']; ?> </th>
      </tr>  
     
      
      <tr>  
         <td width="70%" style="text-align:right;padding-top:3%;"> Before Due Date:   </td>
         <td width="30%" style="text-align:center;padding-top:3%;border-right:1px solid gray;">  <?php echo number_format($total_fee+$other_fee-$WorkAssignValue[$k]['disc_amount'],2); ?>  </td>
      </tr>
   
       <tr>  
         <td width="70%" style="text-align:right;">  Late Fee Fine:   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo $branch[0]['late_fee_fine'];?> </td>
      </tr>

      <?php  if($branch[0]['fine_type']=="0" || $branch[0]['fine_type']==0){  ?> 
   
      <tr>  
         <td width="70%" style="text-align:right;"> After Due Date:   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo number_format($other_fee+$total_fee+$branch[0]['late_fee_fine']-$WorkAssignValue[$k]['disc_amount'],2); ?> </td>
      </tr>
<?php  } else { ?>

       <tr>  
         <td width="100%" colspan="2" style="text-align:left;border-right: 1px solid gray;"><b> After due date <?php echo $branch[0]['late_fee_fine']?> Rs fine will be charged per day.</b></td>
        
      </tr>
 <?php }  ?>

        <?php $discount_amount = $class_standerd_fee - $WorkAssignValue[$k]['tutionfee'];?>
<?php if($WorkAssignValue[$k]['disc_amount']!=""){ ?>
       <tr>  
         <td colspan="2" width="100%" style="text-align:left;border-right: 1px solid gray;"><b>Discount & Reason:- 
            <?php echo number_format(($discount_amount/$class_standerd_fee)*100,0); ?> % fee discount </b> (<?php echo $discount[0]['discount_reason'];?>)</td>
      </tr>
<?php } ?>

</table>

<p style="text-align:center;margin: 3px;font-size: 10px;">Student Fee History</p>
 <table class="table "cellspacing="0"  style="width:100%;">

    <thead>
            
    <tr>
    <th style="background: white;font-size:10px;" width="3%">Month</th>
        <?php
         
      for ($mm=1; $mm<=12; $mm++) { 
//echo $mm;
        $monthss = date('F', mktime(0,0,0,$mm, 1, date('Y')));
        ?>

       <th style="background: white;font-size:10px;" width="3%" class=" center"><?php echo substr($monthss, 0, 3);?></th>

        <?php } ?>
        </tr>  


        <tr>
        <th style="background: white;font-size:10px;" width="3%">Total</th>
       <?php for ($mm=1; $mm<=12; $mm++) {

$stdid=$WorkAssignValue[$k]['student_id'];
$bal = "select * from eduportal_monthly_challan where student_id='$stdid' AND month_id='$mm' AND session_id='$sessionID' AND branch_id=".$_SESSION['branch'];  
  $monthlyTotal = $m->query($bal);

$adm=getFeeOfOtherParameter($monthlyTotal[0]['student_id'],$monthlyTotal[0]['challan_id'],1,$m);
$papr=getFeeOfOtherParameter($monthlyTotal[0]['student_id'],$monthlyTotal[0]['challan_id'],2,$m);
$lib=getFeeOfOtherParameter($monthlyTotal[0]['student_id'],$monthlyTotal[0]['challan_id'],3,$m);
$lab=getFeeOfOtherParameter($monthlyTotal[0]['student_id'],$monthlyTotal[0]['challan_id'],4,$m);
$othr=getFeeOfOtherParameter($monthlyTotal[0]['student_id'],$monthlyTotal[0]['challan_id'],5,$m);
$regfee=getFeeOfOtherParameter($monthlyTotal[0]['student_id'],$monthlyTotal[0]['challan_id'],6,$m);
$secufee=getFeeOfOtherParameter($monthlyTotal[0]['student_id'],$monthlyTotal[0]['challan_id'],7,$m);
$anualfee=getFeeOfOtherParameter($monthlyTotal[0]['student_id'],$monthlyTotal[0]['challan_id'],8,$m);
$otherFee=$adm+$papr+$lib+$lab+$othr+$regfee+$secufee+$anualfee;

$total_MonthlyFee=$otherFee+$monthlyTotal[0]['tutionfee']+$monthlyTotal[0]['transportfee']+$monthlyTotal[0]['balance']+$monthlyTotal[0]['misc_fee']-$monthlyTotal[0]['disc_amount'];

?>
<th style="background: white;font-size:10px;" width="3%" class=" center"><?php echo $total_MonthlyFee;?></th>
<?php } ?>

    </tr>

    <tr>

    <th style="background: white;font-size:10px;" width="3%">Recev</th>
    <?php for ($mm=1; $mm<=12; $mm++) { 

$stdid=$WorkAssignValue['student_id'];
$bal = "select * from eduportal_monthly_challan where student_id='$stdid' AND month_id='$mm' AND session_id='$sessionID' AND branch_id=".$_SESSION['branch'];  
  $monthlyTotal = $m->query($bal);
$totalMonthlyRecev=$monthlyTotal[0]['collected_amount']+$monthlyTotal[0]['paid_again_amount']; 
    ?>
    <th style="background: white;font-size:10px;" width="3%" class=" center"><?php echo $totalMonthlyRecev;?></th>
<?php } ?>

    </tr>  
    </thead>
   </table>

   
      <p width="100%" style="text-align:center;font-size: 11px;margin-top: -5px;"> <br>  

      <?php if($branch[0]['fee_vouc_note']!=NULL){

          echo $branch[0]['fee_vouc_note'];
        ?>
      
      <?php }else { ?>
          Defaulters of two or more months will be expelled out. 
      <?php } ?>
        </p>
   
    

  


  <br>
  <!-- <div style="width:100%;font-size:8px;text-align:center;"> <?php echo getPrintBottom($m);?>  </div> -->  

</div>
 
<!-- ending section  -->



  </div>  <!-- ending box  -->



  <?php  $other_fee="";} ?>


</div>



<div style="float:left;width:100%;">
<hr>




<?php 
// now updating the value of k variable to print each next student in same page
$k+=1;





  $fee_fine;
  if(date("Y-m-d")>$WorkAssignValue[$k]['challan_duedate']){

  $fee_fine=$branch[0]['late_fee_fine'];
   }
   else {

  $fee_fine=0;

   }



  $total_fee=intVal($other_fee)+intVal($WorkAssignValue[$k]['tutionfee'])+intVal($WorkAssignValue[$k]['transportfee'])+intVal($WorkAssignValue[$k]['balance'])+intVal($WorkAssignValue[$k]['misc_fee']);


if($k<count($WorkAssignValue)){

 $array1=array("Institute Copy","Student Copy");

for($i=0;$i<2;$i++){ ?>

<div class="box" >

<div class="section" style="<?php if($i==1){echo 'border-right:none;';}?>">
   
   <div style="width:100%; text-align:center; height:auto;font-size:12px;">
            <?php echo $array1[$i];?>

   </div>


   <div style="">
        
        <div style="width: 15%;float: left;">
            <img src="<?php echo DOMAIN.AgentDirectory;?>img/<?php echo $branch[0]['logo']; ?>" style="height:65px;width:65px;" />    
        </div>
        <div style="width:85%;font-size:18px;float: right;margin-top: 25px;text-align:center;"><?php echo $branch[0]['Branch_Name'];?></div>

      </div>
      <div style="font-size:10px; text-align:center;">  <?php echo $branch[0]['Branch_Location'];?> </div>

<!--  <br>
    <div style="font-size:12px;text-align:center;">  <strong> <u> Due Date <?php echo date("d-M-Y",strtotime($WorkAssignValue[$k]['challan_duedate']));?> </u>  </strong> </div> -->

<br>
   <div style="width:33%; font-size:10px;text-align:left; height:25px; float:left;">

         Month : <?php echo $month_name[0]['Month_Name'];?>
   </div>


   <div style="width:31%;font-size:13px;text-align:center;height:25px;float:left;margin-top: -6px;">

        <span style="border: 1px solid black;padding: 3px;"> Adm No : <?php echo $WorkAssignValue[$k]['ref_no'];?></span>

   </div>


   <div style="width:33%;font-size:10px; text-align:right; height:25px; float:left;">


         Due Date <?php echo date("d-M-Y",strtotime($WorkAssignValue[$k]['challan_duedate']));?>

   </div>



   <table width="100%" style="font-size:11px;" cellspacing="0">  
   
   
      <tr>  
         <td width="20%" style="border:none;"> Name   </td>
         <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo $WorkAssignValue[$k]['first_name'];?>  </td>
         
         <td width="20%" style="border:none;"> Father   </td>
         <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo $WorkAssignValue[$k]['last_name'];?>  </td>

      </tr>
 
    
  <tr>  
     <td width="20%" style="border:none;"> Class </td>
     <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php 
      if($_REQUEST['class_id']!=NULL) {
     echo getClassName($m,$_GET['class_id']);
       } else {
     echo getClassName($m,$WorkAssignValue[$k]['class_id']);
       }?></td>
     
     <td width="20%" style="border:none;"> Section  </td>
     <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo getSectionName($m,$WorkAssignValue[$k]['section_id']);?>  </td>

  </tr>

  
       
  <tr>  

   
     <td width="20%" style="border:none;">  Roll No / Adm  </td>
     <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo $WorkAssignValue[$k]['candidate_roll_no']." / ".$WorkAssignValue[$k]['ref_no'];?>  </td>

     <td width="20%" style="border:none;">  Session  </td>
     <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo $sessionName[0]['session_year'];?>
      </td>
  
  </tr>

     
      

   
   </table>


   <table width="100%" style="font-size:11px;margin-top:2%;" cellspacing="0">  
   

      <tr>  
         <th width="70%"> Particulars    </td>
         <th width="30%" style="text-align:center;border-right:1px solid gray;">  Amount </td>
      </tr>


      <!-- <tr style="background-color: lightgray;">  
         <td width="70%"> Standerd Fee   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php 
           
          $m->where("class_id", $WorkAssignValue[$k]['classs_id']);
          $class_fee = $m->get("eduportal_class_fee_details");
          $class_standerd_fee=$class_fee[0]['tution_fee'];
          echo $class_standerd_fee;
          ?> </td>
      </tr> -->


      <tr> 
         <td width="70%"> Balance   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo $WorkAssignValue[$k]['balance'];?> </td>
      </tr>
      
         
      <tr>  
         <td width="70%"> Monthly Fee   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo $WorkAssignValue[$k]['tutionfee'];?>  </td>
      </tr>
      <?php if($WorkAssignValue[$k]['transportfee']>0){ ?>
       <tr>  
         <td width="70%"> Transport Fee   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo $WorkAssignValue[$k]['transportfee'];?>  </td>
      </tr>
    <?php } ?>

    <?php if($WorkAssignValue[$k]['misc_fee']>0){ ?>

      <tr>  
         <td width="70%"> <?php if ($branch[0]['misc_title']!=NULL){echo $branch[0]['misc_title'];}else {echo 'Miscellaneous';} ?>  </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo $WorkAssignValue[$k]['misc_fee'];?>  </td>
      </tr>
    <?php } ?>
  
  <?php 

      $fee_types = $m->get("eduportal_fee_types");
      $other_fee=0;
      foreach ($fee_types as $type) {
        $fees=getFeeOfOtherParameter($WorkAssignValue[$k]['student_id'],$WorkAssignValue[$k]['challan_id'],$type['feetype_id'],$m);
        if($fees!=""){
   ?>
     <tr>  
         <td width="70%"> <?php echo $type['feetype_name']; ?>   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;"> 
          <?php 
          $other_fee+=$fees;
          echo $fees;  ?> </td>
      </tr>

    <?php } else continue; } ?>
      
<!--    <?php if($fee_fine>0){ ?>
      <tr>  
         <td width="70%"> Fine   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  
         
               <?php  echo $fee_fine;?>
  
         
           </td>
      </tr>
<?php } ?> -->

<?php if($WorkAssignValue[$k]['disc_amount']>0){ ?>
      <tr>  
         <td width="70%"> Fee Discount   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">
  <?php  

  echo ($WorkAssignValue[$k]['disc_amount']/$WorkAssignValue[$k]['tutionfee']*100)."% (".$WorkAssignValue[$k]['disc_amount'].")";?>        
           </td>
      </tr>
<?php } ?>
      
      <tr>  
         <th width="70%" style="text-align:left;"> Total   </th>
         <th width="30%" style="text-align:center;">  <?php echo $total_fee+$other_fee-$WorkAssignValue[$k]['disc_amount']; ?> </th>
      </tr>
   
     
      
      <tr>  
         <td width="70%" style="text-align:right;padding-top:3%;"> Before Due Date:   </td>
         <td width="30%" style="text-align:center;padding-top:3%;border-right:1px solid gray;">  <?php echo number_format($total_fee+$other_fee-$WorkAssignValue[$k]['disc_amount'],2); ?>  </td>
      </tr>

       <tr>  
         <td width="70%" style="text-align:right;">  Late Fee Fine:   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo $branch[0]['late_fee_fine'];?> </td>
      </tr>
  
        <?php  if($branch[0]['fine_type']=="0" || $branch[0]['fine_type']==0){  ?> 
   
      <tr>  
         <td width="70%" style="text-align:right;"> After Due Date:   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo number_format($other_fee+$total_fee+$branch[0]['late_fee_fine']-$WorkAssignValue[$k]['disc_amount'],2); ?> </td>
      </tr>
<?php  } else { ?>

       <tr>  
         <td width="100%" colspan="2" style="text-align:left;border-right: 1px solid gray;"><b> After due date <?php echo $branch[0]['late_fee_fine']?> Rs fine will be charged per day.</b></td>
        
      </tr>
 <?php }  ?>

     
<?php if($WorkAssignValue[$k]['disc_amount']!=""){ ?>
       <tr>  
        
         <td colspan="2" width="100%" style="text-align:left;border-right: 1px solid gray;"><b>Discount & Reason:- 
            <?php echo number_format(($discount_amount/$class_standerd_fee)*100,0); ?> % fee discount </b> (<?php echo $discount[0]['discount_reason'];?>)</td>
      </tr>

    <?php } ?>     

   </table>

 <p style="text-align:center;margin: 3px;font-size: 10px;">Student Fee History</p>
 <table class="table "cellspacing="0"  style="width:100%;">

    <thead>
            
    <tr>
    <th style="background: white;font-size:10px;" width="3%">Month</th>
        <?php
         
      for ($mm=1; $mm<=12; $mm++) { 
//echo $mm;
        $monthss = date('F', mktime(0,0,0,$mm, 1, date('Y')));
        ?>

       <th style="background: white;font-size:10px;" width="3%" class=" center"><?php echo substr($monthss, 0, 3);?></th>

        <?php } ?>
        </tr>  


        <tr>
        <th style="background: white;font-size:10px;" width="3%">Total</th>
       <?php for ($mm=1; $mm<=12; $mm++) {

$stdid=$WorkAssignValue[$k]['student_id'];
$bal = "select * from eduportal_monthly_challan where student_id='$stdid' AND month_id='$mm' AND session_id='$sessionID' AND branch_id=".$_SESSION['branch'];  
  $monthlyTotal = $m->query($bal);

$adm=getFeeOfOtherParameter($monthlyTotal[0]['student_id'],$monthlyTotal[0]['challan_id'],1,$m);
$papr=getFeeOfOtherParameter($monthlyTotal[0]['student_id'],$monthlyTotal[0]['challan_id'],2,$m);
$lib=getFeeOfOtherParameter($monthlyTotal[0]['student_id'],$monthlyTotal[0]['challan_id'],3,$m);
$lab=getFeeOfOtherParameter($monthlyTotal[0]['student_id'],$monthlyTotal[0]['challan_id'],4,$m);
$othr=getFeeOfOtherParameter($monthlyTotal[0]['student_id'],$monthlyTotal[0]['challan_id'],5,$m);
$regfee=getFeeOfOtherParameter($monthlyTotal[0]['student_id'],$monthlyTotal[0]['challan_id'],6,$m);
$secufee=getFeeOfOtherParameter($monthlyTotal[0]['student_id'],$monthlyTotal[0]['challan_id'],7,$m);
$anualfee=getFeeOfOtherParameter($monthlyTotal[0]['student_id'],$monthlyTotal[0]['challan_id'],8,$m);
$otherFee=$adm+$papr+$lib+$lab+$othr+$regfee+$secufee+$anualfee;

$total_MonthlyFee=$otherFee+$monthlyTotal[0]['tutionfee']+$monthlyTotal[0]['transportfee']+$monthlyTotal[0]['balance']+$monthlyTotal[0]['misc_fee']-$monthlyTotal[0]['disc_amount'];

?>
<th style="background: white;font-size:10px;" width="3%" class=" center"><?php echo $total_MonthlyFee;?></th>
<?php } ?>

    </tr>

    <tr>

    <th style="background: white;font-size:10px;" width="3%">Recev</th>
    <?php for ($mm=1; $mm<=12; $mm++) { 

$stdid=$WorkAssignValue['student_id'];
$bal = "select * from eduportal_monthly_challan where student_id='$stdid' AND month_id='$mm' AND session_id='$sessionID' AND branch_id=".$_SESSION['branch'];  
  $monthlyTotal = $m->query($bal);
$totalMonthlyRecev=$monthlyTotal[0]['collected_amount']+$monthlyTotal[0]['paid_again_amount']; 
    ?>
    <th style="background: white;font-size:10px;" width="3%" class=" center"><?php echo $totalMonthlyRecev;?></th>
<?php } ?>

    </tr>  
    </thead>
   </table>

      <p width="100%" style="text-align:center;font-size: 11px;margin-top: -5px;"> <br>  

      <?php if($branch[0]['fee_vouc_note']!=NULL){

          echo $branch[0]['fee_vouc_note'];
        ?>
      
      <?php }else { ?>
          Defaulters of two or more months will be expelled out. 
      <?php } ?>
        </p>
   
    


  <br>
 <!--  <div style="width:100%;font-size:8px;text-align:center;"> <?php echo getPrintBottom($m);?>  </div> -->  

</div>
 
<!-- ending section  -->



  </div>  <!-- ending box  -->



  <?php } 


}// ending if condition

  ?>








</div>



</page>
<br><br>
<?php   $other_fee="";}?>

</body>
</html>
