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

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


  $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 $sql;

$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]['misc_fee']);*/

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


// print_r($challan); 

  
  //$m->where("session_id", $_SESSION['current_session']);
  $m->where("class_id", $discount[0]['class_id']);
  $class_fee = $m->get("eduportal_class_fee_details");
  $class_standerd_fee=$class_fee[0]['tution_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 Double 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:25%; height:auto;float:left;padding-right:2%;margin-left:2%;margin-top:2%;}
     
tr th {background-color:lightgray; text-align:center;font-size:14px;border:1px solid black;padding:1%;}
tr td {border-bottom:1px solid black;border-left:1px solid black;padding:0.5%;}

@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("Institute Copy","Student Copy");

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

 <!-- Vouchere Fist -->
<div class="section" style="<?php if($i<1){echo 'border-right: 2px solid black;border-right-style:dotted;';}?>">
   
      
      <div style="">
        
       <div style="width:100%;font-size:13px;text-align:center;float:left;margin-top:0px;">

         <img src="images/shamimhead.PNG" style="height:60px;width:100%;" />

      </div>
<hr>
      <div style="font-size: 12px;">
        <div style="width: 30%;float: left;border-bottom: 1px solid black;font-weight: bold;">Voucher#</div>
        <div style="width: 70%; float: left;border-bottom: 1px solid black;"><?php echo $WorkAssignListings[0]['month_id']."-".$WorkAssignListings[0]['challan_id'];?><span style="float: right;"><?php echo $array1[$i]; ?></span></div>
      </div>
<br>
      <div style="font-size: 12px;">
        <div style="width: 25%;float: left;font-weight: bold;font-size: 12px;">Student Name</div>
        <div style="width: 75%; float: left;border-bottom: 1px solid black;"><?php echo $WorkAssignListings[0]['first_name'];?></div>
      </div>
<br>
      <div style="font-size: 12px;">
        <div style="width: 25%;float: left;font-weight: bold;font-size: 12px;">Father Name</div>
        <div style="width: 75%; float: left;border-bottom: 1px solid black;"><?php echo $WorkAssignListings[0]['last_name'];?></div>
      </div>
<br>
      <div style="font-size: 12px;">
        <div style="width: 25%;float: left;font-weight: bold;font-size: 12px;">G.R.No</div>
        <div style="width: 25%; float: left;border-bottom: 1px solid black;">.<?php echo $WorkAssignListings[0]['ref_no'];?></div>
        <div style="width: 25%;float: left;font-weight: bold;font-size: 12px;">Class/Sec</div>
        <div style="width: 25%; float: left;border-bottom: 1px solid black;"><?php echo getClassName($m,$WorkAssignListings[0]['class_id']);?>/<?php echo getSectionName($m,$WorkAssignListings[0]['section_id']);?></div>
      </div>

  <br>
      <div style="font-size: 12px;">
        <div style="width: 25%;float: left;font-weight: bold;font-size: 12px;">Month</div>
        <div style="width: 25%; float: left;border-bottom: 1px solid black;"><?php echo getMonthName($m,$WorkAssignListings[0]['month_id'])."-".date("y");?></div>
        <div style="width: 25%;float: left;font-weight: bold;font-size: 12px;">Session</div>
        <div style="width: 25%; float: left;border-bottom: 1px solid black;"><?php echo getSessionName($m,$_SESSION['current_session']);?></div>
      </div>
  		<br><br>
      <div style="font-size:14px;background-color: lightgray; border-bottom: 1px solid black; border-top: 1px solid black;text-align: center;font-weight: bold;">Fee Details</div>

      <div style="margin-top: 5px;font-size:12px;">
        
        <div style="width: 60%;float: left;background-color: lightgray; border-bottom: 1px solid black; border-top: 1px solid black;font-weight: bold;">Standard Tuition Fee <?php echo getMonthName($m,$_GET['month']);?></div>
        <div style="width: 40%; float: left;background-color: lightgray; border-bottom: 1px solid black; border-top: 1px solid black;text-align: center;"><?php echo $class_standerd_fee;?></div>

      </div>

      <!-- <div style="margin-top: 5px;font-size:12px;">

               
        <div style="width: 60%;float: left;background-color: lightgray; border-bottom: 1px solid black; border-top: 1px solid black;margin-top: 5px;font-weight: bold;">Discount <?php  
  echo ($WorkAssignListings[0]['disc_amount']/$WorkAssignListings[0]['tutionfee']*100)."%";?></div>
        <div style="width: 40%; float: left;background-color: lightgray; border-bottom: 1px solid black; border-top: 1px solid black;text-align: center;margin-top: 5px;"><?php if ($WorkAssignListings[0]['disc_amount']>0) {
          echo $WorkAssignListings[0]['disc_amount'];
        } else {
          echo 0;
        } ?></div>

      </div> -->


      <div style="margin-top: 5px;font-size:12px;">

               
        <div style="width: 60%;float: left;background-color: lightgray; border-bottom: 1px solid black; border-top: 1px solid black;margin-top: 5px;font-weight: bold;">Discount <?php  
        $discountAmount=$class_standerd_fee-$WorkAssignListings[0]['tutionfee'];
  echo number_format($discountAmount/$class_standerd_fee*100,2)."%";?></div>
 
        <div style="width: 40%; float: left;background-color: lightgray; border-bottom: 1px solid black; border-top: 1px solid black;text-align: center;margin-top: 5px;"><?php 
          echo $class_standerd_fee-$WorkAssignListings[0]['tutionfee'];
        ?></div>

      </div>



   <table width="100%" style="font-size:12px;margin-top:10%;" 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%" style="font-weight: bold;"> Gross Tution Fee (<?php echo getMonthName($m,$WorkAssignListings[0]['month_id']);?>)   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo $WorkAssignListings[0]['tutionfee']-$WorkAssignListings[0]['disc_amount'];?> </td>
      </tr>

      <?php if($WorkAssignListings[0]['transportfee']>0){ ?>
      <tr>  
         <td width="70%" style="font-weight: bold;"> 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%" style="font-weight: bold;"> <?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%" style="font-weight: bold;"> <?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%" style="font-weight: bold;"> Fine   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  
         
               <?php  echo $fee_fine;?>
  
         
           </td>
      </tr>
<?php } ?>


<?php 
$stdid=$WorkAssignListings[0]['student_id'];
$bal = "select * from eduportal_monthly_challan where student_id='$stdid' AND branch_id=".$_SESSION['branch']." order by challan_id desc limit 5";
  //print_r($bal);
  $previousBalances = $m->query($bal);

  foreach ($previousBalances as $previousBalance ) {
   $totalPreBal+=$previousBalance['balance'];
?>
      <tr>  
         <td width="70%" style="font-weight: bold;"> Balance (<?php echo getMonthName($m,$previousBalance['month_id']);?>)   </td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo $previousBalance['balance'];?> </td>
      </tr>

<?php } ?>
      <tr>  
         <td width="70%" style="background-color: lightgray;font-size: 14px;font-weight: bold;"> Total Payable Amount</td>
         <td width="30%" style="text-align:center;border-right:1px solid gray;background-color: lightgray;">  <?php echo number_format($other_fee+$total_fee+$fee_fine,2);?> </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>

         
   </table>

     <p style="font-size: 10px;">Discount Reasons: <?php echo $discount[0]['discount_reason'];?></p> 

  <div style="font-size: 10px;">
        <div style="width: 25%;float: left;">Issue Date</div>
        <div style="width: 25%; float: left;"><?php echo date("d-M-Y");?></div>
        <div style="width: 25%;float: left;">Due Date</div>
        <div style="width: 25%; float: left;"><?php echo date("d-M-Y",strtotime($WorkAssignListings[0]['challan_duedate']));?></div>
      </div>


   <div style="width:100%;font-size:13px;text-align:center;float:left;margin-top:5px;">

         <img src="images/shamimfooterchange.jpg" style="height:105px;width:100%;" />

      </div>
      <div width="100%" style="text-align:center;border:none;color:black;margin-top: 100px;"> (Signature & Stamp) <br>          
           
          </div>


  <br>

</div>


</div>


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

</body>
</html>
