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

//$branch=$brid;
$branch=$_SESSION['branch'];

   $sessionID;

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

      $sessionID=$_REQUEST['session'];
      
    }else {
      
      $sessionID=$_SESSION['current_session'];
    }




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

      if($_REQUEST['class_id']!=NULL){
      $sql .= " AND class_id ='" . $_REQUEST['class_id']. "' ";
      }

      if($_REQUEST['section']!=NULL){
      $sql .= " AND section_id ='" . $_REQUEST['section']. "' ";
     }

     if($_REQUEST['session']!=NULL){
      $sql .= " AND session_id ='" . $_REQUEST['session']. "' ";
     }

      if($_REQUEST['orderBy']=='alphabetic'){
      $sql .= "order by first_name asc";
    }

    if($_REQUEST['orderBy']=='RollNoWise'){
        $sql .= "order by candidate_roll_no asc";
      }

    if($_REQUEST['orderBy']=='Admascending'){
        $sql .= "order by CAST(ref_no as unsigned)  asc";
      }

      //print_r($sql);
   $WorkAssignListings = $m->query($sql);
     ?>


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


     
     
        <!-- page content -->
          <div class="" role="main" style="margin-left: 25px;margin-right: 25px; margin-top: 10px;">
          <div class="" style="background-color: white;">


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

     <a href="students_reports_link.php">Students Reports </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
          
      Age Wise Reports

          <br>
           
  <section class="add_sub_agent" >
  <div class="container">

 <div class="" style="margin-top:10px;">
      <form  action="update_student_classwise.php" enctype="multipart/form-data" method="get">
        <div class="panel panel-default">

          <h3> Please Select Class/Section and Parameters to updates. </h3>


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

<!-- <div class="pull-right">         

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


</div> -->



          </span><div class="clearfix"></div> </div>
          <div class="panel-body">
          
            <div class="col-md-12" id="advanceSearch" style="">


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

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

                        <?php
 
 
                        $WorkAssignList = $m->get("edu_session_config");
                        foreach($WorkAssignList as $WorkAssignListVal)
                        { ?>

                           <option <?php if($sessionID==$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 form-control" 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-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" onChange="getSubjects(this.value)">
                      
                   <?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-2 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Select Listing Order:</label>
                    
                  <select name="orderBy" id="orderBy" class="form-control" >
            
                     <option  value="alphabetic">Alphabetic</option>
                     <option  value="RollNoWise">Roll No Wise</option>
                     <option  value="Admascending">Adm# Ascending</option>
                       
                    </select>
                  
                </div>
              </div>
           
           <div class="col-md-2 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;">Search Update Students</button>
                </div>
          </div>


  

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

                <div class="col-md-2" >
                  <div class="form-group" > 
                  <label class="container1">
                    <input type="checkbox" name="adm" checked value="adm"/>
                    <span style="font-size:12px;">Adm No</span> <span class="checkmark"></span>
                  </label>
                  
                  </div>
                </div>

                <div class="col-md-2" >
                  <div class="form-group" > 
                  <label class="container1">
                    <input type="checkbox" name="stdName" checked value="stdName"/>
                    <span style="font-size:12px;">Student Name</span> <span class="checkmark"></span>
                  </label>
                  
                  </div>
                </div>

                <div class="col-md-2" >
                  <div class="form-group" > 
                  <label class="container1">
                    <input type="checkbox" name="fName" checked value="fName"/>
                    <span style="font-size:12px;">Father Name</span> <span class="checkmark"></span>
                  </label>
                  
                  </div>
                </div>

                <div class="col-md-2" >
                  <div class="form-group" > 
                  <label class="container1">
                    <input type="checkbox" name="cellno" checked value="cellno"/>
                    <span style="font-size:12px;">Cell Number</span> <span class="checkmark"></span>
                  </label>
                  
                  </div>
                </div>

                <div class="col-md-2" >
                  <div class="form-group" > 
                  <label class="container1">
                    <input type="checkbox" name="dob" checked value="dob"/>
                    <span style="font-size:12px;">DOB</span> <span class="checkmark"></span>
                  </label>
                  
                  </div>
                </div>

                <div class="col-md-2" >
                  <div class="form-group" > 
                  <label class="container1">
                    <input type="checkbox" name="locality" checked value="locality"/>
                    <span style="font-size:12px;">Locality</span> <span class="checkmark"></span>
                  </label>
                  
                  </div>
                </div>

                <div class="col-md-2" >
                  <div class="form-group" > 
                  <label class="container1">
                    <input type="checkbox" name="gender" checked value="gender"/>
                    <span style="font-size:12px;">Gender</span> <span class="checkmark"></span>
                  </label>
                  
                  </div>
                </div>

                <div class="col-md-2" >
                  <div class="form-group" > 
                  <label class="container1">
                    <input type="checkbox" name="doa" checked value="doa"/>
                    <span style="font-size:12px;">DOA</span> <span class="checkmark"></span>
                  </label>
                  
                  </div>
                </div>

                <div class="col-md-2" >
                  <div class="form-group" > 
                  <label class="container1">
                    <input type="checkbox" name="familycode" checked value="familycode"/>
                    <span style="font-size:12px;">Family Code</span> <span class="checkmark"></span>
                  </label>
                  
                  </div>
                </div>

                <div class="col-md-2" >
                  <div class="form-group" > 
                  <label class="container1">
                    <input type="checkbox" name="cnic" checked value="cnic"/>
                    <span style="font-size:12px;">Father CNIC</span> <span class="checkmark"></span>
                  </label>
                  
                  </div>
                </div>

                <div class="col-md-2" >
                  <div class="form-group" > 
                  <label class="container1">
                    <input type="checkbox" name="formBNo" checked value="formBNo"/>
                    <span style="font-size:12px;">B-Form No</span> <span class="checkmark"></span>
                  </label>
                  
                  </div>
                </div>

                <div class="col-md-2" >
                  <div class="form-group" > 
                  <label class="container1">
                    <input type="checkbox" name="stdAddress" checked value="stdAddress"/>
                    <span style="font-size:12px;">Address</span> <span class="checkmark"></span>
                  </label>
                  
                  </div>
                </div>

                
              </tr>
            </div>
            
              </table>


             
            </div>
            <div class="clearfix"></div>
          </div>
        </div>
      </form>
      <div class="clearfix"></div>
    </div>
    <br>
     
          
          <?php  if(isset($_SESSION['error'])){?>

            <div class="alert alert-danger" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Warning!</strong> Result already saved of this class, Please try another one.
            </div>

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

      

          
          <?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="UpdateClassWiseStudent">
  <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 $sessionID; ?>" />
  <input type="hidden" id="section"  name="section" value="<?php echo $_GET['section']; ?>" />

  <input type="hidden" id="selectAdm"  name="selectAdm" value="<?php echo $_GET['adm']; ?>" />
  <input type="hidden" id="selectStdName"  name="selectStdName" value="<?php echo $_GET['stdName']; ?>" />
  <input type="hidden" id="selectFName"  name="selectFName" value="<?php echo $_GET['fName']; ?>" />
  <input type="hidden" id="selectCellno"  name="selectCellno" value="<?php echo $_GET['cellno']; ?>" />
  <input type="hidden" id="selectDob"  name="selectDob" value="<?php echo $_GET['dob']; ?>" />
  <input type="hidden" id="selectLocality"  name="selectLocality" value="<?php echo $_GET['locality']; ?>" />
  <input type="hidden" id="selectGender"  name="selectGender" value="<?php echo $_GET['gender']; ?>" />
  <input type="hidden" id="selectDoa"  name="selectDoa" value="<?php echo $_GET['doa']; ?>" />
  <input type="hidden" id="selectFamilycode"  name="selectFamilycode" value="<?php echo $_GET['familycode']; ?>" />

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

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

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


  
        <div class="col-md-9">
          
           <div id="check_std_msg" style="display:none;" class="alert alert-warning alert-dismissible">
                    <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
                     <strong>Warning !</strong> Please select class to save fee settings !!!
            </div>
    
          <?php  if(isset($_SESSION['error_msg'])){?>

           <div id="error"  class="alert alert-warning alert-dismissible">
                    <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
                     <strong>Warning !</strong> You have already saved the f of this class !!!
            </div>

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

        </div>

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

        <div class="col-md-4 pull-right" style="margin-bottom:1%;">
              <input type="submit" name="submit" class="pull-right btn btn-primary"  value="Update Records"/>

              <a href="update_student_pictures.php?class_id=<?php echo $_REQUEST['class_id'] ?>&section=<?php echo $_REQUEST['section'] ?>&session=<?php echo $_REQUEST['session'] ?>" class="pull-right btn btn-primary">Update Student Pictures</a>
        </div>
      <table data-page-length='100' class="table table-striped table-bordered" style="width:100%">
          
          <thead>
            <tr>
                <th width="3%">S.No</th>
               <!--  <th width="15%">Student Name</th>
                <th width="15%">Last Name</th>
                 -->
                <!-- <th width="10%" style="text-align:center;"> Class </th> -->
                <th width="5%">Roll.No</th>
              
                <?php if (isset($_REQUEST['adm'])) { ?>
                <th width="8%" style="text-align:center;"> Adm No </th>
                <?php } ?>

                <?php if (isset($_REQUEST['stdName'])) { ?>
                <th width="10%" style="text-align:center;"> Student Name </th>
                <?php } ?>

                <?php if (isset($_REQUEST['fName'])) { ?>
                <th width="10%" style="text-align:center;"> Father Name </th>
                <?php } ?>

                <?php if (isset($_REQUEST['cellno'])) { ?>
                <th width="10%" style="text-align:center;"> Cell Number  </th>
                <?php } ?>

                <?php if (isset($_REQUEST['dob'])) { ?>
                <th width="12%" style="text-align:center;"> DOB  </th>
                <?php } ?>
              
                <?php if (isset($_REQUEST['locality'])) { ?>                  
                <th width="12%" style="text-align:center;"> Locality  </th>
                <?php } ?>

                 <?php if (isset($_REQUEST['gender'])) { ?>                  
                <th width="12%" style="text-align:center;"> Gender  </th>
                <?php } ?>

                <?php if (isset($_REQUEST['doa'])) { ?>
                <th width="12%" style="text-align:center;"> DOA  </th>
                <?php } ?>

                <?php if (isset($_REQUEST['familycode'])) { ?>
                <th width="10%" style="text-align:center;"> Family Code  </th>
                <?php } ?>

                <?php if (isset($_REQUEST['cnic'])) { ?>
                <th width="10%" style="text-align:center;"> Father CNIC  </th>
                <?php } ?>

                <?php if (isset($_REQUEST['formBNo'])) { ?>
                <th width="10%" style="text-align:center;"> B-Form No  </th>
                <?php } ?>

                <?php if (isset($_REQUEST['stdAddress'])) { ?>
                <th width="10%" style="text-align:center;"> Address  </th>
                <?php } ?>
  
            </tr>
        </thead>
        <tbody>
   
     
     <?php $count=1;

      foreach($WorkAssignListings as $WorkAssignListVal)
      { 
        
        $m->where("student_id", $WorkAssignListVal['student_id']);
        $fees=$m->get("eduportal_student_fee_structure");

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


        $id=$WorkAssignListVal['student_id'];  

    $show_fee=0;

  if($fees[0]['std_tution_fee']!=""){
    $show_fee=$fees[0]['std_tution_fee'];

  }else {
    $show_fee=$fees1[0]['tution_fee'];
  }

   $misc_fee=0;

  if($fees[0]['std_misc_fee']!=""){
    $misc_fee=$fees[0]['std_misc_fee'];

  }else {
    $misc_fee=$fees1[0]['misc_fee'];
  }

      ?>

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

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

                  <!-- <td style="text-align:center;"> <?php echo getClassName($m,$_GET['class_id']);?> - <?php echo getSectionName($m,$WorkAssignListVal['section_id']);?> </td> -->
                  <!-- <td> <input type="text" name="std_outstanding_blc[]" value="<?php echo $fees[0]['std_outstanding_blc'];?>"> </td> -->
                  <td> <?php echo $WorkAssignListVal['candidate_roll_no'];?> </td>

                  <?php if (isset($_REQUEST['adm'])) { ?>
                  <td><input type="text" style="width:50%;" name="adm_no[]" value="<?php echo $WorkAssignListVal['ref_no'];?>"></td>
                  <?php } ?>

                  <?php if (isset($_REQUEST['stdName'])) { ?>
                  <td><input type="text" name="first_name[]" value="<?php echo $WorkAssignListVal['first_name'];?>"></td>
                  <?php } ?>

                  <?php if (isset($_REQUEST['fName'])) { ?>
                  <td><input type="text" name="last_name[]" value="<?php echo $WorkAssignListVal['last_name'];?>"></td>
                  <?php } ?>

                  <?php if (isset($_REQUEST['cellno'])) { ?>
                  <td> <input style="width: 100px;" type="text" name="cell_no[]"  value="<?php echo $WorkAssignListVal['cell_no'];?>" /> </td>
                  <?php } ?>

                  <?php if (isset($_REQUEST['dob'])) { ?>
                  <td> 
                    <div class="col-md-12 col-sm-12 col-xs-12 " style="padding: 0px 2px 0px 2px;">
                     <div class="form-group ">                       
                            <input class="form-control" type="date" name="dob[]"  id="" value="<?php echo $WorkAssignListVal['dob'];?>">
                     </div>
                   </div>
                  </td>
                  <?php } ?>

                  <?php if (isset($_REQUEST['locality'])) { ?> 
                  <td> 
                    <div class="col-md-12 col-sm-12 col-xs-12 " style="padding: 0px 2px 0px 2px;">
                     <div class="form-group ">                       
                            <select name="locality[]" class="form-control">
                                    <option value="">Choose Locality</option>  
                                <?php
                                $m->where("branch_id", $_SESSION['branch']);
                                $localities = $m->get("eduportal_branch_locality");
                                if(count($localities)>0){
                                foreach($localities as $locality)
                                { ?>
                                   <option <?php if($WorkAssignListVal['locality']==$locality['locality_id']){echo 'selected';}?> value="<?php echo $locality['locality_id']; ?>"><?php echo $locality['locality_name']; ?></option>
                            <?php }  } else { ?>
                                    <option>No Locality</option>
                            <?php    } ?>

                            </select>
                        </div>
                </div>
                </td>
                <?php } ?>

                
                <?php if (isset($_REQUEST['gender'])) { ?> 
                  <td> 
                    <div class="col-md-12 col-sm-12 col-xs-12 " style="padding: 0px 2px 0px 2px;">
                     <div class="form-group ">                       
                            <select name="gender[]" class="form-control">
                                    <option value="">Select Gender </option>
                          <option <?php if($WorkAssignListVal['gender']=="Male"){echo "Selected";} ?> value="Male">Male</option>
                          <option <?php if($WorkAssignListVal['gender']=="Female"){echo "Selected";} ?> value="Female">Female</option> 

                            </select>
                        </div>
                </div>
                </td>
                <?php } ?>


                    <?php if (isset($_REQUEST['doa'])) { ?>
                  <td> 
                    <div class="col-md-12 col-sm-12 col-xs-12 " style="padding: 0px 2px 0px 2px;">
                     <div class="form-group ">                       
                            <input class="form-control" type="date" name="doa[]"  id="" value="<?php echo $WorkAssignListVal['date_of_adms'];?>">
                     </div>
                   </div>
                  </td>
                  <?php } ?>


                  <?php if (isset($_REQUEST['familycode'])) { ?>
                  <td> <input style="width: 100px;" type="text" name="familycode[]"  value="<?php echo $WorkAssignListVal['family_code'];?>" /> </td>
                  <?php } ?>

                  <?php if (isset($_REQUEST['cnic'])) { ?>
                  <td> <input  type="text" name="cnic[]"  value="<?php echo $WorkAssignListVal['cnic'];?>" /> </td>
                  <?php } ?>

                  <?php if (isset($_REQUEST['formBNo'])) { ?>
                  <td> <input  type="text" name="formBNo[]"  value="<?php echo $WorkAssignListVal['formBNo'];?>" /> </td>
                  <?php } ?>

                  <?php if (isset($_REQUEST['stdAddress'])) { ?>
                  <td> <input style="width:100%;"  type="text" name="stdAddress[]"  value="<?php echo $WorkAssignListVal['address'];?>" /> </td>
                  <?php } ?>
                             
                 
              </tr>

              <?php
      } ?>

         
           
        </tbody>
        
    </table>
 
 <?php }  ?>



</form>
</div>
    <br><br>


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

           
          </div>
        </div>

           
          </div>
        </div>
        <!-- /page content -->
  
<!-- jQuery -->
    <script src="js/ajax_functions.js"></script> 
    
  <?php include('RootMe/js_linksscript.php');?>
  </body>
</html>
