<?php 
$tid=$this->uri->segment(3);
$staff_name='';
$staff_data=$this->EContentModel->staff_data($tid);
if($staff_data){
foreach($staff_data as $staff){
$staff_name= $staff['name'];
}
}
?>
<div class="container mt-3 mb-3">
<div class="row">
<div class="col-sm-12">
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="<?php echo base_url();?>Welcome">Home</a>
</li>
<li class="breadcrumb-item"><a href="<?php echo base_url();?>ContentManagement">E-Content</a></li>
<li class="breadcrumb-item"><?php echo $staff_name; ?></li>
</ul>


<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>#</th>    
<th>Subjects</th>
<th>Class-Sec</th>
<th>Chapters / Content</th>
<th>Last Updated</th>
<th>View</th>
</tr>  
</thead>
<tbody>
<?php
$count=0;
// $all_teacheing_staff = $this->EContentModel->get_teaching_staff();
// if($all_teacheing_staff){
// foreach($all_teacheing_staff as $teacheing_staff){
// $count=$count + 1;    
$subject_count=0;

// $tid= $teacheing_staff['id'];
$get_subjects = $this->EContentModel->get_teachers_subjects($tid);
if($get_subjects){
foreach($get_subjects as $subjects){
$subject_count = $subject_count + 1;    
$content_count=0;
$last_updated=$subjects['cat'];
$subject_id=$subjects['id'];

$all_chapters=$this->EContentModel->all_chapters($subject_id,$tid);
$chpater_count=0;
if($all_chapters){
foreach($all_chapters as $chapters){
$chpater_count = $chpater_count + 1;    
}
}

$teachers_content=$this->EContentModel->get_teachers_subject_content($tid,$subject_id);
if($teachers_content){
foreach($teachers_content as $content){
$content_count=$content_count + 1;    
if($content_count == 1){
$last_updated=$content['cat'];    
}
}
}



?>
<tr>
<td><?php echo $subject_count; ?></td>
<td><?php echo $subjects['subject']; ?></td>
<td><?php echo $subjects['class']; echo "-";  echo $subjects['section'];?></td>
<td><?php  echo $chpater_count; echo "/"; echo $content_count;?></td>
<td><?php echo $last_updated; ?></td>
<td>
<a href="<?php echo base_url(); ?>ContentManagement/subject_chapters/<?php echo $subjects['id']; echo "/"; echo $tid; ?>" class="btn btn-sm btn-success">View</a></td>
</tr>
<?php
}
}
// }
// }
?>
    
</tbody>
</table>    
</div>
</div>
</div>
</div>