<?php include("includes/config.php"); ?>
<?php include("includes/sessioncheck.php"); ?>
<?php   



 if($_REQUEST['id']!=NULL){
   $db->where("category_id", $_REQUEST['id']);
   $categories = $db->get("eduportal_expanse_category");
}
  
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    

    <title>Add Category | AdminPanal </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="">
            
            <div class="page-title">
              <div class="title_left">
                <h3>Add New Category</h3>
              </div>
            </div>
          
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                 
                  <div class="x_content">

                    <form action="<?php echo DOMAIN.AdminDirectory; ?>includes/InsertMe.php" method="post" enctype="multipart/form-data" class="form-horizontal form-label-left" novalidate>

<?php 

//print_r($db);
 if($_REQUEST['id']!=NULL){

?>                      

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

<?php } else { ?>                      


                      <input type="hidden" name="action" value="add_category" />

<?php } ?>                      
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Add Category <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="category" class="form-control col-md-7 col-xs-12" name="category" value="<?php echo $categories[0]['category_name']; ?>" placeholder="e.g Rise School" required="required" type="text"> 
                        </div>
                      </div>
                    
                      <div class="ln_solid"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-md-offset-3">
                          
                          <button id="send" type="submit" class="btn btn-success">Submit</button>
                          <button type="submit" class="btn btn-primary">Cancel</button>

                        </div>
                      </div>


                    
                    </form>
                  </div>
                 </div>
<?php
   $db->where("status",'0');
   $db->orderBy("category_id","desc");
   $categories2 = $db->get("eduportal_expanse_category");
   ?>
                        <div class="page-title">
                          <div class="title_left">
                            <h3>View Categories</h3>
                          </div>
                        </div>
                          <div class="clearfix"></div>

<div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                        <ul class="dropdown-menu" role="menu">
                          <li><a href="#">Settings 1</a>
                          </li>
                          <li><a href="#">Settings 2</a>
                          </li>
                        </ul>
                      </li>
                      <li><a class="close-link"><i class="fa fa-close"></i></a>
                      </li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    
                    <table id="datatable" class="table table-striped table-bordered">
                      <thead>
                        <tr>
                          <th>S.No</th>
                          <th>Category Name</th>
                          <th>Action</th>
                          
                        </tr>
                      </thead>
                      <tbody>

                        
<?php  $count=1;
$date= date("Y-m-d");

foreach($categories2 as $category){



?>
                        <tr>
                          <td style="text-align:center;"><?php echo $count; $count++;?></td>
                          <td><?php echo $category['category_name'];?></td>
                         
                         
                          

                          <td>

                              <div class="btn-group">
                                        <button data-toggle="dropdown" class="btn btn-primary dropdown-toggle btn-sm" type="button" aria-expanded="true">Action <span class="caret"></span>
                                        </button>
                                        <ul role="menu" class="dropdown-menu">
                                          
                                          <li><a href="categories.php?<?php echo session_id().session_id().session_id();?>&id=<?php echo $category['category_id'] ;?>">Edit</a></li>
                                          <li><a onClick="return confirm('Are you sure you want to delete this Category parmanently?')" href="<?php echo DOMAIN.AdminDirectory; ?>includes/InsertMe.php?action=DeleteCategory&id=<?php echo $category['category_id'];?>">Delete</a></li> 
                                          
                                        </ul>
                               </div>
                          </td>

                        </tr>
<?php } ?>
                      

                      </tbody>
                    </table>
                  </div>
                </div>
              </div>

            
             
            </div>






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

  <?php include('includes/footer.php');?>


  </div>
    </div>

    <!-- jQuery -->
    <script src="../vendors/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <script src="../vendors/fastclick/lib/fastclick.js"></script>
    <!-- NProgress -->
    <script src="../vendors/nprogress/nprogress.js"></script>
    <!-- validator -->
    <script src="../vendors/validator/validator.js"></script>

    <!-- Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>
  
  </body>
</html>