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

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

<?php



function check_in_range($start_date, $end_date, $date_from_user)

{

  // Convert to timestamp

  $start_ts = strtotime($start_date);

  $end_ts = strtotime($end_date);

  $user_ts = strtotime($date_from_user);



  // Check that user date is between start & end

  return (($user_ts >= $start_ts) && ($user_ts <= $end_ts));

}



 $sql = "SELECT fee.*,std.student_id,std.ref_no,std.first_name,std.last_name,std.cell_no,std.status,std.branch_id,std.class_id,std.section_id,std.session_id,std.family_code FROM eduportal_monthly_challan as fee, edu_student_details as std WHERE fee.student_id=std.student_id and std.status='0' and std.branch_id=".$_SESSION['branch']. " ";



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

 

    if($_REQUEST['class_id']=="All"){

    

    } else {

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



    }



    if($_REQUEST['section']=="All"){

    

    } else {

     $sql .= " AND std.section_id = '" .$_REQUEST['section']. "' ";



    }


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

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

  }



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

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

  }



  if($_REQUEST['fee']=="All"){

  

  } 



  else {

   //$sql .= " AND fee.paid_status = '" .$_REQUEST['fee']. "' ";
    $sql .= " AND fee.paid_status = 0 ";

    }





  if(isset($_REQUEST['from']) && isset($_REQUEST['to']) && $_REQUEST['fee']==1){

     

      if($_REQUEST['from']!=" " && $_REQUEST['from']!=NULL ) {

        $from=date("d-m-Y",strtotime($_REQUEST['from']));  



      }else {

        $from=date("01-m-Y");  

      }

     

      if($_REQUEST['to']!=" " && $_REQUEST['to']!=NULL   ) {

        $to=date("d-m-Y",strtotime($_REQUEST['to']));

      }else {

        $to=date("t-m-Y");  

      } 

      

    

    $sql .= " AND (fee.paying_date BETWEEN '" .$from. "' AND '" .$to. "' OR fee.paid_again_date BETWEEN '" .$from. "' AND '" .$to. "' )";

  }



    if ($_REQUEST['fee']=="All") {

      $sql.=" order by fee.challan_id desc limit 1200 ";

    } else {



      $sql.=" order by fee.classs_id desc ";

    }

    

 //echo $sql;



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



}





  // getting branch details

  

  $branch=getBranch($m);



  // getting details of total records





       $records=0;

      foreach($WorkAssignListings as $WorkAssignListVal)

      { 



  

      $totalAmount= $WorkAssignListVal['tutionfee']+$WorkAssignListVal['transportfee']+$WorkAssignListVal['balance']+$WorkAssignListVal['misc_fee'];

            

        if($totalAmount==0 ||  $totalAmount=="0"){

        

        continue;

        }

        else {

        $records++; 

        }

   }



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

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

 

     ?>



<input type="hidden" name="" value="<?php print_r($sql);?>">

<!DOCTYPE html>

<html lang="en">

  <head>

    

    <title>Fee Reports | EduPortal</title>

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


    <!--  -->

 <!-- x-editor CSS

    ============================================ -->

    <link rel="stylesheet" href="css/editor/select2.css">

    <link rel="stylesheet" href="css/editor/datetimepicker.css">

    <link rel="stylesheet" href="css/editor/bootstrap-editable.css">

    <link rel="stylesheet" href="css/editor/x-editor-style.css">



    <!-- normalize CSS

    ============================================ -->

    <link rel="stylesheet" href="css/data-table/bootstrap-table.css">

    <link rel="stylesheet" href="css/data-table/bootstrap-editable.css">



     <!-- responsive CSS

    ============================================ -->

        <link rel="stylesheet" href="css/responsive.css">

 <!-- main CSS

    ============================================ -->

        <link rel="stylesheet" href="css/main.css">



  <!--  -->

<style>



.thStyle{background-color:lightgray;text-align:center;}



</style>   

  </head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
 <script>  







function PayFullFee(count) {



 

 // others fee parameters

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

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

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





// general parameters to submit the fee

 var student=document.getElementById("student"+count).value;

 var month_name=document.getElementById("month_name"+count).value;

 var fine=document.getElementById("fine"+count).value;

 var challan_id=document.getElementById("challan_id"+count).value;

 var fee_recv_sms=document.getElementById("fee_recv_sms"+count).value;

 var double_sms=document.getElementById("double_confirmation_sms_to_principal"+count).value;

 var std_name=document.getElementById("std_name"+count).value;

 var std_no=document.getElementById("std_no"+count).value;

 var Owner_no=document.getElementById("Owner_no"+count).value;

 var totalAmount=document.getElementById("totalAmount"+count).value;

 var collected=totalAmount;



//alert(month_name);



    if (window.XMLHttpRequest) {

      xmlhttp=new XMLHttpRequest();

    } else { // code for IE6, IE5

      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

    }

  xmlhttp.onreadystatechange=function() {



      if (xmlhttp.readyState==4 && xmlhttp.status==200) {



       if(xmlhttp.responseText=="1" || xmlhttp.responseText==1){

         

          document.getElementById("paynow"+count).style.display="none";

          document.getElementById("fullpaid"+count).style.display="block";

          document.getElementById("totalAmount_col"+count).value=collected;



         //alert(xmlhttp.responseText);

       }// ending main if condition 



      }



    }



  xmlhttp.open("GET","PayFullFee.php?action=PayChallan&collected="+collected+"&challan_id="+challan_id+"&fee_recv_sms="+fee_recv_sms+"&double_confirmation_sms_to_principal="+double_sms+"&student="+student+"&fine="+fine+"&std_name="+std_name+"&std_no="+std_no+"&Owner_no="+Owner_no+"&totalAmount="+totalAmount+"&paid_date="+date+"&month="+month+"&month_name="+month_name+"&PiadBy="+PiadBy+"&student="+student,true);

 

  xmlhttp.send();



}





 





var chk_status;  







function HideDate(str){

  

  if(str=="1"){

    

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

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

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

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

  }

  else {

    

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

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

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

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

  }

}







function show_message(){

  

  $("#msg").slideDown('slow').delay(4000).slideUp('slow');

  $("#error").slideDown('slow').delay(5000).slideUp('slow');



}





function getsec(id){





  var section=document.getElementById("txt_section").value;



    if (window.XMLHttpRequest) {



      // code for IE7+, Firefox, Chrome, Opera, Safari



      xmlhttp=new XMLHttpRequest();



    } else { // code for IE6, IE5



      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");



    }



    xmlhttp.onreadystatechange=function() {



      if (xmlhttp.readyState==4 && xmlhttp.status==200) {



        document.getElementById("txt_section").innerHTML=xmlhttp.responseText;

        // alert(xmlhttp.responseText);



      }



    }



    xmlhttp.open("GET","get_section_all.php?class_id="+id+"&section_id="+section,true);



    xmlhttp.send();









  }

                





</script>



 <script type="text/javascript">

  

 function checkboxes(){

     // alert("786");

    var chk_arr =  document.getElementsByName("students[]");

    var chklength = chk_arr.length;             

    var students;

    var count=0;



      for(k=0;k< chklength;k++)

      {

          

          if(chk_arr[k].checked){

             var vl=chk_arr[k].value.split(",");

             students=students+","+vl[1];

            count++;  

          //  alert(students);

        }



      } 

        

    if(count>0){



      window.location="messages.php?students="+students;

    }else {

      

      alert("Please choose any students from checkboxes OR Check SMS Credit Limit");



    }

  

}







 function checkboxes_urdu(){

     // alert("786");

    var chk_arr =  document.getElementsByName("students[]");

    var chklength = chk_arr.length;             

    var students;

    var count=0;



      for(k=0;k< chklength;k++)

      {

          

          if(chk_arr[k].checked){

             var vl=chk_arr[k].value.split(",");

             students=students+","+vl[1];

            count++;  

          //  alert(students);

        }



      } 

        

    if(count>0){



      window.location="newurdusms.php?students="+students;

    }else {

      

      alert("Please choose any students from checkboxes...");



    }

  

}



</script>



  <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="" style="background-color: white;">

           

          <a href="<?php echo $_SESSION['dashboard'];?>" style="margin-left: 33px;">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp;



          <a href="multi_fee_reports.php">Fee Reports </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp;  



          Monthly Fee Reports





<section class="add_sub_agent" id="table_sub_agent">

  <div class="container">



    <!-- Modal -->

            <div id="Modal<?php echo $_GET['class_id'];?>-<?php echo $_GET['section'];?>" class="modal fade" role="dialog">





              <div class="modal-dialog">



                <!-- Modal content-->

                <div class="modal-content">



                   

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



                  <input type="hidden" name="action" value="PrintFeeParameter">

             

                  <div class="modal-header">

                    <button type="button" class="close" data-dismiss="modal">&times;</button>

                    <h4 class="modal-title">Choose the parameters to display in print. </h4>

                  </div>







                  <div class="modal-body">





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

                  <input type="hidden" name="section" value="<?php echo $_GET['section'];?>" />

                  <!-- <input type="hidden" name="session" value="</?php echo $_GET['session'];?>" /> -->

                  <input type="hidden" name="year" value="<?php echo $_GET['year'];?>" />

                  <input type="hidden" name="month" value="<?php echo $_GET['month'];?>" />

                  <input type="hidden" name="from" value="<?php echo $_GET['from'];?>" />

                  <input type="hidden" name="to" value="<?php echo $_GET['to'];?>" />

                  <input type="hidden" name="fee" value="<?php echo $_GET['fee'];?>" />

                  <input type="hidden" name="others" value="<?php echo $_GET['others'];?>" />

                  <input type="hidden" name="checkboxes[]"  value="1"  class="cb-element" />

                 

               

                  <br> 

            

                                    

                  <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="student_name" checked value="1"/>

                    Student Name

                    <span class="checkmark"></span>

                  </label>



                  <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="father_name" checked value="1"/>

                    Father Name

                    <span class="checkmark"></span>

                  </label>



                   <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="class_sec" checked value="1"/>

                    Class/Sec

                    <span class="checkmark"></span>

                  </label>



                  <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="roll_no" checked value="1"/>

                    Roll No

                    <span class="checkmark"></span>

                  </label>



                  <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="adm_no" checked value="1"/>

                    Admission No

                    <span class="checkmark"></span>

                  </label>



                  <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="cell_no" checked value="1"/>

                    SMS Reporting Number

                    <span class="checkmark"></span>

                  </label>                  



                  <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="father_cellno" checked value="1"/>

                    Father Contact No

                    <span class="checkmark"></span>

                  </label>              



                  <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="mother_cell" checked value="1"/>

                    Mother Contact No

                    <span class="checkmark"></span>

                  </label>



                  <label class="container1" style="text-align: left;">

                    <input type="checkbox" name="home_number" checked value="1"/>

                    Home Contact No

                    <span class="checkmark"></span>

                  </label>



                      <label class="container1" style="text-align: left;">



                       Display Fee Heads in Print

                      

                        <select name="others" class="form-control col-md-12" >



                           <option <?php if($_GET['others']=="0"){echo 'selected';}?> value='0'>NO</option>

                           <option <?php if($_GET['others']=="1"){echo 'selected';}?> value='1'>YES</option>

                      

                          </select>



                        </label>

                   





                  </div>



                

 



                  <div class="modal-footer" style="text-align: right;">

                    <input type="submit" class="btn btn-primary" checked value="Print" />

                  </div>



                   </form>

                </div>



              </div>

            </div>

            <!-- Modal -->







 <div class="" style="margin-top:10px;">

      







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



  <input type="hidden" name="action" value="PrintFeeParameter">

  <input type="hidden" name="student_name" value="1">

  <input type="hidden" name="father_name" value="1">

  <input type="hidden" name="class_sec" value="1">

  <input type="hidden" name="others" value="0">

  <input type="hidden" name="adm_no" value="1">

  <input type="hidden" name="roll_no" value="1">

  

  <div class="panel panel-default">

    <div class="panel-heading " id="heading"><!-- <?php echo $WorkAssignListings;?> Students Records --> 



      <span style="font-size:18;font-weight:bold;"> Fee Receiveable Report </span>



      (<?php echo count($WorkAssignListings);?> records)





      <span style="float:right;margin-top: -7px;">







    <input type="hidden" value="<?php echo session_id().session_id().session_id(); ?>" name="dummysession" />





<div class="pull-right">         











  <a onClick="$('#advanceSearch').toggle('blind')" class="btn btn-primary pull-right" style="cursor:pointer;">Advance Search</a>


<!-- 
<a target="_blank" href="multi_fee_reports.php" class="btn btn-primary pull-right"> Multi Fee Reports </a>

<a target="_blank" href="datewise_partialy_fee_collection.php" class="btn btn-primary pull-right"> Partialy Remaining Fee Report </a> -->





<?php if (isset($_REQUEST['class_id'])) { ?>  




<!-- 
<a style="height: 34px;padding: 9px;" href="export_excel.php?class_id=<?php echo $_GET['class_id'];?>&year=<?php echo $_GET['year'];?>&month=<?php echo $_GET['month'];?>&from=<?php echo $_GET['from'];?>&to=<?php echo $_GET['to'];?>&fee=<?php echo $_GET['fee'];?>&section=<?php echo $_GET['section'];?>" class="pull-right btn btn-success  fa fa-download pull-right"> Export To Excel </a> -->





<?php } ?>









<?php 

 if($_REQUEST['fee']=="0" ){

?>



  <a target="_blank" class="btn btn-success fa fa-print pull-right" style="height: 34px;padding: 9px;" title="Print Fee Report" data-toggle="modal" data-target="#Modal<?php echo $_GET['class_id'];?>-<?php echo $_GET['section'];?>">

    Print Report List

  </a>



<?php 

}

?>





</div>



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

          <div class="panel-body">

                



            <div class="col-md-12" id="advanceSearch" style="display:none;">

             <div class="col-md-2 col-xs-12" style="padding: 8px;">

                <div class="form-group ">

                  <label class="required">Class</label>

                  

                  <input type="hidden" name="fee" value="0" />

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

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



                    <?php

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

                    $WorkAssignList = $m->get("edu_class_config");

                    foreach($WorkAssignList as $WorkAssignListVal)

                    { ?>



                       <option <?php if($_REQUEST['class_id']==$WorkAssignListVal['class_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['class_id']; ?>"><?php echo $WorkAssignListVal['Class_Name']; ?></option>





                            <?php

                    } ?>



                </select> 

                </div>

              </div>

              

              

     

            

              <div class="col-md-2 col-xs-12" style="padding: 8px;">

                <div class="form-group ">

                  <label class="required">Section</label>

                    <select name="section" id="txt_section" class="form-control"   >

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

                   <?php

                              if(isset($_REQUEST['section']))

                              { 



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



                              $secondLevel = $m->get("edu_adm_section_detail");

                              

                              foreach($secondLevel as $secondLevel_val)

                              {

                              

                               ?>

                                <option <?php if($_REQUEST['section']==$secondLevel_val['section_id']){echo "selected";} ?> value="<?php echo $secondLevel_val['section_id']; ?>"><?php echo trim(utf8_encode_all($secondLevel_val['section_name'])); ?></option>



                              <?php }   ?>

                                

                          <?php } ?>



                    </select>



                  

                </div>

              </div>         

                      

              


              <div class="col-md-2 col-xs-12" style="padding:8px;">

                <div class="form-group ">

                  <label class="required">Year</label>

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





                 <div class="col-md-2 col-xs-12" style="padding: 8px;">



            <div class="form-group ">



            <label class="required">Challan Month</label>

            <input type="month" id="month" name="month" required class="form-control" min="<?php echo date("Y")."-".date("m");?>" value="<?php if (isset($_REQUEST['month'])) {
            echo $_REQUEST['month'];
            } else { echo date("Y")."-".date("m");}?>">

            </div>





                    </div> 





                    <div class="col-md-2 col-xs-12" style="padding: 8px;">



                       <div class="form-group ">



                          <label class="required">Report Format</label>

                              <select name="recevabl" id="recevabl" class="form-control" required>                              

                              <option value="PrintList">Print Receivable List</option>
                              <option value="ReceivableReport">Receivable Report</option>

                                 

                              </select>

                            </div>





                    </div>





                   

                     <div class="col-md-2 col-xs-12" style="padding: 8px;">



                       <div class="form-group ">



                      <label class="required">Order By</label>

                          <select name="orderBy" style="width: 178px;" id="orderBy" class="form-control" >

              

                       <option  value="asc">Alphabetic</option>

                       <option  value="RollNoWise">Roll No Wise</option>

                       <option  value="AdmNoWise">Adm No Wise</option>

                       <option  value="ClassWise">Class Wise</option>

                       

                       </select>

                        </div>





                    </div>





                   

        



              <div class="col-md-1" style="padding:2px;float: right;">

                <div class="form-group ">

                   <input type="hidden" name="addaccountAdmin" value="1">

                <button type="submit" class="btn btn-primary" style="float: right;">Search</button>

                </div>

              </div>



             

            </div>

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

          </div>

        </div>

      </form>

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

    </div>

    <br>



   

 <?php  if(!isset($_REQUEST['class_id'])){?>



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



          

           <div id="check_std_msg" style="color:white;font-size:18px;" class="alert alert-danger alert-dismissible">

                    <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>

                     <strong>Warning!</strong> Please select class & session from advance search to save fee reports!!!

            </div>

    



        </div>



  <?php   }?>






<?php 

$total_sms_monthly_used=getCurrentMonthFeeSms($m)+getCurrentMonthResultSms($m)+getCurrentMonthOtherSms($m)+getCurrentMonthAttendanceSms($m)+0;





?>



<?php if (isset($_REQUEST['class_id'])) { ?> 

<!-- <a href="#" class="btn btn-success pull-right" <?php if($sms_credit <= 0) { echo "disabled";}?> onClick="checkboxes();"> Send English SMS To Selected </a>



<a href="#" class="btn btn-success pull-right" <?php if($sms_credit <= 0) { echo "disabled";}?> onClick="checkboxes_urdu();"> Send Urdu SMS To Selected </a> -->





<? } ?>

  

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



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

 

    <div class="alert alert-success" id="msg">

     <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>

      <strong>Success!</strong> Fee challan is paid successfully...

    </div>



</div>

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







    









    <!-- <table id="listofstudents" data-page-length='200' class="table table-striped table-bordered" style="width:100%;font-size:11px;"> -->

      <table id="table" data-toggle="table" class="table-bordered" data-pagination="true" data-search="true" data-show-columns="true" data-show-pagination-switch="true" data-show-refresh="true" data-key-events="true" data-show-toggle="true" data-resizable="true" data-cookie="true" data-show-export="true" data-click-to-select="true" data-toolbar="#toolbar" style="width:100%">

          

          <thead>

            <tr>

                <th width="2%">S.No</th>

                <th width="20%">Student/Father Name</th>

                <th width="12%">Roll/Adm</th>

                <th width="10%" style="text-align:center;"> Class </th>

                <th width="8%" style="text-align:center;">  Month </th>

                <th width="6%">DueDate </th>

              

                <th width="5%">Balance </th>

                <th width="8%">Fee </th>                           

                <th width="8%">Total </th>               

                <th width="10%">Status </th>
        

                 <!--  <th width="5%">

              <label class="container1"><input  type="checkbox" id="checkAll"/><span class="checkmark" style="margin-top: -17px;"></span></label>              

               </th> -->

            </tr>

        </thead>

        <tbody>



     <?php 



     $count=1;

     $counter=0;

      foreach($WorkAssignListings as $WorkAssignListVal)

      { 



      $counter++;          

    

      // getting students details 



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

        $m->where("status", 0);



        $param = array('student_id','ref_no','first_name','last_name','cell_no','branch_id','class_id','candidate_roll_no','section_id','session_id','family_code','status');

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

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





        if(count($student)<=0){

          continue;

        }



        $others_fee=0+getFeeAllOtherFee($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],$m);





        $totalAmount= $WorkAssignListVal['tutionfee']+$WorkAssignListVal['transportfee']+$WorkAssignListVal['balance']+$WorkAssignListVal['misc_fee']+$others_fee-$WorkAssignListVal['disc_amount'];

              

          if($totalAmount==0 ||  $totalAmount=="0"){

          

          continue;

        } 

          



    $start_date = strtotime($WorkAssignListVal['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 row is first and fee is paid then show only collected fine

          if($WorkAssignListVal['paid_status']==1){

          

             $actual_fine=$WorkAssignListVal['collected_fine'];

           

          } 

        // if row is first and fee is not paid then calculate fine



          else if(date("Y-m-d")>$WorkAssignListVal['challan_duedate'] && $WorkAssignListVal['paid_status']==0){

          

            $actual_fine=$student_fine;

          }

      //echo $actual_fine;    



    $totalAmount+=$actual_fine;



        $paid_fee=0;

        $again_paid_fee=0;

        $paidAmountDate;



       $response_paying=check_in_range($_REQUEST['from'], $_REQUEST['to'], $WorkAssignListVal['paying_date']);



       if($response_paying==1){



       $paid_fee=intVal($WorkAssignListVal['collected_amount']+$WorkAssignListVal['collected_fine']);

       $paidAmountDate=$WorkAssignListVal['paying_date'];



         }



        $response_payagain=check_in_range($_REQUEST['from'], $_REQUEST['to'], $WorkAssignListVal['paid_again_date']);

 



      if($response_payagain==1){



         $again_paid_fee+=intVal($WorkAssignListVal['paid_again_amount']);

         $paidAmountDate=$WorkAssignListVal['paid_again_date'];



       }
$toMonthYear=explode("-",$_REQUEST['month']);
      ?>



        <tr>

                  

                  <td style="text-align:center;"> <?php echo $count; ?> </td>



<!-- these are the hidden fields... -->



<input  type="hidden"  value="<?php echo $totalAmount; ?>" id="totalAmount<?php echo $count;?>"/>

<input  type="hidden"  value="<?php echo $WorkAssignListVal['student_id']; ?>" id="student<?php echo $count;?>"/>



<input  type="hidden"  value="<?php echo $actual_fine; ?>" id="fine<?php echo $count;?>"/>



<input  type="hidden"  value="<?php echo $WorkAssignListVal['challan_id']; ?>" id="challan_id<?php echo $count;?>"/>



<input  type="hidden"  value="<?php echo $brid[0]['fee_recv_sms']; ?>"  id="fee_recv_sms<?php echo $count;?>"/>



<input  type="hidden"  value="<?php echo $brid[0]['double_confirmation_sms_to_principal']; ?>" id="double_confirmation_sms_to_principal<?php echo $count;?>"/>



<input  type="hidden"  value="<?php echo $student[0]['first_name']; ?>"  id="std_name<?php echo $count;?>"/>



<input  type="hidden"  value="<?php echo $student[0]['cell_no']; ?>"  id="std_no<?php echo $count;?>"/>

<input  type="hidden"  value="<?php echo $brid[0]['Owner_no']; ?>" id="Owner_no<?php echo $count;?>"/>

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

<input name="tutionfee[]" type="hidden" value="<?php echo $WorkAssignListVal['tutionfee'];?>" />

<input name="transportfee[]" type="hidden" value="<?php echo $WorkAssignListVal['transportfee'];?>" />



<input name="balance[]" type="hidden" value="<?php echo $WorkAssignListVal['balance'];?>" />

   

<input id="month_name<?php echo $count;?>" value="<?php echo getMonthName($m,$_REQUEST['month']);?>"  type="hidden" />


                  <td>  


    <a href="pay_fee.php?student=<?php echo $WorkAssignListVal['student_id']; ?>">

     <?php echo $student[0]['first_name']."/".$student[0]['last_name'];?>

    </a>

     </td>



    <td> <?php echo $student[0]['candidate_roll_no']." / ".$student[0]['ref_no'];?> </td>

    <td style="text-align:center;"> <?php echo getClassName($m,$WorkAssignListVal['class_id']);?>  </td>



    <td> <?php echo substr(getMonthName($m,$toMonthYear[1]), 0, 3)."-".$toMonthYear[0];?> </td>                 

    <td> <?php echo date("d-M",strtotime($WorkAssignListVal['challan_duedate']));?> </td>

    <td style="text-align:center;"> <?php echo $WorkAssignListVal['balance'];?> </td>

    <td style="text-align:center;">  

      <a data-toggle="modal" data-target="#otherFee<?php echo $WorkAssignListVal['student_id'];?>" style="padding: 0px 4px; font-size:14px;"  class="btn btn-warning">

      <?php echo $others_fee;?>  

      </a> 



      <!-- Modal -->

      <div id="otherFee<?php echo $WorkAssignListVal['student_id'];?>" class="modal fade" role="dialog">

        <div class="modal-dialog">



          <!-- Modal content-->

          <div class="modal-content" style="width: 900px;margin-left: -25%;">

            <div class="modal-header">

              <button type="button" class="close" data-dismiss="modal">&times;</button>

              <h4 class="modal-title"> Other Fee Parameters  </h4>

            </div>





            <div class="modal-body">







              <p> <?php echo $student[0]['first_name'];?>  <?php echo $student[0]['last_name'];?>  </b>

                (<?php echo getClassName($m,$WorkAssignListVal['class_id']);?>)



              </p>





            </div>





          <br>

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

            



            <table border="1" width="100%">  





              <tr>  



                <th class="thStyle" style="text-align: center;padding:1%;"> Fee Type  </th>

                <th class="thStyle" style="text-align: center;padding:1%;"> Amount  </th>

              

              </tr>

<?php 



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



if(count($fee_types)<=0){

  echo "<tr> <td colspan='10' style='color:red;text-align:center;'> No record found ! </td> </tr> ";



}



 foreach ($fee_types as $type) {



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

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



  $fee=getFeeOfOtherParameter($WorkAssignListVal['student_id'],$WorkAssignListVal['challan_id'],$type['feetype_id'],$m);

  if($fee==NULL){

    continue;

  }



?>            

              <tr>  



                <td  style="text-align: center;padding:2%;"> <?php if ($feeHeads[0]['fee_head_title']!=NULL){echo $feeHeads[0]['fee_head_title'];}else {echo $type['feetype_name'];} ?> </td> 

                <td  style="text-align: center;padding:2%;"> <?php echo $fee;?> </td> 

                

              </tr>



<?php   } ?>



          

 

             </table>



          </div>



          <br><br>





            <div class="modal-footer">



             <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>





            </div>







          </div>



        </div>

      </div>



      <!-- ending modal -->

   


    </td>


    <td style="text-align:center;"> <?php echo $totalAmount; ?>  </td>



          <td> 



      <?php if($totalAmount>0 && $WorkAssignListVal['paid_status']==0 ){ ?>

          <a style="padding: 0px 5px; font-size:14px;"  class="btn btn-danger">

                  Not Paid

          </a> 

        <?php } ?>

                  </td>




           
               <!--      <td style="padding: 2px;">

              <label class="container1">

                <input type="checkbox" name="students[]" value="<?php echo $WorkAssignListVal['student_id'].",".$student[0]['cell_no'];?>"><span class="checkmark"></span>

              </label>



            </td> -->





              </tr>







               





 <?php   $count++;      } ?>







           

            

           

        </tbody>

        

    </table>













    <br><br>





  </div>

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

</section>            

    



           

          </div>

        </div>



            </div>

          </div>

        </div>

        <!-- /page content -->

  



    

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

  <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>

    <script>

       



    $(document).ready(function() {

    $('#listofstudents').DataTable( {

        dom: 'Bfrtip',

              buttons: [

                  'print'

              ]

          } );

      } );

      $("#checkAll").change(function () {



      $("input:checkbox").prop('checked', $(this).prop("checked"));

      });

    </script>




 <!-- ################## -->



   <!-- JS files for table -->

      <!-- bootstrap JS

    ============================================ -->

  

  <!-- data table JS

    ============================================ -->

    <script src="js/data-table/bootstrap-table.js"></script>

    <script src="js/data-table/tableExport.js"></script>

    <script src="js/data-table/data-table-active.js"></script>

    <script src="js/data-table/bootstrap-table-editable.js"></script>

    <script src="js/data-table/bootstrap-editable.js"></script>

    <script src="js/data-table/bootstrap-table-resizable.js"></script>

    <script src="js/data-table/colResizable-1.5.source.js"></script>

    <script src="js/data-table/bootstrap-table-export.js"></script>

    <!--  editable JS

    ============================================ -->

    <script src="js/editable/jquery.mockjax.js"></script>

    <script src="js/editable/mock-active.js"></script>

    <script src="js/editable/select2.js"></script>

    <script src="js/editable/moment.min.js"></script>

    <script src="js/editable/bootstrap-datetimepicker.js"></script>

    <script src="js/editable/bootstrap-editable.js"></script>

    <script src="js/editable/xediable-active.js"></script>



    <!--###############  -->

  </body>

</html>

