<?php
// $course="";
// $subject_stream="";


// $month_from=$month_from;
// $month_to=$month_to;
$course_id=$course_id;
// $status=$status;
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Fee Defaulters</title>
        <style>
            .w-100{width:100%;}
            .w-50-1{width:50%;float:left;height:100%;border-right:1px dotted red;}
            .w-50-2{width:50%;float:left;height:100%;}
            .w-2{width:0%;float:left;}
            img{height:80px;width:auto;}
            html{padding:0px;margin:0px;}
            body{padding:15px;margin:0px;font-size:15px;}
        </style>
        
        
        <style>
            #student {
                font-family: Arial, Helvetica, sans-serif;
                border-collapse: collapse;
                width: 100%;
            }

            #student td, #student th {
                border: 1px solid #ddd;
                padding: 5px;
            }

            #student td{
                font-size:14px;
            }

            #student tr:nth-child(even){background-color: #f2f2f2;}

            #student tr:hover {background-color: #ddd;}

            #student th {
                padding-top: 4px;
                padding-bottom: 4px;
                text-align: left;
                /*background-color: #eaeded;*/
                /*color: white;*/
            }
        </style>
    </head>
    <body>
        
        
        <table style="width:100%;margin:0px;padding:0px;border:1px solid;background:#fff;color:#4F3F85">
            <tr style="width:100% !important;padding:0px !important;">
                <th style="width:30%;background:;border-bottom:1px solid red;">
                    <img src="<?php echo school_logo_full; ?>" style="">
                </th>
                <td style="width:70%;height:80px;background:;margin:0px;text-align:center;padding:0px;border-bottom:1px solid red;padding-right:20px;">
                    <p style="padding:0px;margin:0px;font-size:26px;font-weight:700;"><?php echo school_full_name; ?></p>
                    <p style="padding:0px;margin:0px;font-size:18px;font-weight:500;"><?php echo school_affiliation;?></p>
                    <p style="padding:0px;margin:0px;font-size:16px;font-weight:500;"><?php echo school_address;?></p>
                    <p style="padding:0px;margin:0px;font-size:16px;font-weight:500;">Contact :<?php echo contact1;?>, <?php echo contact2;?></p>
                
                    <?php
                    $acedemic_session=$this->session->userdata('acedemic_session');
                    $acedemic_session_table='academic_session_details';
                    $get_ac_sess_data=$this->InvoiceModel->get_item_data($acedemic_session,$acedemic_session_table);
                    if($get_ac_sess_data){
                        foreach($get_ac_sess_data as $ac_sess_data){
                    ?>
                        <p style="text-align:center;padding:0px;margin:0px;font-size:16px;font-weight:500;">Academic Year : <?php echo $ac_sess_data['year_long'];?></p>
                        <!--<p style="text-align:center;font-size:14px;font-weight:600;padding:0px;margin:0px;">Course : <?php echo $course; echo " "; echo $subject_stream;?></p>-->
                    <?php
                        }
                    }
                    ?>
                </td>
            </tr>
        </table>
        <table class="" id="student">
            <thead>
                <tr>
                    <th>#</th>
                    <th>Student Name</th>
                    <th>Father's Name</th>
                    <th>Class </th>
                    <th>Fee Paid Months</th>
                </tr>
            </thead>
            <tbody>
                <?php 
                $count=0;
                // $acedemic_session=$this->session->userdata("acedemic_session");
                $get_stud_data=$this->NewFeeModel->get_course_students_combined($course_id,$acedemic_session);
                if($get_stud_data){
                    foreach($get_stud_data as $student){
                        $balance_amount=0;
                        $sid=$student['id'];
                        $apr=0;
                        $may=0;
                        $jun=0;
                        $jul=0;
                        $aug=0;
                        $sep=0;
                        $oct=0;
                        $nov=0;
                        $dec=0;
                        $jan=0;
                        $feb=0;
                        $mar=0;
                        $student_fee_data=$this->NewFeeModel->get_fee_data_for($sid,$acedemic_session);
                        if($student_fee_data){
                            foreach($student_fee_data as $fee_data){
                                if($fee_data['balance_amount_status'] == 1){
                                    $balance_amount=$balance_amount + $fee_data['balance_amount'];
                                }
                                
                                if($fee_data['april'] == 1){
                                    $apr=$apr + 1;    
                                }
                                
                                if($fee_data['may'] == 1){
                                    $may=$may + 1;    
                                }
                                
                                if($fee_data['june'] == 1){
                                    $jun=$jun + 1;    
                                }
                                
                                if($fee_data['july'] == 1){
                                    $jul=$jul + 1;    
                                }
                                
                                if($fee_data['august'] == 1){
                                    $aug=$aug + 1;    
                                }
                                
                                if($fee_data['september'] == 1){
                                    $sep=$sep + 1;    
                                }
                                
                                if($fee_data['october'] == 1){
                                    $oct=$oct + 1;    
                                }
                                
                                if($fee_data['november'] == 1){
                                    $nov=$nov + 1;    
                                }
                                
                                if($fee_data['december'] == 1){
                                    $dec=$dec + 1;    
                                }
                                
                                if($fee_data['january'] == 1){
                                    $jan=$jan + 1;    
                                }
                                
                                if($fee_data['february'] == 1){
                                    $feb=$feb + 1;    
                                }
                                
                                if($fee_data['march'] == 1){
                                    $mar=$mar + 1;    
                                }
                                 
                            }
                        }
                        
                    // if($apr ==1 && $may ==1 && $jun ==1 && $jul ==1 && $aug ==1 && $sep ==1 &&  $oct ==1 && $nov ==1 && $dec ==1 && $jan ==1 && $feb ==1 && $mar ==1 ){
                    if($apr ==1 && $may ==1 && $jun ==1 && $jul ==1 && $aug ==1 && $sep ==1 &&  $oct ==1 && $nov ==1 && $dec ==1 && $jan ==1 && $feb ==1 ){
                    
                        $count=$count + 1;
                    
                    
                ?>
                <tr>
                    <td><?php echo $count; ?></td>
                    <td><?php echo $student['student_name'];?></td>
                    <td><?php echo $student['father_name'];?></td>
                    <td class="text-center"><?php echo $student['class']." ".$student['section']; ?></td>
                    <td>
                    <?php 
                    if($balance_amount == 0){
                    ?>
                    <?php
                    if($mar ==1){
                    ?>
                    <span class="text-success" style="color:green">Apr-22 to March-23 Paid</span>
                    
                    <?php
                    }else{
                    ?>
                    <span class="text-success" style="color:green">Apr 2022 to February 2023 Paid</span>
                    
                    <?php    
                    }
                    
                    }else{
                        echo "BAL : ".$balance_amount;
                    }
                    ?>
                    </td>
                </tr>        
                <?php 
                    
                        }    
                    }
                }
                ?>
            </tbody>
        </table>    
        
    </body>
</html>    