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

$branch=$brid;

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


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

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

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

}


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


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

}

?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Fee Settings | EduPortal</title>
    <?php include('RootMe/css_links.php');?>


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


<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'];?>&class_id=<?php echo $_GET['class_id'];?>" 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-2 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Session</label>
                    <select name="session" id="session" class="form-control" >

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

                        <?php
 
 
 
                      $match;
                      if(!isset($_REQUEST['session'])){
                        $match=$_SESSION['current_session'];
                      }else { $match=$_REQUEST['session']; }
                     
   
                        $WorkAssignList = $m->get("edu_session_config");
                        foreach($WorkAssignList as $WorkAssignListVal)
                        { ?>

                           <option <?php if($match==$WorkAssignListVal['session_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['session_id']; ?>"><?php echo $WorkAssignListVal['session_year']; ?></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="getsec(this.value)"  >
                    <option value="">Select Class</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-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']; ?>" />
  
        
 <?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'])){?>

        <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 Name</th>
                <th width="8%">Roll#</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  
                <th width="20%">Disc.Reason</th>
                    


                </th>
  
            </tr>
        </thead>
        <tbody>
   
     
     <?php $count=1;

      foreach($WorkAssignListings as $WorkAssignListVal)
      { 
        
      	  $m->where("student_id", $WorkAssignListVal['student_id']);
          $m->where("session_id", $_REQUEST['session']);

          $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){
         
         $show_fee=$fees[0]['std_tution_fee'];
         $misc_fee=$fees[0]['std_misc_fee'];
        }else {

         $m->where("class_id", $WorkAssignListVal['class_id']);
         $fees1=$m->get("eduportal_class_fee_details");

         $show_fee=$fees1[0]['tution_fee'];
         $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'];?>

               </td>

              
              <td> <?php echo $WorkAssignListVal['candidate_roll_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 

  if (count($fees>1)) {

      $lcounter=0;
     foreach($fees as $fee){ 

         
          if ($fee['discount_reason']==NULL && $lcounter>0) {


            /*$m->where("student_id", $WorkAssignListVal['student_id']);
            $m->where("session_id", $_REQUEST['session']);

            $m->where("class_id", $_REQUEST['class_id']);
            $m->where("branch_id", $_SESSION['branch']);
            $m->where("stdfee_id", $fee['stdfee_id']);
            $m->delete("eduportal_student_fee_structure");*/

            echo "*";
          }

        $lcounter++;

        }


      
          echo $fee['std_tution_fee'].",";

        } 



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

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