<?php 
$acedemic_session=$this->session->userdata('acedemic_session');
$course_id=$this->uri->segment('3');
$course_table='courses';
$course='';
$subject_stream='';
$get_course_info=$this->NewFeeModel->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'];
        
    }
}
?>

<div class="container-fluid mt-3 mb-3  bg-white">
    <div class="row">
        <div class="col-sm-12 pt-3 pb-3">
            <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();?>FeeManagement">FeeManagement</a></li>
                <li class="breadcrumb-item">Course</li>
                <li class="breadcrumb-item"><?php echo $course; if($subject_stream !=''){echo "( ".$subject_stream." )";}?></li>
            </ul>
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Student Name</th>
                            <th>Father's Name</th>
                            <th>Contact Detail</th>
                            <th>Apr</th>
                            <th>May</th>
                            <th>Jun</th>
                            <th>Jul</th>
                            <th>Aug</th>
                            <th>Sep</th>
                            <th>Oct</th>
                            <th>Nov</th>
                            <th>Dec</th>
                            <th>Jan</th>
                            <th>Feb</th>
                            <th>Mar</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $count=0;
                            $get_strength=$this->NewFeeModel->get_course_students_for_ac_sessionn($course_id,$acedemic_session);
                            if($get_strength){
                                foreach($get_strength as $strength){
                                    
                                    $sid=$strength['sid'];
                                    $student_table='student';
                                    $get_student_info=$this->NewFeeModel->get_item_data($sid,$student_table);
                                    if($get_student_info){
                                        foreach($get_student_info as $student){
                                            if($student['status'] == 1){
                                            $count=$count + 1;
                                            $apr_status=0;
                                            $may_status=0;
                                            $jun_status=0;
                                            $jul_status=0;
                                            $aug_status=0;
                                            $sep_status=0;
                                            $oct_status=0;
                                            $nov_status=0;
                                            $dec_status=0;
                                            $jan_status=0;
                                            $feb_status=0;
                                            $mar_status=0;
                                            
                                            $apr_fee_date='';
                                            $may_fee_date='';
                                            $jun_fee_date='';
                                            $jul_fee_date='';
                                            $aug_fee_date='';
                                            $sep_fee_date='';
                                            $oct_fee_date='';
                                            $nov_fee_date='';
                                            $dec_fee_date='';
                                            $jan_fee_date='';
                                            $feb_fee_date='';
                                            $mar_fee_date='';
                                            $get_student_fee_data=$this->NewFeeModel->get_fee_data_for($sid,$acedemic_session);
                                            if($get_student_fee_data){
                                                foreach($get_student_fee_data as $fee_data){
                                                    $apr_status=$apr_status + $fee_data['april'];
                                                    $may_status=$may_status + $fee_data['may'];
                                                    $jun_status=$jun_status + $fee_data['june'];
                                                    $jul_status=$jul_status + $fee_data['july'];
                                                    $aug_status=$aug_status + $fee_data['august'];
                                                    $sep_status=$sep_status + $fee_data['september'];
                                                    $oct_status=$oct_status + $fee_data['october'];
                                                    $nov_status=$nov_status + $fee_data['november'];
                                                    $dec_status=$dec_status + $fee_data['december'];
                                                    $jan_status=$jan_status + $fee_data['january'];
                                                    $feb_status=$feb_status + $fee_data['february'];
                                                    $mar_status=$mar_status + $fee_data['march'];
                                                   
                                                    if($apr_status ==1){$apr_fee_date=$fee_data['fee_date'];}
                                                    if($may_status ==1){$may_fee_date=$fee_data['fee_date'];}
                                                    if($jun_status ==1){$jun_fee_date=$fee_data['fee_date'];}
                                                    if($jul_status ==1){$jul_fee_date=$fee_data['fee_date'];}
                                                    if($aug_status ==1){$aug_fee_date=$fee_data['fee_date'];}
                                                    if($sep_status ==1){$sep_fee_date=$fee_data['fee_date'];}
                                                    if($oct_status ==1){$oct_fee_date=$fee_data['fee_date'];}
                                                    if($nov_status ==1){$nov_fee_date=$fee_data['fee_date'];}
                                                    if($dec_status ==1){$dec_fee_date=$fee_data['fee_date'];}
                                                    if($jan_status ==1){$jan_fee_date=$fee_data['fee_date'];}
                                                    if($feb_status ==1){$feb_fee_date=$fee_data['fee_date'];}
                                                    if($mar_status ==1){$mar_fee_date=$fee_data['fee_date'];}
                                                }
                                            }
                                            
                                            
                                            
                                            ?>
                                            <tr>
                                                <td><?php echo $count;?></td>
                                                <td><?php echo $student['student_name'];?></td>
                                                <td><?php echo $student['father_name'];?></td>
                                                <td><?php echo $student['contact_no'];?></td>
                                                <td><?php if($apr_status ==1){echo "<span class='text-success'>".date('d-m-Y',strtotime($apr_fee_date))."</span>";}else{ echo "---";} ?></td>
                                                <td><?php if($may_status ==1){echo "<span class='text-success'>".date('d-m-Y',strtotime($may_fee_date))."</span>";}else{ echo "---";} ?></td>
                                                <td><?php if($jun_status ==1){echo "<span class='text-success'>".date('d-m-Y',strtotime($jun_fee_date))."</span>";}else{ echo "---";} ?></td>
                                                <td><?php if($jul_status ==1){echo "<span class='text-success'>".date('d-m-Y',strtotime($jul_fee_date))."</span>";}else{ echo "---";} ?></td>
                                                <td><?php if($aug_status ==1){echo "<span class='text-success'>".date('d-m-Y',strtotime($aug_fee_date))."</span>";}else{ echo "---";} ?></td>
                                                <td><?php if($sep_status ==1){echo "<span class='text-success'>".date('d-m-Y',strtotime($sep_fee_date))."</span>";}else{ echo "---";} ?></td>
                                                <td><?php if($oct_status ==1){echo "<span class='text-success'>".date('d-m-Y',strtotime($oct_fee_date))."</span>";}else{ echo "---";} ?></td>
                                                <td><?php if($nov_status ==1){echo "<span class='text-success'>".date('d-m-Y',strtotime($nov_fee_date))."</span>";}else{ echo "---";} ?></td>
                                                <td><?php if($dec_status ==1){echo "<span class='text-success'>".date('d-m-Y',strtotime($dec_fee_date))."</span>";}else{ echo "---";} ?></td>
                                                <td><?php if($jan_status ==1){echo "<span class='text-success'>".date('d-m-Y',strtotime($jan_fee_date))."</span>";}else{ echo "---";} ?></td>
                                                <td><?php if($feb_status ==1){echo "<span class='text-success'>".date('d-m-Y',strtotime($feb_fee_date))."</span>";}else{ echo "---";} ?></td>
                                                <td><?php if($mar_status ==1){echo "<span class='text-success'>".date('d-m-Y',strtotime($mar_fee_date))."</span>";}else{ echo "---";} ?></td>
                                            </tr>
                                            <?php
                                            }
                                        }
                                    }
                                    $get_student_fee_data=$this->NewFeeModel->get_fee_data_for($sid,$acedemic_session);

                                }
                            }
                        ?>

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