<?php $__env->startSection('workspace'); ?>

    <!-- Breadcrumb -->
    <section class="breadcrumb lg:flex items-start">
        <div>
            <h1>Payment Methods</h1>
            <ul>
                <li><a href="#no-link">Pages</a></li>
                <li class="divider la la-arrow-right"></li>
                <li><a href="#no-link">Payment Method</a></li>
                <li class="divider la la-arrow-right"></li>
                <li>List</li>
            </ul>
        </div>

        <div class="flex flex-wrap gap-2 items-center ltr:ml-auto rtl:mr-auto mt-5 lg:mt-0">
            <!-- Search -->
            <form class="flex flex-auto">
                <label class="form-control-addon-within rounded-full">
                    <input class="form-control border-none" placeholder="Search">
                    <button
                        class="text-gray-300 dark:text-gray-700 text-xl leading-none la la-search ltr:mr-4 rtl:ml-4"></button>
                </label>
            </form>

            <div class="flex gap-x-2">

                <!-- Sort By -->
                <div class="dropdown">
                    <button class="btn btn_outlined btn_secondary uppercase" data-toggle="dropdown-menu">
                        Sort By
                        <span class="ltr:ml-3 rtl:mr-3 la la-caret-down text-xl leading-none"></span>
                    </button>
                    <div class="dropdown-menu">
                        <a href="#no-link">Ascending</a>
                        <a href="#no-link">Descending</a>
                    </div>
                </div>

                <!-- Add New -->
                <a href="<?php echo e(route('paid-accounts.payments.add-view')); ?>" class="btn btn_primary uppercase">Add New</a>
            </div>
        </div>
    </section>

    <!-- List -->
    <div class="card p-5">
        <div class="overflow-x-auto">
            <table class="table table-auto table_hoverable w-full">
                <thead>
                <tr>
                    <th class="ltr:text-left rtl:text-right uppercase">Code</th>
                    <th class="text-center uppercase">Description</th>
                    <th class="text-center uppercase">Payment Type</th>
                    <th class="text-center uppercase"></th>

                </tr>
                </thead>
                <tbody>
                <?php if($paymentMethods->count() > 0): ?>
                    <?php $__currentLoopData = $paymentMethods; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $payment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>

                            <td><?php echo e($payment->code); ?></td>
                            <td class="text-center"><?php echo e($payment->description); ?></td>

                            <?php switch($payment->type):
                                case (0): ?>
                                    <td class="text-center">CASH</td>
                                    <?php break; ?>
                                <?php case (1): ?>
                                    <td class="text-center">QR PAYMENT</td>
                                    <?php break; ?>
                                <?php case (2): ?>
                                    <td class="text-center">PAYMENT TERMINAL</td>
                                    <?php break; ?>
                                <?php case (3): ?>
                                    <td class="text-center">OTHERS</td>
                                    <?php break; ?>

                            <?php endswitch; ?>


                            <td class="ltr:text-right rtl:text-left whitespace-nowrap">
                                <div class="inline-flex ltr:ml-auto rtl:mr-auto">
                                    <a href="<?php echo e(route('paid-accounts.payments.edit-view', $payment->id)); ?>" class="btn btn-icon btn_outlined btn_secondary">
                                        <span class="la la-pen-fancy"></span>
                                    </a>
                                    <button onclick="removePayment('<?php echo e($payment->id); ?>')" class="btn btn-icon btn_outlined btn_danger ltr:ml-2 rtl:mr-2" data-toggle="modal"
                                            data-target="#exampleModalCentered">
                                        <span class="la la-trash-alt"></span>
                                    </button>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <?php else: ?>
                    <tr>
                        <td colspan="6" class="text-center">No records found</td>
                    </tr>
                <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>


    <!-- Centered -->
    <div id="exampleModalCentered" class="modal" data-animations="fadeInDown, fadeOutUp" data-static-backdrop>
        <div class="modal-dialog modal-dialog_centered max-w-2xl">
            <div class="modal-content">
                <div class="modal-header">
                    <h2 class="modal-title">Remove Payment Method</h2>
                    <button class="close la la-times" data-dismiss="modal" onclick="closeRemoveModal()"></button>
                </div>
                <div class="modal-body">
                    <p>   Do you want remove this payment method?</p>

               </div>
                <div class="modal-footer">
                    <div class="flex ltr:ml-auto rtl:mr-auto">
                        <button class="btn btn_secondary uppercase" data-dismiss="modal" onclick="closeRemoveModal()">Close</button>
                        <button class="btn btn_primary ltr:ml-2 rtl:mr-2 uppercase" onclick="confirmRemoveFunction()">Confirm</button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    
    
    

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


<?php $__env->startSection('scripts'); ?>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script>
        let paymentId = '';


        function removePayment(id) {
            paymentId = id;
        }

        function confirmRemoveFunction() {
            axios.post( '<?php echo e(route('paid-accounts.payments.delete')); ?>',{
                _token: '<?php echo e(csrf_token()); ?>',
                id: paymentId
            })
                .then(function (response) {
                    console.log(response);
                    if (response.status === 200) {
                        alert(response.data.message);
                        window.location.reload();
                    } else {
                        alert(response.data.message);
                    }
                })
                .catch(function (error) {
                    console.log(error);
                });
        }

        function closeRemoveModal() {
            paymentId = '';
        }


    </script>

    
    

    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    

    
    
    
    

    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    

    
    

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

<?php echo $__env->make('layouts.master', ['title' => 'List -  Payment Method - Pages'], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/ezyorder/public_html/ezypos.ezyorder.com.my/ezypos-backend/resources/views/pages/paid-account/payment-list.blade.php ENDPATH**/ ?>