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

<?= $this->section("content"); ?>
<?php $page_session = \Config\Services::session(); ?>

<!-- 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">
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="<?= base_url()?>/lecturer/dashboard">Dashboard</a></li>
              <li class="breadcrumb-item active">Courses</li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">  
        <div class="row">
            <div class="col-12 table-responsive">
            <div class="card">
              <!-- /.card-header -->
              <div class="card-header">
                <h3 class="card-title"><b><i class="fa fa-users"></i> All Courses</b></h3>
                <hr/>
                <?php echo form_open('hod/view_courses', ['method' => 'GET', 'autocomplete' => 'off']); ?> 
                <div class="row">
                    <div class="col-6">
                        <div class="form-group">
                            <label>Semester:</label>
                            <select name="semester" id="semester" class="form-control select2" onchange="$(this).parents('form').submit();" required>
                                <option value="" disabled selected>Select Semester</option>
                                <option <?=$semester=='1st'? 'selected' : ''?> value='1st'>1st</option>
                                <option <?=$semester=='2nd'? 'selected' : ''?> value='2nd'>2nd</option>
                            </select>
                      </div>
                    </div>
                    <div class="col-6">
                      <div class="form-group" style="margin-top: 25px;">
                        <a href="<?php echo base_url('hod/view_courses') ?>" class="btn btn-danger"><?php echo lang('reset') ?></a>
                      </div>
                    </div>
                </div>
                <?php echo form_close(); ?>
              </div>
              <div class="card-body">
              	<table id="example1" class="table table-bordered table-hover table-striped" >
                	<thead>
                    	<tr>
	                        <th>S/N</th>
							<th>Course Code</th>
							<th>Title</th>
							<th>Semester</th>
							<th>Credits Unit</th>
							<th>Level</th>                       
						</tr>
	                </thead>
                    <tbody>
						<?php 
						$i = 0;	
                        if(!empty($result)): 
                  		foreach($result as $res): ?>
                    
	                    <tr>
							<td><?= $i = $i + 1; ?></td>                     
							<td><?= $res->id?></td>
							<td><?= $res->title?></td>
							<td><?= $res->semester ?></td>
							<td><?= $res->credit_unit ?></td>
							<td><?= $res->level?></td>
                    
                       </tr>
                      
                       <?php endforeach;
                        endif; ?>

                    </tbody>
              	</table>
              </div>
              <!-- /.card-body -->
            </div>
            <!-- /.card -->
            </div>
        </div>

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

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