<!DOCTYPE html>
<html>
    <head>
        <title>Fee Invoice</title>
        <style>
            .w-100{width:100%;border:2px solid red;}
            .w-50-1{width:50%;float:left;height:100%;border-right:1px dotted red !important;}
            .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:0px;margin:0px;font-size:13px;padding:25px;}
            table{width:100%;}
            /*tr{padding:10px;}*/
        </style>
    </head> 
    <body>
<div class="w-100">

<?php 
$sid=$this->uri->segment('3');
$acedemic_session=$this->session->userdata('acedemic_session');
$student_table='student';
$acedemic_session_table='academic_session_details';
$ace_session='';
$get_acedemic_session_info=$this->NewFeeModel->get_item_data($acedemic_session,$acedemic_session_table);
if($get_acedemic_session_info){
    foreach($get_acedemic_session_info as $ac_session_info){
        $ace_session=$ac_session_info['year_long'];
    }
}


$get_student_info=$this->NewFeeModel->get_item_data($sid,$student_table);
$student_name='';
$enquiry_id='';
if($get_student_info){
    foreach($get_student_info as $student_info){
        $student_name=$student_info['student_name'];
        $enquiry_id=$student_info['enquiry_id'];
    }
}
$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;

$current_month=date('m');
// if()
$course_id='';
$get_active_course_data=$this->NewFeeModel->get_studdents_current_course_data($sid,$acedemic_session);
if($get_active_course_data){
    foreach($get_active_course_data as $course_data){
        $course_id=$course_data['course_id'];
        
    }
}

$courses_table='courses';
$course='';
$subject_stream='';

$get_course_info=$this->NewFeeModel->get_item_data($course_id,$courses_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 mt-3 mb-3 bg-white pt-3 pb-3">-->
<!--    <div class="row">-->
<!--        <div class="col-sm-12">-->
<!--            <ul class="breadcrumb">-->
<!--                <li class="breadcrumb-item"><?php echo $ace_session;?></li>-->
<!--                <li class="breadcrumb-item"><a href="<?php echo base_url();?>Welcome">Home</a></li>-->
<!--                <li class="breadcrumb-item"><a href="<?php echo base_url()?>Fee/all_students">Fee</a></li>-->
<!--                <li class="breadcrumb-item">Ledger</li>-->
<!--                <li class="breadcrumb-item"><?php echo $student_name;?></li>-->
<!--            </ul>-->


            <table style="width:100%;margin:0px;padding:0px;">
                <tr style="width:100% !important;padding:0px !important;">
                    <td style="width:30%;background:;padding:0px;border-bottom:1px solid red;">
                        <img src="<?php echo base_url();?>assets/img/logo.jpg" style="margin:auyo;">
                    </td>
                    <td style="width:70%;margin:0px;text-align:center;padding:0px;border-bottom:1px solid red;padding-right:20px;">
                        <p style="padding:0px;margin:0px;font-size:22px;font-weight:700;">S. J. Education Center</p>
                        <p style="padding:0px;margin:0px;font-size:15px;font-weight:500;">(Affiliated to ICSE/ISC New Delhi)</p>
                        <p style="padding:0px;margin:0px;font-size:13px;font-weight:500;">Hanspuram (Canal Road), Naubasta, Kanpur</p>
                        <p style="padding:0px;margin:0px;font-size:13px;font-weight:500;">Contact :7311109998, 8052191444</p>
                
    
                    <p style="text-align:center;padding:0px;margin:0px;font-size:13px;font-weight:500;">Academic Year : <?php echo $ace_session;?></p>
                
                    </td>
                </tr>
            </table>
            <div class="table-responsive">
                <table class="table table-bordered table-striped" >
                    <thead>
                        <?php
                        if($get_student_info){
                            foreach($get_student_info as $student_info){
                        ?>      
                        <tr>
                            <td style="border-bottom:1px solid red;width:25%;"><b>Student's Name : </b></td>
                            <td style="border-bottom:1px solid red;width:75%;border-left:1px solid red;"><?php echo $student_info['student_name']; ?></td>
                            
                        </tr>             
                        <tr>
                            <td style="border-bottom:1px solid red;font-weight:600;">
                                <?php
                                
                                if($student_info['gender'] == "male"){
                                    echo " S/O Mr. "; 
                                }else if($student_info['gender'] == "female"){
                                    echo " D/O Mr. ";
                                }else{
                                    echo " Father's Name : ";
                                    
                                } 
                                  
                                ?>
                            </td>
                            <td style="border-bottom:1px solid red;border-left:1px solid red;"><?php echo $student_info['father_name'];   ?></td>
                        </tr>
                        <tr>
                            <td style="border-bottom:1px solid red;font-weight:600;">D.O.B. : </td>
                            <td style="border-bottom:1px solid red;border-left:1px solid red;"><?php if($student_info['dob']){ echo date('d-M-Y',strtotime($student_info['dob'])); } ?></td>
                        </tr>
                        <tr>
                            <td style="border-bottom:1px solid red;font-weight:600;">Course : </td>
                            <td style="border-bottom:1px solid red;border-left:1px solid red;">Class <?php echo $course; echo ' '; echo $subject_stream;?></td>
                            
                        </tr>
                        
                        <?php
                            }
                        }
                        ?>

                    </thead>
                    <tbody>


                    </tbody>
                </table>

                        <?php  
                        $prev_ac_session=$acedemic_session - 1;
                        $get_opening_balance_data=$this->NewFeeModel->get_students_opening_fee($sid,$prev_ac_session);
                        if($get_opening_balance_data){
                            foreach($get_opening_balance_data as $opening_balance_data){
                        ?>
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr><th colspan="7" class="text-center text-info" style="border-bottom:1px solid red;">Opening Balance </th></tr>
                        <tr>
                            <th style="border-bottom:1px solid red;" colspan="4">Fee Note</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;" colspan="3">Fee Amount</th>
                        </tr>
                        <tr>
                            <!--<td><?php echo $opening_balance_data['student_name'];?></td>-->
                            <!--<td><?php echo $opening_balance_data['father_name'];?></td>-->
                            <td style="border-bottom:1px solid red;text-align:center;" colspan="4"><?php echo $opening_balance_data['fee_note'];?></td>
                            <td style="border-bottom:1px solid red;text-align:center;border-left:1px solid red;" colspan="3"><?php echo $opening_balance_data['opening_fee_amount'];?></td>
                        </tr>
                        <tr>
                            <th style="border-bottom:1px solid red;">Fee No</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Fee Date</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Est Amount</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Discount</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Received</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Balance</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Invoice</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $get_opening_fee_invoices=$this->NewFeeModel->get_opening_fee_invoices($sid,$acedemic_session);
                        if($get_opening_fee_invoices){
                            foreach($get_opening_fee_invoices as $opening_fee_invoices){
                        ?>                                
                        <tr>
                            <td style="border-bottom:1px solid red;text-align:center;"><?php echo $opening_fee_invoices['id']; ?></td>
                            <td style="border-bottom:1px solid red;text-align:center;border-left:1px solid red;"><?php echo $opening_fee_invoices['date']; ?></td>
                            <td style="border-bottom:1px solid red;text-align:center;border-left:1px solid red;"><?php echo $opening_fee_invoices['estimate_amount']; ?></td>
                            <td style="border-bottom:1px solid red;text-align:center;border-left:1px solid red;"><?php echo $opening_fee_invoices['discount']; ?></td>
                            <td style="border-bottom:1px solid red;text-align:center;border-left:1px solid red;"><?php echo $opening_fee_invoices['received_amount']; ?></td>
                            <td style="border-bottom:1px solid red;text-align:center;border-left:1px solid red;"><?php echo $opening_fee_invoices['balance_amount']; ?></td>
                            <td style="border-bottom:1px solid red;text-align:center;border-left:1px solid red;"><a href="<?php echo base_url();?>OpeningFee/invoice/<?php echo $opening_fee_invoices['id'];?>">Invoice</a></td>
                        </tr>
                        <?php
                            }
                        }else{
                            ?>
                            <tr>
                                <td colspan="7" class="text-center text-danger" style="color:red;">No Fee Found</td>
                            </tr>
                            <?php
                        }
                        ?>
                    </tbody>
                </table>
                        <?php
                            }
                        }else{
                            ?>
                            <div class="alert alert-success" style="font-weight:600;color: green;margin-top:15px;margin-bottom:10px;background:#EAEDED;padding:10px;" >No opening balance data found !</div>
                            <?php
                        }
                        ?>

                <?php 
                
                if($enquiry_id !=0){
                ?>
                <table class="table table-bordered table-striped" style="width:100%;">
                    <thead>
                        <tr>
                            <th colspan="12" style="background:#EAEDED;padding:10px;width:100%;">Enquiry and Admission Fee</th>
                        </tr>
                        <tr>
                            <th style="border-bottom:1px solid red;">Fee No</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Fee Type</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Fee Months</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Fee Date</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Est Amount</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Prev. Bal.</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Prev. Extra</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Discount</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Received</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Balance</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Extra</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Invoice</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
                        $get_enquiry_invoice=$this->NewFeeModel->get_student_enquiry_and_admission_fee_invoice_information($enquiry_id);
                        if($get_enquiry_invoice){
                            foreach($get_enquiry_invoice as $invoice){
                        ?>
                        <tr>
                            <td style="text-align:center;border-bottom:1px solid red;"><?php echo $invoice['fee_no'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $invoice['fee_type'];?></td>
                            <td style="text-transform:uppercase;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $invoice['months'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo date('d-M-Y',strtotime($invoice['fee_date']));?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $invoice['estimate_amount'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $invoice['balance_amount_added'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $invoice['extra_amount_used'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $invoice['discount'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $invoice['received_amount'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $invoice['balance_amount'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $invoice['extra_amount'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><a href="<?php echo base_url();?>Enquiry/fee_receipt/<?php echo $invoice['fee_no'];?>" class="btn btn-sm btn-danger">View</a></td>
                        </tr>                        
                        <?php
                            }
                        }
                    
                    }
                    ?>
                    </tbody>
                </table>
                <table class="table table-bordered table-striped" style="width:100%;">
                    <thead>
                        <tr>
                            <th colspan="12" style="background:#EAEDED;padding:10px;width:100%;">Monthly Fee</th>
                        </tr>
                        <tr>
                            <th style="border-bottom:1px solid red;">Fee No</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Fee Type</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Fee Months</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Fee Date</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Est Amount</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Prev. Bal.</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Prev. Extra</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Discount</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Received</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Balance</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Extra</th>
                            <th style="border-bottom:1px solid red;border-left:1px solid red;">Invoice</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $get_students_all_invoices=$this->NewFeeModel->get_fee_data_for($sid,$acedemic_session);
                        if($get_students_all_invoices){
                            foreach($get_students_all_invoices as $students_all_invoices){
                        ?>
                        <tr>
                            <td style="text-align:center;border-bottom:1px solid red;"><?php echo $students_all_invoices['fee_no'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $students_all_invoices['fee_type'];?></td>
                            <td style="text-transform:uppercase;text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $students_all_invoices['months'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo date('d-M-Y',strtotime($students_all_invoices['fee_date']));?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $students_all_invoices['estimate_amount'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $students_all_invoices['balance_amount_added'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $students_all_invoices['extra_amount_used'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $students_all_invoices['discount'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $students_all_invoices['received_amount'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $students_all_invoices['balance_amount'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><?php echo $students_all_invoices['extra_amount'];?></td>
                            <td style="text-align:center;border-bottom:1px solid red;border-left:1px solid red;"><a href="<?php echo base_url();?>Fee/invoice/<?php echo $students_all_invoices['fee_no'];?>" class="btn btn-sm btn-danger">View</a></td>
                        </tr>
                        <?php
                            }
                        }
                        ?>
                        
                    </tbody>
                    
                </table>

            </div>
            
            
<!--        </div>-->
<!--    </div>-->
<!--</div>-->
</div>


</body>
</html>