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

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

<?php





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

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

$m->where("page_id", 24);

$access = $m->get("users_privilege_detail");



$branch=$brid;



$branchIDs=$_SESSION['branch'];
$sessionID=$_SESSION['current_session'];



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



  $sql = "SELECT * FROM  edu_student_details  WHERE branch_id='$branchIDs' and status='0'";

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

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

      }      

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

    } else {

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

    }



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

     //  $sql .= " AND session_id ='" . $_REQUEST['session']. "' ";

     // }else{


      $sql .= " AND session_id ='" . $_SESSION['current_session']. "' ";

     }





     if($_REQUEST['orderBy']=='RollNoWise'){

        $sql .= "order by candidate_roll_no asc";

      }



    if($_REQUEST['orderBy']=='Admascending'){

        $sql .= "order by CAST(ref_no as unsigned)  asc";

      }



    if($_REQUEST['orderBy']=='Alphabatically'){

        $sql .= "order by first_name  asc";

      }

     // echo $sql;

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



}



?>





<!DOCTYPE html>

<html lang="en">

  <head>

    

    <title>Fee Settings | EduPortal</title>

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





   

  </head>

  

  <script type="text/javascript">





function HideDate(str){

 

  if(str=="YES"){

    

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

   

  }

  else {

    

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

   

  }

}





 function getsectionAll(id){

//alert(id)

            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,true);



            xmlhttp.send();









          }

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



          Classwise Fee Update

           

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

  <div class="container">



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



      <form  action="fee_settings.php" enctype="multipart/form-data" method="get">

        <div class="panel panel-default">

          <div class="panel-heading"><?php echo count($WorkAssignListings);?> Students Records <span style="float:right;margin-top: -7px;">



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

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





<div class="pull-right">         



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





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



    <a href="print_fee_settings.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&session=<?php echo $_GET['session'];?>&year=<?php echo $_GET['year'];?>&class_id=<?php echo $_GET['class_id'];?>&section=<?php echo $_GET['section'];?>&orderBy=<?php echo $_GET['orderBy'];?>" id="subuser"target="_blank" class="btn btn-warning pull-right">Print Fee 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-3 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-3 col-xs-12" style="padding: 8px;">

                <div class="form-group ">

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

 



                  <select name="class_id" id="class_id"  name="term_id"   data-placeholder="Select" class="chosen-multi-select inputfield" onChange="getsectionAll(this.value)"  >

                    <option value="">Select Class</option>



                    <?php

                    $m->where("branch_id", $_SESSION['branch']);
                    $m->orderBy("orderno", "asc");
                    $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-3 col-xs-12" style="padding: 8px;">

                <div class="form-group ">

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

 



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

                  

                   <?php

                              if($_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-3 col-xs-12" style="padding: 8px;">

                <div class="form-group ">

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



                  <select name="orderBy" id="orderBy" class="form-control" >                     

                     <option <?php if($_REQUEST['orderBy']=="RollNoWise"){echo "Selected";} ?> value="RollNoWise">Roll No Wise</option>

                     <option <?php if($_REQUEST['orderBy']=="Admascending"){echo "Selected";} ?> value="Admascending">Adm# Ascending</option>

                     <option <?php if($_REQUEST['orderBy']=="Alphabatically"){echo "Selected";} ?> value="Alphabatically">Alphabatically</option>

                       

                    </select> 

                </div>

              </div>



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

                <div class="form-group ">

                  <label  class="required">Increment Monthly Fee</label> 



                  <select name="increment" id="increment" onChange="HideDate(this.value);" class="form-control" >  

                     <option <?php if($_REQUEST['increment']=="NO"){echo "Selected";} ?>  value="NO">NO</option>                   

                     <option <?php if($_REQUEST['increment']=="YES"){echo "Selected";} ?> value="YES">YES</option>

                  </select> 

                </div>

              </div>



              <div class="col-md-3 col-xs-12" id="incremented_amount" style="padding: 8px; display: none;">

                <div class="form-group ">

                  <label class="required">Enter Incremented Fee</label> 



                  <input type="text" name="incremented_amount" class="form-control"> 

                </div>

              </div>

           

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

                <div class="form-group ">

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

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

                </div>

          </div>



             

            </div>

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

          </div>

        </div>

      </form>

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

    </div>

    <br>



     

          

          

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





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

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

              <strong>Success!</strong> Fee updated successfully...

            </div>



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



      

<div style="overflow-x:auto;">



<form class="form-style-7" action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post"  onSubmit="return student_check();"  enctype="multipart/form-data">





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



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

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

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



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

  

        

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

            </div>

    



        </div>



  <?php   }?>



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



    <div style="color:black;font-size:18px;" class="alert alert-warning alert-dismissible">

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

                     <strong>Alert !</strong> This previous balance only apply when there is no any challan created in the system. 

        </div>



  <?php   }?>



 <?php  //if(isset($_REQUEST['class_id']) AND $access[0]['edit_access']!=NULL ){?>



        <div class="col-md-1 pull-right" style="margin-bottom:1%;">

              <input type="submit" name="submit" class="pull-right btn btn-primary"  value="Save Fee Settings"  />

        </div>



  <?php  // }?>







 

    <table data-page-length='100' class="table table-striped table-bordered" style="width:100%">

          

          <thead>

            <tr>

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

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

                <th width="8%">Roll#</th>

                <th width="8%">Adm#</th>

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

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

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

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

                  <?php if ($brid[0]['misc_title']!=NULL){echo $brid[0]['misc_title'];}else {echo 'Miscellaneous';} ?> </th>

                <th width="10%" style="text-align:center;"> Monthly Fee <input type="text" onkeyup="change_total(this.value);" id="total_marks" autocomplete="off"  tabindex=1 style="width: 100px;" />



                    <script>



       function change_total(value){



        

        var elements=document.getElementsByName("std_tution_fee[]");



        for(var i=0;i<elements.length; i++){

            

            //alert(elements[i].value);

            if(value!="" ){



              elements[i].value=value;

            }

            

        

        }

      

      }



      </script>



                 </th>

                <th width="20%">Disc.Reason</th>

                    





                

  

            </tr>

        </thead>

        <tbody>

   

     

     <?php 

     $count=1;

     $IncreamentAmount;



     if ($_REQUEST['increment']=="YES") {



       $IncreamentAmount=$_REQUEST['incremented_amount'];



     }



      foreach($WorkAssignListings as $WorkAssignListVal)

      { 

        

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

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

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

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

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

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

        

         // print_r($fees);

         $show_fee=0;

         $misc_fee=0;



        if(count($fees)>0){

         

         if ($fees[0]['std_tution_fee']==0) {

           $IncreamentAmount=0;

         } else {

          $IncreamentAmount=$_REQUEST['incremented_amount'];

         }

         $show_fee=$fees[0]['std_tution_fee']+$IncreamentAmount;

         $misc_fee=$fees[0]['std_misc_fee'];
       

        }else {


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

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



         if ($fees1[0]['tution_fee']==0) {

           

           $IncreamentAmount=0;

         } else {

          $IncreamentAmount=$_REQUEST['incremented_amount'];

         }



         $show_fee=$fees1[0]['tution_fee']+$IncreamentAmount;

         $misc_fee=$fees1[0]['misc_fee'];





        }







       

       $id=$WorkAssignListVal['student_id'];  



    

   



      ?>



    <tr>

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

              <td>



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

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



               </td>



              

              <td> <?php echo $WorkAssignListVal['candidate_roll_no'];?> </td>



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



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



              <td> <input type="text" class="form-control" name="std_outstanding_blc[]" value="<?php echo $fees[0]['std_outstanding_blc'];?>"> </td>



              <td><input type="text" class="form-control" name="std_transport_fee[]" value="<?php echo $fees[0]['std_transport_fee'];?>"></td>



              <td><input type="text" class="form-control" name="std_misc_fee[]" value="<?php echo $misc_fee;?>"></td>

              <td> <input type="text"  class="form-control"name="std_tution_fee[]"  value="<?php echo $show_fee;?>" /> </td>

           

              <td><input type="text" class="form-control" name="discount_reason[]" value="<?php echo $fees[0]['discount_reason'];?>"></td>



             

          </tr>











              <?php

      } ?>







           

            

           

        </tbody>

        

    </table>

 



</form>

</div>

    <br><br>





  </div>

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

</section>          

    



           

          </div>

        </div>



            </div>

          </div>

        </div>

        <!-- /page content -->

  



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

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

  </body>

</html>

