<?php
$acedemic_session=$this->session->userdata('acedemic_session');
$courses_table='courses';
$get_courses_data=$this->NewFeeModel->get_data($courses_table);


?>

<style>
.data-portal{background:#F9F9F9 !important;margin-bottom:10px;}  
.down{
border-radius:2px;padding:5px; box-shadow: 0 0 2px silver;   
cursor:pointer;
}
</style>
<div class="container-fluid data-portal ">
    <div class="row">
        <div class="col-sm-12 pt-3 pb-3">
            <ul class="breadcrumb mt-3">
                <li class="breadcrumb-item"><a href="<?php echo base_url();?>FeeManagement/dashboard">Home</a></li>
                <li class="breadcrumb-item">Fee</li>
                <li class="breadcrumb-item"><a href="<?php echo base_url();?>FeeManagement/detail_Portal"> Detail Portal</a></li>
            </ul>    
                
                
                            
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th colspan="2">Class</th>
                            <!--<th>#</th>-->
                            <th>Str.</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 
                        if($get_courses_data){
                            foreach($get_courses_data as $courses_data){
                                
                                
                                $course_id=$courses_data['id'];
                                $course_fee_structure=$this->NewFeeModel->course_fee_structure_for_session($acedemic_session,$course_id);
                                
                                // $apr_expected_fee=0;
                                // $may_expected_fee=0;
                                // $jun_expected_fee=0;
                                // $jul_expected_fee=0;
                                // $aug_expected_fee=0;
                                // $sep_expected_fee=0;
                                // $oct_expected_fee=0;
                                // $nov_expected_fee=0;
                                // $dec_expected_fee=0;
                                // $jan_expected_fee=0;
                                // $feb_expected_fee=0;
                                // $mar_expected_fee=0;
                                
                                // $apr_rec_fee=0;
                                // $may_rec_fee=0;
                                // $jun_rec_fee=0;
                                // $jul_rec_fee=0;
                                // $aug_rec_fee=0;
                                // $sep_rec_fee=0;
                                // $oct_rec_fee=0;
                                // $nov_rec_fee=0;
                                // $dec_rec_fee=0;
                                // $jan_rec_fee=0;
                                // $feb_rec_fee=0;
                                // $mar_rec_fee=0;
                                
                                // $apr_des_fee=0;
                                // $may_des_fee=0;
                                // $jun_des_fee=0;
                                // $jul_des_fee=0;
                                // $aug_des_fee=0;
                                // $sep_des_fee=0;
                                // $oct_des_fee=0;
                                // $nov_des_fee=0;
                                // $dec_des_fee=0;
                                // $jan_des_fee=0;
                                // $feb_des_fee=0;
                                // $mar_des_fee=0;
                                
                                        // $apr_fee=0;
                                        // $may_fee=0;
                                        // $jun_fee=0;
                                        // $jul_fee=0;
                                        // $aug_fee=0;
                                        // $sep_fee=0;
                                        // $oct_fee=0;
                                        // $nov_fee=0;
                                        // $dec_fee=0;
                                        // $jan_fee=0;
                                        // $feb_fee=0;
                                        // $mar_fee=0;
                                // if($course_fee_structure){
                                //     foreach($course_fee_structure as $fee_structure){
                                        
                                //         if($fee_structure['april'] ==1){$apr_fee=$fee_structure['amount'];}
                                //         if($fee_structure['may'] ==1){$may_fee=$fee_structure['amount'];}
                                //         if($fee_structure['june'] ==1){$jun_fee=$fee_structure['amount'];}
                                //         if($fee_structure['july'] ==1){$jul_fee=$fee_structure['amount'];}
                                //         if($fee_structure['august'] ==1){$aug_fee=$fee_structure['amount'];}
                                //         if($fee_structure['august'] ==1){$sep_fee=$fee_structure['amount'];}
                                //         if($fee_structure['august'] ==1){$oct_fee=$fee_structure['amount'];}
                                //         if($fee_structure['august'] ==1){$nov_fee=$fee_structure['amount'];}
                                //         if($fee_structure['august'] ==1){$dec_fee=$fee_structure['amount'];}
                                //         if($fee_structure['august'] ==1){$jan_fee=$fee_structure['amount'];}
                                //         if($fee_structure['august'] ==1){$feb_fee=$fee_structure['amount'];}
                                //         if($fee_structure['august'] ==1){$mar_fee=$fee_structure['amount'];}
                                        
                                //     }
                                // }
                                
                                $course_strength=0;
                                $apr_fee_count=0;
                                $may_fee_count=0;
                                $jun_fee_count=0;
                                $jul_fee_count=0;
                                $aug_fee_count=0;
                                $sep_fee_count=0;
                                $oct_fee_count=0;
                                $nov_fee_count=0;
                                $dec_fee_count=0;
                                $jan_fee_count=0;
                                $feb_fee_count=0;
                                $mar_fee_count=0;
                                
                                $get_strength=$this->NewFeeModel->get_course_students_for_ac_sessionn($course_id,$acedemic_session);
                                if($get_strength){
                                    foreach($get_strength as $strength){
                                        $student_table='student';
                                        $sid=$strength['sid'];
                                        $check_student_exist=$this->NewFeeModel->get_item_data($sid,$student_table);
                                        if($check_student_exist){
                                            foreach($check_student_exist as $exist){
                                                $course_strength=$course_strength + 1;        
                                            }
                                        }
                                        
                                        
                                        
                                        
                                        $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){
                                                
                                                
                                                if($fee_data['april'] ==1){$apr_fee_count =$apr_fee_count + 1;}
                                                if($fee_data['may'] ==1){$may_fee_count =$may_fee_count + 1;}
                                                if($fee_data['june'] ==1){$jun_fee_count=$jun_fee_count  + 1;}
                                                if($fee_data['july']==1){$jul_fee_count=$jul_fee_count + 1;}
                                                if($fee_data['august']==1){$aug_fee_count=$aug_fee_count + 1;}
                                                if($fee_data['september']==1){$sep_fee_count=$sep_fee_count + 1;}
                                                if($fee_data['october']==1){$oct_fee_count=$oct_fee_count + 1;}
                                                if($fee_data['november']==1){$nov_fee_count =$nov_fee_count + 1;}
                                                if($fee_data['december']==1){$dec_fee_count=$dec_fee_count + 1;}
                                                if($fee_data['january'] ==1){$jan_fee_count=$jan_fee_count + 1;}
                                                if($fee_data['february'] ==1){$feb_fee_count=$feb_fee_count + 1;}
                                                if($fee_data['march']==1){$mar_fee_count=$mar_fee_count + 1;}
                                                
                                                
                                            }
                                        }
                                    }
                                }
                                
                                // $apr_expected_fee=$course_strength * $apr_fee;
                                // $may_expected_fee=0;
                                // $jun_expected_fee=0;
                                // $jul_expected_fee=0;
                                // $aug_expected_fee=0;
                                // $sep_expected_fee=0;
                                // $oct_expected_fee=0;
                                // $nov_expected_fee=0;
                                // $dec_expected_fee=0;
                                // $jan_expected_fee=0;
                                // $feb_expected_fee=0;
                                // $mar_expected_fee=0;
                        ?>
                        <tr>
                            <td><?php echo $courses_data['course']; if($courses_data['subject_stream'] !=''){ echo " - "; echo $courses_data['subject_stream'];} ?></td>
                            <td>
                                <a href="<?php echo base_url();?>FeeManagement/course_fee_data/<?php echo $course_id;?>" class="btn btn-sm btn-info">
                                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-down-square-fill" viewBox="0 0 16 16">
                                        <path d="M0 2a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2zm4 4a.5.5 0 0 0-.374.832l4 4.5a.5.5 0 0 0 .748 0l4-4.5A.5.5 0 0 0 12 6H4z"/>
                                    </svg>
                                </a>
                            </td>
                            <td><?php echo $course_strength; ?></td>
                            <td>(<span class="text-success"><?php echo $apr_fee_count;?></span>,<span class="text-danger"><?php echo $course_strength - $apr_fee_count; ?></span>)</td>
                            <td>(<span class="text-success"><?php echo $may_fee_count;?></span>,<span class="text-danger"><?php echo $course_strength - $may_fee_count; ?></span>)</td>
                            <td>(<span class="text-success"><?php echo $jun_fee_count;?></span>,<span class="text-danger"><?php echo $course_strength - $jun_fee_count; ?></span>)</td>
                            <td>(<span class="text-success"><?php echo $jul_fee_count;?></span>,<span class="text-danger"><?php echo $course_strength - $jul_fee_count; ?></span>)</td>
                            <td>(<span class="text-success"><?php echo $aug_fee_count;?></span>,<span class="text-danger"><?php echo $course_strength - $aug_fee_count; ?></span>)</td>
                            <td>(<span class="text-success"><?php echo $sep_fee_count;?></span>,<span class="text-danger"><?php echo $course_strength - $sep_fee_count; ?></span>)</td>
                            <td>(<span class="text-success"><?php echo $oct_fee_count;?></span>,<span class="text-danger"><?php echo $course_strength - $oct_fee_count; ?></span>)</td>
                            <td>(<span class="text-success"><?php echo $nov_fee_count;?></span>,<span class="text-danger"><?php echo $course_strength - $nov_fee_count; ?></span>)</td>
                            <td>(<span class="text-success"><?php echo $dec_fee_count;?></span>,<span class="text-danger"><?php echo $course_strength - $dec_fee_count; ?></span>)</td>
                            <td>(<span class="text-success"><?php echo $jan_fee_count;?></span>,<span class="text-danger"><?php echo $course_strength - $jan_fee_count; ?></span>)</td>
                            <td>(<span class="text-success"><?php echo $feb_fee_count;?></span>,<span class="text-danger"><?php echo $course_strength - $feb_fee_count; ?></span>)</td>
                            <td>(<span class="text-success"><?php echo $mar_fee_count;?></span>,<span class="text-danger"><?php echo $course_strength - $mar_fee_count; ?></span>)</td>
                        </tr>
                        <?php
                            }
                        }
                        ?>
                    </tbody>
                </table>    
            </div>
        </div>    
    </div>    
</div>

<script>
$(document).ready(function(){
    
loadallclasses_data();
function loadallclasses_data(){


$.ajax({
url: '<?php echo base_url() ?>FeeManagement/getallclasses_data/',
type: 'POST', 

success: function(data){
$(".load-data").html(data);
}
})
} 


});    
    
</script>