<?php 
$subject_id=$this->uri->segment(3);
$tid=$this->uri->segment(4);
$staff_name='';
$staff_data=$this->EContentModel->staff_data($tid);
if($staff_data){
foreach($staff_data as $staff){
$staff_name= $staff['name'];
}
}

$subject='';
$class='';
$section='';
$subject_data=$this->EContentModel->subject_data($subject_id);
if($subject_data){
foreach($subject_data as $data){
$subject =$data['subject'];    
$class=$data['class'];
$section=$data['section'];
}    
}
?>

<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"><a href="<?php echo base_url();?>ContentManagement/subjects/<?php echo $tid;?>"><?php echo $staff_name;?></a></li>
<li class="breadcrumb-item "><a href="#"><?php echo $subject; echo ","; echo $class; echo "-"; echo $section; ?> </a></li>
<li class="breadcrumb-item active"><a href="#">Chapters</a></li>
</ul>    
        
        
        
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>#</th>
<th>Chapter Title</th>
<th>Chapter Summery</th>
<th>Contents</th>
<th>View</th>
</tr>    
</thead> 
<tbody>
<?php 
$count=0;

$all_chapters=$this->EContentModel->all_chapters($subject_id,$tid);
if($all_chapters){
foreach($all_chapters as $chapters){
$count=$count+1;
$chapter_id=$chapters['id'];
$cont_count=0;
$all_chapter_contents=$this->EContentModel->all_chapter_contents($chapter_id);
if($all_chapter_contents){
foreach($all_chapter_contents as $chapter_contents){
$cont_count = $cont_count + 1;    
}
}

?>
<tr>
<td><?php echo $count; ?></td>
<td><?php echo $chapters['chapter_title']; ?></td>
<td><?php echo $chapters['chapter_info'];?></td>
<td><?php echo $cont_count;?></td>
<td><a href="<?php echo base_url();?>ContentManagement/content/<?php echo $subject_id; echo "/"; echo $tid; echo "/"; echo $chapter_id; ?>" class="text-white btn btn-sm btn-success">View</a></td>
</tr>    
<?php
}
}
?>


</tbody>
</table>    
</div>        
</div>
</div>
</div>