<style type="text/css">

     table .logo-head{text-align: center !important;}

     table.payrollDatatableReport {       
        border-collapse: collapse;
        border: 0;
        text-align: left !important;
    }
    table.payrollDatatableReport td, table.payrollDatatableReport th {
        padding: 6px 15px;
    }
    table.payrollDatatableReport td, table.payrollDatatableReport th {
        border: 1px solid #ededed;
        border-collapse: collapse;
    }
    table.payrollDatatableReport td.noborder {
        border: none;
        padding-top: 40px;
    }
    table.payrollDatatableReport tbody tr td {
        font-size: 13px;
        padding-left: 5px;
    }

    table.payrollDatatableReport thead tr th {
        font-size: 10px;
        padding-left: 5px;
    }
</style>

<?php if(isset($gra_ret_5_data) && !empty($gra_ret_5_data)){?>

<div class="panel panel-bd"> 
    
    <div class="panel-body">

    <div id="">

        <div style="padding:20px;">

            <div class="row mb-10">
                <table class="table" style="width: 100%;text-align: center;">
                    <thead>
                        <tr>
                            <td class="text-center" style="border:none;">
                                <?php
                                    $path = base_url((!empty($setting->logo)?$setting->logo:''));
                                    $type = pathinfo($path, PATHINFO_EXTENSION);
                                    $data = file_get_contents($path);
                                    $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
                                ?>

                                <img src="<?php echo  $base64; ?>" alt="logo">
                            </td>
                        </tr>
                        <tr>
                            <th class="text-center fs-20" style="border:none;">EMPLOYERS SCHEDULE OF MONTHLY PAYE DEDUCTIONS FROM EMPLOYEES REMUNERATION</th>
                        </tr>
                    </thead>
                </table>
            </div> 

             <br>

            <div class="row mb-10">
                <table class="info-section" cellspacing="0" cellpadding="1" border="0" width="100%">
                    <tbody>
                        <tr>
                            <td width="33%" style="border-top:none;">EMPLOYERs TIN:</td>
                            <td width="33%" style="border-top:none;text-align: center;">1810082912</td>
                            <td width="33%" style="border-top:none;padding-left: 20px;">GRA RET 5</td>
                        </tr>
                        <tr>
                            <td width="33%" style="border-top:none;">NAME OF EMPLOYER:</td>
                            <td width="33%" style="border-top:none;text-align: center;"><?php echo $setting->title;?></td>
                            <td width="33%" style="border-top:none;"></td>
                        </tr>
                        <tr>
                            <td width="33%" style="border-top:none;">ADDRESS OF EMPLOYER a. POSTAL:</td>
                            <td width="33%" style="border-top:none;text-align: center;"><?php echo $setting->address;?></td>
                            <td width="33%" style="border-top:none;"></td>
                        </tr>
                        <tr>
                            <td width="33%" style="border-top:none;">FOR MONTH OF: </td>
                            <td width="33%" style="border-top:none;text-align: center;"><?php echo $month.'-'.$year;?></td>
                            <td width="33%" style="border-top:none;"></td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <br>

            <div class="row">
                <table width="99%" class="payrollDatatableReport table table-striped table-bordered table-hover">
                    <thead>
                        <tr style="background-color: #c3bfbf;color: #000;text-align: center;font-weight: bold;font-size: 14px;">
                            <td>Employee TIN</td>
                            <td>Name of Employee</td>
                            <td>Gross Salary/Wages</td>
                            <td>Cumulative Salary Up To Date</td>
                            <td>Monthly Tax Deduction</td>
                            <td>Cumulative Tax Deduction Up To Date</td>
                        </tr>

                    </thead>
                    <tbody>

                        <?php 

                        $total_gross             = 0.0;
                        $total_cumulative_gross  = 0.0;

                        $total_state_income_tax             = 0.0;
                        $total_cumulative_state_income_tax  = 0.0;

                        foreach ($gra_ret_5_data as $key => $row) {

                            $gra_ret_5_monthly = $gra_ret_5_report_monthly[$row->employee_id];

                            $gross_salary = $gra_ret_5_monthly['gross_salary'];
                            $income_tax   = $gra_ret_5_monthly['income_tax'];
                            $tin_no       = $gra_ret_5_monthly['tin_no'];

                            $total_gross             = $total_gross + floatval($gross_salary);
                            $total_state_income_tax  = $total_state_income_tax + floatval($income_tax);

                            $total_cumulative_gross              = $total_cumulative_gross + floatval($row->cumilative_gross_salary);
                            $total_cumulative_state_income_tax  = $total_cumulative_state_income_tax + floatval($row->cumilative_income_tax);

                        ?>

                        <tr style="text-align: center;">
                            <td style="text-align: center;"><?php echo $tin_no;?></td>
                            <td><?php echo $row->first_name.' '.$row->last_name;?></td>
                            <td><?php echo $setting->currency_symbol.' '.$gross_salary;?></td>
                            <td><?php echo $setting->currency_symbol.' '.$row->cumilative_gross_salary;?></td>
                            <td><?php echo $setting->currency_symbol.' '.$income_tax;?></td>
                            <td><?php echo $setting->currency_symbol.' '.$row->cumilative_income_tax;?></td>
                        </tr>

                         <?php }?>

                        <tr style="background-color: #c3bfbf;color: #000;text-align: center;font-weight: bold;font-size: 14px;">
                            <td>Totals</td>
                            <td></td>
                            <td><?php echo $setting->currency_symbol.' '.$total_gross;?></td>
                            <td><?php echo $setting->currency_symbol.' '.$total_cumulative_gross;?></td>
                            <td><?php echo $setting->currency_symbol.' '.$total_state_income_tax;?></td>
                            <td><?php echo $setting->currency_symbol.' '.$total_cumulative_state_income_tax;?></td>
                        </tr>
                    </tbody>

                    <tfoot>
                       <tr>
                            <td colspan="7" class="noborder">
                                <table border="0" width="100%" style="padding-top: 30px;border: none !important;">                                                
                                <tr style="height:50px;padding-top: 30px;border-left: none !important;">
                                    <td align="left" class="noborder" width="30%">
                                        <div class="border-top"><?php echo display('prepared_by')?>: <b><?php echo $user_info['fullname'];?></b></div>
                                    </td>
                                    <td align="left"  class="noborder" width="30%"> <div class="border-top"><?php echo display('checked_by')?></div>
                                    </td>  
                                     <td align="left"  class="noborder" width="20%">
                                        <div class="border-top"><?php echo display('authorised_by')?></div>
                                    </td>
                                </tr>  
                             </table>  
                            </td>                    
                        </tr> 
                   </tfoot>

                </table>

            </div>

        </div>

    </div>

    </div>
</div>

<?php }else{?>

    <?php if(!isset($gra_ret_5_data)){?>

        <div class="panel panel-bd"> 
            
            <div class="panel-body">

                <div class="row mb-10 text-center">
                    <h3 style="color:green;">Please select a date to get the report !</h3>
                </div>

            </div>

        </div>

    <?php }else{?>

    <div class="panel panel-bd"> 
        
        <div class="panel-body">

            <div class="row mb-10 text-center">
                <h3 style="color:red;">No data available, please check for other date !</h3>
            </div>

        </div>

    </div>

<?php }

}?>

<style type="text/css">
    
    .underline {
        border-bottom: 2px solid #000;
    }

    .justify-content-center {
        justify-content: center;
    }

    .d-flex {
        display: flex;
    }

</style>