<!DOCTYPE html>
<html>
    <head>
        <title>Fee Invoice</title>
        <link rel="preconnect" href="https://fonts.googleapis.com">
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link href="https://fonts.googleapis.com/css2?family=Inconsolata:wght@200;300;400;500;600;700&display=swap" rel="stylesheet"> 
        <style>
            .w-100{
                width:100%;
                /*background-image:url('<?php echo base_url(); ?>assets/img/logo.jpg');*/
            }
            /*.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-50-1{width:50%;float:left;height:100%;border-right:1px dotted red;
                 background-image: url("<?php echo school_logo_full; ?>");
                opacity: 0.1;
                background-repeat: no-repeat;
                background-size: 40% auto;
                background-position: center;
                z-index: -1;
            }
            .w-50-2{
                width:50%;
                float:left;
                height:100%;
                background-image: url("<?php echo school_logo_full; ?>");
                opacity: 0.1;
                background-repeat: no-repeat;
                background-size: 40% auto;
                background-position: center;
                z-index: -1;
            }
            
            .w-2{
                width:0%;
                float:left;
                
            }
            img{
                height:80px;
                width:auto;
            }
            html{
                padding:0px;
                margin:0px;
            }
            body{
                padding:0px;
                margin:0px;
                font-size:11px;
                font-family: 'Inconsolata', monospace; 
            }
        </style>
    </head> 
    <body>
        <?php
        $tid=$this->session->userdata('tid');
        $staff_table='school_staff';
        $get_user_info=$this->InvoiceModel->get_item_data($tid,$staff_table);
        $user_name='';
        $user_salutation='';
    
        $fee_staff_name='';
        if($get_user_info){
            foreach($get_user_info as $user_info){
                $user_salutation=$user_info['salutation'];
                $user_name=$user_info['name'];
            }
        }
        
        $fee_no=$this->uri->segment('3');
        $get_fee_invoice_data=$this->InvoiceModel->get_fee_data($fee_no);
        if($get_fee_invoice_data){
            foreach($get_fee_invoice_data as $fee){
                $fee_staff_id=$fee['tid'];
            
                $get_fee_staff_info=$this->InvoiceModel->get_item_data($fee_staff_id,$staff_table);
                if($get_fee_staff_info){
                    foreach($get_fee_staff_info as $fee_staff_info){
                        $fee_staff_name=$fee_staff_info['salutation']." ".$fee_staff_info['name'];
                    }
                }
                
                
                $enquiry_id=$fee['enquiry_id'];
                $enquiry_table='enquiry';
                $get_student_info=$this->InvoiceModel->get_item_data($enquiry_id,$enquiry_table);
                if($get_student_info){
                    foreach($get_student_info as $info){
                        
                        $course_id=$info['course_id'];
                        $course_table='courses';
                        $subject_stream='';
                        $get_course_info=$this->InvoiceModel->get_item_data($course_id,$course_table);
                        if($get_course_info){
                            foreach($get_course_info as $course_info){
                                $subject_stream=$course_info['subject_stream'];
                            }
                        }
        ?>
        <div class="w-100">
            <div class="w-50-1">
                <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;text-align:center;">
                        <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['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: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. : <?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="padding-left:20px;">Name : <span style="text-transform:uppercase;"><?php echo $info['first_name']; echo " "; echo $info['last_name'];?></span></td>
                    <td style="padding-right:20px;">Class : <?php echo $info['class']; echo " "; echo $subject_stream;?></td>
                </tr>
                <tr><td colspan="2" style="padding-left:20px;padding-right:20px;">Father's Name : <?php echo $info['father_name'];?></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
                $course=$info['class'];

                $acedemic_session=$fee['acedemic_session'];
                $fee_info=$fee['fee_info'];
                $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){
                        $fee_head_amount=0;
                        if($fee_head['status']==1){
                            $fee_head_id=$fee_head['id'];
                        if($fee_info == $fee_head['fee_info']){
                            
                            
                            $get_fee_structure = $this->InvoiceModel->get_fee_structure($fee_head_id,$acedemic_session,$course_id);
                            if($get_fee_structure){
                                foreach($get_fee_structure as $structure){
                                    $fee_head_amount = $fee_head_amount + $structure['amount'];
                                }
                            }
                            
                            
                        }
                        
                        echo '<tr>';
                        echo '<td style="padding-left:20px;border-right:1px solid red;">'.$fee_head['title'].'</td>';
                        if($fee_head_amount ==0){
                        echo '<td style="padding-right:20px;">-</td>';    
                        }else{
                        echo '<td style="padding-right:20px;">'.$fee_head_amount.'</td>';
                        }
                        echo '</tr>';
                    }
                    
                }
                
                }
                ?>
                    <tr>
                        <td  style="padding-left:20px;border-right:1px solid red;border-top:2px solid red;">Total Rs.</td>
                        <td style="border-top:2px solid red;"><?php echo $fee['estimate_amount'];?></td>
                    </tr>
                    <tr>
                        <td style="padding-left:20px;border-right:1px solid red;border-top:1px solid red;">Discount</td>
                        <td style="border-top:1px solid red;"><?php echo $fee['discount'];?></td>
                    </tr>
                    
                    <tr>
                        <td style="padding-left:20px;border-top:1px solid red;border-right:1px solid red;">Received Rs.</td>
                        <td style="border-top:1px solid red;"><?php echo $fee['received_amount'];?></td>
                    </tr>
                    
                    <tr>
                        <td style="padding-left:20px;border-top:1px solid red;border-right:1px solid red;border-bottom:2px solid red;">Balance</td>
                        <td style="border-top:1px solid red;border-bottom:2px solid red;"><?php echo $fee['balance_amount'];?></td>
                    </tr>
                </table>
                <!--<br><br>-->
                <!--<p style="padding-left:20px;"><b>Note : </b><span style="">Receipt should be reserved for the academic year.</span><span style="text-align:right;"> &nbsp; &nbsp;Cashier</span></p>-->
                
                <table style="margin:0px;width:100%;">
                        <tr style="padding:0px;margin:0px;">
                            <th style="padding:0px;margin:0px;">Received By :</th>
                            <th style="padding:0px;margin:0px;"><?php echo $fee_staff_name; ?></th>
                        </tr>
                        <tr>
                            <td style="border-top:2px solid red;padding-left:20px;margin:0px;" colspan="2"><b>Note:</b>Receipt should be reserved for the academic year.</td>
                        </tr>
                        <tr>
                            <td colspan="2" style="border-top:1px dotted red; text-align:center;font-size:6px;">Printed by : <?php echo $user_salutation; echo " "; echo $user_name; echo " "; echo date('d-M-Y H:i:sa'); ?></td>
                        </tr>
                    </table>
            </div>
            <div class="w-50-2">
                
                <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;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['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: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. : <?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="padding-left:20px;">Name : <span style="text-transform:uppercase;"><?php echo $info['first_name']; echo " "; echo $info['last_name']; ?></span></td>
                        <td style="padding-right:20px;">Class : <?php echo $info['class']; echo " "; echo $subject_stream; ?></td>
                    </tr>
                    <tr>
                        <td colspan="2" style="padding-left:20px;padding-right:20px;">Father's Name : <?php echo $info['father_name']; ?></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
                $course=$info['class'];
                $acedemic_session=$fee['acedemic_session'];
                $fee_info=$fee['fee_info'];
                $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){
                        $fee_head_amount=0;
                        if($fee_head['status']==1){
                            $fee_head_id=$fee_head['id'];
                        if($fee_info == $fee_head['fee_info']){
                            
                            
                            $get_fee_structure = $this->InvoiceModel->get_fee_structure($fee_head_id,$acedemic_session,$course_id);
                            if($get_fee_structure){
                                foreach($get_fee_structure as $structure){
                                    $fee_head_amount = $fee_head_amount + $structure['amount'];
                                }
                            }
                            
                            
                        }
                        
                        echo '<tr>';
                        echo '<td style="padding-left:20px;border-right:1px solid red;">'.$fee_head['title'].'</td>';
                        if($fee_head_amount ==0){
                        echo '<td style="padding-right:20px;">-</td>';    
                        }else{
                        echo '<td style="padding-right:20px;">'.$fee_head_amount.'</td>';
                        }
                        echo '</tr>';
                    }
                    
                }
                
                }
                ?>
                    <tr>
                        <td  style="padding-left:20px;border-right:1px solid red;border-top:2px solid red;">Total Rs.</td>
                        <td style="border-top:2px solid red;"><?php echo $fee['estimate_amount'];?></td>
                    </tr>
                    <tr>
                        <td style="padding-left:20px;border-right:1px solid red;border-top:1px solid red;">Discount</td>
                        <td style="border-top:1px solid red;"><?php echo $fee['discount'];?></td>
                    </tr>
                    
                    <tr>
                        <td style="padding-left:20px;border-top:1px solid red;border-right:1px solid red;">Received Rs.</td>
                        <td style="border-top:1px solid red;"><?php echo $fee['received_amount'];?></td>
                    </tr>
                    
                    <tr style="border-bottom:2px solid red;">
                        <td style="padding-left:20px;border-top:1px solid red;border-right:1px solid red;border-bottom:2px solid red;">Balance</td>
                        <td style="border-top:1px solid red;border-bottom:2px solid red;"><?php echo $fee['balance_amount'];?></td>
                    </tr>
                    
                    <tr>

            </table>
            <!--<br><br>-->
            <!--<p style="padding-left:20px;"><b>Note : </b>Receipt should be reserved for the academic year. &nbsp; &nbsp; Cashier</p>-->
                <table style="margin:0px;width:100%;">
                        <tr style="padding:0px;margin:0px;">
                            <th style="padding:0px;margin:0px;">Received By :</th>
                            <th style="padding:0px;margin:0px;"><?php echo $fee_staff_name; ?></th>
                        </tr>
                        <tr>
                            <td style="border-top:2px solid red;padding-left:20px;margin:0px;" colspan="2"><b>Note:</b>Receipt should be reserved for the academic year.</td>
                        </tr>
                        <tr>
                            <td colspan="2" style="border-top:1px dotted red; text-align:center;font-size:6px;">Printed by : <?php echo $user_salutation; echo " "; echo $user_name; echo " "; echo date('d-M-Y H:i:sa'); ?></td>
                        </tr>
                </table>
            </div>
        </div>
        <?php
                    }
                }
            }
        }
        ?>
    </body>
</html>