<style>
body{background:#EAEDED;}
.form-group{width:25%;float:left;margin-top:10px;margin-bottom:10px;}
.search-defaulter{width:45%;float:left;margin-top:10px;margin-bottom:10px;padding-left:5px;padding-right:5%;}
</style>
<div class="container-fluid bg-white mt-3">
    <div class="row">
        <div class="col-sm-12 pt-3 pb-3">
            <ul class="breadcrumb">
                <li class="breadcrumb-item"><?php echo $this->session->userdata('ac_year'); ?></li> 
                <li class="breadcrumb-item"><a href="<?php echo base_url(); ?>Welcome">Home</a></li> 
                <li class="breadcrumb-item">Fee Defaulter</li> 
            </ul>
            <div style="background:#EAEDED;width:100%;height:70px;padding:10px;" class="mb-3">    
                <div class="form-group">
                    <select class="form-control" id="defaulter_from_month">
                        <option value="4">April</option>
                        <option value="5">May</option>
                        <option value="6">June</option>
                        <option value="7">July</option>
                        <option value="8">August</option>
                        <option value="9">September</option>
                        <option value="10">October</option>
                        <option value="11">November</option>
                        <option value="12">December</option>
                        <option value="1">January</option>
                        <option value="2">February</option>
                        <option value="3">March</option>
                    </select>
                
                </div>
                <div style="width:5%;float:left;padding:10px;height:70px;vertical-align:middle;margin-top:10px;margin-bottom:10px;font-weight:600;" class="text-center text-success"> to </div>
                <div class="form-group">
                    <select class="form-control" id="defaulter_to_month">
                        <option value="3">March</option>
                        <option value="2">February</option>
                        <option value="1">January</option>
                        <option value="12">December</option>
                        <option value="11">November</option>
                        <option value="10">October</option>
                        <option value="9">September</option>
                        <option value="8">August</option>
                        <option value="7">July</option>
                        <option value="6">June</option>
                        <option value="5">May</option>
                        <option value="4">April</option>
                    </select>
                
                </div>
                <div class="search-defaulter">
                    <button type="button" class="btn btn-info" id="search-defaulter">
                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-search" viewBox="0 0 16 16">
                            <path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/>
                        </svg>
                    </button>
                </div>
            </div>
            
            <div id="get_defaulter" class="table-responsive"></div>
            
            <div class="table-responsive">
                <table class="table table-bordered table-striped" id="mytable">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Name</th>
                            <th>Father Name</th>
                            <th>Sch. No.</th>
                            <th>Class Section</th>
                            <th>Fee Months</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
                        $count=0;
                        $student_table='student';
                        $acedemic_session=$this->session->userdata('acedemic_session');
                        $all_students=$this->WelcomeModel->get_students_ac_session($acedemic_session);
                        if($all_students){
                            foreach($all_students as $students){
                                $sid=$students['sid'];
                                $get_student_data=$this->WelcomeModel->get_item_data($sid,$student_table);
                                if($get_student_data){
                                    foreach($get_student_data as $student_data){
                                        if($student_data['status'] ==1){
                                        $april=0;
                                        $may=0;
                                        $june=0;
                                        $july=0;
                                        $august=0;
                                        $september=0;
                                        $october=0;
                                        $november=0;
                                        $december=0;
                                        $january=0;
                                        $february=0;
                                        $march=0;
                                        $april=0;
                                        
                                        $fee_invoices=$this->NewFeeModel->get_fee_data_for($sid,$acedemic_session);
                                        if($fee_invoices){
                                            foreach($fee_invoices as $fee){
                                                if($fee['april']==1){
                                                 $april=$april + 1;   
                                                }
                                                if($fee['may']==1){
                                                 $may=$may + 1;   
                                                }
                                                if($fee['june']==1){
                                                 $june=$june + 1;   
                                                }
                                                if($fee['july']==1){
                                                 $july=$july + 1;   
                                                }
                                                if($fee['august']==1){
                                                 $august=$august + 1;   
                                                }
                                                if($fee['september']==1){
                                                 $september=$september + 1;   
                                                }
                                                if($fee['october']==1){
                                                 $october=$october + 1;   
                                                }
                                                if($fee['november']==1){
                                                 $november=$november + 1;   
                                                }
                                                if($fee['december']==1){
                                                 $december=$december + 1;   
                                                }
                                                if($fee['january']==1){
                                                 $january=$january + 1;   
                                                }
                                                if($fee['february']==1){
                                                 $february=$february + 1;   
                                                }
                                                if($fee['march']==1){
                                                 $march=$march + 1;   
                                                }
                                                
                                            }
                                        }
                                        if($april==0 || $may==0 || $june ==0 || $july==0 || $august==0 || $september ==0 || $october ==0 || $november ==0 || $december ==0 || $january ==0 || $february ==0 || $march ==0){
                                        $count = $count + 1    
                                            
                                        ?>
                        <tr>
                            <th><?php echo $count;?></th>
                            <td><?php echo $student_data['student_name'];?></td>
                            <td><?php echo $student_data['father_name'];?></td>
                            <td><?php echo $student_data['sch_no'];?></td>
                            <td><?php echo $student_data['class']; echo " "; echo $student_data['section'];?></td>
                            <td>
                                <?php if($april ==0){ echo "Apr ,";} ?>
                                <?php if($may ==0){ echo "May ,";} ?>
                                <?php if($june ==0){ echo "Jun ,";} ?>
                                <?php if($july ==0){ echo "Jul ,";} ?>
                                <?php if($august ==0){ echo "Aug ,";} ?>
                                <?php if($september ==0){ echo "Sep ,";} ?>
                                <?php if($october ==0){ echo "Oct ,";} ?>
                                <?php if($november ==0){ echo "Nov ,";} ?>
                                <?php if($december ==0){ echo "Dec ,";} ?>
                                <?php if($january ==0){ echo "Jan ,";} ?>
                                <?php if($february ==0){ echo "Feb ,";} ?>
                                <?php if($march ==0){ echo "Mar ,";} ?>
                            </td>
                        </tr>
                                        <?php
                                        }
                                        
                                        }
                                    }
                                }
                            }
                        }
                        ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>


<script>
$(document).ready(function(){
    $("#search-defaulter").click(function(){
        var defaulter_from_month=$("#defaulter_from_month").val();
        var defaulter_to_month=$("#defaulter_to_month").val();
        // alert(defaulter_from_month);
        $.ajax({
            url: '<?php echo base_url() ?>Fee/get_defaulter_links/',
            type: 'POST', 
            data: {defaulter_from_month:defaulter_from_month,defaulter_to_month:defaulter_to_month},
            success: function(data){
                $("#get_defaulter").html(data);
                // alert(data);
            }
        });
    });        
});
</script>