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

<?php include('Sessioncheck.php');?>

<?php 



  //getting branch details 

 // $m->where("session_id", $_SESSION['current_session'];

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

  $discount=$m->get("eduportal_student_fee_structure");





  $branch=getBranch($m);

  $branchID=$_SESSION['branch'];



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

 }





  $start_date = strtotime($WorkAssignListings[0]['challan_duedate']);

  if ($WorkAssignListings[0]['paid_status']=='1') {

  $end_date = strtotime($WorkAssignListings[0]['paying_date']);

  

   } else {

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

  }

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



    $student_fine=0;

    $actual_fine=0;





if (date("Y-m-d")>$WorkAssignListings[0]['challan_duedate']) {

    



  

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



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



  else {

    

    $student_fine= ($datediffrence * $branch[0]['late_fee_fine']);

   }



}





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



// print_r($challan); 



  

  $m->where("session_id", $_SESSION['current_session']);

  $m->where("class_id", $WorkAssignListings[0]['class_id']);

  $class_fee = $m->get("eduportal_class_fee_details");

  $class_standerd_fee=$class_fee[0]['tution_fee'];
  $class_standerd_adm=$class_fee[0]['admission_fee'];





  $m->where("Month_Id", $month_id);

  $month_name=$m->get("eduportal_month_config");





  $sessionID=$_SESSION['current_session'];



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

  $signatures = $m->get("eduportal_upload_acadmic_signature");



?>

 <!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;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:16px;border:1px solid black;padding:1%;}

tr td {border-bottom:1px solid black;border-left:1px solid black;padding:0.5%;}

.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;

  }

}



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

  <page size="A4">

<?php



 $array1=array("Student Copy");



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



<div class="box" >

 <!-- Vouchere Fist -->

<div class="section" style="<?php if($i<1){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: 15%;float: left;">

            <img src="<?php echo DOMAIN.AgentDirectory;?>img/<?php echo $branch[0]['logo']; ?>" style="height:80px;width:70px;" />    

        </div>

        <div style="width:85%;font-size:18px;float: right;margin-top: 25px;text-align:center;"><?php echo $branch[0]['Branch_Name'];?></div>



      </div>

      <br><br>

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

       <div style="font-size:12px; text-align:center;">  Contact: <?php echo $branch[0]['branch_contact'];?><br> <span style="float:left;font-size: 10px;margin-left: 20px;">Voucher Valid: <?php echo date("d-M-Y",strtotime($brid[0]['voucher_validity']));?></span> <span style="float:right;font-size: 10px;">Issue date: <?php echo date('d-M-Y');?></span></div>

<br>

   <hr>

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



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



   </div>



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



         <span style="border: 1px solid black;padding: 3px; text-align: center;"> Adm No : <?php echo $WorkAssignListings[0]['ref_no'];?></span>



   </div>





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



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



   </div>







   <table width="100%" style="font-size:14px;" 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>



          <?php if ($brid[0]['no_type']==1 || $brid[0]['no_type']==0) { ?>

                        

         <td width="15%" style="border:none;font-size: 12px;"> Comp 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>



        <?php } elseif ($brid[0]['no_type']==2 || $brid[0]['no_type']==0) { ?>

            

         <td width="15%" style="border:none;font-size: 12px;"> Reg No:   </td>

         <td width="35%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  

         <?php echo $WorkAssignListings[0]['ref_no'];?>  </td>



        <?php } ?>

      </tr>









      <tr>  

         <td width="15%" style="border:none;"> Year:   </td>

         <td width="35%" style="border-bottom: 1px solid black;text-align:center;border-left:none;font-size: 12px;"> 

         <?php echo $_GET['month'].", ".$WorkAssignListings[0]['year'];?>  </td>      

         <td width="15%" style="border:none;"> Voucher No:   </td>

         <td width="35%" style="border-bottom: 1px solid black;text-align:center;border-left:none;font-size:14px;">  

         <?php

         if($WorkAssignListings[0]['challan_id']!=NULL){echo $WorkAssignListings[0]['challan_id'];} ?>  </td>

      </tr>

 </table>



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


      <tr>  
        <th width="37%"> Particulars </th>
        <th width="20%"> Standard </th>
        <th width="20%"> S.ship </th>
        <th width="20%" style="text-align:center;border-right:1px solid gray;">  Net </th>
        
      </tr>


      


      <?php 
      $discount_amount = $class_standerd_fee - $WorkAssignListings[0]['tutionfee'];
      ?>

        <tr>  
        <td width="40%"> Monthly Fee   </td>
        <td width="20%"> <?php echo $class_standerd_fee;?>   </td>
        <td width="20%"> <?php echo $discount_amount;?>   </td>
        <td width="20%" style="text-align:center;border-right:1px solid gray;">  <?php echo $WorkAssignListings[0]['tutionfee'];?></td>
       
        </tr>



<?php if($WorkAssignListings[0]['transportfee']>0 && $WorkAssignListings[0]['transportfee']!="0" ){ ?>

      <tr>  

         <td width="40%"> <?php if ($brid[0]['transport_title']!=NULL){echo $brid[0]['transport_title'];}else {echo 'Transport Fee';} ?>   </td>
         <td width="20%"> <?php //echo $class_standerd_fee;?>   </td>
         <td width="20%"> <?php //echo $class_standerd_fee;?>   </td>
         <td width="20%" style="text-align:center;border-right:1px solid gray;">  <?php echo $WorkAssignListings[0]['transportfee'];?>  </td>
                </tr>

<?php } ?>



<?php if($WorkAssignListings[0]['misc_fee']>0 && $WorkAssignListings[0]['misc_fee']!="0" || $WorkAssignListings[0]['misc_fee']<"0" ){ ?>

      <tr>  

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

<?php } ?>

    <tr style="background: lightgray;"> 
        <td>Arrears</td>
        <td></td>
        <td></td>
        <td></td>
        <?php  if($WorkAssignListings[0]['paid_status']==1 || $WorkAssignListings[0]['paid_status']=="1"){  ?>
        <td></td>
        <?php } ?>
    </tr>

    
     <?php
      $s_ids=$WorkAssignListings[0]['student_id'];
      $b_i=$_SESSION['branch'];
      $pre = "select * from eduportal_monthly_challan where student_id='$s_ids' AND branch_id='$b_i' order by month_id desc";
       
     $previousMonthRemaining = $m->query($pre);
  
  //echo $pre;
     foreach ($previousMonthRemaining as $previousMonthRem) { 

        if ($previousMonthRem['month_id']==$_REQUEST['month_id']) {
           continue;
        }

        if ($previousMonthRem['month_id'] > $_REQUEST['month_id']) {
           continue;
        }

        if ($previousMonthRem['paid_status']==1) {
            
            if ($previousMonthRem['remaining_tutionfee'] == 0) {
           continue;
        }
        }
        

        $RemTutionFee=$previousMonthRem['tutionfee']/*-$previousMonthRem['tutionfee_received']*/;
      //  $TotalRecvTutionFee+=$previousMonthRem['tutionfee_received'];
        $TotalRemTutionFee+=$previousMonthRem['tutionfee']/*-$previousMonthRem['tutionfee_received']*/;
        $totalRemReceived+=$previousMonthRem['tutionfee'];
        if ($RemTutionFee!=NULL || $RemTutionFee != 0 ) {
        ?>

      <tr>  

         <td width="40%"> Monthly Fee <?php echo substr(getMonthName($m,$previousMonthRem['month_id']), 0, 3)."-".$previousMonthRem['year'];?>   </td>
         <td width="20%"> <?php //echo $class_standerd_fee;?>   </td>
         <td width="20%"> <?php //echo $class_standerd_fee;?>   </td>
         <td width="20%" style="text-align:center;border-right:1px solid gray;">  <?php echo $previousMonthRem['tutionfee'];?>  </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!="" && $fees!="0" ){



        $query11="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id=".$type['feetype_id'];

        $feeHeads = $m->query($query11);

        $chlId=$WorkAssignListings[0]['challan_id'];
        $std=$WorkAssignListings[0]['student_id'];
        $query12="SELECT * FROM eduportal_monthly_challan_details WHERE  branch_id='$branchID' and challan_id='$chlId' and student_id='$std' and feetype_id=".$type['feetype_id'];

        $feeHeadsReceived = $m->query($query12);
       // $totalFeeHeadsReceived+=$feeHeadsReceived[0]['fee_received'];

        
   ?>

     <tr>  

         <td width="40%"> <?php if ($feeHeads[0]['fee_head_title']!=NULL){echo $feeHeads[0]['fee_head_title'];}else {echo $type['feetype_name']." ";} ?>   </td>
         <td width="20%"> <?php if ($type['feetype_id']==1) {
            echo $class_standerd_adm;
         } ?>   </td>
         <td width="20%"> <?php if ($type['feetype_id']==1) { echo $class_standerd_adm-$fees;}?>   </td>
         <td width= "20%" style="text-align:center;border-right:1px solid gray;"> <?php $other_fee+=$fees;
          echo $fees;  ?></td>
               
      </tr>





    <?php } else continue; } ?>

 

 <?php if ($WorkAssignListings[0]['paid_status']==1) {

     $student_fine=$WorkAssignListings[0]['collected_fine'];

  } ?>       



<?php if($student_fine>0 && date("Y-m-d")>$WorkAssignListings[0]['challan_duedate']){ ?>

 

      <tr>  

         <td width="40%"> Fine   </td>
         <td width="20%"> <?php //echo $class_standerd_fee;?>   </td>
         <td width="20%"> <?php //echo $class_standerd_fee;?>   </td>
         <td width="20%" style="text-align:center;border-right:1px solid gray;">  

         

               <?php  echo $student_fine;?>

  

         

           </td>

      </tr>

<?php } ?>


      

      <tr>  

         <th width="40%" style="text-align:left;"> &nbsp;&nbsp; Total   </th>
         <th width="20%"> <?php //echo $class_standerd_fee+$class_standerd_adm;?>   </th>
         <th width="20%"> <?php //echo $discount_amount;?>   </th>
         <th width="20%" style="text-align:center;">  
          <?php echo number_format($other_fee+$total_fee+$totalRemReceived+$student_fine,2); ?> </th>
         
      </tr>
     

      <?php  if($branch[0]['fine_type']=="0" || $branch[0]['fine_type']==0){  ?> 

     <!--   <tr>  

         <td width="40%" style="text-align:right;">  Late Fee Fine:   </td>
         <td width="20%"> <?php //echo $class_standerd_fee;?>   </td>
         <td width="20%"> <?php //echo $class_standerd_fee;?>   </td>
         <td width="20%" style="text-align:center;border-right:1px solid gray;">  <?php echo $branch[0]['late_fee_fine'];?> </td>

      </tr> -->


    <?php } ?>
 

<?php  if($branch[0]['fine_type']=="0" || $branch[0]['fine_type']==0){  ?>    

    <!--   <tr>  

         <td width="40%" style="text-align:right;"> After Due Date:   </td>
         <td width="20%"> <?php //echo $class_standerd_fee;?>   </td>
         <td width="20%"> <?php //echo $class_standerd_fee;?>   </td>
         <td width="20%" style="text-align:center;border-right:1px solid gray;">  <?php echo number_format($other_fee+$total_fee+$branch[0]['late_fee_fine'],2); ?> </td>

      </tr> -->

<?php  } else { ?>
     <!--   <tr>  

         <td width="100%" colspan="4" 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 }  ?>

     
    

   </table>





<?php if ($WorkAssignListings[0]['fee_remarks']!=NULL) { ?>

<p style="margin: 1px; border: 1px solid black;padding: 2px; font-size: 11px;"> Fee Remarks: <?php echo $WorkAssignListings[0]['fee_remarks'];?></p>

<?php } ?>






<br>

    <p style="font-size:11px;text-align: center; margin: 1px;">

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



   <table width="100%" style="font-size:12px;" cellspacing="0">  

   

   

         <tr>  

         <td width="100%" colspan="2" style="text-align:center;border-left:none;"> <?php if($signatures[0]['principal_signature']!=NULL && $brid[0]['display_signature']==1){ ?>

                        

            <img src="<?php echo DOMAIN;?>Production/signatures/<?php echo $signatures[0]['principal_signature'];?>" id="preview" class="img-thumbnail" style="width:100px;height:55px;"   />



         <?php } ?>  </td>

         

         </tr>



         <tr>  

         <td width="100%" colspan="2" style="text-align:center;border:none;color:black;"> (Signature & Stamp) <br>

            

            <!-- <span style="font-size:11px;"> <?php echo getPrintBottom($m);?>  </span> -->



          </td>

         

         </tr>

   </table>



</div>





</div>

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



<?php } ?>

</page>

</body>

</html>

