<!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');
    $fee__table='student_fee_deleted';
    $get_fee_invoice_data=$this->NewFeeModel->get_invoice_info($fee_no,$fee__table);
    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%;background:;padding:0px;border-bottom:1px solid red;">
                        <img src="<?php echo base_url();?>assets/img/logo.jpg" style="margin:auto;">
                    </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;">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>
                
                    <?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. : 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 $fee['student_class'];?></td>
                <?php
                
        $fee_months=$fee['months'];
        
        
        $array = explode(",",$fee_months);
        $first_word = $array[0];
        $last_word  = $array[count($array)-1];
        $count_months=count($array);
        if($count_months >1){
        ?>
        <td style="padding-right:20px;">Months : <span style="text-transform:uppercase;"><?php 
        echo $first_word; echo '</span> to <span style="text-transform:uppercase;">'; echo $last_word;?></span>
        </td>

        <?php
        }else{
            ?>
            <td>Fee Months : <span style="text-transform:uppercase;"><?php echo $fee_months;?></span></td>
            <?php
        }
        
        ?>
        </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
            $apr_fee=$fee['april'];
            $may_fee=$fee['may'];
            $jun_fee=$fee['june'];
            $jul_fee=$fee['july'];
            $aug_fee=$fee['august'];
            $sep_fee=$fee['september'];
            $oct_fee=$fee['october'];
            $nov_fee=$fee['november'];
            $dec_fee=$fee['december'];
            $jan_fee=$fee['january'];
            $feb_fee=$fee['february'];
            $mar_fee=$fee['march'];
        
            $term_charge=0;
            $monthly_fee=0;
            $computer_fee=0;
            $lab_fee=0;
            $other_fee=0;
            $total_fee=0;
            $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){
                        $aplicable_months=0;
                        $fee_head_amount= 0;
                        $fee_head_amount_total=0;
                        $fee_head_id=$fee_head['id'];
                        $acedemic_session=$fee['acedemic_session'];
                
                        $course=$info['class'];
                        $course_id=$course_info['course_id'];
                        $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'];
                    
                                if($fee['april'] == 1 && $structure['april'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($fee['may'] == 1 && $structure['may'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($fee['june'] == 1 && $structure['june'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($jul_fee ==1 && $structure['july'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($aug_fee ==1 && $structure['august'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($sep_fee == 1 && $structure['september'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($oct_fee == 1 && $structure['october'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($nov_fee == 1 && $structure['november'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($dec_fee == 1 && $structure['december'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($jan_fee == 1 && $structure['january'] == 1){
                                    $aplicable_months=$aplicable_months + 1;
                                }
                                if($feb_fee == 1 && $structure['february'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($mar_fee == 1 && $structure['march'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                    
                    
                            }
                        }
                    echo '<tr style="">';
                    echo '<td style="border-right:1px solid red;padding-left:20px;">'.$fee_head['title'].'</td>';
                    if($fee_head['fee_type']=='monthly'){
                    $fee_head_amount_total =$fee_head_amount * $aplicable_months;
                    $total_fee=$total_fee + $fee_head_amount_total;
                    echo '<td style="padding-right:20px;">Rs. '.($fee_head_amount_total).'</td>';
                    }
                    else{
                        echo '<td>-</td>';
                        // echo '<td>-</td>';
                    }
                    
                    echo '</tr>';
                    
                    }
                }
            }
              
            echo '<tr>
            <td style="border-right:1px solid red;border-top:2px solid red;text-align:right;padding-left:20px;">Total </td>
            <td style="border-top:2px solid red;padding-right:20px;">'.$fee['estimate_amount'].'</td>
            </tr>';  
            if($fee['balance_amount_added'] !=0){
                echo '<tr>
                        <td colspan="" style="text-align:right;border-top:1px solid red;border-right:1px solid red;padding-left:20px;">Previous Balance &nbsp;</td>
                        <td style="border-bottom:1px solid red !important;border-top:1px solid red;padding-right:20px;">'.$fee['balance_amount_added'].'</td>
                    </tr>';
            }
            
            if($fee['extra_amount_used'] !=0){
                echo '<tr>
                        <td colspan="" style="text-align:right;border-top:1px solid red !important;border-right:1px solid red;">Previous Extra &nbsp;</td>
                        <td style="border-top:1px solid red !important;">'.$fee['extra_amount_used'].'</td>
                    </tr>';                
            }

            if($fee['discount'] !=0){
                echo '<tr>
                        <td style="text-align:right;border-right:1px solid red;border-top:1px solid red;">Discount &nbsp;</td>
                        <td style="border-top:1px solid red;">'.$fee['discount'].'</td>
                    </tr>';                
            }

        
        $total_fee = $fee['received_amount'];
        echo '<tr>
        <td colspan="" style="text-align:right;border-right:1px solid red;border-top:1px solid red !important;">Received Rs.</td>
        <td style="border-top:1px solid red !important;">'.$total_fee.'</td>
        </tr>';
            
            if($fee['balance_amount'] !=0){
                echo '<tr>
                        <td style="text-align:right;border-right:1px solid red;border-top:1px solid red !important;">Balance</td>
                        <td style="border-top:1px solid red !important;">'.$fee['balance_amount'].'</td>
                    </tr>';                
            }

        if($fee['extra_amount'] !=0){
        echo '<tr>
            <td style="text-align:right;border-right:1px solid red;border-top:1px solid red;">Extra</td>
            <td style="border-top:1px solid red;>'.$fee['extra_amount'].'</td>
        </tr>';
        }    
            ?>
            <tr>
            </tr>
        </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-2"></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;">
                        <img src="<?php echo base_url();?>assets/img/logo.jpg" style="margin:auto;">
                    </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;">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>
                
                    <?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: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 $fee['student_class'];?></td>
                <?php
                
        $fee_months=$fee['months'];
        
        
        $array = explode(",",$fee_months);
        $first_word = $array[0];
        $last_word  = $array[count($array)-1];
        $count_months=count($array);
        if($count_months >1){
        ?>
        <td style="padding-right:20px;">Months : <span style="text-transform:uppercase;"><?php 
        echo $first_word; echo '</span> to <span style="text-transform:uppercase;">'; echo $last_word;?></span>
        </td>

        <?php
        }else{
            ?>
            <td>Fee Months : <span style="text-transform:uppercase;"><?php echo $fee_months;?></span></td>
            <?php
        }
        
        ?>
        </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
            $apr_fee=$fee['april'];
            $may_fee=$fee['may'];
            $jun_fee=$fee['june'];
            $jul_fee=$fee['july'];
            $aug_fee=$fee['august'];
            $sep_fee=$fee['september'];
            $oct_fee=$fee['october'];
            $nov_fee=$fee['november'];
            $dec_fee=$fee['december'];
            $jan_fee=$fee['january'];
            $feb_fee=$fee['february'];
            $mar_fee=$fee['march'];
        
            $term_charge=0;
            $monthly_fee=0;
            $computer_fee=0;
            $lab_fee=0;
            $other_fee=0;
            $total_fee=0;
            $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){
                        $aplicable_months=0;
                        $fee_head_amount= 0;
                        $fee_head_amount_total=0;
                        $fee_head_id=$fee_head['id'];
                        $acedemic_session=$fee['acedemic_session'];
                
                        $course=$info['class'];
                        $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'];
                    
                                if($fee['april'] == 1 && $structure['april'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($fee['may'] == 1 && $structure['may'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($fee['june'] == 1 && $structure['june'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($jul_fee ==1 && $structure['july'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($aug_fee ==1 && $structure['august'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($sep_fee == 1 && $structure['september'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($oct_fee == 1 && $structure['october'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($nov_fee == 1 && $structure['november'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($dec_fee == 1 && $structure['december'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($jan_fee == 1 && $structure['january'] == 1){
                                    $aplicable_months=$aplicable_months + 1;
                                }
                                if($feb_fee == 1 && $structure['february'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                                if($mar_fee == 1 && $structure['march'] == 1){
                                    $aplicable_months= $aplicable_months + 1;
                                }
                    
                    
                            }
                        }
                    echo '<tr style="">';
                    echo '<td style="border-right:1px solid red;padding-left:20px;">'.$fee_head['title'].'</td>';
                    if($fee_head['fee_type']=='monthly'){
                    $fee_head_amount_total =$fee_head_amount * $aplicable_months;
                    $total_fee=$total_fee + $fee_head_amount_total;
                    echo '<td style="padding-right:20px;">Rs. '.($fee_head_amount_total).'</td>';
                    }
                    else{
                        echo '<td>-</td>';
                        // echo '<td>-</td>';
                    }
                    
                    echo '</tr>';
                    
                    }
                }
            }
              
            echo '<tr>
            <td style="border-right:1px solid red;border-top:2px solid red;text-align:right;padding-left:20px;">Total  </td>
            <td style="border-top:2px solid red;padding-right:20px;">'.$fee['estimate_amount'].'</td>
            </tr>';  
            if($fee['balance_amount_added'] !=0){
                echo '<tr>
                        <td colspan="" style="text-align:right;border-top:1px solid red;border-right:1px solid red;padding-left:20px;">Previous Balance &nbsp;</td>
                        <td style="border-bottom:1px solid red !important;border-top:1px solid red;padding-right:20px;">'.$fee['balance_amount_added'].'</td>
                    </tr>';
            }
            
            if($fee['extra_amount_used'] !=0){
                echo '<tr>
                        <td colspan="" style="text-align:right;border-top:1px solid red !important;border-right:1px solid red;">Previous Extra &nbsp;</td>
                        <td style="border-top:1px solid red !important;">'.$fee['extra_amount_used'].'</td>
                    </tr>';                
            }

            if($fee['discount'] !=0){
                echo '<tr>
                        <td style="text-align:right;border-right:1px solid red;border-top:1px solid red;">Discount &nbsp;</td>
                        <td style="border-top:1px solid red;">'.$fee['discount'].'</td>
                    </tr>';                
            }

        
        $total_fee = $fee['received_amount'];
        echo '<tr>
        <td colspan="" style="text-align:right;border-right:1px solid red;border-top:1px solid red !important;">Received Rs.</td>
        <td style="border-top:1px solid red !important;">'.$total_fee.'</td>
        </tr>';
        
            if($fee['balance_amount'] !=0){
                echo '<tr>
                        <td style="text-align:right;border-right:1px solid red;border-top:1px solid red !important;">Balance</td>
                        <td style="border-top:1px solid red !important;">'.$fee['balance_amount'].'</td>
                    </tr>';
            }
        

        if($fee['extra_amount'] !=0){
        echo '<tr>
            <td style="text-align:right;border-right:1px solid red;border-top:1px solid red;">Extra</td>
            <td style="border-top:1px solid red;>'.$fee['extra_amount'].'</td>
        </tr>';
        }    
            ?>
            <!--<tr>-->
            <!--</tr>-->
        </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
                }
            }
                }
            }
        }
    }
    ?>
    
    
    
    <!--<div class="w-50" style="border-right:1px dotted red;"></div>-->
    <!--<div class="w-50"></div>-->
</div>
</body>
</html>