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

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



 $m->query ('ALTER TABLE edu_class_config ADD COLUMN orderno INT(11)');


 $pageName = basename($_SERVER['PHP_SELF']);



 $m->where("page_name", $pageName);

 $pageNameAccess=$m->get("eduportal_modules_pages_detail");



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

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

$m->where("page_id", $pageNameAccess[0]['page_id']);

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





$pageName=basename($_SERVER['PHP_SELF']);



 $m->where("page_name", $pageName);

 $video = $m->get("eduportal_modules_pages_detail");



 //echo $video[0]['video_url'];





 // ============= delete class script ============= 



    if(isset($_GET['delete_class'])){



  

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

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

      $class_data =  $m->get ('edu_class_config', $data);

  

     


        $data = array(



      'class_id' => $class_data[0]['class_id'],

      'Class_Name' => $class_data[0]['Class_Name'],

      'branch_id' => $_SESSION['branch'],

      'active_inactive' => $class_data[0]['active_inactive'],

      'creation' => $class_data[0]['creation'],

      'class_code' => $class_data[0]['class_code']

    );



      $m->insert('edu_class_config_deleted_backup',$data);



      // after insertion as backup now delete the record



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

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

      $m->delete('edu_class_config');





      $data = array(



    'status' => 1,



    'expel_date' => date("Y-m-d"),



    'expel_reason' => "Class Deleted",



    );



     //print_r($data);



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



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



    $result =  $m->update ('edu_student_details', $data);





      header("location:manage_classes.php?".session_id().session_id().session_id()."&deleteLocalStorage=deleteLocalStorage");



  }





 ?>



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



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

              Manage Classes

                  <br><br>

        

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

    <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%;">





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

  

  <a href="watch_video.php?videourl=<?php echo $video[0]['video_url'];?>" target="_blank" class="btn btn-success" style="padding: 5px 5px; font-size:14px;color:white;float: right;">Watch Video</a>



<?php } ?> 

   

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

       

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

             <h3>Manage Classes</h3>





            </div>



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



              <a href="manage_sections.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&page=<?php echo $pageNameAccess[0]['page_id'];?>" class="btn btn-primary" style="color: white;"> Manage Sections </a> 



            </div>



       </div>







      <table class="table table-bordered table-hover text-center" style="width: 60%;float: left;">

        <thead>

          <tr class="" style="color:#e2333b;">

            <td>Class Name</td>

            <td> Sections  </td>

            <td> Monthly Fee  </td>

            <td> Adm Fee  </td>

            <td> Order No  </td>

            <td> Action</td>

          </tr>

        </thead>

        <tbody>

 <?php

$branch=$_SESSION['branch'];

$WorkAssignList = $m->query("select * from edu_class_config where branch_id='$branch' order by orderno asc");



if($WorkAssignList[0]>0)

{

foreach($WorkAssignList as $WorkAssignListVal)

{

if(is_array($WorkAssignListVal))

{



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

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





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

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

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

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



  //print_r($details);



?>             

          <tr>

            <td style="padding:1px;font-size:12px;"><?php echo utf8_decode_all($WorkAssignListVal['Class_Name']);?></td>

           

            <td style="padding:1px;font-size:12px;">  <a href="manage_sections.php?class_id=<?php echo $WorkAssignListVal['class_id'];?>"> View Sections (<?php echo count($sections);?>)</a></td>

            

            

            <td style="padding:1px;font-size:12px;"><?php echo utf8_decode_all($details[0]['tution_fee']);?> </td>

            <td style="padding:1px;font-size:12px;"><?php echo utf8_decode_all($details[0]['admission_fee']);?> </td>                       



            <td style="padding:1px;font-size:12px;"><?php echo $WorkAssignListVal['orderno'];?></td>



            <td style="padding:1px;font-size:12px;">



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



            <a  href="manage_classes.php?<?php echo session_id().session_id().session_id().session_id().session_id();?>&id=<?php echo $WorkAssignListVal['class_id'];?>&fee=<?php echo $details[0]['tution_fee'];?>" style="cursor:pointer;"  class="btn btn-success">Edit</a>



            <a onclick="return confirm('Are you sure you want to delete this record? it will also delete all students with this particular class...!');"  href="manage_classes.php?<?php echo session_id().session_id().session_id().session_id().session_id();?>&cid=<?php echo $WorkAssignListVal['class_id'];?>&deleteLocalStorage=deleteLocalStorage&delete_class=1" style="cursor:pointer;"  class="btn btn-danger">Delete</a>

            

          <?php } ?>



        

            </td>



          </tr>

             

             

       <?php 

$i++;

} } } else { ?>



<tr><td colspan="9" ><p style="margin-top:15px; margin-bottom:10px;"><a href="" class="label label-danger" style="padding: 8px;font-size:15px;">There is no any class added by you</a></p>

</td></tr>

<?php } ?>   

         

        </tbody>

      </table>

      <div class="addclasswidth">

        <?php include('add_class.php'); ?>



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



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

  

  </body>

</html>

