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


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

//getting branch details 

$branch=getBranch($m);

$month_id=$_GET['month_id'];

$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']." AND fee.student_id=".$_REQUEST['student_id'];


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

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


//echo $sql1;

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


// now getting the other fee parameters of student against selected month



$fee_fine;

if(date("Y-m-d")>$WorkAssignListings[0]['challan_duedate']){
$fee_fine=$branch[0]['late_fee_fine'];
 }
 else {
$fee_fine=0;
 }



$total_fee=intVal($WorkAssignListings[0]['tutionfee'])+intVal($WorkAssignListings[0]['transportfee'])+intVal($WorkAssignListings[0]['balance'])+intVal($WorkAssignListings[0]['misc_fee']);


 //print_r($WorkAssignListings); 

  $m->where("class_id", $WorkAssignListings[0]['class_id']);
  $m->where("session_id", $_SESSION['current_session']);
  $class_fee = $m->get("eduportal_class_fee_details");
  $class_standerd_fee=$class_fee[0]['tution_fee'];

   //print_r($class_fee); 


?>
 <!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 Triple 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:28%; height:auto;float:left;padding-right:2%;margin-left:2%;margin-top:2%;}
     
tr th {background-color:gray; text-align:center;font-size:14px;border:1px solid black;}
tr td {border-bottom:1px solid black;border-left:1px solid black;padding:1%;}

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

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

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

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

   </div>
 

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

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

<hr>

<?php  

  $m->where("branch_id", $_SESSION['branch']);
  $accounts=$m->get("edu_branch_bank_details");
  if(count($accounts)>0){

  if($accounts[0]['bank_accountitle']!=NULL){
?>

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

        <b> Acc Title: <?php  echo $accounts[0]['bank_accountitle'];?></b> 
   </div>
<?php 
}
?>
   <div style="width:100%; font-size:12px;text-align:left; height:25px; float:left;">

         <b>Bank: (<?php  echo $accounts[0]['bank_branch'];?>) <?php  echo $accounts[0]['bank_accountno'];?> </b>
   </div>

<hr>
<?php 
}
?>


   <div style="font-size:12px;margin-top:2%;text-align:center;">  <strong> <u> Fee Voucher </u>  </strong> </div>


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

         Voucher No : <?php echo $WorkAssignListings[0]['month_id']."-".$WorkAssignListings[0]['challan_id'];?>


   </div>


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


         Issued : <?php echo date("d-M-Y");?>

   </div>



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

      </tr>


  
  
      <tr>  
         <td width="15%" style="border:none;"> Class (Sec):   </td>
         <td width="35%" style="border-bottom: 1px solid black;text-align:center;border-left:none;"> 
         <?php echo getClassName($m,$WorkAssignListings[0]['class_id']);?>
          (<?php echo getSectionName($m,$WorkAssignListings[0]['section_id']);?>) </td>
      
         <td width="15%" style="border:none;"> Roll No:   </td>
         <td width="35%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  
         <?php echo $WorkAssignListings[0]['candidate_roll_no'];?>  </td>

      </tr>




      <tr>  
         <td width="15%" style="border:none;"> Month/Session:   </td>
         <td width="35%" style="border-bottom: 1px solid black;text-align:center;border-left:none;"> 
         <?php echo getMonthName($m,$WorkAssignListings[0]['month_id']);?>/<?php echo getSessionName($m,$WorkAssignListings[0]['session_id']);?>  </td>
      
         <td width="15%" style="border:none;"> Adm #:   </td>
         <td width="35%" style="border-bottom: 1px solid black;text-align:center;border-left:none;font-size:14px;">  
         <?php
         
         
         if($WorkAssignListings[0]['ref_no']!=NULL){echo $WorkAssignListings[0]['ref_no'];} ?>  </td>

      </tr>

 </table>




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

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


      <tr>  
         <td width="70%"> Previous Balance   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  
         	<?php echo number_format($WorkAssignListings[0]['balance']);?> </td>
      </tr>
      
         
      <tr>  
         <td width="70%"> Tuition Fee   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo $WorkAssignListings[0]['tutionfee'];?>  </td>
      </tr>

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

    <?php if($WorkAssignListings[0]['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 $WorkAssignListings[0]['misc_fee'];?>  </td>
      </tr>
    <?php } ?>

   <?php 

      $fee_types = $m->get("eduportal_fee_types");
      $other_fee=0;
      foreach ($fee_types as $type) {
        $fees=getFeeOfOtherParameter($WorkAssignListings[0]['student_id'],$WorkAssignListings[0]['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($WorkAssignListings[0]['disc_amount']!=""){ ?>
    <tr>  
         <td width="70%"> Fee Discount   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">
  <?php  

  echo number_format(($WorkAssignListings[0]['disc_amount']/$WorkAssignListings[0]['tutionfee']*100),2)."% (".$WorkAssignListings[0]['disc_amount'].")";

  ?>        
           </td>
      </tr>
  <?php } ?>
      <tr>  
         <th width="70%" style="text-align:left;"> &nbsp;&nbsp; Total   </th>
         <th width="30%" style="text-align:center;">
          <?php echo number_format(($other_fee+$total_fee+$fee_fine)-$WorkAssignListings[0]['disc_amount'],2); ?> </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(($other_fee+$total_fee)-$WorkAssignListings[0]['disc_amount'],2); ?>  </td>
      </tr> -->

      <tr>  
         <td width="70%" style="text-align:right;">  Due Date:   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo date("d-M-Y",strtotime($WorkAssignListings[0]['challan_duedate']));?> </td>
      </tr>

  <?php if($fee_fine>0){ ?>
<?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'])-$WorkAssignListings[0]['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 - $WorkAssignListings[0]['tutionfee'];?>
<?php if($discount_amount>0){ ?>
       <tr>  
         <td colspan="2" width="100%" style="text-align:left;border-right: 1px solid gray;"><b>Regular 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 } ?>

      
<?php  if($WorkAssignListings[0]['paid_status']==1 || $WorkAssignListings[0]['paid_status']=="1"){  ?> 
  
      <tr>  
         <th width="70%" style="text-align:right;"> Paid: &nbsp;&nbsp;   </th>
         <th width="30%" style="text-align:center;">  <?php echo number_format($WorkAssignListings[0]['collected_amount'],2); ?> </th>
      </tr>
   
      <tr>  
         <th width="70%" style="text-align:right;"> Remaining: &nbsp;&nbsp;  </th>
         <th width="30%" style="text-align:center; ">  <?php echo number_format(($other_fee+$total_fee+$fee_fine)-$WorkAssignListings[0]['collected_amount'],2); ?> </th>
      </tr>
     
<?php  }  ?>

 
         <tr>  
         <td width="100%" colspan="2" style="text-align:center;border:none;"> <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 } ?>
  
          </td>
         
      </tr>

   
   </table>



   <table width="100%" style="font-size:11px;" cellspacing="0">  
   
   
         <tr>  
         <td width="100%" colspan="2" style="text-align:center;border-left:none;color:white;"> .  </td>
         
         </tr>

         <tr>  
         <td width="100%" colspan="2" style="text-align:center;border:none;color:black;"> (Signature & Stamp) <br>
            
            <span style="font-size:8px;"> <?php echo getPrintBottom($m);?>  </span>

          </td>
         
         </tr>
   </table>

</div>


</div>


<?php } ?>

</body>
</html>
