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

//getting branch details 

$branch=getBranch($m);

$month_id=$_REQUEST['month'];
$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['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']!=''){
      $sql .= " AND std.section_id =" . $_REQUEST['section']. " ";
 }

//echo $sql;

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


  $m->where("class_id", $_REQUEST['class_id']);
  $m->where("branch_id", $_SESSION['branch']);
  $class_fee = $m->get("eduportal_class_fee_details");
  $class_standerd_fee=$class_fee[0]['tution_fee'];

  $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">
<!-- Favicons-->
<link rel="icon" type="image/png" href="img/favicon.png" sizes="32x32" />
<title>Print Triple Voucheres</title>
<!-- Favicons-->
<link rel="icon" type="image/png" href="img/favicon.png" sizes="32x32" />

<script type="text/javascript">
  //window.print();
</script>
<style> 
  
.section{width:32%; height:auto;float:left;border-right: 2px solid black;border-right-style:dotted;padding-right:1%;margin-left:1%;}
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.9%;}

  
@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;
  }
}


  body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: #FAFAFA;
    font-weight:bold;
    font-size:15px;
    /*font: 12pt "Tahoma";*/
}
* {
    box-sizing: border-box;
    -moz-box-sizing: border-box;
}
.page {
    width: 297mm;
    min-height:190mm;        
    padding-left:5mm;
    padding-top:5mm;
    padding-bottom:35mm;
    margin: 10mm auto;
    border: 1px #D3D3D3 solid;
    border-radius: 5px;
    background: white;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}
.subpage {
    width: 280mm;
    height:170mm;
    
}

@page {
    size: A4 landscape;
    margin: 0;
}
@media print {
    html, body {
        width:297mm;
        height:190mm;        
    }
    .page {
        margin: 0;
        border: initial;
        border-radius: initial;
        width: initial;
        min-height: initial;
        box-shadow: initial;
        background: initial;
        page-break-after: blue;
    }
}


  </style>

</head>
<body>



<?php

// printing all the voucheres


foreach($WorkAssignListings as $WorkAssignValue){ 

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

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

  $fee_fine=0;

   }



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


if($total_fee==0 ||  $total_fee=="0"){
  
  continue;
} 
  
    $m->where("student_id", $WorkAssignValue['student_id']);
    $discount=$m->get("eduportal_student_fee_structure");

?>


  <div class="book">
    <div class="page">
        <div class="subpage">




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


<?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:none;';}?>">
   
   <div style="width:100%; text-align:center; height:auto;font-size:12px;color:black;">
            <?php echo $array1[$i]; ?>

   </div>

   <div style="">
        
        <div style="width:25%;float: left;">
            <img src="<?php echo DOMAIN.AgentDirectory;?>img/aliedbank.jpg" style="height:100px;width:80px;" />    
        </div>


        <div style="width:75%;font-size:35px;float: right;margin-top: 35px;text-align:center;">Allied Bank</div>
        <div style="text-align: center;">MITHI BARANCH - 0090</div>
        <div style="text-align: center;margin-top: 11px;text-align: center;
    margin-top: 11px;font-size: 13px;width: 100%;background-color: #193c76;color:white;padding: 2%;">

        AL-MEHRAN PUBLIC HIGH SCHOOL MITHI

        <br>

        A/C No. 0010048198690022

      </div>

       <br>
            

          </div>

   
   		<div style="width: 40%; height: 22px; border: 1px solid black; text-align: center; font-weight: bold;" >Issue Date</div>
   		<div style="width: 40%; height: 22px; border: 1px solid black; text-align: center;"><?php echo date("d-M-Y",strtotime($WorkAssignValue['challan_duedate']));?></div>
   		<div style="width: 40%; height: 22px; border: 1px solid black; float: right;margin-top: -44px;text-align: center; font-weight: bold;" >Due Date</div>
   		<div style="width: 40%; height: 22px; border: 1px solid black; float: right;margin-top: -21px;text-align: center;"><?php echo getMonthName($m,$WorkAssignValue['month_id']);?></div>


  


   

<?php 

    $start_date = strtotime($WorkAssignValue['challan_duedate']); 
    $end_date = strtotime(date("Y-m-d"));
    $datediffrence =($end_date - $start_date)/60/60/24;

    $student_fine=0;
    $actual_fine=0;



  
   if($branch_details[0]['fine_type']=="0" || $branch_details[0]['fine_type']==0){  

    $student_fine= $branch_details[0]['late_fee_fine']; } 

  else {
    
    $student_fine= ($datediffrence * $branch_details[0]['late_fee_fine']);
   }


  //if(date("Y-m-d")>$details['challan_duedate'] && $details['paid_status']==1){

// if row is first 

  

        // if row is first and fee is paid then show only collected fine
          if($WorkAssignValue['paid_status']==1){
             echo $WorkAssignValue['collected_fine'];
             $actual_fine=$WorkAssignValue['collected_fine'];
           
          } 
        // if row is first and fee is not paid then calculate fine
          else if(date("Y-m-d")>$WorkAssignValue['challan_duedate'] && $WorkAssignValue['paid_status']==0){
           // echo $student_fine; 
            $actual_fine=$student_fine;
          }
      
 
    


    $totalAmount1+=$actual_fine;

        ?> 
<br>
<div style="width: 30%; float: left;">Name: </div>
<div style="width: 70%; float: right;"><?php echo $WorkAssignValue['first_name'];?> </div>
<br><br>
<div style="width: 35%; float: left;">Father Name: </div>
<div style="width: 65%; float: right;"><?php echo $WorkAssignValue['last_name'];?> </div>
<br><br>
<div style="width: 25%; float: left;">Class: </div>
<div style="width: 25%; float: left;"><?php echo getClassName($m,$_GET['class_id']);?> (<?php echo  getSectionName($m,$WorkAssignValue['section_id']);?>) </div>
<div style="width: 25%; float: left;">Month: </div>
<div style="width: 25%; float: left;"><?php echo getMonthName($m,$WorkAssignValue['month_id']);?> </div>
<br><br>
<div><u>Discription</u></div>
<div style="width: 50%;float: left;background-color: lightgray;">Particulars</div>
<div style="width: 50%;float: right;background-color: lightgray;text-align: right;">Amount</div>
<br><br>
<div style="text-align: right;">Charges to be currently Paid</div>

   <table width="100%" style="font-size:11px;margin-top:2%;" cellspacing="0">  
   
    <?php 
      $m->where("feetype_id", 1);
      $adm_fee = $m->get("eduportal_fee_types");
          
        $admfees=getFeeOfOtherParameter($WorkAssignValue['student_id'],$WorkAssignValue['challan_id'],$adm_fee[0]['feetype_id'],$m);
        
   ?>

      <tr>  
         <td width="70%" style="border-top: 1px solid black;"> Admission Fee   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;border-top: 1px solid black;">  <?php 
             echo $admfees;  ?> </td>
      </tr>
      
      
         
      <tr>  
         <td width="70%"> Monthly Fee   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo $WorkAssignValue['tutionfee'];?>  </td>
      </tr>

      <?php 
      $m->where("feetype_id", 2);
      $papr_fee = $m->get("eduportal_fee_types");
      
     
        $paprfees=getFeeOfOtherParameter($WorkAssignValue['student_id'],$WorkAssignValue['challan_id'],$papr_fee[0]['feetype_id'],$m);
        
   ?>
     
      <tr>  
         <td width="70%"> Examination Fee   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php 
             echo $paprfees;  ?>  </td>
      </tr>
  
    <?php 
      $m->where("feetype_id", 5);
      $othr_fee = $m->get("eduportal_fee_types");
      
     
        $othrfees=getFeeOfOtherParameter($WorkAssignValue['student_id'],$WorkAssignValue['challan_id'],$othr_fee[0]['feetype_id'],$m);
        
   ?>

      <tr>  
         <td width="70%"> Any Other Fee   </td>

         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php 
             echo $othrfees;  ?>  </td>
      </tr>
 
   </table>
  <div style="text-align: right;">Former unpaid Charges & Dues</div>
   <br>

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

      <tr>  
         <td width="70%" style="border-top: 1px solid black;"> Total Amount <br>Payable with in due date  </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;border-top: 1px solid black;">  <?php echo $WorkAssignValue['tutionfee']+$admfees+$paprfees+$othrfees;?> </td>
      </tr>
      
         
      <tr>  
         <td width="70%"> Late Payment Surcharges   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php  echo $actual_fine;?>  </td>
      </tr>
     
      <tr>  
         <td width="70%"> Total Amount <br> Payable after due date  </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo $WorkAssignValue['tutionfee']+$admfees+$paprfees+$othrfees+$actual_fine;?>  </td>
      </tr>
  
    <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>
<br>
   <div style="width: 45%; float: left;">Admin Officer</div>
   
   <div style="width: 55%; float: right;">Bank Authorize Officer</div>


  </div>




    <?php } ?>

    </div>




        </div>    
    </div>      
   </div>




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

</body>
</html>