<?php defined('BASEPATH') OR exit('No direct script access allowed');
$pagehead   = "New Class Form"; ?>
<!doctype html>
<html lang="en">
<head>
  <?php $this->load->view('admin/includes/header-script')?>
  <title><?=TITLE?></title>
</head>
<body class="pushmenu-push pushmenu-push-toright">
  <?php $this->load->view('admin/includes/left-menu')?> 
  <?php $this->load->view('admin/includes/header')?>
  <section class="admin-content">
   <div class="container">
    <h2><?=$pagehead?></h2>
    <?php
    $success_msg= $this->session->flashdata('success_msg');
    $error_msg= $this->session->flashdata('error_msg');
    if($success_msg) { ?>
     <div class="alert alert-success">
       <?php echo $success_msg; ?>
       <a href="#" class="close" data-dismiss="alert" aria-label="close" >×</a>
     </div>
   <?php } if($error_msg){ ?>
     <div class="alert alert-danger">
      <a href="#" class="close" data-dismiss="alert" aria-label="close" >×</a>
      <?php echo $error_msg; ?>
    </div>
  <?php } ?>
  <div class="class-form d-flex">
   <div class="col-lg-7 col-md-12">
    <h3 class="general-h3">General Information</h3>
    <div class="general">
     <?php echo form_open('admin/class-manage'); ?>
     <div class="form-group d-flex">
      <div class="col-sm-6 d-flex no-pad ">
       <label for="">Class&nbspName</label>
       <select name="class_id" id="target1" style="margin-right: 10px;" required>
         <option value="">Select Class</option>
         <?php foreach ($class_name as $value)
         {
          $selected = '';
          if($value['class_id'] == $class_id)
          {
           $selected = 'selected';
         } ?>
         <option <?=$selected?> value="<?=$value['class_id']?>"><?=$value['class_name']?></option>
       <?php } ?>
     </select>
   </div>
   <div class="col-sm-6 d-flex no-pad">
     <label for="">Total&nbspSeats</label>
     <input type="text" name="class_seats" value="<?=isset($class_seats)? $class_seats : ''?>" class="general-input" placeholder="No Of Seats" required>
   </div>
 </div>
 <div class="form-group d-flex">
  <div class="col-sm-6 d-flex no-pad ">
   <label for="">Instructor:</label>
   <select name="instr_id" id="target2" style="margin-right: 10px;" required>
    <option value="">Select Instructor</option>
    <?php foreach ($class_instructor as $value)
    {
      $selected = '';
      if($value['instr_name'] == $instr_name)
      {
       $selected = 'selected';
     } ?>
     <option <?=$selected?> value="<?=$value['instr_id']?>"><?=$value['instr_name']?></option>
   <?php } ?>
 </select>
</div>
<div class="col-sm-6 d-flex no-pad">
 <label for="">Hours:</label>
 <input type="text" name="class_hours" value="<?=isset($class_hours)? $class_hours : ''?>" class="general-input" placeholder="Class Hours" required>
</div>
<div class="col-sm-6 d-flex no-pad ">
</div>
</div>
<h3 class="general-h3">Eligible Registrants</h3>
<div class="form-group d-flex">
  <div class="col-sm-6 d-flex no-pad">
   <span class="chk-abc"><input type="checkbox" value="M" <?php if(isset($class_registrants)) { if(in_array('M', $class_registrants)) { echo "checked"; } } ?> name="class_registrants[]" id="start"  class="chk-date1"><label for="start"></label>Members / Alumni</span>
 </div>
 <div class="col-sm-6 d-flex no-pad ">
   <label for="">Price:</label>
   <input type="text" name="class_price_m" value="<?=isset($class_price_m)? $class_price_m : ''?>" class="general-input" placeholder="Price">
 </div>
</div>
<div class="form-group d-flex">
  <div class="col-sm-6 d-flex no-pad">
   <span class="chk-abc"><input type="checkbox" value="M2" <?php if(isset($class_registrants)) { if(in_array('M2', $class_registrants)) { echo "checked"; } } ?> name="class_registrants[]" id="start1"  class="chk-date1"><label for="start1"></label>Members / Alumni 2+</span>
 </div>
 <div class="col-sm-6 d-flex no-pad ">
   <label for="">Price:</label>
   <input type="text" name="class_price_m2" value="<?=isset($class_price_m2)? $class_price_m2 : ''?>" class="general-input" placeholder="Price">
 </div>
</div>
<div class="form-group d-flex">
  <div class="col-sm-6 d-flex no-pad">
   <span class="chk-abc"> <input type="checkbox" id="start2" value="N" <?php if(isset($class_registrants)) { if(in_array('N', $class_registrants)) { echo "checked"; } } ?> name="class_registrants[]" class="chk-date2"><label for="start2"></label>Non-Member</span>
 </div>
 <div class="col-sm-6 d-flex no-pad ">
   <label for="">Price:</label>
   <input type="text" name="class_price_n" value="<?=isset($class_price_n)? $class_price_n : ''?>" class="general-input" placeholder="Price">
 </div>
</div>
<div class="form-group d-flex">
  <div class="col-sm-6 d-flex no-pad">
   <span class="chk-abc"> <input type="checkbox" id="start3" value="N2" <?php if(isset($class_registrants)) { if(in_array('N2', $class_registrants)) { echo "checked"; } } ?> name="class_registrants[]" class="chk-date2"><label for="start3"></label>Non-Member 2+</span>
 </div>
 <div class="col-sm-6 d-flex no-pad ">
   <label for="">Price:</label>
   <input type="text" name="class_price_n2" value="<?=isset($class_price_n2)? $class_price_n2 : ''?>" class="general-input" placeholder="Price">
 </div>
</div>
<div class="form-group d-flex">
  <div class="col-sm-6 d-flex no-pad">
   <span class="chk-abc"><input type="checkbox" id="start4" value="S" <?php if(isset($class_registrants)) { if(in_array('S', $class_registrants)) { echo "checked"; } } ?> name="class_registrants[]" class="chk-date3"><label for="start4"></label>SE</span>
 </div>
 <div class="col-sm-6 d-flex no-pad ">
   <label for="">Price:</label>
   <input type="text" name="class_price_s" value="<?=isset($class_price_s)? $class_price_s : ''?>" class="general-input" placeholder="Price">
 </div>
</div>
<div class="date-time" id="expand1">
  <h3 class="general-h3">Date and Time</h3>
  <div class="form-group d-flex">
    <span class="chk-abc"> <input type="checkbox" <?php if(isset($class_day)) { if(in_array("Mon", $class_day)) { echo "checked"; } } ?> name="class_day[]" value="Mon" id="d1" ><label for="d1"></label>Monday</span>
    <span class="chk-abc"> <input type="checkbox" <?php if(isset($class_day)) { if(in_array("Tue", $class_day)) { echo "checked"; } } ?> name="class_day[]" value="Tue" id="d2" ><label for="d2"></label>Tuesday</span>
    <span class="chk-abc"> <input type="checkbox" <?php if(isset($class_day)) { if(in_array("Wed", $class_day)) { echo "checked"; } } ?> name="class_day[]" value="Wed" id="d3" ><label for="d3"></label>Wednesday</span>
    <span class="chk-abc"> <input type="checkbox" <?php if(isset($class_day)) { if(in_array("Thu", $class_day)) { echo "checked"; } } ?> name="class_day[]" value="Thu" id="d4" ><label for="d4"></label>Thursday</span>
    <span class="chk-abc"> <input type="checkbox" <?php if(isset($class_day)) { if(in_array("Fri", $class_day)) { echo "checked"; } } ?> name="class_day[]" value="Fri" id="d5" ><label for="d5"></label>Friday</span>
  </div>
  <div class="form-group d-flex">
   <div class="col-sm-6 d-flex no-pad ">
    <label for="">Start&nbspDate:</label>
    <input type="text" name="calss_start_date" value="<?=isset($calss_start_date)? $calss_start_date : ''?>" class="general-input datepicker" placeholder="Start Date">
  </div>
  <div class="col-sm-6 d-flex no-pad ">
    &nbsp<label for="">End&nbspDate:</label>
    <input type="text" name="calss_end_date" value="<?=isset($calss_end_date)? $calss_end_date : ''?>" class="general-input datepicker" placeholder="End Date">
  </div>
</div>
<div class="form-group d-flex">
 <div class="col-sm-6 d-flex no-pad ">
  <label for="">Start&nbspTime:</label>
  <input type="text" name="calss_start_time" value="<?=isset($calss_start_time)? $calss_start_time : ''?>" class="general-input m-10 timepicker" placeholder="Start Time">
</div>
<div class="col-sm-6 d-flex no-pad ">
  <label for="">End&nbspTime:</label>
  <input type="text" name="calss_end_time" value="<?=isset($calss_end_time)? $calss_end_time : ''?>" class="general-input timepicker" placeholder="End Time">
</div>
</div>
</div>
<h3 class="general-h3">Location</h3>
<div class="form-group d-flex">
  <div class="col-sm-6 d-flex no-pad ">
    <label for="">Location:</label>
    <select name="locat_id" style="margin-right: 10px;" id="target3" required>
      <option value="">Select Location</option>
      <?php foreach ($class_location as $value)
      {
        $selected = '';
        if($value['locat_id'] == $locat_id)
        {
         $selected = 'selected';
       } ?>
       <option <?=$selected?> value="<?=$value['locat_id']?>"><?=$value['locat_name']?></option>
     <?php } ?>
   </select>
 </div>
 <div class="col-sm-6 d-flex no-pad ">
   <label for="">Room:</label>
   <input type="text" name="class_room" value="<?=isset($class_room)? $class_room : ''?>" class="general-input" placeholder="Room" required>
 </div>
</div>
<div class="form-group d-flex">
  <div class="col-sm-6 d-flex no-pad ">
   <label for="">Physical&nbspAddress:</label>
   <input type="text" name="class_address" value="<?=isset($class_address)? $class_address : ''?>" class="general-input m-10" placeholder="Address" required>
 </div>
 <div class="col-sm-6 d-flex no-pad ">
   <label for="">City:</label>
   &nbsp<input type="text" name="class_city" value="<?=isset($class_city)? $class_city : ''?>" class="general-input" placeholder="City" required>
 </div>
</div>
<div class="form-group d-flex">
  <div class="col-sm-6 d-flex no-pad ">
    <label for="">State:</label>
    <input type="text" name="class_state" value="<?=isset($class_state)? $class_state : ''?>" class="general-input m-10" placeholder="State" required>
  </div>
  <div class="col-sm-6 d-flex no-pad ">
   <label for="">Zip&nbspCode:</label>
   <input type="text" name="class_code" value="<?=isset($class_code)? $class_code : ''?>" class="general-input" placeholder="Zip Code" required>
 </div>
</div>
<div class="form-group d-flex">
  <div class="col-sm-6 d-flex no-pad ">
   <label for="">Phone&nbspNumber:</label>
   <input type="text" name="class_phone" value="<?=isset($class_phone)? $class_phone : ''?>" class="general-input m-10 yourphone" placeholder="Phone Number" required>
 </div>
 <div class="col-sm-6 d-flex no-pad ">    
 </div>
</div>
<h3 class="general-h3">Class Description</h3>
<textarea class="form-control" name="class_description" rows="5" id="comment"><?=isset($class_description)? $class_description : ''?></textarea>
<div class="submit-class d-flex"> 
  <?php if(isset($form_id)) { ?>
    <div class="col6">
      <input type="hidden" name="form_id" value="<?=isset($form_id)? $form_id : ''?>">  
      <input type="submit" name="submit" value="Update" style="cursor: pointer;" class="submit">
    </div>
    <div class="col6">
      <a href="<?= base_url();?>admin/create-class"><input type="button" value="Cancel" style="cursor: pointer;" class="reset"></a>
    </div>
  <?php } else { ?>
    <div class="col6">
      <input type="submit" name="submit" value="Add" style="cursor: pointer;" class="submit">
    </div>
    <div class="col6">
     <input type="reset" value="Reset" style="cursor: pointer;" class="reset">
   </div>
 <?php } ?>
</div>
<?php echo form_close(); ?>
</div>
</div>
<div class="col-lg-5 col-md-12 class-table">
  <h3 class="general-h3">List of Classes</h3>
  <?php echo form_open('admin/Createclass/delete_form'); ?>
  <select onChange="this.form.submit()" name="action" class="duplicate-sl" id="target4">
   <option value="">Action</option>
   <option value="duplicate">Duplicate Record</option>
   <option value="delete">Delete Record</option>
 </select>
 <table class="table">
   <thead>
    <tr>
     <th><span class="chk-abc"><input type="checkbox" name="chk" class="selectall" id="tb7"><label for="tb7"></label></span></th>
     <th>Form Id</th>
     <th>Created</th>
     <th>Class Name</th>
     <th>Edit</th>
     <th>Delete</th>
   </tr>
 </thead>
 <tbody>
  <?php foreach($all_class as $val) { ?>
    <tr>
      <td><span class="chk-abc"><input name="check_id[]" type="checkbox" value="<?=$val['form_id']?>" class="case" id="<?=$val['form_id']?>"><label for="<?=$val['form_id']?>"></label></span></td>
      <td><?=$val['form_id']?></td>
      <td><?=date("d-m-Y",strtotime($val['form_createddate']))?></td>
      <td><?=$val['class_name']?></td>
      <td><a href="<?=base_url();?>admin/create-class-edit/<?=$val['form_id']?>" title="Edit"><img src="<?=base_url();?>assets/admin/img/edit.png" alt=""><a></td>
       <td><a href="<?=base_url();?>admin/create-class-delete/<?=$val['form_id']?>" onclick="return confirm('Are you sure want to Delete?')" title="Delete"><img src="<?=base_url();?>assets/admin/img/delete.png" alt=""><a></td>
       </tr>
     <?php } ?>
   </tbody>
 </table>
 <?php echo form_close(); ?>
</div>
</div>

</section>
<!-- Optional JavaScript -->
<?php $this->load->view('admin/includes/footer-script')?>
<script language="JavaScript">
 $(document).ready(function(){
   $('.selectall').on('click',function(){
     if(this.checked){
       $('.case').each(function(){
         this.checked = true;
       });
     }else{
      $('.case').each(function(){
       this.checked = false;
     });
    }
  });

   $('.case').on('click',function(){
     if($('.case:checked').length == $('.case').length){
       $('.selectall').prop('checked',true);
     }else{
       $('.selectall').prop('checked',false);
     }
   });
 });
</script>
</body>
</html>