<?= $this->extend("templates/hod_base"); ?>

<?= $this->section("content"); ?>
                <?php $page_session = \Config\Services::session(); $pg='vca';?>
<!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h4>Level Coordinators</h4>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="<?= base_url()?>/hod/dashboard">Dashboard</a></li>
              <li class="breadcrumb-item active">Level Coordinators</li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid"> <?php

              if($page_session->getTempdata('saveSuccess')):       
                                ?>
                                <div class = "alert alert-success alert-dismissible">
                                  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                                     <?= $page_session->getTempdata('saveSuccess'); ?>
                                </div>
                                <?php 
                                endif;
                                ?>
              
                              <?php
              
                              if($page_session->getTempdata('saveError')):       
                              ?>
                              <div class = "alert alert-danger alert-dismissible">
                                  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                                  <?= $page_session->getTempdata('saveError'); ?>
                              </div>
                              <?php 
                              endif;
                              ?> 
        <div class="row">
            <div class="col-12">
            <div class="card">
              <div class="card-header">
                <div class="row">
                  <div class="col-12">
                    <div id="accordion">
                      <button class="btn btn-primary btn-sm pull-right" id="add_lc" name="add_lc" data-toggle="collapse" href="#addLC"><i class="fa fa-plus"></i>  Assign Level Coordinator</button>
                      <div id="addLC" class="collapse" data-parent="#accordion">
                        <hr/>
                        <span class="badge badge-danger">Default Level Coordinator password is 123456</span>
                        <form method="POST" action="<?= base_url('hod/level_coordinators_action') ?>" id="lc_form">
                          <input type="hidden" name="action" value="add"/>
                          <div class="row">
                            <div class="col-md-3">
                              <div class="form-group">
                                <label>Session Started:</label>
                                <select name="session" id="session" class="form-control select2" required>
                                  <option value="" disabled selected>Select Session</option> 
                                  <option <?php if($page_session->get('current_session')=='2017/2018') echo 'selected'; ?> value = "2017/2018">2017/2018</option>
                                   <option <?php if($page_session->get('current_session')=='2018/2019') echo 'selected'; ?> value = "2018/2019">2018/2019</option>
                                   <option <?php if($page_session->get('current_session')=='2019/2020') echo 'selected'; ?> value = "2019/2020">2019/2020</option>
                                  <option <?php if($page_session->get('current_session')=='2020/2021') echo 'selected'; ?> value = "2020/2021">2020/2021</option>
                                 
                                  <option <?php if($page_session->get('current_session')=='2022/2023') echo 'selected'; ?> value = "2022/2023">2022/2023</option>
                                  <option <?php if($page_session->get('current_session')=='2023/2024') echo 'selected'; ?> value = "2023/2024">2023/2024</option>
                                  <option <?php if($page_session->get('current_session')=='2024/2025') echo 'selected'; ?> value = "2024/2025">2024/2025</option>
                                  <option <?php if($page_session->get('current_session')=='2025/2026') echo 'selected'; ?> value = "2025/2026">2025/2026</option>
                                  <option <?php if($page_session->get('current_session')=='2026/2027') echo 'selected'; ?> value = "2026/2027">2026/2027</option>
                                  <option <?php if($page_session->get('current_session')=='2027/2028') echo 'selected'; ?> value = "2027/2028">2027/2028</option>
                                  <option <?php if($page_session->get('current_session')=='2028/2029') echo 'selected'; ?> value = "2028/2029">2028/2029</option>
                                  <option <?php if($page_session->get('current_session')=='2029/2030') echo 'selected'; ?> value = "2029/2030">2029/2030</option>
                                  <option <?php if($page_session->get('current_session')=='2030/2031') echo 'selected'; ?> value = "2030/2031">2030/2031</option>
                                  <option <?php if($page_session->get('current_session')=='2031/2032') echo 'selected'; ?> value = "2031/2032">2031/2032</option>
                                  <option <?php if($page_session->get('current_session')=='2032/2033') echo 'selected'; ?> value = "2032/2033">2032/2033</option>
                                  <option <?php if($page_session->get('current_session')=='2033/2034') echo 'selected'; ?> value = "2033/2034">2033/2034</option>
                                  <option <?php if($page_session->get('current_session')=='2034/2035') echo 'selected'; ?> value = "2034/2035">2034/2035</option>
                                  <option <?php if($page_session->get('current_session')=='2035/2036') echo 'selected'; ?> value = "2035/2036">2035/2036</option>
                                </select>
                              </div>
                            </div>
                            <div class="col-md-3">
                              <div class="form-group">
                                <label>Staff</label>
                                <select name="staff" id="staff" class="form-control select2" required>
                                  <option value="" disabled selected>Select Staff</option>
                                  <?php foreach($staff as $st): ?>
                                  <option value='<?= $st->id ?>'><?= $st->name ?></option>
                                  <?php endforeach; ?>
                                </select>
                              </div>
                            </div>
                            <div class="col-md-3">
                              <!-- <div id = "checkBoxesArea"></div> -->
                              <div class="form-group">
                                <label>Level</label>
                                <div class="select2-primary">
                                <select name="level" id="level" data-placeholder="Select Level" class="form-control select2" required>
                                  <option value='' disabled selected>Select Level</option>
                                  <option value='100'>100</option>
                                  <option value='200'>200</option>
                                  <option value='300'>300</option>
                                  <option value='400'>400</option>
                                  <option value='SO1'>SO I</option>
                                  <option value='SO2'>SO II</option>
                                </select>
                                </div>
                              </div>
                            </div>
                            <div class="col-md-3">
                              <!-- <div id = "checkBoxesArea"></div> -->
                              <div class="form-group">
                                <label>Programme</label>
                                <div class="select2-primary">
                                <select name="programme" id="programme" data-placeholder="Select Programme" class="form-control select2" required>
                                  <?php foreach($programmes as $prog): ?>
                                  <option value='<?= $prog->id ?>'><?= $prog->title ?></option>
                                  <?php endforeach; ?>
                                </select>
                                </div>
                              </div>
                            </div>
                          </div>
                          <div class="row" align="right">
                            <div class="col-12">
                              <input type="submit" name="submit" id="submit_button" value="Submit" class="btn btn-primary pull-right">
                            </div>
                          </div>
                        </form>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <!-- /.card-header -->
              <div class="card-body">
                <div class="table-responsive">
                  <table id="eo_tbl" class="table table-bordered table-hover table-striped medium" cellspacing="0" width="100%">
                    <thead>
                        <tr>
                          <th>#</th>
                          <th>Staff Name</th>
                          <th>Email</th>
                          <th>Programme(s)</th>
                          <th>Current Level</th>
                          <th>Session Started</th>
                          <th>Created On</th>
                          <th class="text-center">Action</th>
                        </tr>
                    </thead>
                    <tbody>
                      <?php 
                      if(is_array($lcs)){
                        $i=1;
                        foreach($lcs as $lc):
                       ?>
                        <tr>
                          <td><?= $i++?></td>
                          <td><?= $lc->name?></td>
                          <td><?= $lc->email?></td>
                          <td>
                            <ul>
                            <?php
                              /*$program = explode(',',$lc->programme_id);
                              foreach($program as $prog){*/
                                $pdetail = $model->get_program_details($lc->programme_id);
                            ?>
                                <li><?=$pdetail[0]->title?></li>
                            <?php
                              //}
                            ?>
                              </ul>
                          </td>
                          <td class="text-center"><?= $lc->current_level?></td>
                          <td><?= $lc->session_started?></td>
                          <td><?= date('h:i a - d M, Y', strtotime($lc->created_at))?></td>
                          <td class="text-center"><button class="btn btn-danger btn-xs delete_btn2" data-id="<?= $lc->id?>"><i class="fas fa-trash"></i></button></td>
                        </tr>
                      <?php endforeach; 
                      }
                      ?>
                    </tbody>
                  </table>
                </div>
              </div>
              <!-- /.card-body -->
            </div>
            <!-- /.card -->
            </div>
        </div>

        </div><!-- /.container-fluid -->
    </section>
<!-- /.content -->
</div>

<?= $this->endSection(); ?>