<?php include 'header.php'; ?>

<div class="px-0 py-3 md:p-2 lg:p-6">

    <!-- Header -->
    <div
        class="flex flex-col md:flex-row md:items-center md:justify-between gap-4 mb-5 bg-white p-4 rounded-lg border border-gray-200">

        <!-- Title -->
        <div>
            <h1 class="text-2xl font-bold text-gray-800">
                Payment Modes
            </h1>

            <p class="text-sm text-gray-500">
                Manage all payment modes from here
            </p>
        </div>

        <!-- Actions -->
        <div class="flex flex-col sm:flex-row gap-3">

            <!-- Search -->
            <div class="relative">

                <input type="text" placeholder="Search Payment Mode..."
                    class="w-full sm:w-[240px] pl-10 pr-4 py-2.5 rounded-xl border border-gray-200 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none text-sm">

                <i class="ri-search-line absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"></i>

            </div>


            <!-- Add -->
            <a href="puresaas_add_payment_mode.php"
                class="bg-gradient-to-r from-blue-500 to-indigo-600 hover:from-blue-600 hover:to-indigo-700 text-white text-sm font-medium px-5 py-2.5 rounded-xl shadow-lg hover:shadow-blue-200 transition-all duration-300 flex items-center gap-2">

                <i class="ri-add-line text-lg"></i>
                Add Payment Mode

            </a>

        </div>

    </div>

    <!-- Table -->
    <div class="bg-white rounded-lg border border-gray-200 shadow-sm overflow-x-auto overflow-y-hidden">

        <div class="overflow-x-auto">

            <table class="w-full min-w-[1000px]">

                <!-- Head -->
                <thead class="bg-gray-50 border-b border-gray-200">

                    <tr class="text-left">

                        <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider">
                            Sr No
                        </th>

                        <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider">
                            Payment Mode
                        </th>

                        <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider">
                            Description
                        </th>

                        <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider">
                            Payment Date
                        </th>

                        <th class="px-6 py-4 text-center text-xs font-semibold text-gray-500 uppercase tracking-wider">
                            Action
                        </th>

                    </tr>

                </thead>

                <!-- Body -->
                <tbody class="divide-y divide-gray-100 bg-white">

                    <!-- Row -->
                    <tr class="hover:bg-gray-50 transition">

                        <td class="px-6 py-4 text-sm font-medium text-gray-600">
                            1
                        </td>

                        <td class="px-6 py-4">
                            <h4 class="font-semibold text-gray-800">
                                Cash
                            </h4>
                        </td>


                        <td class="px-6 py-4 text-sm text-gray-600">
                            Cash payment transactions
                        </td>


                        <td class="px-6 py-4 text-sm text-gray-600">
                            26-05-2026
                        </td>

                        <td class="px-6 py-4">

                            <div class="flex items-center justify-center gap-2">

                                <!-- Edit -->
                                <button
                                    class="w-9 h-9 rounded-lg bg-blue-50 text-blue-600 hover:bg-blue-100 transition flex items-center justify-center">

                                    <i class="ri-edit-line"></i>

                                </button>

                                <!-- Delete -->
                                <button
                                    onclick="deleteRow(this)"
                                    class="w-9 h-9 rounded-lg bg-red-50 text-red-600 hover:bg-red-100 transition flex items-center justify-center">

                                    <i class="ri-delete-bin-line"></i>

                                </button>

                            </div>

                        </td>

                    </tr>

                    <!-- Row -->
                    <tr class="hover:bg-gray-50 transition">

                        <td class="px-6 py-4 text-sm font-medium text-gray-600">
                            2
                        </td>

                        <td class="px-6 py-4">
                            <h4 class="font-semibold text-gray-800">
                                UPI
                            </h4>
                        </td>


                        <td class="px-6 py-4 text-sm text-gray-600">
                            Online UPI payments
                        </td>


                        <td class="px-6 py-4 text-sm text-gray-600">
                            25-05-2026
                        </td>

                        <td class="px-6 py-4">

                            <div class="flex items-center justify-center gap-2">

                                <button
                                    class="w-9 h-9 rounded-lg bg-blue-50 text-blue-600 hover:bg-blue-100 transition flex items-center justify-center">

                                    <i class="ri-edit-line"></i>

                                </button>

                                <button
                                    onclick="deleteRow(this)"
                                    class="w-9 h-9 rounded-lg bg-red-50 text-red-600 hover:bg-red-100 transition flex items-center justify-center">

                                    <i class="ri-delete-bin-line"></i>

                                </button>

                            </div>

                        </td>

                    </tr>

                    <!-- Row -->
                    <tr class="hover:bg-gray-50 transition">

                        <td class="px-6 py-4 text-sm font-medium text-gray-600">
                            3
                        </td>

                        <td class="px-6 py-4">
                            <h4 class="font-semibold text-gray-800">
                                Bank Transfer
                            </h4>
                        </td>

                        <td class="px-6 py-4 text-sm text-gray-600">
                            Direct bank transfer payments
                        </td>

                        <td class="px-6 py-4 text-sm text-gray-600">
                            24-05-2026
                        </td>

                        <td class="px-6 py-4">

                            <div class="flex items-center justify-center gap-2">

                                <button
                                    class="w-9 h-9 rounded-lg bg-blue-50 text-blue-600 hover:bg-blue-100 transition flex items-center justify-center">

                                    <i class="ri-edit-line"></i>

                                </button>

                                <button
                                    onclick="deleteRow(this)"
                                    class="w-9 h-9 rounded-lg bg-red-50 text-red-600 hover:bg-red-100 transition flex items-center justify-center">

                                    <i class="ri-delete-bin-line"></i>

                                </button>

                            </div>

                        </td>

                    </tr>

                </tbody>

            </table>

        </div>

        <!-- Footer -->
        <div
            class="px-4 py-4 border-t border-gray-100 flex flex-col md:flex-row items-center justify-between gap-4">

            <!-- Left -->
            <p class="text-sm text-gray-500">
                Showing 1 to 3 of 12 payment modes
            </p>

            <!-- Pagination -->
            <div class="flex items-center gap-2">

                <button
                    class="w-9 h-9 rounded-xl border border-blue-100 text-blue-500 hover:bg-gradient-to-r hover:from-blue-500 hover:to-indigo-600 hover:text-white transition-all duration-300">

                    <i class="ri-arrow-left-s-line"></i>

                </button>

                <button
                    class="w-9 h-9 rounded-xl bg-gradient-to-r from-blue-500 to-indigo-600 text-white font-medium shadow-md">
                    1
                </button>

                <button
                    class="w-9 h-9 rounded-xl border border-blue-100 text-blue-600 hover:bg-gradient-to-r hover:from-blue-500 hover:to-indigo-600 hover:text-white transition-all duration-300">
                    2
                </button>

                <button
                    class="w-9 h-9 rounded-xl border border-blue-100 text-blue-500 hover:bg-gradient-to-r hover:from-blue-500 hover:to-indigo-600 hover:text-white transition-all duration-300">

                    <i class="ri-arrow-right-s-line"></i>

                </button>

            </div>

        </div>

    </div>

</div>




<script>

    const category = new TomSelect("#category", {

        create: false,
        maxOptions: 10,
        placeholder: "Search Category...",
        openOnFocus: false,
        dropdownParent: "body",

        onType: function (str) {

            if (str.length > 0) {

                this.open();

            } else {

                this.close();

            }

        }

    });

    const status = new TomSelect("#status", {

        create: false,
        maxOptions: 10,
        placeholder: "Search Status...",
        openOnFocus: false,
        dropdownParent: "body",

        onType: function (str) {

            if (str.length > 0) {

                this.open();

            } else {

                this.close();

            }

        }

    });

    [category, status].forEach(select => {

        select.control.classList.add(
            "flex",
            "items-center",
            "h-11",
            "w-full",
            "rounded-md",
            "border",
            "border-slate-200",
            "bg-slate-50",
            "pl-10",
            "pr-4",
            "text-sm",
            "text-slate-700"
        );

        select.dropdown.classList.add(
            "z-[99999]",
            "overflow-hidden",
            "rounded-md",
            "border",
            "border-slate-200",
            "bg-white",
            "shadow-xl"
        );

        select.control_input.classList.add(
            "w-full",
            "bg-transparent",
            "text-sm",
            "text-slate-700",
            "placeholder:text-slate-400",
            "focus:outline-none",
            "ml-2"
        );

        select.on("dropdown_open", function () {

            const controlRect = select.control.getBoundingClientRect();

            select.dropdown.style.position = "absolute";

            select.dropdown.style.width =
                controlRect.width + "px";

            select.dropdown.style.top =
                (controlRect.bottom + window.scrollY + 5) + "px";

            select.dropdown.style.left =
                (controlRect.left + window.scrollX) + "px";

            select.dropdown.style.zIndex = "99999";

        });

    });

</script>

<script>

    function deleteRow(button) {

        Swal.fire({

            title: "Delete Record?",
            text: "This payment mode will be deleted.",
            icon: "warning",

            width: "320px",
            padding: "1rem",

            showCancelButton: true,
            scrollbarPadding: false,
            confirmButtonText: "Delete",
            cancelButtonText: "Cancel",

            confirmButtonColor: "#2563eb",
            cancelButtonColor: "#ef4444",

            customClass: {

                popup: "rounded-2xl",
                title: "text-lg font-semibold",
                htmlContainer: "text-sm text-gray-500",
                confirmButton: "px-4 py-2 rounded-lg text-sm",
                cancelButton: "px-4 py-2 rounded-lg text-sm"

            }

        }).then((result) => {

            if (result.isConfirmed) {

                button.closest("tr").remove();

                Swal.fire({

                    icon: "success",
                    title: "Deleted!",
                    text: "Payment mode removed successfully.",

                    width: "300px",
                    padding: "1rem",

                    showConfirmButton: false,
                    timer: 1400

                });

            }

        });

    }

</script>

<script>

    new TomSelect('#paymentMode', {

        create:false,

        allowEmptyOption:true,

        placeholder:'Search Payment Mode...',

        closeAfterSelect:true

    });

</script>

<?php include 'footer.php'; ?>