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

<style>
    .ts-dropdown{
    margin-top:0 !important;
}
</style>

<!-- Page Wrapper -->
<div class="px-0 py-4 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">Quotations</h1>

            <p class="text-sm text-gray-500 mt-1">
                Add, manage and track all quotation information in one place
            </p>
        </div>

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

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

                <input type="text" placeholder="Search"
                    class="w-full sm:w-[220px] 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>

            <!-- Filter -->
            <button id="openFilter"
                class="px-4 py-2.5 rounded-xl border border-blue-100 bg-white hover:bg-gradient-to-r hover:from-blue-500 hover:to-indigo-600 hover:text-white transition-all duration-300 text-sm text-blue-600 flex items-center gap-2">

                <i class="ri-filter-3-line"></i>
                Filter

            </button>

            <!-- Add Quotation -->
            <a href="add_lockora_account_quotation.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 Quotation

            </a>

        </div>

    </div>

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

        <!-- Table -->
        <div class="overflow-x-auto w-full">

            <table class="min-w-[1300px] w-max">

                <!-- Table 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 whitespace-nowrap">
                            Quotation No
                        </th>

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

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

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

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

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

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

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

                    </tr>

                </thead>

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

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

                        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
                            QT-1001
                        </td>

                        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
                            Raj Enterprise
                        </td>

                        <td class="px-6 py-4 text-sm text-gray-600 whitespace-nowrap">
                            Shiv Trading
                        </td>

                        <td class="px-6 py-4 text-sm text-gray-600 whitespace-nowrap">
                            CRM Development
                        </td>

                        <td class="px-6 py-4 text-sm text-gray-600 whitespace-nowrap">
                            ₹45,000
                        </td>

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

                            <span
                                class="px-3 py-1 rounded-full text-xs font-medium bg-green-100 text-green-700">
                                Approved
                            </span>

                        </td>

                        <td class="px-6 py-4 text-sm text-gray-600 whitespace-nowrap">
                            15 Aug 2026
                        </td>

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

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

                                <!-- View -->
                                <a href="view_lockora_account_quotation.php"
                                    class="w-9 h-9 rounded-lg bg-green-50 text-green-600 hover:bg-green-100 transition flex items-center justify-center">
                                    <i class="ri-eye-line"></i>
                                </a>

                                <!-- 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 2 -->
                    <tr class="hover:bg-gray-50 transition">

                        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
                            QT-1002
                        </td>

                        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
                            Bright Solutions
                        </td>

                        <td class="px-6 py-4 text-sm text-gray-600 whitespace-nowrap">
                            Akshar Infotech
                        </td>

                        <td class="px-6 py-4 text-sm text-gray-600 whitespace-nowrap">
                            E-commerce Website
                        </td>

                        <td class="px-6 py-4 text-sm text-gray-600 whitespace-nowrap">
                            ₹72,500
                        </td>

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

                            <span
                                class="px-3 py-1 rounded-full text-xs font-medium bg-yellow-100 text-yellow-700">
                                Pending
                            </span>

                        </td>

                        <td class="px-6 py-4 text-sm text-gray-600 whitespace-nowrap">
                            17 Aug 2026
                        </td>

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

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

                                <a href="view_lockora_account_quotation.php"
                                    class="w-9 h-9 rounded-lg bg-green-50 text-green-600 hover:bg-green-100 transition flex items-center justify-center">
                                    <i class="ri-eye-line"></i>
                                </a>

                                <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 3 -->
                    <tr class="hover:bg-gray-50 transition">

                        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
                            QT-1003
                        </td>

                        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
                            Shree Infotech
                        </td>

                        <td class="px-6 py-4 text-sm text-gray-600 whitespace-nowrap">
                            Mahadev Solutions
                        </td>

                        <td class="px-6 py-4 text-sm text-gray-600 whitespace-nowrap">
                            HR Management
                        </td>

                        <td class="px-6 py-4 text-sm text-gray-600 whitespace-nowrap">
                            ₹95,000
                        </td>

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

                            <span
                                class="px-3 py-1 rounded-full text-xs font-medium bg-red-100 text-red-700">
                                Rejected
                            </span>

                        </td>

                        <td class="px-6 py-4 text-sm text-gray-600 whitespace-nowrap">
                            20 Aug 2026
                        </td>

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

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

                                <a href="view_lockora_account_quotation.php"
                                    class="w-9 h-9 rounded-lg bg-green-50 text-green-600 hover:bg-green-100 transition flex items-center justify-center">
                                    <i class="ri-eye-line"></i>
                                </a>

                                <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 25 quotations
            </p>

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

                <button
                    class="w-9 h-9 rounded-lg border border-gray-200 text-gray-500 hover:bg-gray-100 transition">
                    <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-lg border border-gray-200 text-gray-600 hover:bg-gray-100 transition">
                    2
                </button>

                <button
                    class="w-9 h-9 rounded-lg border border-gray-200 text-gray-600 hover:bg-gray-100 transition">
                    3
                </button>

                <button
                    class="w-9 h-9 rounded-lg border border-gray-200 text-gray-500 hover:bg-gray-100 transition">
                    <i class="ri-arrow-right-s-line"></i>
                </button>

            </div>

        </div>

    </div>

</div>

<!-- Filter Sidebar -->
<div id="filterSidebar"
    class="fixed top-0 right-[-400px] w-[320px] h-full bg-white shadow-2xl z-50 transition-all duration-300 border-l border-gray-200">

    <!-- Header -->
    <div class="flex items-center justify-between p-5 border-b border-gray-100">

        <h2 class="text-lg font-bold text-gray-800">
            Filters
        </h2>

        <button id="closeFilter"
            class="w-9 h-9 text-black flex items-center justify-center">

            <i class="ri-close-line text-xl"></i>

        </button>

    </div>

    <!-- Body -->
    <div class="p-5 space-y-5 pb-28 overflow-y-auto">

        <!-- From Date -->
        <div class="w-full">

            <label class="mb-1 block text-sm font-medium text-slate-700">
                From Date
            </label>

            <div class="relative">

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

                <input type="date"
                    class="h-11 w-full rounded-md border border-slate-200 bg-slate-50 pl-10 pr-4 text-sm text-slate-700 outline-none transition focus:border-blue-500 focus:bg-white focus:ring-2 focus:ring-blue-100">

            </div>

        </div>

        <!-- To Date -->
        <div class="w-full">

            <label class="mb-1 block text-sm font-medium text-slate-700">
                To Date
            </label>

            <div class="relative">

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

                <input type="date"
                    class="h-11 w-full rounded-md border border-slate-200 bg-slate-50 pl-10 pr-4 text-sm text-slate-700 outline-none transition focus:border-blue-500 focus:bg-white focus:ring-2 focus:ring-blue-100">

            </div>

        </div>

        <!-- Vendor -->
        <div class="w-full">

            <label class="mb-1 block text-sm font-medium text-slate-700">
                Vendor
            </label>

            <div class="relative">

                <div class="pointer-events-none absolute left-3 top-1/2 z-10 -translate-y-1/2 text-slate-400">

                    <i class="ri-user-3-line"></i>

                </div>

                <select id="vendorSelect">

                    <option value="">Select Vendor</option>
                    <option value="Shiv Trading">Shiv Trading</option>
                    <option value="Akshar Infotech">Akshar Infotech</option>
                    <option value="Mahadev Solutions">Mahadev Solutions</option>

                </select>

            </div>

        </div>
        <!-- Status -->
        <div class="w-full">
        
            <label class="mb-1 block text-sm font-medium text-slate-700">
                Status
            </label>
        
            <div class="relative">
        
                <div class="pointer-events-none absolute left-3 top-1/2 z-10 -translate-y-1/2 text-slate-400">
        
                    <i class="ri-loader-4-line"></i>
        
                </div>
        
                <select id="statusSelect">
        
                    <option value="">Select Status</option>
        
                    <option value="Approved">
                        Approved
                    </option>
        
                    <option value="Pending">
                        Pending
                    </option>
        
                    <option value="Rejected">
                        Rejected
                    </option>
        
                    <option value="All">
                        All
                    </option>
        
                </select>
        
            </div>
        
        </div>

        <!-- Client Name -->
        <div class="w-full">
        
            <label class="mb-1 block text-sm font-medium text-slate-700">
                Client Name
            </label>
        
            <div class="relative">
        
                <i class="ri-user-3-line absolute left-3 top-1/2 -translate-y-1/2 text-slate-400"></i>
        
                <input 
                    type="text"
                    id="clientName"
                    placeholder="Enter Client Name"
                    class="h-11 w-full rounded-md border border-slate-200 bg-slate-50 pl-10 pr-4 text-sm text-slate-700 outline-none transition focus:border-blue-500 focus:bg-white focus:ring-2 focus:ring-blue-100"
                >
        
            </div>
        
        </div>
        
        <!-- Vendor Name -->
        <div class="w-full">
        
            <label class="mb-1 block text-sm font-medium text-slate-700">
                Vendor Name
            </label>
        
            <div class="relative">
        
                <i class="ri-store-2-line absolute left-3 top-1/2 -translate-y-1/2 text-slate-400"></i>
        
                <input 
                    type="text"
                    id="vendorName"
                    placeholder="Enter Vendor Name"
                    class="h-11 w-full rounded-md border border-slate-200 bg-slate-50 pl-10 pr-4 text-sm text-slate-700 outline-none transition focus:border-blue-500 focus:bg-white focus:ring-2 focus:ring-blue-100"
                >
        
            </div>
        
        </div>
        
        <!-- Project Name -->
        <div class="w-full">
        
            <label class="mb-1 block text-sm font-medium text-slate-700">
                Project Name
            </label>
        
            <div class="relative">
        
                <i class="ri-folder-2-line absolute left-3 top-1/2 -translate-y-1/2 text-slate-400"></i>
        
                <input 
                    type="text"
                    id="projectName"
                    placeholder="Enter Project Name"
                    class="h-11 w-full rounded-md border border-slate-200 bg-slate-50 pl-10 pr-4 text-sm text-slate-700 outline-none transition focus:border-blue-500 focus:bg-white focus:ring-2 focus:ring-blue-100"
                >
        
            </div>
        
        </div>

    </div>

    <!-- Bottom Fixed Buttons -->
    <div class="absolute bottom-0 left-0 w-full border-t border-gray-200 bg-white p-4">

        <div class="flex flex-row items-center justify-center gap-3 whitespace-nowrap">

            <!-- Reset Button -->
            <button
                class="w-1/2 h-11 rounded-md border border-slate-200 bg-slate-100 text-sm font-medium text-slate-700 transition hover:bg-slate-200">
                Reset
            </button>

            <!-- Apply Filter Button -->
            <button
                class="w-1/2 h-11 rounded-md bg-gradient-to-r from-blue-500 to-indigo-600 text-sm font-medium text-white shadow-md transition hover:from-blue-600 hover:to-indigo-700">
                Apply Filter
            </button>

        </div>

    </div>

</div>

<script>

    const openFilter = document.getElementById("openFilter");
    const closeFilter = document.getElementById("closeFilter");
    const filterSidebar = document.getElementById("filterSidebar");
    const sidebarOverlay = document.getElementById("sidebarOverlay");

    openFilter.addEventListener("click", () => {

        filterSidebar.style.right = "0";
        sidebarOverlay.classList.remove("hidden");

    });

    closeFilter.addEventListener("click", () => {

        filterSidebar.style.right = "-400px";
        sidebarOverlay.classList.add("hidden");

    });

    sidebarOverlay.addEventListener("click", () => {

        filterSidebar.style.right = "-400px";
        sidebarOverlay.classList.add("hidden");

    });

</script>

<script>

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

    create: false,
    maxOptions: 10,
    placeholder: "Search Vendor...",

    openOnFocus: false,
    dropdownParent: "body",

    closeAfterSelect:true,

    onType: function(str) {

        if (str.trim().length > 0) {

            this.open();

        } else {

            this.close();

        }

    },

    onItemAdd:function(){

        this.control_input.value = "";

        this.control_input.setAttribute(
            "readonly",
            "readonly"
        );

        this.blur();
        this.close();

    },

    onDropdownOpen:function(){

        this.control_input.removeAttribute(
            "readonly"
        );

    }

});


// Control Style
vendorSelect.control.classList.add(
    "flex",
    "items-center",
    "h-11",
    "w-full",
    "rounded-lg",
    "border",
    "border-gray-200",
    "bg-white",
    "pl-10",
    "pr-4",
    "text-sm",
    "text-gray-700"
);


// Dropdown Style
vendorSelect.dropdown.classList.add(
    "z-[99999]",
    "overflow-hidden",
    "rounded-xl",
    "border",
    "border-gray-200",
    "bg-white",
    "shadow-xl"
);


// Input Style
vendorSelect.control_input.classList.add(
    "w-full",
    "bg-transparent",
    "text-sm",
    "text-gray-700",
    "placeholder:text-gray-400",
    "focus:outline-none",
    "ml-2"
);


// Dropdown Position Fix
vendorSelect.on("dropdown_open", function() {

    const controlRect =
        vendorSelect.control.getBoundingClientRect();

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

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

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

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

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

});

</script>

<script>
    const statusSelect = new TomSelect("#statusSelect", {

    create: false,
    maxOptions: 10,
    placeholder: "Search Status...",

    openOnFocus: false,
    dropdownParent: "body",

    closeAfterSelect:true,

    onType: function(str) {

        if (str.trim().length > 0) {

            this.open();

        } else {

            this.close();

        }

    },

    onItemAdd:function(){

        this.control_input.value = "";

        this.control_input.setAttribute(
            "readonly",
            "readonly"
        );

        this.blur();
        this.close();

    },

    onDropdownOpen:function(){

        this.control_input.removeAttribute(
            "readonly"
        );

    }

});

// Control Style
statusSelect.control.classList.add(
    "flex",
    "items-center",
    "h-11",
    "w-full",
    "rounded-lg",
    "border",
    "border-gray-200",
    "bg-white",
    "pl-10",
    "pr-4",
    "text-sm",
    "text-gray-700"
);


// Dropdown Style
statusSelect.dropdown.classList.add(
    "z-[99999]",
    "overflow-hidden",
    "rounded-xl",
    "border",
    "border-gray-200",
    "bg-white",
    "shadow-xl"
);


// Input Style
statusSelect.control_input.classList.add(
    "w-full",
    "bg-transparent",
    "text-sm",
    "text-gray-700",
    "placeholder:text-gray-400",
    "focus:outline-none",
    "ml-2"
);


// Dropdown Position Fix
statusSelect.on("dropdown_open", function() {

    const controlRect =
        statusSelect.control.getBoundingClientRect();

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

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

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

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

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

});
</script>

<script>

function deleteRow(button) {

     Swal.fire({

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

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

        showCancelButton: true,
        scrollbarPadding: false,
        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: "Record removed successfully.",

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

                showConfirmButton: false,
                timer: 1400

            });

        }

    });

}

</script>

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