

<?php
    use Carbon\Carbon;
    Carbon::setLocale('id');

     // MENGAMBIL PARAMETER DARI URL
    $tampilkanPpn = request()->query('ppn', 'yes') == 'yes'; // Default: 'yes'

    // ASUMSI: $PPN dan $totalBiaya sudah dihitung di Controller.
    // Jika $PPN adalah PPN murni (10%) dan $totalBiaya adalah (Total Harga Pesanan + Ongkir + PPN)

    $ppnDitampilkan = 0;
    $totalAkhir = $totalBiaya; // Asumsi $totalBiaya sudah termasuk PPN

    if (!$tampilkanPpn) {
        // Jika PPN TIDAK ditampilkan, kita kurangi PPN dari total biaya
        $ppnDitampilkan = 0;
        $totalAkhir = $totalBiaya - $PPN;
    } else {
        // Jika PPN ditampilkan, gunakan nilai PPN yang sebenarnya
        $ppnDitampilkan = $PPN;
        $totalAkhir = $totalBiaya;
    }
?>

<style>
    .printable-area {
        width: auto; /* Atur lebar sesuai ukuran struk thermal Anda */
        height: auto;
        align-content: center;
        font-family: Arial, Helvetica, sans-serif;
        /* margin: 0 auto; Agar berada di tengah */
    }

    .table-transaksi {
        width: auto;
        page-break-inside: avoid; /* Hindari pemutusan halaman dalam tabel */
    }

    .table-transaksi thead tr th {
        width: auto;
    }

    .table-transaksi tbody tr td {
        font-size: 38px;
    }

    .conten-nota {
        font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
        font-size: px; /* Sesuaikan ukuran font */
        margin: 0; /* Hapus margin untuk menghemat ruang */
    }

    .nota-head {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    /* Tambahkan properti ini untuk memastikan halaman tidak terpisah */
    @media print {
        .printable-area, .table-transaksi, .section_nama_pesanan_qty_harga, .conten-nota {
            page-break-inside: avoid; /* Hindari pemutusan halaman dalam area ini */
            page-break-after: auto; /* Tambahkan properti ini untuk menghindari pemisahan halaman */
            page-break-before: auto; /* Tambahkan properti ini untuk menghindari pemisahan halaman */
        }
        .printable-area {
            break-inside: avoid; /* Untuk mendukung berbagai browser */
        }
    }
</style>

<?php echo $__env->make('component.head', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>


<div class="printable-area">
    <!-- Isi dari nota transaksi yang ingin dicetak -->
    <div style="text-align:center;">
        <img style="width: 45vw; margin: 0 auto;"  src="<?php echo e(asset('asset-modified/image/logo-usaha.jpg')); ?>" alt="img warung makan">
        <p style="font-size: 37px;">Pusat  : Jln. Wahidin II No. 3A Jakarta Pusat Telp. 021-3810137</p>
        <p style="font-size: 37px;">Cabang : Jln. Raya Radar Auri No.63 Cisalak - Depok Telp. 021-8733461 Wa.0857 8888 6617</p></div>
    <h1 style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-size:40px;" class="text-center">Nota transaksi</h1>
    <div class="text-center" style="font-size: 50px;">
        <?php $__currentLoopData = $transaksiSerupa; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tS): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="col" style="font-size: 55px;">
            <?php if($loop->first || $tS->jenis_pesanan != $transaksiSerupa[$loop->index - 1]->jenis_pesanan): ?>
            <td style="vertical-align:middle;" rowspan="<?php echo e($transaksiSerupa->where('jenis_pesanan', $tS->jenis_pesanan)->count()); ?>">
                <?php echo e(Carbon::parse($tS->created_at)->translatedFormat('l, d F Y')); ?>

            </td>
            
            <?php endif; ?>
        </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>
    <div class="text-center" style="font-size: 50px;">
        <?php $__currentLoopData = $transaksiSerupa; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tS): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="col" style="font-size: 55px;">
            <?php if($loop->first || $tS->jenis_pesanan != $transaksiSerupa[$loop->index - 1]->jenis_pesanan): ?>
            <td style="vertical-align:middle; text-align:center; align-items:center;" rowspan="<?php echo e($transaksiSerupa->where('jenis_pesanan', $tS->jenis_pesanan)->count()); ?>"> 
                <?php echo e($tS->jenis_pesanan); ?> 
            </td>
            <br>
            <td style="vertical-align:middle; text-align:center; align-items:center;" rowspan="<?php echo e($transaksiSerupa->where('jenis_pesanan', $tS->jenis_pesanan)->count()); ?>"> 
                <?php echo e($tS->status_bayar); ?> 
            </td>
            <?php endif; ?>
        </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>
    
    <h3 class="text-center">----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</h3>
    
    <div class="row">
        <div class="col" style="text-align: start;">
            <div>
                <h4 style="font-weight: 700; font-size:45px">Kode Pesanan</h4>
            </div>
            <?php $__currentLoopData = $transaksiSerupa; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tS): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>            
                <div style="font-size: 45px;">
                    <?php if($loop->first || $tS->kode_pesanan != $transaksiSerupa[$loop->index - 1]->kode_pesanan): ?>
                    <td style="vertical-align:middle; font-size:30px text-align:center; align-items:center;" rowspan="<?php echo e($transaksiSerupa->where('kode_pesanan', $tS->kode_pesanan)->count()); ?>"> 
                    <?php echo e($tS->kode_pesanan); ?> 
                    </td>
                    <?php endif; ?>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>               
            <div>
                <h4 style="font-weight: 700; font-size:45px">Pembayaran</h4>
            </div>
            <div>
                <?php $__currentLoopData = $transaksiSerupa; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tS): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>            
                <div style="font-size: 45px;">
                    <?php if($loop->first || $tS->metode_bayar != $transaksiSerupa[$loop->index - 1]->metode_bayar): ?>
                    <td style="vertical-align:middle; color:green; text-align:center; align-items:center;" rowspan="<?php echo e($transaksiSerupa->where('metode_bayar', $tS->metode_bayar)->count()); ?>"> 
                    <?php echo e($tS->metode_bayar); ?> 
                    </td>
                    <?php endif; ?>
                </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>  
            </div>
        </div>
            
        <div class="col" style="text-align: end;">
            <div>
                <h4 style="font-weight: 700; font-size:45px">Kasir</h4>
            </div>
            <?php $__currentLoopData = $transaksiSerupa; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tS): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div style="font-size: 45px;">
                    <?php if($loop->first || $tS->nama_kasir != $transaksiSerupa[$loop->index - 1]->nama_kasir): ?>
                    <td style="vertical-align:middle; font-size:30px text-align:center; align-items:center;" rowspan="<?php echo e($transaksiSerupa->where('nama_kasir', $tS->nama_kasir)->count()); ?>"> 
                       <?php echo e($tS->nama_kasir); ?> 
                    </td>
                    <?php endif; ?>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <div>
                <h4 style="font-weight: 700; font-size:45px">Nama Pemesan</h4>
            </div>
            <?php $__currentLoopData = $transaksiSerupa; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tS): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div style="font-size: 45px;">
                    <?php if($loop->first || $tS->nama_pemesan != $transaksiSerupa[$loop->index - 1]->nama_pemesan): ?>
                    <td style="vertical-align:middle; text-align:center; align-items:center;" rowspan="<?php echo e($transaksiSerupa->where('nama_pemesan', $tS->nama_pemesan)->count()); ?>"> 
                    <?php echo e($tS->nama_pemesan); ?> 
                    </td>
                    <?php endif; ?>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>
    </div>
    
    <h1 class="text-center">---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</h1>
    
    <div class="row section_nama_pesanan_qty_harga">
        <div class="col">
            <table style="width: 100%;">
                <?php $__currentLoopData = $transaksiSerupa; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dT): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr style="font-size:60px;">
                        <td><?php echo e($dT->pesanan); ?></td>
                        <td style="font-size: 30px; text-align: center;">X</td>
                        <td style="text-align: center;"><?php echo e($dT->qty); ?></td>
                        <td class="text-center"><?php echo e(number_format($dT->harga_pesanan_plus_qty, 0, ',', '.')); ?></td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </table>
        </div>
    </div>
    
    <h1 class="text-center">----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</h1>
    
    <h1 style="font-size: 45px; font-weight:800;">Payment Details</h1>
    
    <div class="row conten-nota">
        <div class="col">
            <br>
            <div style="font-size: 55px">
                <h1>Total</h1>
            </div>
            <div style="font-size: 55px">
                <h1>Ongkir</h1>
            </div>
        </div>
        <div class="col" style="text-align: end;">
            <div style="font-size: 55px">
                <?php $__currentLoopData = $transaksiSerupa; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tS): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div>
                        <td rowspan="<?php echo e($transaksiSerupa->where('total_harga_pesanan', $tS->total_harga_pesanan)->count()); ?>"> 
                        <?php if($loop->first || $tS->total_harga_pesanan != $transaksiSerupa[$loop->index - 1]->total_harga_pesanan): ?>
                        <?php echo e(number_format($tS->total_harga_pesanan, 0,',','.')); ?> 
                        <?php endif; ?>
                        </td>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
                <div style="font-size: 55px">
                        <?php $__currentLoopData = $transaksiSerupa; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tS): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div>
                                <td style="" rowspan="<?php echo e($transaksiSerupa->where('ongkir', $tS->ongkir)->count()); ?>"> 
                                <?php if($loop->first || $tS->ongkir != $transaksiSerupa[$loop->index - 1]->ongkir): ?>
                                <?php echo e(number_format($tS->ongkir, 0,',','.')); ?> 
                                <?php endif; ?>
                                </td>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                </div>
                <?php if($tampilkanPpn): ?>
                    <div class="row" style="font-size: 55px" >
                        <div class="col">
                            <th>PPN (10%)</th>
                        </div>
                        <div class="col" style="text-align: end; display:flex; flex-direction:column; margin:0; padding:0;">
                            <td style="text-align: end;">
                                <?php echo e(number_format($ppnDitampilkan, 0,',','.')); ?>

                            </td>
                        </div>
                    </div>
                <?php endif; ?>

                <div class="row" style="font-size: 55px" >
                    <div class="col">
                        <th>Total Harga</th>
                    </div>
                    <div class="col" style="text-align: end; display:flex; flex-direction:column; margin:0; padding:0;">
                        <td style="text-align: end;">
                            <?php echo e(number_format($totalAkhir, 0,',','.')); ?>

                        </td>
                    </div>
                </div>
      </div>
      <?php if($transaksiSerupa->where('alamat_delivery_order', '!=', null)->isNotEmpty() || $transaksiSerupa->where('no_hp_customer', '!=', null)->isNotEmpty()): ?>
      <h1 class="text-center">-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</h1>
      <h1 style="font-size: 40px; font-weight:600">Detail Delivery Order</h1>
      <p style="font-size: 50px;">
        <?php $__currentLoopData = $transaksiSerupa; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tS): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <?php if($loop->first || $tS->alamat_delivery_order != $transaksiSerupa[$loop->index - 1]->alamat_delivery_order): ?>
        <td rowspan="<?php echo e($transaksiSerupa->where('alamat_delivery_order', $tS->alamat_delivery_order)->count()); ?>"> 
        <?php echo e($tS->alamat_delivery_order); ?> 
        </td>
        <?php endif; ?>
        <?php if($loop->first || $tS->no_hp_customer != $transaksiSerupa[$loop->index - 1]->no_hp_customer): ?>
        <td rowspan="<?php echo e($transaksiSerupa->where('no_hp_customer', $tS->no_hp_customer)->count()); ?>"> 
        <?php echo e($tS->no_hp_customer); ?> 
        </td>
        <?php endif; ?>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
      </p>
    <?php endif; ?>
      <br>
      <tfoot class="mt-2">
        <span style="font-size: 35px">Selamat menikmati,</span> <br>
        <span style="font-size: 35px" >Senang melayani anda,</span>
      </tfoot>
</div>

<script type="text/javascript">
    window.onload = function() {
        window.print();
    }
</script>

<?php echo $__env->make('component.footer-script', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<?php /**PATH D:\jejakcoding\Penawaran aplikasi kasir\kasir24\resources\views/Transaksi/layout-transaksi/print-nota.blade.php ENDPATH**/ ?>