<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('header', null, []); ?> 
        <div class="flex justify-between items-center print:hidden">
            <h2 class="font-semibold text-xl text-gray-800 leading-tight">
                <?php echo e(__('Payment Receipt')); ?>

            </h2>
            <div class="flex space-x-2">
                <a href="<?php echo e(url()->current()); ?>?ids=<?php echo e(request()->query('ids')); ?>&download=pdf" class="bg-indigo-600 text-white px-4 py-2 rounded shadow hover:bg-indigo-700">
                    Download PDF
                </a>
                <button onclick="window.print()" class="bg-blue-600 text-white px-4 py-2 rounded shadow hover:bg-blue-700">
                    Print Receipt
                </button>
            </div>
        </div>
     <?php $__env->endSlot(); ?>

    <div class="py-12 print:py-0">
        <div class="max-w-xl mx-auto sm:px-6 lg:px-8 print:w-full print:max-w-none">
            <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg print:shadow-none border print:border-0 p-6">
                
                <!-- Business Header -->
                <div class="text-center mb-6 border-b pb-4">
                    <h1 class="text-2xl font-bold uppercase"><?php echo e(config('app.name', 'LANKA ENTERPRISES')); ?></h1>
                    <div class="text-xs text-gray-600 mt-1 mb-2">
                        No: 469, Dangalla, Pepiliyawala, Pugoda.<br>
                        ☎ 0773431790, 0774 557943<br>
                        Email: salis@lankaenterprises.lk | Website: lankaenterprises.lk
                    </div>
                    <p class="text-sm font-bold text-gray-800 border-t border-b py-1 inline-block px-4">OFFICIAL RECEIPT</p>
                    <p class="text-xs text-gray-500 mt-1">
                        Receipt No: <?php echo e($payments->first()->receipt_number ?? 'N/A'); ?> <br>
                        <?php echo e(now()->format('Y-m-d h:i A')); ?>

                    </p>
                </div>

                <!-- Rep & Customer Info -->
                <div class="mb-6 grid grid-cols-2 gap-4 text-sm">
                    <div>
                        <span class="block text-gray-500 text-xs uppercase">Collected By</span>
                        <span class="font-bold"><?php echo e($collector->name); ?></span>
                    </div>
                    <div class="text-right">
                        <span class="block text-gray-500 text-xs uppercase">Customer</span>
                        <span class="font-bold"><?php echo e($customer->name); ?></span>
                        <div class="text-xs"><?php echo e($customer->address); ?></div>
                        <div class="text-xs"><?php echo e($customer->mobile); ?></div>
                    </div>
                </div>

                <!-- Payment Details -->
                <div class="mb-6 bg-gray-50 p-4 rounded border print:border-gray-300">
                    <div class="flex justify-between items-center mb-2">
                        <span class="text-gray-600 font-medium">Total Paid</span>
                        <span class="text-xl font-bold text-gray-900">LKR <?php echo e(number_format($totalPaid, 2)); ?></span>
                    </div>
                    
                    <?php $__currentLoopData = $payments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $payment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="text-xs text-gray-500 mt-1 border-t pt-1 flex justify-between">
                            <span>Method: <?php echo e($payment->method); ?></span>
                            <span><?php echo e($payment->created_at->format('Y-m-d H:i')); ?></span>
                        </div>
                        <?php if($payment->method == 'Cheque'): ?>
                            <div class="text-xs text-gray-500 pl-2">
                                Bank: <?php echo e($payment->bank_name); ?> | No: <?php echo e($payment->cheque_number); ?> <br>
                                Date: <?php echo e($payment->cheque_date ? \Carbon\Carbon::parse($payment->cheque_date)->format('Y-m-d') : '-'); ?>

                            </div>
                        <?php endif; ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>

                <!-- Allocation Details -->
                <div class="mb-6">
                    <h3 class="text-xs font-bold uppercase text-gray-500 mb-2 border-b pb-1">Payment Allocation (FIFO)</h3>
                    <table class="w-full text-sm">
                        <thead>
                            <tr class="text-left text-xs text-gray-500">
                                <th class="pb-2">Invoice</th>
                                <th class="pb-2 text-right">Allocated</th>
                                <th class="pb-2 text-right">Balance Due</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $allocations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $alloc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td class="py-1"><?php echo e($alloc['invoice']); ?></td>
                                    <td class="py-1 text-right font-medium">LKR <?php echo e(number_format($alloc['amount'], 2)); ?></td>
                                    <td class="py-1 text-right text-gray-500"><?php echo e(number_format($alloc['sale_balance_after'], 2)); ?></td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>

                <!-- Other Unpaid Invoices -->
                <?php if($otherUnpaid && $otherUnpaid->count() > 0): ?>
                <div class="mb-6">
                    <h3 class="text-xs font-bold uppercase text-gray-500 mb-2 border-b pb-1">Other Unpaid Invoices</h3>
                    <table class="w-full text-sm">
                        <tbody>
                            <?php $__currentLoopData = $otherUnpaid; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $inv): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td class="py-1 text-gray-500"><?php echo e($inv->invoice_number); ?> (<?php echo e($inv->created_at->format('Y-m-d')); ?>)</td>
                                    <td class="py-1 text-right text-red-500"><?php echo e(number_format($inv->balance_due, 2)); ?></td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
                <?php endif; ?>

                <!-- Total Outstanding -->
                <div class="border-t pt-4">
                    <div class="flex justify-between items-center">
                        <span class="font-bold text-gray-800">Total Outstanding Balance</span>
                        <span class="font-bold text-red-600">LKR <?php echo e(number_format($customer->current_outstanding, 2)); ?></span>
                    </div>
                </div>

                <!-- Footer -->
                <div class="mt-8 text-center text-xs text-gray-400">
                    <p>Thank you for your business!</p>
                    <p>Generated by <?php echo e(config('app.name')); ?> System</p>
                </div>

            </div>
            
            <div class="mt-4 text-center print:hidden">
                <a href="<?php echo e(route('sales.payments.index')); ?>" class="text-blue-600 text-sm hover:underline">Return to Collections</a>
            </div>
        </div>
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH C:\Users\kavishka\Desktop\laravel\bulkLkDeliver\resources\views/sales/payments/receipt.blade.php ENDPATH**/ ?>