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

$m->where("user_id", $_SESSION['user_id']);
$m->where ("branch_id", $_SESSION['branch']);
$m->where("page_id", 52);
$access = $m->get("users_privilege_detail");


if($_REQUEST['id']!='')
{
$m->where("section_id", $_REQUEST['id']);
$UsersWorkAssignList = $m->get("edu_adm_section_detail");

}

 ?>

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


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

<script>
var clr=document.getElementById("deleteLocalStorage").value;
if (clr=="deleteLocalStorage") {
localStorage.clear();
}
</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="row" style="background-color:white;">
 <section class="add_sub_agent" id="table_sub_agent">
  <div class="container">
   <div class="box_visa_form">
    <div class="table-responsive" style="min-height:320px;padding:3%;">


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

        <div class="col-md-3 ">    
         <h3>Manage Sections</h3>


        </div>

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

              <a href="manage_classes.php" class="btn btn-primary" style="color: white;"> Manage Classes </a> 

            </div>

       </div>

      

      <table class="table table-bordered table-hover text-center" style="width:60%;float: left;">
        <thead>
          <tr class="" style="color:#e2333b;">
            <td> Section Name</td>
            <td> Class  </td>
            <td> Created  </td>
            <td> Action</td>
          </tr>
        </thead>
        <tbody>
 <?php

$qr="select sec.* from edu_adm_section_detail as sec,edu_class_config as cls where cls.class_id=sec.class_id and cls.branch_id='".$_SESSION['branch']."' ";

if($_REQUEST['class_id']!='')
{  $qr.=" and cls.class_id='".$_REQUEST['class_id']."' ";
 } 


$WorkAssignList = $m->query($qr);

if($WorkAssignList[0]>0)
{
foreach($WorkAssignList as $WorkAssignListVal)
{
if(is_array($WorkAssignListVal))
{

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

?>             
          <tr>
            <td style="padding:1px;font-size:12px;"><?php echo utf8_decode_all($WorkAssignListVal['section_name']);?></td>
            
            <td style="padding:1px;font-size:12px;"><?php echo utf8_decode_all($sections[0]['Class_Name']);?> </td>
            
            <td style="padding:1px;font-size:12px;"><?php echo date("d-M-Y", strtotime($WorkAssignListVal['creation']));?></td>

            <td style="padding:1px;font-size:12px;">
               <?php if ($access[0]['edit_access']!=NULL) { ?>

            <a  href="manage_sections.php?<?php echo session_id().session_id().session_id();?>&id=<?php echo $WorkAssignListVal['section_id'];?>&class_id=<?php echo $WorkAssignListVal['class_id']; echo "&s=".session_id().session_id();?>" style="cursor:pointer;" style="font-size:12px;padding:0px 5px;"  class="btn btn-success">Edit</a>

            <?php } ?>

            <?php if ($access[0]['delete_access']!=NULL) { ?>

            <a href="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php?id=<?php echo $WorkAssignListVal['section_id'];?>&action=DeleteSection" style="padding: 0px 5px; font-size:14px;" onClick="return confirm('Are you sure you want to delete this record');"  class="btn btn-danger"><i class="fa fa-remove"></i> </a>

          <?php } ?>
          
            </td>

          </tr>
          
            
       <?php 
$i++;
} } } else { ?>

<tr><td colspan="7"><p align="center" style="margin-top:15px; margin-bottom:10px;"><a href="" class="label label-danger" style="padding: 8px;font-size: 15px;">There is no any sections added by you</a></p>
</td></tr>
<?php } ?>   
         
        </tbody>
      </table>
  <div class="addclasswidth">
   <form class="form-style-7" action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post" enctype="multipart/form-data">

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

<input type="hidden" name="action" value="EditSectionDetail">
<input type="hidden" name="eid" value="<?php echo $UsersWorkAssignList[0]['section_id'];?>">
<?php } else { ?>
<input type="hidden" name="action" value="AddSection">
<input type="hidden" name="deleteLocalStorage" value="deleteLocalStorage">
<?php } ?>
      <ul style="list-style-type:none;">
  <div class="col-md-12" style=""> <h3 class="heding_name">Add New Section </h3></div>

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

         <li>

          <label for=""> Select Class </label>
            <select name="class_id" class="select_add inputfield">
              <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($_GET['class_id']==$WorkAssignListVal['class_id']){echo 'selected="selected";';}?> 
         value="<?php echo $WorkAssignListVal['class_id']; ?>"><?php echo $WorkAssignListVal['Class_Name']; ?></option>
      <?php  } ?>



         </select>

        </li>
        
        <li>
          <label for=""> Section Name </label>
          <input type="text" name="name" class="inputfield"   value="<?php echo $UsersWorkAssignList[0]['section_name'];?>" onkeypress='return alpha(event);' onpaste="return false;"  autocomplete="off" required maxlength="100">
        </li>
       
           <div class="clearfix"></div>
        <li class=" pull-left" style="margin-top:30px;">
        
          <input type="submit" value=" Submit " class="btn btn-primary" >
        </li>
      </ul>
    </form>
  </div>


    </div>
      <div class="clearfix"></div>
     </div>
  </div>
  <div class="clearfix"></div>
</section>
<section class="sub_agent_form" id="sub_user_form" style="display:none;">
  <div class="container">
   <div class="box_visa_form">
    
     <div class="clearfix"></div>
     </div>
  </div>
  <div class="clearfix"></div>
</section>            



           
          </div>
        </div>

            </div>
          </div>
        </div>
        <!-- /page content -->
  

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