<?php 
$course_id=$this->uri->segment('3');
$course_table='courses';
$course='';
$subject_stream='';
$get_course_info=$this->DeveloperModel->get_item_data($course_id,$course_table);
if($get_course_info){
    foreach($get_course_info as $course_info){
        $course=$course_info['course'];
        $subject_stream=$course_info['subject_stream'];
    }
}




$acedemic_session=$this->session->userdata('acedemic_session');
$get_courses_data=$this->DeveloperModel->get_course_students_data($course_id,$acedemic_session);

?>
<div class="container mt-3 mb-3 pt-3 pb-3 bg-white">
    <div class="row">
        <div class="col-sm-12">
            
            <ul class="breadcrumb">
                <li class="breadcrumb-item">Home</li>
                <li class="breadcrumb-item">HS Fee Invoice </li>
                <li class="breadcrumb-item"><?php echo $course;?></li>
                <li class="breadcrumb-item"><?php echo $subject_stream;?></li>
                
            </ul>
            
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Name</th>
                            <th>Father Name</th>
                            <th>Invoices</th>
                            <th>(Estimate Amount / Received Am. / Discount / Balance / Months )</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $fee_student_count=0;                        
                        if($get_courses_data){
                            foreach($get_courses_data as $data){
                                // $course_strength=$course_strength + 1;        
                                $sid=$data['sid'];

                                $inv_count=0;
                                $check_student_fee_invoices=$this->DeveloperModel->get_student_fee_data($sid,$acedemic_session);
                                if($check_student_fee_invoices){
                                    foreach($check_student_fee_invoices as $fee_invoices){
                                        $inv_count =$inv_count + 1;
                                        
                                        
                                        if($fee_student_count ==1){

                                        }
                                        
                                        
                                    }
                                }
                                if($inv_count >=1){
                                    $fee_student_count=$fee_student_count + 1;
                                    
                                    $student_table='student';
                                    $get_student_info=$this->DeveloperModel->get_item_data($sid,$student_table);
                                    if($get_student_info){
                                        foreach($get_student_info as $info){
                                    ?>
                        <tr>
                            <td><?php echo $fee_student_count;?></td>
                            <td><?php echo $info['student_name'];?></td>
                            <td><?php echo $info['father_name'];?></td>
                            <td><?php echo $inv_count;?></td>
                            <td>
                                <ul>
                                    <?php
                                    $count=0;
                                    if($check_student_fee_invoices){
                                        foreach($check_student_fee_invoices as $fee_invoices){
                                            $count=$count + 1;
                                            ?>
                                            <li><?php echo $count; echo " / "; echo $fee_invoices['estimate_amount']; echo " / "; echo $fee_invoices['received_amount']; echo " / "; echo $fee_invoices['balance_amount']; echo " / "; echo $fee_invoices['discount']; echo " / "; echo "<a href='".base_url()."Fee/edit_fee_data/".$fee_invoices['fee_no']."'>Edit</a>"; echo " / <span style='text-transform:uppercase;'>"; echo $fee_invoices['months']; echo "</span> ";?></li>
                                            <?php 
                                        }
                                    }
                                    ?>
                                    
                                </ul>
                            </td>
                        </tr>
                                    <?php
                                        }
                                    }
                                }
                            }
                        }
                        
                        ?>
                        
                    </tbody>
                </table>
                
            </div>
            
            
        </div>
    </div>
</div>