<!DOCTYPE html>
<html>
    <head>
        <title>Fee Invoice</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:0px;margin:0px;font-size:13px;}
    </style>
</head>
<body>

<div class="w-100">
    <?php
    $fee_no=$this->uri->segment('3');
    $get_fee_invoice_data=$this->OpeningBalanceModel->get_opening_fee_invoice_info($fee_no);
    if($get_fee_invoice_data){
        foreach($get_fee_invoice_data as $fee){
            $sid=$fee['sid'];
            $student_table='student';
            $get_student_course_info=$this->NewFeeModel->get_studdents_current_course_data($sid,$fee['acedemic_session']);
            if($get_student_course_info){
                foreach($get_student_course_info as $course_info){
                    
            //     }
            // }
            
            $get_student_info=$this->InvoiceModel->get_item_data($sid,$student_table);
            if($get_student_info){
                foreach($get_student_info as $info){
            ?>
        <div class="w-50-1" style="">
            <table style="width:100%;margin:0px;padding:0px;">
                <tr style="width:100% !important;padding:0px !important;">
                    <td style="width:30%;border-bottom:1px solid red;text-align:center;padding:10px;text-align:center;">
                        <img src="<?php echo school_logo_full; ?>" style="">
                    </td>
                    <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:22px;font-weight:700;"><?php echo school_full_name;?></p>
                        <p style="padding:0px;margin:0px;font-size:15px;font-weight:500;"><?php echo school_affiliation; ?></p>
                        <p style="padding:0px;margin:0px;font-size:13px;font-weight:500;"><?php echo school_address;?></p>
                        <p style="padding:0px;margin:0px;font-size:13px;font-weight:500;">Contact : <?php echo contact1;?>, <?php echo contact2;?></p>
                
                    <?php
                    $acedemic_session_table='academic_session_details';
                    $get_ac_sess_data=$this->InvoiceModel->get_item_data($fee['fee_for_ac_sess'],$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:13px;font-weight:500;">Academic Year : <?php echo $ac_sess_data['year_long'];?></p>
                    <?php
                        }
                    }
                    ?>
                    </td>
                </tr>
            </table>
            <table style="width:100%;margin:0px;padding-left:;padding:0px;">
            <tr style="width:100% !important;padding:0px !important;">
                <td style="height:;background:;margin:0px;text-align:left;padding:0px;padding-left:20px;">No. : SJEC-2122-<?php echo $fee_no;?></td>
                
                <td style="width:;height:;background:;margin:0px;text-align:left;padding:0px;padding-right:20px;">Date : <?php echo date('d-m-Y',strtotime($fee['fee_date']));?></td>
            </tr>
            <tr>
                <td style="margin:0px;padding:0px;padding-left:20px;" colspan="2">Name : <?php echo $info['student_name'];?></td>
            </tr>
            <tr>
                
            
            <?php
            if($info['gender'] == 'male'){
            ?>            
            
            <td style="margin:0px;padding:0px;padding-left:20px;" colspan="2">S/o : Mr. <?php echo $info['father_name'];?></td>
            <?php
            }else if($info['gender'] == 'female'){
            ?>
            <td style="margin:0px;padding:0px;padding-left:20px;" colspan="2">D/o : Mr. <?php echo $info['father_name']; ?></td>
            <?php
            }else{
            ?>
            <td style="margin:0px;padding:0px;padding-left:20px;" colspan="2">Father's Name : Mr. <?php echo $info['father_name']; ?></td>
            <?php
            }
            ?>

            </tr>
            <tr>
                <td style="width:;height:;background:;margin:0px;text-align:left;padding:0px;padding-left:20px;">Class : <?php echo $info['class'];?></td>
                <td></td>
        </tr>
            
        </table>
        <table style="width:100%;padding:0px;margin:0px;border-top:2px solid red;">
            
            <tr>
                <th style="text-align:left;border-right:1px solid red;border-bottom:1px solid red;padding-left:20px;">Particulars</th>
                <th style="text-align:left;border-bottom:1px solid red;padding-right:20px;">Total Rs.</th>
            </tr>
        <?php
            $fee_head_table='fee_heads';
            $get_fee_heads=$this->InvoiceModel->get_table_data($fee_head_table);
            if($get_fee_heads){
                foreach($get_fee_heads as $fee_head){
                    if($fee_head['status']==1){
                        echo '<tr style="">';
                        echo '<td style="border-right:1px solid red;padding-left:20px;">'.$fee_head['title'].'</td>';
                        echo '<td style="text-align:center;">-</td>';
                        echo "</tr>";
                    }
                }
            }
        
        ?>
        
        <tr>
            <th style="border-right:1px solid red;border-top:2px solid red;text-align:right;padding-left:20px;">Total  </th>
            <th style="border-top:2px solid red;"><?php echo $fee['estimate_amount'];?></th>
        </tr>
        
        <?php 
        if($fee['discount'] !=0){
        ?>
        <tr>
            <th style="border-right:1px solid red;border-top:2px solid red;text-align:right;padding-left:20px;">Discount</th>
            <th style="border-top:2px solid red;"><?php echo $fee['discount'];?></th>
        </tr>
        <?php 
        }
        ?>
        <tr>
            <th style="border-right:1px solid red;border-top:2px solid red;text-align:right;padding-left:20px;">Received</th>
            <th style="border-top:2px solid red;"><?php echo $fee['received_amount'];?></th>
        </tr>
        <?php 
        if($fee['balance_amount'] !=0){
        ?>
        <tr>
            <th style="border-right:1px solid red;border-top:2px solid red;text-align:right;padding-left:20px;">Balance</th>
            <th style="border-top:2px solid red;"><?php echo $fee['balance_amount'];?></th>
        </tr>
        <?php 
        }
        ?>
            
        </table>
        <table style="margin:0px;width:100%;">
            <tr>
                <td style="border-top:2px solid red;padding-top:30px;padding-left:20px;margin:0px;"><b>Note : </b>Receipt should be reserved for the academic year.</td>
                <td style="border-top:2px solid red;padding-top:30px;text-align:center;">Cashier</td>
            </tr>
        </table>
        
        </div>
        
        <div class="w-50-2" style="">
            <table style="width:100%;margin:0px;padding:0px;">
                <tr style="width:100% !important;padding:0px !important;">
                    <td style="width:30%;border-bottom:1px solid red;text-align:center;padding:10px;">
                        <img src="<?php echo school_logo_full; ?>">
                    </td>
                    <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:22px;font-weight:700;"><?php echo school_full_name;?></p>
                        <p style="padding:0px;margin:0px;font-size:15px;font-weight:500;"><?php echo school_affiliation;?></p>
                        <p style="padding:0px;margin:0px;font-size:13px;font-weight:500;"><?php echo school_address;?></p>
                        <p style="padding:0px;margin:0px;font-size:13px;font-weight:500;">Contact :<?php echo contact1;?>, <?php echo contact2;?></p>
                
                    <?php
                    $acedemic_session_table='academic_session_details';
                    $get_ac_sess_data=$this->InvoiceModel->get_item_data($fee['fee_for_ac_sess'],$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:13px;font-weight:500;">Academic Year : <?php echo $ac_sess_data['year_long'];?></p>
                    <?php
                        }
                    }
                    ?>
                    </td>
                </tr>
            </table>
                        <table style="width:100%;margin:0px;padding-left:;padding:0px;">
            <tr style="width:100% !important;padding:0px !important;">
                <td style="height:;background:;margin:0px;text-align:left;padding:0px;padding-left:20px;">No. : SJEC-2122-<?php echo $fee_no;?></td>
                
                <td style="width:;height:;background:;margin:0px;text-align:left;padding:0px;padding-right:20px;">Date : <?php echo date('d-m-Y',strtotime($fee['fee_date']));?></td>
            </tr>
            <tr>
                <td style="margin:0px;padding:0px;padding-left:20px;" colspan="2">Name : <?php echo $info['student_name'];?></td>
            </tr>
            <tr>
                
            
            <?php
            if($info['gender'] == 'male'){
            ?>            
            
            <td style="margin:0px;padding:0px;padding-left:20px;" colspan="2">S/o : Mr. <?php echo $info['father_name'];?></td>
            <?php
            }else if($info['gender'] == 'female'){
            ?>
            <td style="margin:0px;padding:0px;padding-left:20px;" colspan="2">D/o : Mr. <?php echo $info['father_name']; ?></td>
            <?php
            }else{
            ?>
            <td style="margin:0px;padding:0px;padding-left:20px;" colspan="2">Father's Name : Mr. <?php echo $info['father_name']; ?></td>
            <?php
            }
            ?>

            </tr>
            <tr>
                <td style="width:;height:;background:;margin:0px;text-align:left;padding:0px;padding-left:20px;">Class : <?php echo $info['class'];?></td>
                <td></td>
        </tr>
            
        </table>
                <table style="width:100%;padding:0px;margin:0px;border-top:2px solid red;">
            
            <tr>
                <th style="text-align:left;border-right:1px solid red;border-bottom:1px solid red;padding-left:20px;">Particulars</th>
                <th style="text-align:left;border-bottom:1px solid red;padding-right:20px;">Total Rs.</th>
            </tr>
        <?php
            $fee_head_table='fee_heads';
            $get_fee_heads=$this->InvoiceModel->get_table_data($fee_head_table);
            if($get_fee_heads){
                foreach($get_fee_heads as $fee_head){
                    if($fee_head['status']==1){
                        echo '<tr style="">';
                        echo '<td style="border-right:1px solid red;padding-left:20px;">'.$fee_head['title'].'</td>';
                        echo '<td style="text-align:center;">-</td>';
                        echo "</tr>";
                    }
                }
            }
        
        ?>
        
        <tr>
            <th style="border-right:1px solid red;border-top:2px solid red;text-align:right;padding-left:20px;">Total  </th>
            <th style="border-top:2px solid red;"><?php echo $fee['estimate_amount'];?></th>
        </tr>
        <?php 
        if($fee['discount'] !=0){
        ?>
        <tr>
            <th style="border-right:1px solid red;border-top:2px solid red;text-align:right;padding-left:20px;">Discount</th>
            <th style="border-top:2px solid red;"><?php echo $fee['discount'];?></th>
        </tr>
        <?php 
        }
        ?>
        <tr>
            <th style="border-right:1px solid red;border-top:2px solid red;text-align:right;padding-left:20px;">Received</th>
            <th style="border-top:2px solid red;"><?php echo $fee['received_amount'];?></th>
        </tr>
        <?php 
        if($fee['balance_amount'] !=0){
        ?>
        <tr>
            <th style="border-right:1px solid red;border-top:2px solid red;text-align:right;padding-left:20px;">Balance</th>
            <th style="border-top:2px solid red;"><?php echo $fee['balance_amount'];?></th>
        </tr>
        <?php 
        }
        ?>

        </table>
        <table style="margin:0px;width:100%;">
            <tr>
                <td style="border-top:2px solid red;padding-top:30px;padding-left:20px;margin:0px;"><b>Note : </b>Receipt should be reserved for the academic year.</td>
                <td style="border-top:2px solid red;padding-top:30px;text-align:center;">Cashier</td>
            </tr>
        </table>
        </div>
            <?php
                }
            }
                }
            }
        }
    }
            ?>