<?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'];

$year=$_REQUEST['year'];



if($_REQUEST['class_id']!=NULL) {



$sql = " select std.student_id, std.first_name, std.last_name, std.candidate_roll_no, std.section_id, std.ref_no, std.class_id, std.dob, std.section_id, std.cell_no, 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['year']!=NULL) {

    $sql .= " AND fee.year =" . $_REQUEST['year']. " ";

}



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']. "' ";

   }



//echo $sql;

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



} else {



    $sql =" select std.student_id, std.first_name, std.last_name, std.candidate_roll_no, std.section_id, std.ref_no, std.class_id, std.dob, std.section_id, std.cell_no, 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.year='$year' order by fee.classs_id asc";



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

}

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

  $branch_details = $m->get("edu_branch_config");



//print_r($branch_details);





?>



<!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 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:48%; height:auto;float:left;border-right: 2px solid black;border-right-style:dotted;padding-right:1%;margin-left:1%;}

tr th {background-color:lightgray;text-align:center;font-size:14px;border:1px solid gray;}

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



  

@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: 29.7cm;

    height: 21cm;        

    padding-left:3mm;

    padding-top:3mm;

    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: 29.7cm;

    height: 21cm;

    

}



@page {

    size: A4 landscape;

    margin: 0;

}

@media print {

    html, body {

        width: 29.7cm;

        height: 21cm;        

    }

    .page {

        margin: 0;

        border: initial;

        border-radius: initial;

        width: initial;

        min-height: initial;

        box-shadow: initial;

        background: initial;

        page-break-after: blue;

    }

}



ol li {

font-size: 11px;

margin-left: -32px;

}



  </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="">





<?php



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



 for($i=0; $i<2;$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: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:16px;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>



   <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 

}

?>

   

<?php 

}

?>



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



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

   </div>





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



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

   </div>





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





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



   </div>



   <div style="width:100%; font-size:14px;text-align:center;font-weight: bold;">



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

   </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){

             

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



        ?> 





   <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 $WorkAssignValue['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 $WorkAssignValue['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,$WorkAssignValue['classs_id']);?> (<?php echo  getSectionName($m,$WorkAssignValue['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 $WorkAssignValue['candidate_roll_no'];?>  </td>



      </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;"> 

         <?php echo $_REQUEST['year'];?>  </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($WorkAssignValue['ref_no']!=NULL){echo $WorkAssignValue['ref_no'];} ?>  </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['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['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['tutionfee'];?>  </td>

      </tr>

      <?php 

      if($WorkAssignValue['transportfee']>0){ ?>

      <tr>  

         <td width="70%"> Transport Fee   </td>

         <td width="30%" style="text-align:center;border-right:1px solid gray;">  <?php echo $WorkAssignValue['transportfee'];?>  </td>

      </tr>

    <?php } ?>



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

      </tr>

   <?php } ?>





   <?php 



      $fee_types = $m->get("eduportal_fee_types");

      $other_fee=0;

      foreach ($fee_types as $type) {

        $fees=getFeeOfOtherParameter($WorkAssignValue['student_id'],$WorkAssignValue['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($actual_fine>0){ ?>

      <tr>  

         <td width="70%"> Fine   </td>

         <td width="30%" style="text-align:center;border-right:1px solid gray;">

               <?php  echo $actual_fine;?>        

           </td>

      </tr>

<?php } ?> -->



<?php if($WorkAssignValue['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['disc_amount']/$WorkAssignValue['tutionfee']*100)."% (".$WorkAssignValue['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['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($other_fee+$total_fee-$WorkAssignValue['disc_amount'],2); ?>  </td>

      </tr> -->



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



      <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 $student_fine;?> </td>

      </tr>



      <?php } ?>

      

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

   

      <tr>  

         <th width="70%" style="text-align:right;"> After Due Date:   </th>

         <th 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['disc_amount'],2); ?> </th>

      </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['tutionfee'];?>

   



      <?php if($discount_amount>0 && $brid[0]['display_discount_reason']==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 } ?>



</table>

<p style="text-align:center;margin: 3px;">Student Fee History</p>

 <table class="table "cellspacing="0"  style="width:100%;">



    <thead>

            

    <tr>

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



        <?php } ?>

        </tr>  





        <tr>

        <th style="background: white;font-size:12px;" width="3%">Total</th>

       <?php for ($mm=1; $mm<=12; $mm++) {



$stdid=$WorkAssignValue['student_id'];

$bal = "select chl.tutionfee, chl.transportfee, chl.balance, chl.misc_fee, chl.disc_amount, SUM(dtil.fee_amount) as amt from eduportal_monthly_challan as chl LEFT JOIN eduportal_monthly_challan_details as dtil ON chl.challan_id=dtil.challan_id where chl.student_id='$stdid' AND chl.month_id='$mm' AND chl.year='$year' AND chl.branch_id=".$_SESSION['branch'];  

  $monthlyTotal = $m->query($bal);





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



?>

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

<?php } ?>



    </tr>



    <tr>



    <th style="background: white;font-size:12px;" width="3%">Recev</th>

    <?php for ($mm=1; $mm<=12; $mm++) { 



$stdid=$WorkAssignValue['student_id'];

$bal = "select collected_amount, collected_fine, paid_again_amount from eduportal_monthly_challan where student_id='$stdid' AND month_id='$mm' AND year='$year' 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:12px;" width="3%" class=" center"><?php echo $totalMonthlyRecev;?></th>

<?php } ?>



    </tr>  

    </thead>

   </table>



     <br>  



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



          echo $branch[0]['fee_vouc_note'];

        ?>

      

      <?php }else { ?>

          <p style="text-align: center;">Defaulters of two or more months will be expelled out. </p>

      <?php } ?>

        



   





  





   <br>



   <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;">  (Signature & Stamp) <br><br>

            

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



          </td>

         

         </tr>

   </table>





  </div>









    <?php } ?>



    </div>









        </div>    

    </div>      

   </div>









<?php  $other_fee="";

}

 ?>



</body>

</html>