<?php $__env->startSection('title', 'Payroll'); ?>
<?php $__env->startSection('content'); ?>
<div class="card">
    <div class="card-header pb-0 d-flex justify-content-between align-items-center flex-wrap">
        <h6 class="mb-0">Payslips</h6>
        <div class="d-flex gap-2">
            <form method="GET" class="d-flex gap-2">
                <select name="month" class="form-select form-select-sm" onchange="this.form.submit()">
                    <?php for($m=1;$m<=12;$m++): ?><option value="<?php echo e($m); ?>" <?php if($month==$m): echo 'selected'; endif; ?>><?php echo e(\Carbon\Carbon::create()->month($m)->format('M')); ?></option><?php endfor; ?>
                </select>
                <input type="number" name="year" value="<?php echo e($year); ?>" class="form-control form-control-sm" style="width:90px" onchange="this.form.submit()">
            </form>
            <a href="<?php echo e(route('payroll.batch', ['month'=>$month,'year'=>$year])); ?>" class="btn btn-sm btn-outline-primary mb-0"><i class="bi bi-file-earmark-pdf me-1"></i>Batch PDF</a>
            <a href="<?php echo e(route('payroll.create', ['month'=>$month,'year'=>$year])); ?>" class="btn btn-sm btn-primary mb-0"><i class="bi bi-plus-lg me-1"></i>New Payslip</a>
        </div>
    </div>
    <div class="card-body">
        <div class="table-responsive"><table class="table align-items-center mb-0">
            <thead><tr class="text-xxs text-uppercase text-secondary"><th class="ps-2">Staff</th><th>Period</th><th>Earning</th><th>Deductions</th><th>Nett</th><th>Status</th><th></th></tr></thead>
            <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $payslips; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr>
                    <td class="ps-2"><a href="<?php echo e(route('payroll.show', $p)); ?>" class="font-weight-bold text-sm"><?php echo e($p->staff->name); ?></a>
                        <div class="text-xs text-muted"><?php echo e($p->staff->passport_no); ?></div></td>
                    <td class="text-sm"><?php echo e($p->periodLabel()); ?></td>
                    <td class="text-sm">RM <?php echo e(number_format($p->total_earning,2)); ?></td>
                    <td class="text-sm">RM <?php echo e(number_format($p->total_deductions,2)); ?></td>
                    <td class="text-sm font-weight-bold">RM <?php echo e(number_format($p->nett_pay,2)); ?></td>
                    <td><span class="badge bg-<?php echo e($p->status==='finalized'?'success':'secondary'); ?>"><?php echo e(ucfirst($p->status)); ?></span></td>
                    <td class="text-end pe-2">
                        <a href="<?php echo e(route('payroll.show', $p)); ?>" class="text-secondary me-2"><i class="bi bi-eye"></i></a>
                        <a href="<?php echo e(route('payslips.pdf', $p)); ?>" class="text-secondary"><i class="bi bi-file-earmark-pdf"></i></a>
                    </td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr><td colspan="7" class="text-center text-muted py-4">No payslips for this period. <a href="<?php echo e(route('payroll.create', ['month'=>$month,'year'=>$year])); ?>">Create one</a>.</td></tr>
            <?php endif; ?>
            </tbody>
        </table></div>
        <div class="mt-3"><?php echo e($payslips->links()); ?></div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /Users/kalaiarasen/projects/myindependent-worker-management/resources/views/payroll/index.blade.php ENDPATH**/ ?>