<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Employee Payslip</title>
    <style>
        @page { margin: 40px 35px; }

        body {
            font-family: DejaVu Sans, sans-serif;
            font-size: 10px;
            color: #000;
            margin: 0;
        }

        /* ---- PAIR ROW ---- */
        .pair-table {
            width: 100%;
            border-collapse: collapse;
            page-break-after: always;
        }
        .pair-table:last-child {
            page-break-after: auto;
        }
        .payslip-cell {
            width: 50%;
            vertical-align: top;
            padding: 0 8px 0 0;
            border-right: 1px dashed #aaa;
        }
        .payslip-cell-right {
            width: 50%;
            vertical-align: top;
            padding: 0 0 0 8px;
        }
        .payslip-cell-only {
            width: 50%;
            vertical-align: top;
        }

        /* ---- HEADER ---- */
        .header-table {
            width: 100%;
            border-bottom: 2px solid #000;
            padding-bottom: 6px;
            margin-bottom: 8px;
        }
        .header-left { vertical-align: top; }
        .header-right {
            vertical-align: top;
            text-align: right;
            width: 70px;
        }
        .company-name {
            font-size: 13px;
            font-weight: bold;
        }
        .company-address {
            font-size: 9px;
            margin-top: 2px;
        }
        .company-logo {
            max-width: 65px;
            max-height: 65px;
        }

        /* ---- TITLE ---- */
        .payslip-title {
            font-size: 11px;
            font-weight: bold;
            margin: 6px 0 10px 0;
        }

        /* ---- EMPLOYEE INFO ---- */
        .info-table {
            width: 100%;
            margin-bottom: 10px;
        }
        .info-table td {
            padding: 1px 0;
            font-size: 10px;
        }
        .info-label { font-weight: bold; width: 80px; }
        .info-colon { width: 8px; }

        /* ---- SALARY TABLE ---- */
        .salary-table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 3px;
        }
        .salary-table td {
            padding: 1px 0;
            font-size: 10px;
            vertical-align: top;
        }
        .col-name  { width: 65%; }
        .col-colon { width: 5%; text-align: right; }
        .col-amt   { width: 30%; text-align: right; }

        .currency-header td {
            font-weight: bold;
            padding-bottom: 3px;
        }
        .bold td { font-weight: bold; }
        .spacer td { padding-top: 5px; }

        /* ---- SECTION HEADING ---- */
        .section-heading {
            font-weight: bold;
            text-decoration: underline;
            margin: 8px 0 3px 0;
            font-size: 10px;
        }

        /* ---- FOOTER ---- */
        .payslip-footer {
            margin-top: 16px;
            font-size: 9px;
        }
    </style>
</head>
<body>

<?php $pairs = collect($payslips)->chunk(2); ?>

<?php $__currentLoopData = $pairs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $pair): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<table class="pair-table">
    <tr>
        <?php $__currentLoopData = $pair; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $idx => $payslip): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <?php
            $employee             = $payslip['employee'];
            $detail               = $payslip['detail'];
            $process              = $payslip['process'];
            $additionsBeforeGross = $payslip['additions_before_gross'];
            $additionsAfterGross  = $payslip['additions_after_gross'];
            $deductions           = $payslip['deductions'];
            $loans                = $payslip['loans'];

            $currency = optional($company->baseCurrency)->symbol ?? 'Rs.';

            $totalAdditionsAfterGross = $additionsAfterGross->sum('amount');
            $totalDeductions          = $deductions->sum('amount');
            $totalLoans               = $loans->sum('amount');
            $totalEarning             = $detail->gross_salary + $totalAdditionsAfterGross;

            $address = trim(implode(', ', array_filter([
                $company->address_line1 ?? null,
                $company->address_line2 ?? null,
            ])));

            $cellClass = ($pair->count() === 1)
                ? 'payslip-cell-only'
                : ($idx === 0 ? 'payslip-cell' : 'payslip-cell-right');
        ?>
        <td class="<?php echo e($cellClass); ?>">

            
            <table class="header-table">
                <tr>
                    <td class="header-left">
                        <div class="company-name"><?php echo e($company->legal_name ?? $company->display_name); ?></div>
                        <?php if($address): ?>
                            <div class="company-address"><?php echo e($address); ?></div>
                        <?php endif; ?>
                    </td>
                    <?php if(!empty($company->logo)): ?>
                    <td class="header-right">
                        <img class="company-logo" src="<?php echo e(public_path($company->logo)); ?>">
                    </td>
                    <?php endif; ?>
                </tr>
            </table>

            
            <div class="payslip-title">EMPLOYEE PAY SLIP</div>

            
            <table class="info-table">
                <tr>
                    <td class="info-label">Month</td>
                    <td class="info-colon">:</td>
                    <td><?php echo e($process->date_from->format('F Y')); ?></td>
                </tr>
                <tr>
                    <td class="info-label">Name</td>
                    <td class="info-colon">:</td>
                    <td><?php echo e(trim($employee->first_name . ' ' . $employee->middle_name . ' ' . $employee->last_name)); ?></td>
                </tr>
                <tr>
                    <td class="info-label">Designation</td>
                    <td class="info-colon">:</td>
                    <td><?php echo e(optional($employee->designation)->name ?? '-'); ?></td>
                </tr>
                <tr>
                    <td class="info-label">EMP No</td>
                    <td class="info-colon">:</td>
                    <td><?php echo e($employee->employee_code); ?></td>
                </tr>
                <tr>
                    <td class="info-label">EPF No</td>
                    <td class="info-colon">:</td>
                    <td><?php echo e($employee->epf_no ?? '-'); ?></td>
                </tr>
            </table>

            
            <table class="salary-table">
                <tr class="currency-header">
                    <td class="col-name"></td>
                    <td class="col-colon"></td>
                    <td class="col-amt"><?php echo e($currency); ?></td>
                </tr>
                <tr class="bold">
                    <td class="col-name">Basic Salary</td>
                    <td class="col-colon">:</td>
                    <td class="col-amt"><?php echo e(number_format($detail->basic_salary, 2)); ?></td>
                </tr>
                <?php $__currentLoopData = $additionsBeforeGross; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $addition): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                    <td class="col-name"><?php echo e(optional($addition->addition)->payslip_label ?: optional($addition->addition)->name); ?></td>
                    <td class="col-colon">:</td>
                    <td class="col-amt"><?php echo e($addition->amount > 0 ? number_format($addition->amount, 2) : '-'); ?></td>
                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <tr class="bold">
                    <td class="col-name">Gross Salary</td>
                    <td class="col-colon">:</td>
                    <td class="col-amt"><?php echo e(number_format($detail->gross_salary, 2)); ?></td>
                </tr>
                <?php $__currentLoopData = $additionsAfterGross; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $addition): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                    <td class="col-name"><?php echo e(optional($addition->addition)->payslip_label ?: optional($addition->addition)->name); ?></td>
                    <td class="col-colon">:</td>
                    <td class="col-amt"><?php echo e($addition->amount > 0 ? number_format($addition->amount, 2) : '-'); ?></td>
                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <tr class="bold spacer">
                    <td class="col-name">Total Earning</td>
                    <td class="col-colon">:</td>
                    <td class="col-amt"><?php echo e(number_format($totalEarning, 2)); ?></td>
                </tr>
            </table>

            
            <div class="section-heading">Deductions:</div>
            <table class="salary-table">
                <?php $__currentLoopData = $deductions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $deduction): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                    <td class="col-name"><?php echo e(optional($deduction->deduction)->payslip_label ?: optional($deduction->deduction)->name); ?></td>
                    <td class="col-colon">:</td>
                    <td class="col-amt"><?php echo e($deduction->amount > 0 ? number_format($deduction->amount, 2) : '-'); ?></td>
                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <?php $__currentLoopData = $loans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $loan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                    <td class="col-name"><?php echo e(optional(optional($loan->employeeLoan)->loan)->name ?? 'Loan'); ?> Recovery</td>
                    <td class="col-colon">:</td>
                    <td class="col-amt"><?php echo e($loan->amount > 0 ? number_format($loan->amount, 2) : '-'); ?></td>
                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <tr class="bold spacer">
                    <td class="col-name">Total Deductions</td>
                    <td class="col-colon">:</td>
                    <td class="col-amt"><?php echo e(number_format($totalDeductions + $totalLoans, 2)); ?></td>
                </tr>
            </table>

            
            <table class="salary-table" style="margin-top:5px;">
                <tr class="bold">
                    <td class="col-name">*Net Salary Payable</td>
                    <td class="col-colon">:</td>
                    <td class="col-amt"><?php echo e(number_format($detail->net_salary, 2)); ?></td>
                </tr>
            </table>

            
            <div class="section-heading" style="margin-top:10px;">Company Contribution:</div>
            <table class="salary-table">
                <tr>
                    <td class="col-name">EPF 12%</td>
                    <td class="col-colon">:</td>
                    <td class="col-amt"><?php echo e(number_format($detail->epf_12, 2)); ?></td>
                </tr>
                <tr>
                    <td class="col-name">ETF 3%</td>
                    <td class="col-colon">:</td>
                    <td class="col-amt"><?php echo e(number_format($detail->etf_3, 2)); ?></td>
                </tr>
            </table>

            
            <div class="payslip-footer">
                <div>*Salary remitted to your Bank Account on <?php echo e($process->date_to->format('d.m.Y')); ?></div>
                <div>Note: &nbsp; Period considered – <?php echo e($process->date_from->format('jS F Y')); ?> to <?php echo e($process->date_to->format('jS F Y')); ?></div>
            </div>

        </td>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        <?php if($pair->count() === 1): ?>
        <td style="width:50%;"></td>
        <?php endif; ?>
    </tr>
</table>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

</body>
</html>
<?php /**PATH /media/madu/E8460E1D460DECDE/projects/laraoffice/app/Modules/HR/Reports/Providers/../Views/pdf/payslip.blade.php ENDPATH**/ ?>