<!-- ===Datatables=== -->

    <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.js"></script>
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.12.1/css/jquery.dataTables.min.css">

<div class="cmt-page-title-row bg-base-dark cmt-bg cmt-bgimage-yes clearfix">
            <div class="cmt-titlebar-wrapper-bg-layer cmt-bg-layer"></div>
            <div class="container">
                <div class="row align-items-center">
                    <div class="col-lg-12">
                        <div class="cmt-page-title-row-inner">
                            <div class="page-title-heading">
                                <h2 class="title"><?php echo $cat['facultyName'] ; ?></h2>
                            </div>
                            <div class="breadcrumb-wrapper">
                                <span>
                                    <a title="Homepage" href="<?php echo base_url();?>">Home</a>
                                </span>
                                <span><?php echo $cat['facultyName'] ; ?></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>                    
        </div>

	<div class="container">
	
		<div class="table-responsive">
			<table class="ui celled table" id="employee_data">
				<thead>
					<tr>
						<th>No.</th>
						<th>Course Title</th>
						<th>Course Duration</th>
						
						<?php
						 	$session = \Config\Services::session();
							$userId = $session->get('userId');
							if($userId){
                        echo '<th colspan="2">Action</th>';
							}else{
						echo '<th>Course Content & Register</th>';
								}
							?>
					</tr>
				</thead>
				<tbody>
					<?php
					   $i=1;
              foreach($courses as $course ):   ?>
					<tr>
						<td><?php echo $i;?></td>
						<td><a style="color: #00924C" href="../course/<?php echo $course->courseID;?>"><?php echo ucwords(strtolower($course->courseName));?></a></td>
						<td><?php echo $course->duration.' '.$course->typeName;?></td>
							<?php
							if($userId){ ?>
						<td><a class="btn-xs btn-info btn-xs" href="../course/<?php echo $course->courseID;?>" >View Course</a></td>
						<td><a class="btn-xs btn-warning btn-xs" href="../updatecourse/<?php echo $course->courseID;?>" ><i class="fa fa-pencil"></i> Edit </a></td>
						<td><a class="btn-xs btn-danger btn-xs" href="../deletecourse/<?php echo $course->courseID;?>"><i class="fa fa-trash"></i> Delete</a></td>
							<?php

						}else{  ?>
						<td><a class="btn-xs btn-dark btn-sm"  href="../course/<?php echo $course->courseID;?>" ><i class="fa fa-eye"></i> View & Register</a></td>
					<?php
                	}
                	?>
		        </tr>
							<?php
							$i++;
						   endforeach;
							     ?>
					</tbody>
				</table>
		</div>
</div>

<script type="text/javascript" src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>

 <script>
 $(document).ready(function () {
    $('#employee_data').DataTable({
        autoWidth: false,
        columnDefs: [
            {
                targets: ['_all'],
                className: 'mdc-data-table__cell',
            },
        ],
    });
});
</script>


