{"id":95,"date":"2026-03-31T05:27:39","date_gmt":"2026-03-31T05:27:39","guid":{"rendered":"https:\/\/ph-portal.zyneventures.com\/?page_id=95"},"modified":"2026-03-31T05:27:39","modified_gmt":"2026-03-31T05:27:39","slug":"file","status":"publish","type":"page","link":"https:\/\/ph-portal.zyneventures.com\/index.php\/file\/","title":{"rendered":"File"},"content":{"rendered":"<style>.kadence-column95_614ff1-5c > .kt-inside-inner-col,.kadence-column95_614ff1-5c > .kt-inside-inner-col:before{border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;}.kadence-column95_614ff1-5c > .kt-inside-inner-col{column-gap:var(--global-kb-gap-sm, 1rem);}.kadence-column95_614ff1-5c > .kt-inside-inner-col{flex-direction:column;}.kadence-column95_614ff1-5c > .kt-inside-inner-col > .aligncenter{width:100%;}.kadence-column95_614ff1-5c > .kt-inside-inner-col:before{opacity:0.3;}.kadence-column95_614ff1-5c{position:relative;}@media all and (max-width: 1024px){.kadence-column95_614ff1-5c > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}@media all and (max-width: 767px){.kadence-column95_614ff1-5c > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}<\/style>\n<div class=\"wp-block-kadence-column kadence-column95_614ff1-5c\"><div class=\"kt-inside-inner-col\"><style>.kb-row-layout-id95_c5ef6c-a9 > .kt-row-column-wrap{align-content:start;}:where(.kb-row-layout-id95_c5ef6c-a9 > .kt-row-column-wrap) > .wp-block-kadence-column{justify-content:start;}.kb-row-layout-id95_c5ef6c-a9 > .kt-row-column-wrap{column-gap:var(--global-kb-gap-md, 2rem);row-gap:var(--global-kb-gap-md, 2rem);padding-top:var(--global-kb-spacing-sm, 1.5rem);padding-bottom:var(--global-kb-spacing-sm, 1.5rem);grid-template-columns:minmax(0, 1fr);}.kb-row-layout-id95_c5ef6c-a9 > .kt-row-layout-overlay{opacity:0.30;}@media all and (max-width: 1024px){.kb-row-layout-id95_c5ef6c-a9 > .kt-row-column-wrap{grid-template-columns:minmax(0, 1fr);}}@media all and (max-width: 767px){.kb-row-layout-id95_c5ef6c-a9 > .kt-row-column-wrap{grid-template-columns:minmax(0, 1fr);}}<\/style><div class=\"kb-row-layout-wrap kb-row-layout-id95_c5ef6c-a9 alignnone wp-block-kadence-rowlayout\"><div class=\"kt-row-column-wrap kt-has-1-columns kt-row-layout-equal kt-tab-layout-inherit kt-mobile-layout-row kt-row-valign-top\">\n<style>.kadence-column95_1c8ec3-bd > .kt-inside-inner-col,.kadence-column95_1c8ec3-bd > .kt-inside-inner-col:before{border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;}.kadence-column95_1c8ec3-bd > .kt-inside-inner-col{column-gap:var(--global-kb-gap-sm, 1rem);}.kadence-column95_1c8ec3-bd > .kt-inside-inner-col{flex-direction:column;}.kadence-column95_1c8ec3-bd > .kt-inside-inner-col > .aligncenter{width:100%;}.kadence-column95_1c8ec3-bd > .kt-inside-inner-col:before{opacity:0.3;}.kadence-column95_1c8ec3-bd{position:relative;}@media all and (max-width: 1024px){.kadence-column95_1c8ec3-bd > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}@media all and (max-width: 767px){.kadence-column95_1c8ec3-bd > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}<\/style>\n<div class=\"wp-block-kadence-column kadence-column95_1c8ec3-bd\"><div class=\"kt-inside-inner-col\">\n<style>\n        :root {\n            --primary-blue: #0180FF;\n            --text-dark: #212529;\n            --text-muted: #8D8C9C;\n            --border-color: #EFEFEF;\n            --success-green: #34A853;\n            --error-red: #D93025;\n            --bg-light: #F8F9FA;\n        }\n\n        body { \n            margin: 0; \n            font-family: 'Sora', sans-serif; \n            color: var(--text-dark); \n            background-color: #fff;\n        }\n        \n        \/* \u2500\u2500 Header: two-row layout \u2500\u2500 *\/\n        .header-container {\n            margin-bottom: 24px;\n        }\n        .header-row1 {\n            display: flex;\n            align-items: center;\n            gap: 10px;\n            margin-bottom: 16px;\n        }\n        .header-row1 h2 { \n            margin: 0; \n            font-size: 21px; \n            font-weight: 500; \n            text-transform: uppercase; \n            letter-spacing: 0.5px; \n        }\n        .count { \n            color: var(--text-muted); \n            font-size: 16px; \n            font-weight: 400; \n        }\n        .header-row2 {\n            display: flex;\n            align-items: center;\n            gap: 12px;\n            flex-wrap: wrap;\n        }\n\n        .search-wrapper { \n            background: #F1F3F4; \n            border-radius: 6px; \n            padding: 8px 15px; \n            display: flex; \n            align-items: center; \n            flex: 1;\n            min-width: 0;\n            gap: 12px;\n        }\n        .search-icon { \n            width: 18px; \n            height: 18px; \n            color: #8D8C9C; \n            flex-shrink: 0;\n        }\n        .search-wrapper input { \n            border: none; \n            background: transparent; \n            outline: none; \n            width: 100%; \n            font-size: 12px; \n            font-family: 'Sora'; \n            color: #212529;\n        }\n\n        \/* \u2500\u2500 Filter button \u2014 matches screenshot exactly \u2500\u2500 *\/\n        .btn-filter {\n            width: 36px;\n            height: 36px;\n            padding: 0;\n            background: transparent;\n            border: 1px solid;\n            border-color: #F1F3F4;            \n            border-radius: 6px;\n            cursor: pointer;\n            display: flex;\n            align-items: center;\n            justify-content: center;\n            flex-shrink: 0;\n            color: #5f6368;\n            transition: background 0.2s;\n        }\n        .btn-filter:hover { background: transparent; color: #212529; }\n\n        .btn { \n            padding: 8px 20px; \n            border-radius: 6px; \n            font-size: 13px; \n            font-weight: 400; \n            cursor: pointer; \n            border: none; \n            transition: 0.2s; \n            display: flex; \n            align-items: center; \n            justify-content: center;\n            white-space: nowrap;\n        }\n        .btn-primary { background: var(--primary-blue); color: white; }\n        .btn-primary:hover { background: #0068d9; }\n        .btn-outline { background: #F1F3F4; color: #5f6368; border: none; }\n        \n        .btn-close { \n            background: transparent; \n            color: #212529; \n            border: none; \n            cursor: pointer; \n            outline: none; \n        }\n        .btn-close:hover { \n            color: #212529;\n            background-color: transparent;  \n        }\n\n        \/* Grid *\/\n        .files-grid { \n            display: grid; \n            grid-template-columns: repeat(3, 1fr); \n            gap: 24px; \n            margin-top: 20px; \n        }\n        \n        .file-card { \n            border: 1px solid var(--border-color); \n            border-radius: 12px; \n            padding: 24px; \n            background: #fff;\n            position: relative;\n        }\n        \n        .card-header { \n            display: flex; \n            justify-content: space-between; \n            align-items: flex-start; \n            margin-bottom: 24px; \n            gap: 10px;\n        }\n        .card-title { \n            font-weight: 500; \n            font-size: 16px; \n            color: #3C4043;\n            flex: 1;\n            line-height: 1.4;\n            word-break: break-word;\n        }\n        \n        .badge-container { \n            display: flex; \n            align-items: center; \n            gap: 8px; \n            flex-shrink: 0;\n        }\n        \n        .status-badge { \n            padding: 4px 0; \n            border-radius: 20px; \n            font-size: 11px; \n            font-weight: 500; \n            display: flex; \n            align-items: center; \n            justify-content: center;\n            gap: 5px; \n            width: 75px;\n            flex-shrink: 0;\n        }\n        .status-active { background: #E6F4EA; color: var(--success-green); }\n        .status-active::before { content: '\u25cf'; font-size: 7px; }\n        .status-inactive { background: #FCE8E6; color: var(--error-red); }\n        .status-inactive::before { content: '\u25cf'; font-size: 7px; }\n        \n        .card-body { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 10px 15px; }\n        .info-group { display: flex; flex-direction: row; gap: 5px; font-size: 13px; }\n        .info-label { color: #70757A; min-width: 100px; white-space: nowrap; }\n        .info-value { font-weight: 400; color: #202124; }\n        .info-link { color: var(--primary-blue); text-decoration: none; cursor: pointer; }\n\n        .menu-dots { cursor: pointer; color: #5f6368; font-size: 18px; padding-left: 5px; flex-shrink: 0; }\n\n        \/* \u2500\u2500 Modal with slide-down animation \u2500\u2500 *\/\n        .modal-overlay { \n            display: none; \n            position: fixed; \n            top: 0; left: 0; \n            width: 100%; \n            height: 100%; \n            background: rgba(0,0,0,0.5); \n            z-index: 1000; \n            justify-content: center; \n            align-items: center;\n            overflow-y: auto;\n            padding: 40px 0;\n        }\n        .modal-overlay.active {\n            display: flex;\n        }\n        .modal-content { \n            background: white; \n            padding: 40px; \n            border-radius: 12px; \n            width: 90%;\n            max-width: 500px; \n            box-shadow: 0 12px 30px rgba(0,0,0,0.15); \n            position: relative;\n            margin: auto;\n            \/* Slide-down animation *\/\n            animation: slideDown 0.3s ease forwards;\n        }\n        @keyframes slideDown {\n            from { opacity: 0; transform: translateY(-40px); }\n            to   { opacity: 1; transform: translateY(0); }\n        }\n        .modal-content h3 { margin: 0 0 25px 0; font-size: 20px; font-weight: 500; color: #202124; }\n        \n        .form-group { margin-bottom: 18px; }\n        .form-group label { \n            display: block; \n            font-size: 13px; \n            font-weight: 500; \n            margin-bottom: 8px; \n            color: #3C4043;\n        }\n        .form-group label span { color: var(--error-red); }\n        .form-control { \n            width: 100%; \n            padding: 10px 12px; \n            border: 1px solid #DADCE0; \n            border-radius: 6px; \n            box-sizing: border-box; \n            font-family: 'Sora'; \n            font-size: 13px; \n        }\n\n        \/* Toggle Switch *\/\n        .toggle-row { display: flex; justify-content: space-between; align-items: center; margin: 20px 0; }\n        .switch { \n            position: relative; \n            display: inline-block; \n            width: 40px; \n            height: 20px; \n            flex-shrink: 0; \n        }\n        .switch input { opacity: 0; width: 0; height: 0; }\n        .slider { \n            position: absolute; \n            cursor: pointer; \n            top: 0; \n            left: 0; \n            right: 0; \n            bottom: 0; \n            background-color: #ccc; \n            transition: .4s; \n            border-radius: 34px; \n        }\n        .slider:before { \n            position: absolute; \n            content: \"\"; \n            height: 14px; \n            width: 14px; \n            left: 3px; \n            bottom: 3px; \n            background-color: white; \n            transition: .4s; \n            border-radius: 50%; \n        }\n        input:checked + .slider { background-color: var(--primary-blue); }\n        input:checked + .slider:before { transform: translateX(20px); }\n\n        \/* Pagination *\/\n        .pagination-footer { \n            margin-top: 40px; \n            display: flex; \n            justify-content: space-between; \n            align-items: center; \n            color: #70757A; \n            font-size: 13px;\n            flex-wrap: wrap;\n            gap: 10px;\n        }\n        .pagination-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }\n        .page-num { \n            cursor: pointer; \n            width: 32px; \n            height: 32px; \n            display: flex; \n            align-items: center; \n            justify-content: center; \n            border-radius: 50%; \n        }\n        .page-num.active { background: var(--primary-blue); color: white; }\n        .nav-btn { cursor: pointer; color: var(--text-dark); font-weight: 500; white-space: nowrap; }\n        .nav-btn.disabled { color: #BDC1C6; pointer-events: none; }\n\n        \/* Dropdown *\/\n        .dropdown-content { \n            display: none; \n            position: absolute; \n            right: 0; \n            top: 30px; \n            background: white; \n            min-width: 130px; \n            box-shadow: 0 4px 12px rgba(0,0,0,0.1); \n            z-index: 10; \n            border-radius: 8px; \n            border: 1px solid #eee; \n        }\n        .dropdown-content.show { display: block; }\n        .dropdown-item { padding: 10px 15px; font-size: 13px; cursor: pointer; text-align: left; }\n        .dropdown-item:hover { background: #F8F9FA; color: var(--primary-blue); }\n\n        @media (max-width: 1024px) {\n            .files-grid { grid-template-columns: repeat(2, 1fr); }\n        }\n        @media (max-width: 768px) {\n            body { padding: 20px; }\n            .files-grid { grid-template-columns: 1fr; }\n            .search-wrapper { width: 100%; }\n            .header-row2 { gap: 8px; }\n            \/* Entry info wraps to its own row on mobile *\/\n            .pagination-footer {\n                flex-direction: column;\n                align-items: flex-start;\n            }\n            #entryInfo {\n                width: 100%;\n                text-align: left;\n            }\n        }\n    <\/style>\n\n\n<div class=\"header-container\">\n    <!-- Row 1: Title -->\n    <div class=\"header-row1\">\n        <h2>File<\/h2>\n        <span class=\"count\" id=\"fileCount\">(0)<\/span>\n    <\/div>\n    <!-- Row 2: Search + Filter + Action buttons -->\n    <div class=\"header-row2\">\n        <div class=\"search-wrapper\">\n            <svg class=\"search-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n                <circle cx=\"11\" cy=\"11\" r=\"8\"><\/circle>\n                <line x1=\"21\" y1=\"21\" x2=\"16.65\" y2=\"16.65\"><\/line>\n            <\/svg>\n            <input type=\"text\" id=\"searchInput\" placeholder=\"Search File...\" oninput=\"handleSearch()\">\n        <\/div>\n        <!-- Filter button matching screenshot -->\n        <button class=\"btn-filter\" title=\"Filter\">\n            <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n                <line x1=\"4\" y1=\"6\" x2=\"20\" y2=\"6\"><\/line>\n                <line x1=\"8\" y1=\"12\" x2=\"16\" y2=\"12\"><\/line>\n                <line x1=\"11\" y1=\"18\" x2=\"13\" y2=\"18\"><\/line>\n            <\/svg>\n        <\/button>\n        <button class=\"btn btn-primary\" onclick=\"openModal('add')\">+ Add New File<\/button>\n        <button class=\"btn btn-primary\" onclick=\"downloadCSV()\">+ CSV Download<\/button>\n    <\/div>\n<\/div>\n\n<div class=\"files-grid\" id=\"filesContainer\"><\/div>\n\n<div class=\"pagination-footer\">\n    <div class=\"pagination-controls\">\n        <span id=\"prevBtn\" class=\"nav-btn\">\u00ab Previous<\/span>\n        <div id=\"pageNumbers\" style=\"display:flex; gap:5px; flex-wrap:wrap;\"><\/div>\n        <span id=\"nextBtn\" class=\"nav-btn\">Next \u00bb<\/span>\n    <\/div>\n    <div id=\"entryInfo\">Showing 0 to 0 of 0 entries<\/div>\n<\/div>\n\n<div class=\"modal-overlay\" id=\"fileModal\">\n    <div class=\"modal-content\">\n        <h3 id=\"modalTitle\">New File<\/h3>\n        <form id=\"fileForm\">\n            <input type=\"hidden\" id=\"editFileId\">\n            <div class=\"form-group\">\n                <label>File Name <span>*<\/span><\/label>\n                <input type=\"text\" id=\"fileName\" class=\"form-control\" placeholder=\"Enter File Name\" required>\n            <\/div>\n            <div class=\"form-group\" style=\"display: grid; grid-template-columns: 1fr 1fr; gap: 20px;\">\n                <div>\n                    <label>Dos Count <span>*<\/span><\/label>\n                    <input type=\"number\" id=\"dosCount\" class=\"form-control\" placeholder=\"Enter Dos Count\" required>\n                <\/div>\n                <div>\n                    <label>Page <span>*<\/span><\/label>\n                    <input type=\"number\" id=\"pageCount\" class=\"form-control\" placeholder=\"Enter Page\" required>\n                <\/div>\n            <\/div>\n            <div class=\"form-group\">\n                <label>Received On <span>*<\/span><\/label>\n                <input type=\"date\" id=\"receivedOn\" class=\"form-control\" required>\n            <\/div>\n            <div class=\"form-group\">\n                <label>File Link <span>*<\/span><\/label>\n                <input type=\"text\" id=\"fileLink\" class=\"form-control\" placeholder=\"Enter File Link\" required>\n            <\/div>\n            \n            <div class=\"toggle-row\">\n                <label style=\"font-size:13px; font-weight:500;\">Active File<span>*<\/span><\/label>\n                <label class=\"switch\">\n                    <input type=\"checkbox\" id=\"fileActive\" checked>\n                    <span class=\"slider\"><\/span>\n                <\/label>\n            <\/div>\n\n            <div style=\"display:flex; justify-content:flex-end; gap:15px; margin-top:30px;\">\n                <button type=\"button\" class=\"btn btn-close\" onclick=\"closeModal()\">Close<\/button>\n                <button type=\"submit\" id=\"saveBtn\" class=\"btn btn-primary\" style=\"padding: 10px 40px;\">Save<\/button>\n            <\/div>\n        <\/form>\n    <\/div>\n<\/div>\n\n<script>\n    const BASE_URL = 'https:\/\/api-ph-portal.zyneventures.com\/api\/v1';\n    const ENDPOINTS = {\n        ALL: `${BASE_URL}\/file\/all`,\n        DETAIL: `${BASE_URL}\/file\/detail`,\n        ADD: `${BASE_URL}\/file\/add`,\n        UPDATE: `${BASE_URL}\/file\/update`,\n        DELETE: `${BASE_URL}\/file\/delete`\n    };\n\n    let allFiles = [];\n    let paginationData = { page: 1, limit: 10, total: 0, pages: 0 };\n\n    const getHeaders = () => ({\n        'Content-Type': 'application\/json',\n        'Authorization': `Bearer ${localStorage.getItem(\"TOKEN\")}`\n    });\n\n    async function fetchFiles(page = 1) {\n        try {\n            const res = await fetch(`${ENDPOINTS.ALL}?page=${page}`, { headers: getHeaders() });\n            const result = await res.json();\n            if (result.code === 200) {\n                allFiles = result.data.data;\n                paginationData = result.data.pagination;\n                renderFiles();\n                renderPagination();\n            }\n        } catch (err) { console.error(\"Fetch Error:\", err); }\n    }\n\n    function renderFiles(filtered = null) {\n        const container = document.getElementById('filesContainer');\n        const list = filtered || allFiles;\n        document.getElementById('fileCount').textContent = `(${paginationData.total})`;\n        \n        const start = paginationData.total === 0 ? 0 : ((paginationData.page - 1) * paginationData.limit) + 1;\n        const end = Math.min(paginationData.page * paginationData.limit, paginationData.total);\n        document.getElementById('entryInfo').textContent = `Showing ${start} to ${end} of ${paginationData.total} entries`;\n\n        container.innerHTML = '';\n        list.forEach(file => {\n            const isActive = file.is_active == 1;\n            const card = document.createElement('div');\n            card.className = 'file-card';\n            \n            card.innerHTML = `\n                <div class=\"card-header\">\n                    <span class=\"card-title\">${file.file_name || file.name}<\/span>\n                    <div class=\"badge-container\">\n                        <span class=\"status-badge ${isActive ? 'status-active' : 'status-inactive'}\">\n                            ${isActive ? 'Active' : 'Inactive'}\n                        <\/span>\n                        <div style=\"position: relative;\">\n                            <span class=\"menu-dots\" onclick=\"toggleMenu(event, ${file.id})\">\u22ee<\/span>\n                            <div class=\"dropdown-content\" id=\"dropdown-${file.id}\">\n                                <div class=\"dropdown-item\" onclick=\"openModal('edit', ${file.id})\">Edit<\/div>\n                                <div class=\"dropdown-item\" style=\"color:var(--error-red)\" onclick=\"deleteFile(${file.id})\">Delete<\/div>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n                <\/div>\n                <div class=\"card-body\">\n                    <div class=\"info-group\"><div class=\"info-label\">File ID :<\/div><div class=\"info-value\">${file.id}<\/div><\/div>\n                    <div class=\"info-group\"><div class=\"info-label\">No. of DOS :<\/div><div class=\"info-value\">${file.total_dos || file.dos_count || 0}<\/div><\/div>\n                    <div class=\"info-group\"><div class=\"info-label\">Pages :<\/div><div class=\"info-value\">${file.pages || 0}<\/div><\/div>\n                    <div class=\"info-group\"><div class=\"info-label\">Assigned DOS :<\/div><div class=\"info-value\">${file.total_assigned_dos || 0}<\/div><\/div>\n                    <div class=\"info-group\"><div class=\"info-label\">File Link :<\/div><div class=\"info-value info-link\" onclick=\"window.open('${file.file_link}','_blank')\">${file.file_link === 'N\/A' ? 'N\/A' : 'Link'}<\/div><\/div>\n                    <div class=\"info-group\"><div class=\"info-label\">Completed DOS :<\/div><div class=\"info-value\">${file.total_completed_dos || 0}<\/div><\/div>\n                    <div class=\"info-group\"><div class=\"info-label\">Received :<\/div><div class=\"info-value\">${file.received_on || 'N\/A'}<\/div><\/div>\n                    <div class=\"info-group\"><div class=\"info-label\">Pending DOS :<\/div><div class=\"info-value\">${file.total_pending_dos || 0}<\/div><\/div>\n                <\/div>`;\n            container.appendChild(card);\n        });\n    }\n\n    async function openModal(mode, id = null) {\n        const modal = document.getElementById('fileModal');\n        const form = document.getElementById('fileForm');\n        \/\/ Remove and re-add modal-content to re-trigger animation\n        const content = modal.querySelector('.modal-content');\n        content.style.animation = 'none';\n        form.reset();\n        \n        if (mode === 'edit') {\n            document.getElementById('modalTitle').textContent = 'Update file';\n            try {\n                const res = await fetch(ENDPOINTS.DETAIL, { \n                    method: 'POST', \n                    headers: getHeaders(), \n                    body: JSON.stringify({ id }) \n                });\n                const result = await res.json();\n                const data = result.data;\n                \n                document.getElementById('editFileId').value = data.id;\n                document.getElementById('fileName').value = data.file_name;\n                document.getElementById('dosCount').value = data.dos_count;\n                document.getElementById('pageCount').value = data.pages;\n                document.getElementById('receivedOn').value = data.received_on;\n                document.getElementById('fileLink').value = data.file_link;\n                document.getElementById('fileActive').checked = (data.is_active == 1);\n            } catch (err) { console.error(err); }\n        } else {\n            document.getElementById('modalTitle').textContent = 'New File';\n            document.getElementById('editFileId').value = '';\n        }\n        \n        modal.classList.add('active');\n        \/\/ Re-trigger animation\n        requestAnimationFrame(() => {\n            content.style.animation = '';\n        });\n        document.body.style.overflow = 'hidden'; \n    }\n\n    function closeModal() { \n        document.getElementById('fileModal').classList.remove('active');\n        document.body.style.overflow = 'auto'; \n    }\n\n    \/\/ Close modal when clicking overlay background\n    document.getElementById('fileModal').addEventListener('click', function(e) {\n        if (e.target === this) closeModal();\n    });\n\n    document.getElementById('fileForm').onsubmit = async (e) => {\n        e.preventDefault();\n        const id = document.getElementById('editFileId').value;\n        const payload = {\n            file_name: document.getElementById('fileName').value,\n            dos_count: parseInt(document.getElementById('dosCount').value),\n            pages: parseInt(document.getElementById('pageCount').value),\n            received_on: document.getElementById('receivedOn').value,\n            file_link: document.getElementById('fileLink').value,\n            is_active: document.getElementById('fileActive').checked ? 1 : 0\n        };\n\n        if (id) payload.id = parseInt(id);\n        const url = id ? ENDPOINTS.UPDATE : ENDPOINTS.ADD;\n\n        try {\n            const res = await fetch(url, {\n                method: 'POST',\n                headers: getHeaders(),\n                body: JSON.stringify(payload)\n            });\n            if (res.ok) {\n                closeModal();\n                fetchFiles(paginationData.page);\n            }\n        } catch (err) { console.error(err); }\n    };\n\n    function renderPagination() {\n        const container = document.getElementById('pageNumbers');\n        container.innerHTML = '';\n        const { page, pages } = paginationData;\n\n        document.getElementById('prevBtn').onclick = () => fetchFiles(page - 1);\n        document.getElementById('prevBtn').className = page === 1 ? 'nav-btn disabled' : 'nav-btn';\n        document.getElementById('nextBtn').onclick = () => fetchFiles(page + 1);\n        document.getElementById('nextBtn').className = page === pages ? 'nav-btn disabled' : 'nav-btn';\n\n        if (pages === 0) return;\n\n        const addNum = (n) => {\n            const span = document.createElement('span');\n            span.className = n === page ? 'page-num active' : 'page-num';\n            span.textContent = n;\n            span.onclick = () => fetchFiles(n);\n            container.appendChild(span);\n        };\n        const addDots = () => {\n            const dots = document.createElement('span');\n            dots.textContent = '...';\n            dots.style.cssText = 'display:flex;align-items:center;padding:0 4px;color:#70757A';\n            container.appendChild(dots);\n        };\n\n        if (pages <= 5) {\n            for (let i = 1; i <= pages; i++) addNum(i);\n        } else {\n            addNum(1);\n            if (page > 3) addDots();\n            const start = Math.max(2, page - 1);\n            const end = Math.min(pages - 1, page + 1);\n            for (let i = start; i <= end; i++) addNum(i);\n            if (page < pages - 2) addDots();\n            addNum(pages);\n        }\n    }\n\n    function handleSearch() {\n        const q = document.getElementById('searchInput').value.toLowerCase();\n        const filtered = allFiles.filter(\n            f => (f.file_name || f.name).toLowerCase().includes(q)\n        );\n        renderFiles(filtered);\n    }\n\n    function toggleMenu(e, id) {\n        e.stopPropagation();\n        document.querySelectorAll('.dropdown-content').forEach(d => d.classList.remove('show'));\n        document.getElementById(`dropdown-${id}`).classList.add('show');\n    }\n\n    async function deleteFile(id) {\n        if (confirm(\"Are you sure you want to delete this file?\")) {\n            try {\n                const res = await fetch(ENDPOINTS.DELETE, { \n                    method: 'POST', \n                    headers: getHeaders(), \n                    body: JSON.stringify({ id }) \n                });\n                const result = await res.json();\n                if (res.ok || result.code === 200) {\n                    fetchFiles(paginationData.page);\n                } else {\n                    alert(result.message || 'Delete failed. Please try again.');\n                }\n            } catch (err) { \n                console.error(err); \n                alert('An error occurred while deleting. Please try again.');\n            }\n        }\n    }\n\n    function downloadCSV() {\n        if (!allFiles || allFiles.length === 0) {\n            alert('No data available to download.');\n            return;\n        }\n        const headers = ['File ID', 'File Name', 'Pages', 'No. of DOS', 'Assigned DOS', 'Completed DOS', 'Pending DOS', 'File Link', 'Received On', 'Status'];\n        const rows = allFiles.map(file => [\n            file.id,\n            `\"${(file.file_name || file.name || '').replace(\/\"\/g, '\"\"')}\"`,\n            file.pages || 0,\n            file.total_dos || file.dos_count || 0,\n            file.total_assigned_dos || 0,\n            file.total_completed_dos || 0,\n            file.total_pending_dos || 0,\n            `\"${(file.file_link || 'N\/A').replace(\/\"\/g, '\"\"')}\"`,\n            file.received_on || 'N\/A',\n            file.is_active == 1 ? 'Active' : 'Inactive'\n        ]);\n        const csvContent = [headers.join(','), ...rows.map(r => r.join(','))].join('\\n');\n        const blob = new Blob([csvContent], { type: 'text\/csv;charset=utf-8;' });\n        const url = URL.createObjectURL(blob);\n        const a = document.createElement('a');\n        a.href = url;\n        a.download = `files_export_${new Date().toISOString().slice(0,10)}.csv`;\n        document.body.appendChild(a);\n        a.click();\n        document.body.removeChild(a);\n        URL.revokeObjectURL(url);\n    }\n\n    window.onclick = () => \n        document.querySelectorAll('.dropdown-content').forEach(d => d.classList.remove('show'));\n\n    fetchFiles();\n<\/script>\n<\/div><\/div>\n\n<\/div><\/div><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>File (0) + Add New File + CSV Download \u00ab Previous Next \u00bb Showing 0 to 0 of 0 entries New File File Name * Dos Count * Page * Received On * File Link * Active File* Close Save<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"class_list":["post-95","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/pages\/95","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/comments?post=95"}],"version-history":[{"count":1,"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/pages\/95\/revisions"}],"predecessor-version":[{"id":98,"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/pages\/95\/revisions\/98"}],"wp:attachment":[{"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/media?parent=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}