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

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



<?php



$branch=$_SESSION['branch'];



$classes = $m->query("select * from edu_class_config where branch_id=".$branch." order by class_id asc limit 1");

// print_r($classes);





$session;



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



$session=$_REQUEST['session'];



}else {



$session=$_SESSION['current_session'];

}





/* code for advance Search*/





$sql = "SELECT * FROM  edu_student_details as std, edu_class_config as cls  WHERE std.class_id=cls.class_id and std.branch_id='$branch' and std.status='0' and std.session_id='$session' ";



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



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

$sql;

} else {

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



}



if($_REQUEST['section']!=''){

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

}

if($_REQUEST['orderby']=='classwise'){
$sql .= "order by cls.orderno, std.section_id asc";
} elseif ($_REQUEST['orderby']=='admwise') {
  $sql .= "order by std.ref_no asc";
} else {
  $sql .= "order by cls.orderno, std.section_id asc";
}
//echo $sql;



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

}





?>



<!DOCTYPE html>

<html lang="en">

  <head>

   

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

  



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

  <div class="container">





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



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

    

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

          

      View Biometric ID's List



      <br><br>









      <form class="" action="genrate_student_biomatric_ids.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" />





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

          <div class="panel-body">

          

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





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

                <div class="form-group ">

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

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



                    <!-- <option value="">All</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" onChange="getsec(this.value)" class="form-control" >

                     <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-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-2 col-xs-12" style="padding: 8px;">

                       <div class="form-group ">

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

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

                                 <option <?php if($_GET['orderby']=="class"){echo 'selected';}?> value='classwise'>Class Wise</option>    

                                 <option <?php if($_GET['orderby']=="admwise"){echo 'selected';}?> value='admwise'>Adm Wise</option>                               

                              </select>

                            </div>
                </div>

              

          

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

                <div class="form-group ">

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

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

                </div>

              </div>



             

            </div>

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

          </div>

        </div>

      </form>

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

    </div>

    <br>

  





 



<form action="manage_students.php" enctype="multipart/form-data" method="post">





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

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





<div style="">









<table id="listofstudents" class="table table-striped table-bordered" style="width:100%">



  

   

        <thead>

            <tr>



              

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

                <th width="12%">Student</th>

                <th width="12%">Father</th>

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

                <th width="12%"> Class </th>

               <th width="25%" style="text-align:center">Biomatric ID </th>

          

                                

            </tr>

        </thead>

        <tbody>



     <?php 



      $count=1;

      foreach($WorkAssignListings as $WorkAssignListVal)

      { 



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

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



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

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



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

        $session=$m->get("edu_session_config");





 // coding to generate auto roll number





    $sql = "SELECT MAX(CAST(SUBSTR(std_biometric_id,6,LENGTH(std_biometric_id)) AS UNSIGNED)) AS prev_code



    FROM edu_student_details as std WHERE std.branch_id =  '$branch' /*AND std.status='0'*/ ";  

     //print_r($sql);

      

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

   

    $prev=str_pad($evt[0]['prev_code'], 4, "0", STR_PAD_LEFT);



      $numb;     

      $Bnumb=str_pad($_SESSION['branch'], 4, "0", STR_PAD_LEFT);

      $Autonumb=str_pad($Biometriccount, 3, "0", STR_PAD_LEFT);

       $numb="2".$Bnumb.$Autonumb;



        if($WorkAssignListVal['std_biometric_id']=="" || $WorkAssignListVal['std_biometric_id']=="NULL"){    



          $numb="2".$Bnumb.$prev+1;        



        } else{ $numb+=1;}



//echo $numb;

      $stdsID=$WorkAssignListVal['student_id'];

      $branchID=$_SESSION['branch'];



      if ($WorkAssignListVal['std_biometric_id']=="" || $WorkAssignListVal['std_biometric_id']=="NULL") {        

      

     $query = "UPDATE edu_student_details SET std_biometric_id = '$numb' WHERE student_id = '$stdsID' and branch_id='$branchID'";     

//echo $query;

     $m->query($query);



      $Biometriccount++;



     }

        

      ?>



        <tr>



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



  <td style="padding: 2px;" ><?php echo $WorkAssignListVal['first_name'];?>

                     

  </td>

  <td style="padding: 2px; text-align:left;"> &nbsp; <?php echo $WorkAssignListVal['last_name']; ?> </td>

  <td style="padding: 2px; text-align: center;"> <?php echo $WorkAssignListVal['ref_no']; ?> / <?php echo $WorkAssignListVal['candidate_roll_no']; ?> </td>

       

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

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

      

              



    <td style="text-align:center; font-size:14px;">

      

      <?php echo $WorkAssignListVal['std_biometric_id'];?>



    </td>



  



  </tr> <?php   } ?>

 

        </tbody>

        

    </table>



  </div>



    </form>



    <br><br>





  </div>

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

</section>



        </div> 

        </div>





            </div>

          </div>

        </div>





     

        <!-- /page content -->





 <!-- jQuery -->

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

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

  <!-- Links for Datatable-->



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

 <script>

        

  $(document).ready(function() {

    $('#listofstudents').DataTable({

      "pageLength": 100

    });

    } 

  );





</script>

  

  </body>

</html>

