
<?php $__env->startSection('konten-list-transaksi-lunas'); ?>

<main class="app-main"> 
<?php echo $__env->make('flash-message', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php echo $__env->make('Transaksi/layout-transaksi/navbar-transaksi', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <div class="flex items-center justify-center row m-2">
        <table class="table table-transaksi">
            <thead>
                <tr>

                    
                    <style>
                        .table thead tr th {
                            text-align: center;
                            font-size: 9px;
                        }
                        .table tbody tr td {
                            text-align: center;
                            font-size: 8px;
                        }
                    </style>
                    <th class="text-center" scope="col">No</th>
                    <th class="text-center" scope="col">Kode Pesanan</th>
                    <th scope="col">Pemesan</th>
                    <th scope="col">Nomor Meja</th>
                    <th scope="col">Metode Bayar</th>
                    <th scope="col">Jenis Pesanan</th>
                    <th scope="col">Status Bayar</th>
                    <th scope="col">Total Harga</th>
                    <th scope="col">PPN 10%</th>
                    <th class="text-center" scope="col">Action</th>
                </tr>
            </thead>
            <tbody>
                <?php $__currentLoopData = $dataTransaksiLunas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dTL): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                        <td><?php echo e($dataTransaksiLunas->firstItem() + $loop->index); ?></td>
                        <td style="vertical-align: middle; color: green; font-weight: 500; text-align: center; align-items: center;">
                            <a class="text-xs btn fa-xl" href="#" onclick="konfirmasiCetak(event, '<?php echo e(route('print-nota-transaksi', ['id' => $dTL->id])); ?>')"><i class="fa-solid fa-print"></i></a>
                            <?php if(!empty($dTL->id)): ?>
                            <a href="<?php echo e(route('TambahPesananPadaListTransaksi',['kode_pesanan' => $dTL->kode_pesanan])); ?>">
                                <?php echo e($dTL->kode_pesanan); ?>

                            </a>
                        <?php else: ?>
                            <span style="color:red;">ID tidak ditemukan</span>
                        <?php endif; ?>
                        </td>
                        <td style="vertical-align: middle; color: green; font-weight: 600; text-align: center; align-items: center;">
                            <?php echo e($dTL->nama_pemesan); ?>

                        </td>
                        <td style="vertical-align: middle; color: green; font-weight: 600; text-align: center; align-items: center;">
                            <?php echo e($dTL->nomor_meja); ?>

                        </td>
                        <td style="vertical-align: middle; color: <?php echo e($dTL->metode_bayar == 'On Process' ? 'gold' : ($dTL->metode_bayar == 'Lunas' ? 'green' : 'black')); ?>; font-weight: 600; text-align: center; align-items: center;">
                            <a href="<?php echo e(route('updatemetodebayar', ['id' => $dTL->id])); ?>">
                                <?php echo e($dTL->metode_bayar); ?>

                                <i class="fa-solid fa-circle-check"></i>
                            </a>
                        </td>
                        <td style="vertical-align: middle; color: green; font-weight: 600; text-align: center; align-items: center;">
                            <?php echo e($dTL->jenis_pesanan); ?>

                        </td>
                        <td style="vertical-align: middle; color: <?php echo e($dTL->status_bayar == 'On Process' ? 'gold' : ($dTL->status_bayar == 'Lunas' ? 'green' : 'black')); ?>; font-weight: 600; text-align: center; align-items: center;">
                            <a href="<?php echo e(route('statusListTransaksiUpdate', ['id' => $dTL->id])); ?>">
                                <?php echo e($dTL->status_bayar); ?>

                                <i class="fa-solid fa-circle-check"></i>
                            </a>
                        </td>
                        <td style="vertical-align: middle; color: green; font-weight: 600; text-align: center; align-items: center;">
                            Rp <?php echo e(number_format($dTL->total_harga_pesanan, 2, ',', '.')); ?>

                        </td>
                        <td style="vertical-align: middle; color: green; font-weight: 600; text-align: center; align-items: center;">
                            Rp <?php echo e(number_format($dTL->ppn, 2, ',', '.')); ?>

                        </td>
                        <td style="vertical-align: middle; text-align: center;" class="text-center">
                            <button>
                                <a class="text-xs btn" href="<?php echo e(route('hapus-list-transaksi', ['id' => $dTL->id])); ?>" onclick="return confirmationDelete()"><i class="fa-solid fa-circle-xmark"></i></a>
                                <a class="text-xs btn" href="<?php echo e(route('print-nota-kitchen', ['id' => $dTL->id])); ?>"><i class="fa-solid fa-clipboard"></i></a>
                               

                            </button>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>
            
                    <div  class="modal" id="validasiVoid" tabindex="-1">
                    <div class="modal-dialog" 
                    style="text-align: center;">
                        <div class="modal-content" style="background-color: rgb(55, 194, 148);">
                        <div  class="modal-header"
                        style="justify-content:center;">
                            <h5 class="modal-title"
                            style="font-family:Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;">Void Transaksi</h5>
                        </div>
                        <div class="modal-body">
                            <div id="formContainer">
                            <input autofocus autocomplete="off" style="border: 5px; border-radius:5px; padding:10px; background-color:rgb(10, 107, 78);" 
                            placeholder="input kode void" type="text" id="userInput" />
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                            <button class="btn btn-primary" onclick="validateInput()">Submit</button>
                        </div>
                        </div>
                    </div>
                    </div>
                  

                    
                                    <script>
                                        document.querySelectorAll('#voidBtn').forEach(button => {
                            button.addEventListener('click', function() {
                                document.getElementById('formContainer').style.display = 'block';
                                document.getElementById('validasiVoid').setAttribute('data-kode_pesanan', this.getAttribute('data-kode_pesanan'));
                            });
                        });

                        function validateInput() {
                            var correctNumber = 555; // Ubah sesuai angka valid
                            var userNumber = document.getElementById('userInput').value;
                            var kodePesanan = document.getElementById('validasiVoid').getAttribute('data-kode_pesanan');

                            if (parseInt(userNumber) === correctNumber) {
                                var route = "<?php echo e(route('voidView', ['kode_pesanan' => ':kode_pesanan'])); ?>".replace(':kode_pesanan', kodePesanan);
                                window.location.href = route;
                            } else {
                                alert("Kode void anda salah");
                            }
                        }
                </script>


                    
            
                   



        </table>
        <?php echo e($dataTransaksiLunas->links('pagination::bootstrap-4')); ?>

    </div>
    <script>
        function confirmationDelete(){
            return confirm("Apakah anda mau menghapus data ini ?")
        }
    </script>

    <script>
    // Fungsi untuk konfirmasi cetak PPN
    function konfirmasiCetak(event, url) {
        event.preventDefault(); // Mencegah tautan langsung dibuka

        // Tampilkan dialog konfirmasi
        var tampilkanPpn = confirm("Apakah PPN (10%) akan ditampilkan pada nota transaksi?");

        var finalUrl = url;

        // Tambahkan parameter 'ppn' ke URL berdasarkan jawaban
        if (tampilkanPpn) {
            finalUrl += '?ppn=yes';
        } else {
            finalUrl += '?ppn=no';
        }

        // Arahkan ke URL yang telah dimodifikasi
        window.location.href = finalUrl;
    }

    function confirmationDelete(){
        return confirm("Apakah anda mau menghapus data ini ?")
    }
    
</script>

</main>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('menu/index', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\jejakcoding\Penawaran aplikasi kasir\kasir24\resources\views/Transaksi/layout-transaksi/list-transaksi.blade.php ENDPATH**/ ?>