﻿<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Print Bill <?php echo e($order->order_no); ?></title>
    <style>
        @page { size: 80mm auto; margin: 0mm; }
        body { font-family: Arial, sans-serif; font-size: 15px; color: #111; margin: 0; width: 80mm; text-align: left; }
        .receipt { padding: 0; margin: 0; width: 80mm; }
        h1 { font-size: 22px; margin: 0 0 2px; text-align: center; }
        .center { text-align: center; }
        .meta { font-size: 14px; margin-bottom: 2px; text-align: left; }
        .meta-row { display: grid; grid-template-columns: 18mm 2mm 1fr; gap: 0; }
        .total-row { display: flex; justify-content: space-between; margin-top: 6px; margin-bottom: 0; font-weight: bold; font-size: 15px; }
        table { width: 100%; border-collapse: collapse; font-size: 14px; text-align: left; }
        thead tr { border-bottom: 1px dashed #ccc; }
        th, td { padding: 6px 4px; text-align: left; }
        .total { font-weight: bold; margin-top: 12px; text-align: right; }
    </style>
</head>
<body>
    <div class="receipt">
    <?php if(app_setting('app_logo')): ?>
        <div class="flex justify-center center">
            <img src="<?php echo e(asset('storage/branding/icon_bill.jpeg')); ?>" alt="Logo" style="max-width: 40mm; height: auto;">
        </div>
    <?php endif; ?>
    <h1><?php echo e(app_setting('app_name', 'Foodcourt')); ?></h1>
        <div class="meta">
            <div class="meta-row"><span>Order</span><span>:</span><span><?php echo e($order->order_no); ?></span></div>
            <div class="meta-row"><span>Tanggal</span><span>:</span><span><?php echo e($order->tanggal->format('d-m-Y H:i')); ?></span></div>
            <?php ($paidAt = $order->status === 'closed' ? $order->updated_at : null); ?>
            <div class="meta-row"><span>Tgl Bayar</span><span>:</span><span><?php echo e($paidAt ? $paidAt->format('d-m-Y H:i') : '-'); ?></span></div>
            <div class="meta-row"><span>Meja</span><span>:</span><span><?php echo e($order->meja?->no_meja ?? '-'); ?></span></div>
            <div class="meta-row"><span>Pelanggan</span><span>:</span><span><?php echo e($order->nama_pelanggan ?? '-'); ?></span></div>
        </div>
        <table>
            <thead>
                <tr>
                    <th>Menu</th>
                    <th>Qty</th>
                    <th>Harga</th>
                    <th>Subtotal</th>
                </tr>
            </thead>
            <tbody>
                <?php $__currentLoopData = $order->details->where('status', 'active'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $detail): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td><?php echo e($detail->menu?->nama); ?></td>
                        <td><?php echo e($detail->qty); ?></td>
                        <td><?php echo e(format_rupiah($detail->harga)); ?></td>
                        <td><?php echo e(format_rupiah($detail->line_total)); ?></td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>
        </table>
        <div class="total-row">
            <span>Grand Total</span>
            <span><?php echo e(format_rupiah($order->grand_total)); ?></span>
        </div>
        <?php if(($order->discount_amount ?? 0) > 0): ?>
            <div class="total-row" style="font-weight: normal;">
                <span>Diskon<?php echo e($order->discount_name ? ' (' . $order->discount_name . ')' : ''); ?></span>
                <span>-<?php echo e(format_rupiah($order->discount_amount)); ?></span>
            </div>
            <div class="total-row">
                <span>Total Setelah Diskon</span>
                <span><?php echo e(format_rupiah($order->grand_total_after_discount ?? $order->grand_total)); ?></span>
            </div>
        <?php endif; ?>
        <div class="total-row" style="font-weight: normal;">
            <span>Pembayaran</span>
            <span><?php echo e(strtoupper($order->tipe_pembayaran ?? '-')); ?></span>
        </div>
        <?php if(($order->tipe_pembayaran ?? '') !== 'cash' && $order->no_transaksi_pembayaran): ?>
            <div class="total-row" style="font-weight: normal;">
                <span>No Transaksi</span>
                <span><?php echo e($order->no_transaksi_pembayaran); ?></span>
            </div>
        <?php endif; ?>
        <div class="total-row" style="font-weight: normal;">
            <span>Bayar</span>
            <span><?php echo e(format_rupiah($order->amount_paid)); ?></span>
        </div>
        <div class="total-row" style="font-weight: normal;">
            <span>Kembalian</span>
            <span><?php echo e(format_rupiah($order->change_amount ?? 0)); ?></span>
        </div>
        <div class="center" style="margin-top: 10px; font-size: 14px; font-weight: 600;">
            Terima Kasih ❤️
        </div>
    </div>

    <script>
        window.onload = () => {
            window.print();
        };
    </script>
</body>
</html>
<?php /**PATH C:\laragon\www\foodcourt\resources\views\orders\print.blade.php ENDPATH**/ ?>