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

<?php  include("sessioncheck.php"); ?>

<?php 



   if(isset($_REQUEST['student'])){



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

    $student = $m->get("edu_student_details");

  }



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

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

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

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



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



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

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

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



?>

<!DOCTYPE html>

<html lang="en">

  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <!-- Meta, title, CSS, favicons, etc. -->

    <meta charset="utf-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Student Fee Plan | EduPortal </title>

    <!-- Bootstrap -->

    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- Font Awesome -->

    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">

    <!-- NProgress -->

    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">

    <!-- bootstrap-daterangepicker -->

    <link href="../vendors/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">



    <!-- Custom Theme Style -->

    <link href="../build/css/custom.min.css" rel="stylesheet">

    <style type="text/css">

 



  .tile-stats .icon i{

    font-size: 35px; 

  }



    .vl {

  border-left: 1px solid lightgray;

  height: 40px;

  position: absolute;

  left: 50%;

  margin-left: -3px;

  margin-top: 24px;

}

    </style>



<input type="hidden" id="deleteLocalStorage" value="<?php echo $_REQUEST['deleteLocalStorage'];?>">

<script>

  var clr=document.getElementById("deleteLocalStorage").value;

  //if (clr=="delete") {

    //alert("786");

  localStorage.clear();

//}

</script>



<script type="text/javascript">



      function HideDate(str){

  //alert(str);

  if(str=="1"){

    

    document.getElementById("annual_package").style.display="block";

    document.getElementById("no_installment").style.display="block";

    document.getElementById("hideMonthlyPlan").style.display="none";

    document.getElementById("duedate").style.display="none";

    document.getElementById("month_id").style.display="none";

    document.getElementById("myID").style.display="block";

   

  }

  else {

    

    document.getElementById("annual_package").style.display="none";

    document.getElementById("no_installment").style.display="none";

    document.getElementById("hideMonthlyPlan").style.display="block";

    document.getElementById("duedate").style.display="block";

    document.getElementById("month_id").style.display="block";

    document.getElementById("myID").style.display="none";

   

   

  }

}



function getDiscount(str)
{

var clsFee=document.getElementById("standard_fee").value;
var disAmt=clsFee-str;
//alert(clsFee);
//alert(str);
 var dis=document.getElementById("monthly_scholarship").value=disAmt;

 var perc=dis*100/clsFee;

 var pr=document.getElementById("sch_per").value=perc+"%";

  populateSecondField();

}


function getAdmDiscount(str)
{

var clsFee=document.getElementById("admission_fee").value;
var disAmt=clsFee-str;
//alert(clsFee);
//alert(str);
 var dis=document.getElementById("admission_scholarship").value=disAmt;

 var perc=dis*100/clsFee;

 var pr=document.getElementById("adm_sch_per").value=perc.toFixed(2)+"%";

  populateAdmSecondField();

}


function populateSecondField() {
var firstField = document.getElementById('tution_fee');
var secondField = document.getElementById('1');
secondField.value = firstField.value;
}


function populateAdmSecondField() {
var firstField = document.getElementById('adm_fee');
var secondField = document.getElementById('2');
secondField.value = firstField.value;
}


function populateRegSecondField(val) {
//var firstField = document.getElementById('reg_fee');
var secondField = document.getElementById('6');
secondField.value = val;
}




 function StudentInstallment(str)

    {

      //alert(str);



       var pkgAmount=document.getElementById("pkgAmount").value;

     

        var ajx;  // The variable that makes Ajax possible!



        if (window.XMLHttpRequest)

            ajx = new XMLHttpRequest();

        ajx.onreadystatechange = function ()

        {

          //alert("786");

            if (ajx.readyState == 4)

            {

              //  alert(ajx.responseText);  

                document.getElementById("myID").innerHTML = ajx.responseText;



            }

        }

        

        ajx.open("GET", "get_student_installment_no.php?insttallmentNo="+str+"&pkgAmount="+pkgAmount);

        ajx.send();



    }




function monthCalculate(id) {


var month = document.getElementById("month_id_from").value;
var monthlyFee = document.getElementById("tution_fee").value;

const fromMonth = month.split("-");
const toMonth = id.split("-");   

var monthDiffrence = toMonth[1]-fromMonth[1];

var totalMonth = monthDiffrence+1;

var totalMonthFee = totalMonth * monthlyFee;

document.getElementById("1").value=totalMonthFee;
//document.getElementById("total_amt").value=totalMonthFee;
}





    </script>



  </head>



  

  <body class="nav-md">

    <div class="container body">

      <div class="main_container">

        <div class="col-md-3 left_col">

     

        <?php include('RootMe/sidebar.php');?>



        <?php include('RootMe/header.php');?>

     

     

        <!-- page content -->

        <div class="right_col" role="main">

          <div class="">

            

            <div class="clearfix"></div>



            <div class="row">



              <div class="col-md-12 col-sm-12 col-xs-12">

                <div class="x_panel">

                  <div class="x_title">

                    <h2>Create Fee Plan </h2>

                  

                    <div class="clearfix"></div>

                  </div>

                  <div class="x_content">





                    <!-- Smart Wizard -->

                    

                    <div id="wizard" class="form_wizard wizard_horizontal">

                      <ul class="wizard_steps">

                        <li>

                          <a href="#step-1" class="done">

                            <span class="step_no">1</span>

                            <span class="step_descr">

                                  Step 1<br />

                                  <small> Basic Information</small>

                              </span>

                          </a>

                        </li>

                        <li>

                          <a href="#step-2"  class="<?php if($_SESSION['AddStudent_Step']==2){echo 'selected';}else{echo 'done';} ?>">

                            <span class="step_no">2</span>

                            <span class="step_descr">

                                  Step 2<br />

                                  <small>Save Fee Plan </small>

                              </span>

                          </a>

                        </li>

                        <li>

                         <a href="#step-3" 

                         class="<?php if($_SESSION['AddStudent_Step']==3){echo 'done';}else{echo 'disabled';} ?>" >



                            <span class="step_no">3</span>

                            <span class="step_descr">

                                Step 3<br />

                                <small> Print Voucher</small>

                            </span>

                          </a>

                        </li>

                       

                      </ul>

                     



                   <div id="step-2" style="<?php if($_SESSION['AddStudent_Step']==2){echo 'display:block;';}else{ echo 'display:none;'; } ?>">

<!-- if(($_REQUEST['fee_type']=='0')) -->

              <form action="<?php echo DOMAIN.AgentDirectory; ?>parent/InsertMe.php" method="post" enctype="multipart/form-data" class="form-horizontal form-label-left">



                       <input type="hidden" name="action" value="CreateInstallmentFeePLan"  />

                       <input type="hidden" name="session_id" value="<?php echo $student[0]['session_id']; ?>"  />

                       <input type="hidden" name="class_id"   value="<?php echo $student[0]['class_id']; ?>"  />

                       <input type="hidden" name="section_id" value="<?php echo $student[0]['section_id']; ?>"  />

                       <input type="hidden" name="student_id" value="<?php echo $student[0]['student_id']; ?>"  />

                       



                       <h2>Manage Student Fee

                         <span style="color:red;font-size:14px;">

                       (Monthly Fee Parameters) </span>

                       </h2>



                       <div class="col-md-12 col-sm-6 col-xs-12 form-group has-feedback">



                        <div class="col-md-4 col-sm-6 col-xs-12 form-group has-feedback">

                        <label>Payment Mode</label>

                         <select name="fee_type" onChange="HideDateqq(this.value);" class="form-control">



                              <option value="0">Monthly</option>

                              <!-- <option value="1">Installments</option> -->



                        </select>

                            

                        </div> 



                      <div class="col-md-4 col-sm-6 col-xs-12 form-group has-feedback" id="annual_package" style="display:none;">

                        <label>Annual Package</label>

                        <input type="text" value="<?php echo $details1[0]['annual_package']; ?>" class="form-control has-feedback-left" id="pkgAmount"  name="annual_package" placeholder="Annual Package" autocomplete="off" />

                        <span class="fa fa-dollar form-control-feedback left" aria-hidden="true"></span>

                      </div>



                       <div class="col-md-4 col-sm-6 col-xs-12 form-group has-feedback" id="no_installment" style="display:none;">

                        <label>No of Installments</label>

                         <select name="no_installment" onChange="StudentInstallment(this.value)"  class="form-control">

                              <option value="">Choose</option>

                              <option value="1">1</option>

                              <option value="2">2</option>

                              <option value="3">3</option>

                              <option value="4">4</option>

                              <option value="5">5</option>

                              <option value="6">6</option>

                              <option value="7">7</option>

                              <option value="8">8</option>

                              <option value="9">9</option>

                              <option value="10">10</option>

                              <option value="11">11</option>

                              <option value="12">12</option>

                                                    



                        </select>

                            

                          </div>



                      <div id="myID">   



                      </div> 



                      </div>



                      <div id="hideMonthlyPlan">


                      <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback">

                        <input type="text" value="<?php echo $ClassFee[0]['tution_fee']; ?>" class="form-control has-feedback-left" id="standard_fee" name="standard_fee" placeholder="Class Standard fee" autocomplete="off" />

                        <span class="fa fa-dollar form-control-feedback left" aria-hidden="true"></span>

                      </div>

                      <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback">

                        <input type="text" value="<?php echo $ClassFee[0]['tution_fee']; ?>" class="form-control has-feedback-left" onkeyup="getDiscount(this.value)" id="tution_fee" name="tution_fee" placeholder="Monthly fee" autocomplete="off" />

                        <span class="fa fa-dollar form-control-feedback left" aria-hidden="true"></span>

                      </div>


                      <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback" style="display:none11;">

                        <input type="text" value="" class="form-control has-feedback-left" id="monthly_scholarship" name="monthly_scholarship" placeholder="Monthly Scholarship " autocomplete="off" />

                        <span class="fa fa-dollar form-control-feedback left" aria-hidden="true"></span>

                      </div>


                      <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback" style="display:none11;">

                        <input type="text" value="" class="form-control has-feedback-left" id="sch_per" name="sch_per" placeholder="Scholarship Percentage " autocomplete="off" />

                        <span class="fa fa-dollar form-control-feedback left" aria-hidden="true"></span>

                      </div>



                      <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback">

                        <input type="text" value="<?php echo $ClassFee[0]['admission_fee']; ?>" class="form-control has-feedback-left" id="admission_fee" name="admission_fee" placeholder="Class Admission fee" autocomplete="off" />

                        <span class="fa fa-dollar form-control-feedback left" aria-hidden="true"></span>

                      </div>

                      <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback">

                        <input type="text" value="<?php echo $ClassFee[0]['admission_fee']; ?>" class="form-control has-feedback-left" onkeyup="getAdmDiscount(this.value)" id="adm_fee" name="adm_fee" placeholder="Admission fee" autocomplete="off" />

                        <span class="fa fa-dollar form-control-feedback left" aria-hidden="true"></span>

                      </div>


                      <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback" style="display:none11;">

                        <input type="text" value="" class="form-control has-feedback-left" id="admission_scholarship" name="admission_scholarship" placeholder="Admission Scholarship " autocomplete="off" />

                        <span class="fa fa-dollar form-control-feedback left" aria-hidden="true"></span>

                      </div>


                      <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback" style="display:none11;">

                        <input type="text" value="" class="form-control has-feedback-left" id="adm_sch_per" name="adm_sch_per" placeholder="Admission Percentage " autocomplete="off" />

                        <span class="fa fa-dollar form-control-feedback left" aria-hidden="true"></span>

                      </div>


                       <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback">

                        <input type="text" value="" onkeyup="populateRegSecondField(this.value)" class="form-control" name="reg_fee" id="reg_fee" placeholder="Reg.Fee" autocomplete="off" />

                        <span class="fa fa-dollar form-control-feedback right" aria-hidden="true"></span>

                      </div>



                      <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback">

                        <input type="text" value="<?php echo $details1[0]['std_outstanding_blc']; ?>" class="form-control" name="outstanding" id="outstanding" placeholder="Old Balance" autocomplete="off" />

                        <span class="fa fa-dollar form-control-feedback right" aria-hidden="true"></span>

                      </div>



                       <!-- <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback">

                        <input type="text" value="<?php echo $details1[0]['std_transport_fee']; ?>" class="form-control" name="transport_fee" id="transport_fee" placeholder="<?php if ($brid[0]['transport_title']!=NULL){echo $brid[0]['transport_title'];}else {echo 'Transport';} ?>" autocomplete="off" />

                        <span class="fa fa-dollar form-control-feedback right" aria-hidden="true"></span>

                      </div> -->



                     <!--  <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback">

                        <input type="text"  value="<?php echo $details1[0]['std_misc_fee']; ?>" class="form-control" name="std_misc_fee" id="std_misc_fee" placeholder="<?php if ($brid[0]['misc_title']!=NULL){echo $brid[0]['misc_title'];}else {echo 'Miscellaneous Fee';} ?>" autocomplete="off" />

                        <span class="fa fa-dollar form-control-feedback right" aria-hidden="true"></span>

                      </div> -->

                     

                     

                      <div class="col-md-12 col-sm-6 col-xs-12 form-group has-feedback">

                        

                        <input type="text"  value="<?php echo $details1[0]['discount_reason']; ?>" class="form-control" name="discount_reason" id="discount_reason" placeholder="Discount Reason...">

                        

                      </div>

                     



                      <h2 class="col-md-12">Create Voucher  

                        <span style="color:red;font-size:14px;">

                       (These fee parameters will only include on selected month of voucher)  </span>

                     </h2>





                     <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback">

                       <select name="year" class="form-control">

                        <option value="All">All</option>

                        <?php

                        $match;

                        if(!isset($_REQUEST['year'])){

                          $match=date("Y");

                        }else { $match=$_REQUEST['year']; }

                        for($i=2018;$i<2031;$i++){ ?> 

                          <option <?php if($match==$i){echo 'selected';}?> value="<?php echo $i; ?>"><?php echo $i; ?></option>

                        <?php } ?>  

                      </select>



                    </div>


                      <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback">

                        <input type="month" id="month_id_from" name="from_year_month" required class="form-control" min="" value="<?php echo date("Y")."-".date("m");?>">                        

                      </div>


                      <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback">

                        <input type="month" id="month_id_to" onchange="monthCalculate(this.value)" name="to_year_month" required class="form-control" min="" value="<?php echo date("Y")."-".date("m");?>">                        

                      </div>



                       

                      <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback">



                        <input type="date" class="form-control" id="duedate" name="duedate" placeholder="Date of Birth" value="<?php echo date("Y-m-d") ?>">

                        <span class="form-control-feedback right" aria-hidden="true">Ddate</span>

                      </div>


                      <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback">



                        <input type="date" class="form-control" id="validity_date" name="validity_date" placeholder="" value="<?php echo date("Y-m-d") ?>">

                        <span class="form-control-feedback right" aria-hidden="true">Vdate</span>

                      </div>



                      <?php 



                      /*printing all the fee types variables*/

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

                      foreach ($fee_types as $type) {



                        $branchIds=$_SESSION['branch'];

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

                      //echo $query11;

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



                      /*if ($feeHeads[0]['status']=="0"){

                      continue;

                    }*/



                    ?>



                    <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback">

                      <input type="text" onkeyup="create_challan_calculation(this.value)" class="form-control" <?php if ($type['feetype_id']==1) { echo "required"; } ?>  name="type<?php echo $type['feetype_id']; ?>" id="<?php echo $type['feetype_id'];?>" placeholder="<?php if ($feeHeads[0]['fee_head_title']!=NULL){echo $feeHeads[0]['fee_head_title'];}else {echo $type['feetype_name'];} ?>" autocomplete="off" />

                      <span class="fa fa-dollar form-control-feedback right" aria-hidden="true"></span>

                    </div>

                  <?php  } ?>


                  <div class="col-md-3 col-sm-6 col-xs-12 form-group has-feedback">

                  <input type="text" class="form-control" name="" id="total_amt" placeholder="Total" readonly />

                  <span class="fa fa-dollar form-control-feedback right" aria-hidden="true"></span>

                  </div>



  </div>

                       <div class="col-md-2 col-sm-6 col-xs-12 form-group">

                        <input type="submit" value="Save & Next" class="form-control btn btn-primary" name="submit" />

                       </div>

       



                        </form>

                      </div>



                      <div id="step-3"  style="<?php if($_SESSION['AddStudent_Step']==3){echo 'display:block;';}else {echo 'display:none;';}?>">



                       <div class="form-group">

                          <div class="col-md-12 col-sm-12 col-xs-12 text-center">



                          <?php if(isset($_SESSION['Student_Added'])){ ?>



              <div class="alert alert-success alert-dismissible fade in" role="alert">

                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span> </button>

                <strong>Congrats!</strong> Your record is added sucessfully...

              </div>

              	<?php unset($_SESSION['Student_Added']); } ?>

                    <br><br>

                      <a href="add_student.php" class="btn btn-primary">Add New Student</a>

                      <a href="pay_fee.php?s=<?php echo session_id().session_id();?>

                      &student=<?php echo $_GET['student'];?>" class="btn btn-success">Pay Fee</a>

                      <!-- <a href="print_double_voucher.php?s=<?php echo session_id().session_id();?>

                      &student_id=<?php echo $_GET['student'];?>&month=<?php echo $_GET['month'];?>&month_id=<?php echo date("m");?>&s=<?php echo session_id().session_id();?>" class="btn btn-success">Print Double Voucher</a>

                      <a href="print_voucher.php?s=<?php echo session_id().session_id();?>

                      &student_id=<?php echo $_GET['student'];?>&month=<?php echo $_GET['month'];?>&month_id=<?php echo date("m");?>&s=<?php echo session_id().session_id();?>" class="btn btn-success">Print Triple Voucher</a> -->

                      <a href="student_profile.php?s=<?php echo session_id().session_id();?>

                      &student=<?php echo $_GET['student'];?>&s=<?php echo session_id().session_id();?>" class="btn btn-primary">View Profile</a>

                      <a href="adm_form_standard.php?s=<?php echo session_id().session_id();?>

                      &student=<?php echo $_GET['student'];?>&s=<?php echo session_id().session_id();?>" class="btn btn-primary">Admission Form</a>

                    </div>

                  </div>

                </div>

              </div>

                    <!-- End SmartWizard Content -->

                  </div>

                </div>

              </div>

            </div>

          </div>

        </div>

        <!-- /page content -->

 <script type="text/javascript">





function copyData()

{

  var n1 = document.getElementById('installment');

  var n2 = document.getElementById('firstInstallment');

  n2.value = n1.value;

 

calculate_totalAmount(22,1);

}



function copyDueDate()

{

  

  var d1 = document.getElementById('duedate');

  var d2 = document.getElementById('firstInstallmentDuedate');

  d2.value = d1.value;





}





   



function calculate_totalAmount(val,id){

 //alert(val+"==="+id);

 var firstInstall=document.getElementById("firstInstallment").value;

 var transport=document.getElementById("transport_fee1").value;

 var misc=document.getElementById("installment_std_misc_fee1").value;

 var arrear=document.getElementById("installment_outstanding1").value;

 var total=0;

 for(i=1;i<=8;i++){



  var sum=document.getElementById("fee_type"+i).value;



  total = parseInt(total) + parseInt(sum);



 }

 

   var totalPayable= Number(total) + Number(firstInstall) + Number(transport) + Number(misc) + Number(arrear);



  document.getElementById("total_payable").value=totalPayable;





}


function create_challan_calculation(id) {        
              
        
        var type1=document.getElementById("1").value;
        var type2=document.getElementById("2").value;
        var type3=document.getElementById("3").value;
        var type4=document.getElementById("4").value;
        var type5=document.getElementById("5").value;
        var type6=document.getElementById("6").value;
        var type7=document.getElementById("7").value;
        var type8=document.getElementById("8").value;
        //var reg=document.getElementById("reg_fee").value;
        var bal=document.getElementById("outstanding").value;
       
        
        var total_amount= (Number(type1) + Number(type2) + Number(type3) + Number(type4) + Number(type5) + Number(type6) + Number(type7) + Number(type8) + Number(bal) /*+ Number(type9) */ );
   
        document.getElementById("total_amt").value=total_amount;
        
      }






/*function totalFee(id){





 var firstInstall=document.getElementById("firstInstallment").value;

 var transport=document.getElementById("transport_fee").value;

 var misc=document.getElementById("installment_std_misc_fee").value;

 var arrear=document.getElementById("installment_outstanding").value;



 

   var total= Number(firstInstall) + Number(transport) + Number(misc) + Number(arrear);



  document.getElementById("total_payable").value=total;



  

}*/





    </script>

    <!-- jQuery -->

    <script src="js/ajax_functions.js"></script>  



    <!-- jQuery -->

    <script src="../vendors/jquery/dist/jquery.min.js"></script>

    <!-- Bootstrap -->

    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>

    <!-- FastClick -->

    <script src="../vendors/fastclick/lib/fastclick.js"></script>

    <!-- NProgress -->

    <script src="../vendors/nprogress/nprogress.js"></script>

    

    <!-- Custom Theme Scripts -->

    <script src="../build/js/custom.min.js"></script>



  </body>

</html>

