{"id":115,"date":"2026-03-31T05:44:07","date_gmt":"2026-03-31T05:44:07","guid":{"rendered":"https:\/\/ph-portal.zyneventures.com\/?page_id=115"},"modified":"2026-03-31T05:44:07","modified_gmt":"2026-03-31T05:44:07","slug":"client","status":"publish","type":"page","link":"https:\/\/ph-portal.zyneventures.com\/index.php\/client\/","title":{"rendered":"Client"},"content":{"rendered":"<style>.kadence-column115_c3f457-57 > .kt-inside-inner-col,.kadence-column115_c3f457-57 > .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-column115_c3f457-57 > .kt-inside-inner-col{column-gap:var(--global-kb-gap-sm, 1rem);}.kadence-column115_c3f457-57 > .kt-inside-inner-col{flex-direction:column;}.kadence-column115_c3f457-57 > .kt-inside-inner-col > .aligncenter{width:100%;}.kadence-column115_c3f457-57 > .kt-inside-inner-col:before{opacity:0.3;}.kadence-column115_c3f457-57{position:relative;}@media all and (max-width: 1024px){.kadence-column115_c3f457-57 > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}@media all and (max-width: 767px){.kadence-column115_c3f457-57 > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}<\/style>\n<div class=\"wp-block-kadence-column kadence-column115_c3f457-57\"><div class=\"kt-inside-inner-col\"><style>.kb-row-layout-id115_3a3b10-cb > .kt-row-column-wrap{align-content:start;}:where(.kb-row-layout-id115_3a3b10-cb > .kt-row-column-wrap) > .wp-block-kadence-column{justify-content:start;}.kb-row-layout-id115_3a3b10-cb > .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-id115_3a3b10-cb > .kt-row-layout-overlay{opacity:0.30;}@media all and (max-width: 1024px){.kb-row-layout-id115_3a3b10-cb > .kt-row-column-wrap{grid-template-columns:minmax(0, 1fr);}}@media all and (max-width: 767px){.kb-row-layout-id115_3a3b10-cb > .kt-row-column-wrap{grid-template-columns:minmax(0, 1fr);}}<\/style><div class=\"kb-row-layout-wrap kb-row-layout-id115_3a3b10-cb 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-column115_90991c-87 > .kt-inside-inner-col,.kadence-column115_90991c-87 > .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-column115_90991c-87 > .kt-inside-inner-col{column-gap:var(--global-kb-gap-sm, 1rem);}.kadence-column115_90991c-87 > .kt-inside-inner-col{flex-direction:column;}.kadence-column115_90991c-87 > .kt-inside-inner-col > .aligncenter{width:100%;}.kadence-column115_90991c-87 > .kt-inside-inner-col:before{opacity:0.3;}.kadence-column115_90991c-87{position:relative;}@media all and (max-width: 1024px){.kadence-column115_90991c-87 > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}@media all and (max-width: 767px){.kadence-column115_90991c-87 > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}<\/style>\n<div class=\"wp-block-kadence-column kadence-column115_90991c-87\"><div class=\"kt-inside-inner-col\">\n<style>\n        :root {\n            --primary-blue: #0180FF;        \n            --hover-blue: #3499FF;\n            --text-dark: #212529;\n            --text-muted: #8D8C9C;\n            --border-color: #EFEFEF;\n            --success-green: #28a745;\n            --error-red: #dc3545;\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        \/* Header Section *\/\n        .header-container { \n            display: flex; \n            justify-content: space-between; \n            align-items: center; \n            margin-bottom: 24px;\n            flex-wrap: wrap;\n            gap: 12px;\n        }\n        .title-group { \n            display: flex; \n            align-items: center; \n            gap: 10px; \n        }\n        .title-group 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        \n        .action-group { \n            display: flex; \n            gap: 10px; \n            align-items: center; \n            flex-wrap: wrap;\n        }\n\n        \/* Filter Button - matches original exactly *\/\n        .btn-filter {\n            background: #fff;\n            border: 1px solid #E0E0E0;\n            border-radius: 6px;\n            width: 38px;\n            height: 38px;\n            display: flex;\n            align-items: center;\n            justify-content: center;\n            cursor: pointer;\n            flex-shrink: 0;\n            padding: 0;\n            color: #5f6368;\n            transition: 0.2s;\n        }\n        .btn-filter:hover { background: #f8f9fa; }\n\n        \/* Search Bar *\/\n        .search-wrapper { \n            background: #F1F3F4; \n            border-radius: 6px; \n            padding: 8px 15px; \n            display: flex; \n            align-items: center; \n            width: 300px; \n            gap: 12px;\n        }\n        .search-icon { \n            width: 18px; \n            height: 18px; \n            color: #8D8C9C; \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        .btn { \n            padding: 8px 15px; \n            border-radius: 6px; \n            font-size: 12px; \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        }\n        .btn-primary { background: var(--primary-blue); color: white; }\n        .btn-primary:hover { background-color: #3499FF; }\n        .btn-outline { background: #F1F3F4; color: #5f6368; border: none; }\n        \n        \/* Close Button *\/\n        .btn-close { \n            background: transparent !important; \n            color: #212529; \n            border: none;\n            box-shadow: none;\n        }\n        .btn-close:hover { \n            background: transparent !important; \n            color: #212529;\n        }\n\n        \/* Grid - 3 cards per row with equal heights *\/\n        .client-grid { \n            display: grid; \n            grid-template-columns: repeat(3, 1fr); \n            gap: 20px; \n            margin-top: 20px; \n            align-items: stretch;\n        }\n        \n        .client-card { \n            border: 1px solid var(--border-color); \n            border-radius: 12px; \n            padding: 24px; \n            background: #fff;\n            position: relative;\n            display: flex;\n            flex-direction: column;\n            justify-content: space-between;\n            min-height: 140px; \/* Ensures uniform size *\/\n        }\n        \n        .card-header { \n            display: flex; \n            justify-content: space-between; \n            align-items: flex-start; \n            margin-bottom: 20px; \n        }\n        .card-title { \n            font-weight: 500; \n            font-size: 18px; \n            color: var(--text-dark);\n            line-height: 1.3;\n            padding-right: 10px;\n            word-break: break-word;\n        }\n        \n        .badge-container { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }\n        \n        \/* Status Badge Fixed Size - Never changes due to title size *\/\n        .status-badge { \n            padding: 4px 12px; \n            border-radius: 20px; \n            font-size: 12px; \n            font-weight: 400; \n            display: flex; \n            align-items: center; \n            justify-content: center;\n            gap: 6px; \n            width: 90px; \n            height: 28px;\n            box-sizing: border-box;\n            flex-shrink: 0;\n        }\n        .status-active { background: #E6F4EA; color: var(--success-green); }\n        .status-active::before { content: '\u25cf'; font-size: 8px; }\n        .status-inactive { background: #FCE8E6; color: var(--error-red); }\n        .status-inactive::before { content: '\u25cf'; font-size: 8px; }\n        \n        .info-label { color: var(--text-muted); font-size: 14px; margin-top: auto; }\n\n        \/* Dropdown Menu *\/\n        .menu-container { position: relative; }\n        .menu-dots { cursor: pointer; color: #212529; font-size: 20px; padding: 0 5px; }\n        .dropdown-content { \n            display: none; \n            position: absolute; \n            right: 0; \n            top: 25px; \n            background: white; \n            min-width: 110px; \n            box-shadow: 0 4px 12px rgba(0,0,0,0.1); \n            z-index: 100; \n            border-radius: 8px; \n            border: 1px solid #eee; \n        }\n        .dropdown-content.show { display: block; }\n        .dropdown-item { \n            padding: 8px 15px; \n            font-size: 12px; \n            cursor: pointer; \n            color: #212529; \n            text-align: left; }\n        .dropdown-item:hover { \n            background-color: #f8f9fa; \n            color: var(--primary-blue); \n        }\n\n        \/* Modal styling *\/\n        .modal-overlay { \n            display: none; \n            position: fixed; \n            top: 0; \n            left: 0; \n            width: 100%; \n            height: 100%; \n            background: rgba(0,0,0,0.4); \n            z-index: 1000; \n            justify-content: center; \n            align-items: center; \n        }\n        .modal-content { \n            background: white; \n            padding: 40px; \n            border-radius: 12px; \n            width: 480px; \n            box-shadow: 0 20px 40px rgba(0,0,0,0.2);\n        }\n        .modal-content h3 { margin: 0 0 30px 0; font-size: 24px; font-weight: 500; color: #333; }\n        .form-group { margin-bottom: 25px; }\n        .form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 10px; }\n        .form-group label span { color: var(--error-red); }\n        .form-control { \n            width: 100%; \n            padding: 12px 15px; \n            border: 1px solid #E0E0E0; \n            border-radius: 8px; \n            box-sizing: border-box; \n            font-family: 'Sora'; \n            font-size: 14px;\n        }\n\n        \/* Toggle Switch *\/\n        .toggle-row { \n            display: flex; \n            justify-content: space-between; \n            align-items: center; \n            margin-bottom: 30px; \n        }\n        .switch { position: relative; display: inline-block; width: 44px; height: 22px; }\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: 16px; \n            width: 16px; \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(22px); }\n\n        \/* Pagination *\/\n        .pagination-footer { \n            margin-top: 40px; \n            display: flex; \n            justify-content: space-between; \n            align-items: center; \n            color: var(--text-muted); \n            font-size: 12px;\n            flex-wrap: wrap;\n            gap: 12px;\n        }\n        .pagination-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }\n        .page-num { \n            cursor: pointer; \n            width: 35px; \n            height: 35px; \n            display: flex; \n            align-items: center; \n            justify-content: center; \n            border-radius: 50%; \n            font-weight: 400;\n            font-size: 12px;\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: #ccc; pointer-events: none; }\n\n        \/* Responsive *\/\n        @media (max-width: 900px) {\n            .client-grid { grid-template-columns: repeat(2, 1fr); }\n        }\n        @media (max-width: 600px) {\n            body { padding: 16px; }\n            .client-grid { grid-template-columns: 1fr; }\n            .search-wrapper { width: 100%; }\n            .header-container { flex-direction: column; align-items: flex-start; }\n            .action-group { width: 100%; justify-content: flex-start; }\n            \/* Mobile pagination: entry info on its own row *\/\n            .pagination-footer {\n                flex-direction: column;\n                align-items: center;\n            }\n            .pagination-controls { justify-content: center; }\n            #entryInfo { width: 100%; text-align: center; }\n        }\n    <\/style>\n\n\n<div class=\"header-container\">\n    <div class=\"title-group\">\n        <h2>Client<\/h2>\n        <span class=\"count\" id=\"clientCount\">(0)<\/span>\n    <\/div>\n    <div class=\"action-group\">\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 Clients...\" oninput=\"handleGlobalSearch()\">\n        <\/div>\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\"><line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"><\/line><line x1=\"6\" y1=\"12\" x2=\"18\" y2=\"12\"><\/line><line x1=\"9\" y1=\"18\" x2=\"15\" y2=\"18\"><\/line><\/svg>\n        <\/button>\n        <button class=\"btn btn-primary\" onclick=\"openModal('add')\">+ Add New Clients<\/button>\n        <button class=\"btn btn-primary\" onclick=\"downloadCSV()\">Download CSV<\/button>\n    <\/div>\n<\/div>\n\n<div class=\"client-grid\" id=\"clientContainer\"><\/div>\n\n<div class=\"pagination-footer\" id=\"paginationFooter\">\n    <div class=\"pagination-controls\">\n        <span id=\"prevBtn\" class=\"nav-btn\">\u00ab Previous<\/span>\n        <div id=\"pageNumbers\" style=\"display:flex; gap:8px;\"><\/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=\"clientModal\">\n    <div class=\"modal-content\">\n        <h3 id=\"modalTitle\">New Client<\/h3>\n        <form id=\"clientForm\">\n            <input type=\"hidden\" id=\"editClientId\">\n            <div class=\"form-group\">\n                <label>Client Name <span>*<\/span><\/label>\n                <input type=\"text\" id=\"clientName\" class=\"form-control\" placeholder=\"Enter Client Name\" required>\n            <\/div>\n            \n            <div class=\"toggle-row\">\n                <label id=\"toggleLabel\">Client Active <span>*<\/span><\/label>\n                <label class=\"switch\">\n                    <input type=\"checkbox\" id=\"clientActive\" checked>\n                    <span class=\"slider\"><\/span>\n                <\/label>\n            <\/div>\n\n            <div style=\"display:flex; justify-content:flex-end; gap:15px; margin-top:20px;\">\n                <button type=\"button\" class=\"btn btn-close\" onclick=\"closeModal()\">Close<\/button>\n                <button type=\"submit\" 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}\/client\/all`,\n        DETAIL: `${BASE_URL}\/client\/detail`,\n        ADD: `${BASE_URL}\/client\/add`,\n        UPDATE: `${BASE_URL}\/client\/update`\n    };\n\n    let allClientsGlobal = []; \/\/ Stores ALL data for search\n    let currentPageData = [];  \/\/ Stores current page data\n    let paginationData = { page: 1, limit: 10, total: 0, pages: 0 };\n    let isSearchActive = false;\n\n    const getHeaders = () => ({\n        'Content-Type': 'application\/json',\n        'Authorization': `Bearer ${localStorage.getItem(\"TOKEN\")}`\n    });\n\n    \/\/ Fetch initial data and pagination\n    async function fetchClients(page = 1) {\n        try {\n            const res = await fetch(\n                `${ENDPOINTS.ALL}?page=${page}`, \n                { headers: getHeaders() }\n            );\n            const result = await res.json();\n            if (result.code === 200) {\n                currentPageData = result.data.data;\n                paginationData = {\n                    page: result.data.current_page,\n                    limit: result.data.per_page,\n                    total: result.data.total,\n                    pages: result.data.last_page\n                };\n                \n                \/\/ If this is first load, fetch all for global search capability\n                if(allClientsGlobal.length === 0) fetchAllForSearch();\n\n                if(!isSearchActive) {\n                    renderClients(currentPageData);\n                    renderPagination();\n                    document.getElementById('paginationFooter').style.display = 'flex';\n                }\n            }\n        } catch (err) { console.error(\"Fetch Error:\", err); }\n    }\n\n    \/\/ Secondary fetch to cache all items for global search\n    async function fetchAllForSearch() {\n        try {\n            const res = await fetch(\n                `${ENDPOINTS.ALL}?limit=1000`, \n                { headers: getHeaders() }\n            );\n            const result = await res.json();\n            if (result.code === 200) {\n                allClientsGlobal = result.data.data;\n            }\n        } catch (err) {}\n    }\n\n    function renderClients(list) {\n        const container = document.getElementById('clientContainer');\n        document.getElementById('clientCount').textContent = `(${isSearchActive ? list.length : paginationData.total})`;\n        \n        const start = \n            isSearchActive ? (list.length > 0 ? 1 : 0) : (((paginationData.page - 1) * paginationData.limit) + 1);\n        const end = \n            isSearchActive ? list.length : Math.min(paginationData.page * paginationData.limit, paginationData.total);\n        document.getElementById('entryInfo').textContent = `Showing ${start} to ${end} of ${isSearchActive ? list.length : paginationData.total} entries`;\n\n        container.innerHTML = '';\n        list.forEach(client => {\n            const isActive = client.is_active == 1;\n            const card = document.createElement('div');\n            card.className = 'client-card';\n            card.innerHTML = `\n                <div class=\"card-header\">\n                    <span class=\"card-title\">${client.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 class=\"menu-container\">\n                            <span class=\"menu-dots\" onclick=\"toggleMenu(event, ${client.id})\">\u22ee<\/span>\n                            <div class=\"dropdown-content\" id=\"dropdown-${client.id}\">\n                                <div class=\"dropdown-item\" onclick=\"openModal('edit', ${client.id})\">Edit<\/div>\n                                <div class=\"dropdown-item\" style=\"color:var(--error-red)\" onclick=\"deleteClient(${client.id})\">Delete<\/div>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n                <\/div>\n                <div class=\"info-label\">Client ID: ${client.id}<\/div>`;\n            container.appendChild(card);\n        });\n    }\n\n    \/\/ Global search across all data\n    function handleGlobalSearch() {\n        const query = document.getElementById('searchInput').value.toLowerCase().trim();\n        if (query === \"\") {\n            isSearchActive = false;\n            document.getElementById('paginationFooter').style.display = 'flex';\n            renderClients(currentPageData);\n            renderPagination();\n        } else {\n            isSearchActive = true;\n            document.getElementById('paginationFooter').style.display = 'none';\n            const filtered = allClientsGlobal.filter(c => \n                c.name.toLowerCase().includes(query) || \n                c.id.toString().includes(query)\n            );\n            renderClients(filtered);\n        }\n    }\n\n    async function openModal(mode, id = null) {\n        const modal = document.getElementById('clientModal');\n        const form = document.getElementById('clientForm');\n        form.reset();\n        \n        if (mode === 'edit') {\n            document.getElementById('modalTitle').textContent = 'Update Client';\n            document.getElementById('toggleLabel').innerHTML = 'Client file <span>*<\/span>';\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                document.getElementById('editClientId').value = data.id;\n                document.getElementById('clientName').value = data.name;\n                document.getElementById('clientActive').checked = (data.is_active == 1);\n            } catch (err) { console.error(err); }\n        } else {\n            document.getElementById('modalTitle').textContent = 'New Client';\n            document.getElementById('toggleLabel').innerHTML = 'Client Active <span>*<\/span>';\n            document.getElementById('editClientId').value = '';\n        }\n        modal.style.display = 'flex';\n    }\n\n    function closeModal() { document.getElementById('clientModal').style.display = 'none'; }\n\n    document.getElementById('clientForm').onsubmit = async (e) => {\n        e.preventDefault();\n        const id = document.getElementById('editClientId').value;\n        const payload = {\n            name: document.getElementById('clientName').value,\n            is_active: document.getElementById('clientActive').checked ? 1 : 0\n        };\n        const url = id ? ENDPOINTS.UPDATE : ENDPOINTS.ADD;\n        if (id) payload.id = parseInt(id);\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                allClientsGlobal = []; \/\/ Reset global cache to force refresh\n                fetchClients(paginationData.page); \n            }\n        } catch (err) { console.error(err); }\n    };\n\n    function renderPagination() {\n        const container = document.getElementById('pageNumbers');\n        container.innerHTML = '';\n        document.getElementById('prevBtn').onclick = () => \n            fetchClients(paginationData.page - 1);\n        document.getElementById('prevBtn').className = paginationData.page === 1 ? 'nav-btn disabled' : 'nav-btn';\n        \n        for (let i = 1; i <= paginationData.pages; i++) {\n            const span = document.createElement('span');\n            span.className = i === paginationData.page ? 'page-num active' : 'page-num';\n            span.textContent = i;\n            span.onclick = () => fetchClients(i);\n            container.appendChild(span);\n        }\n        \n        document.getElementById('nextBtn').onclick = () => \n            fetchClients(paginationData.page + 1);\n        document.getElementById('nextBtn').className = paginationData.page === paginationData.pages ? 'nav-btn disabled' : 'nav-btn';\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    window.onclick = () => \n        document.querySelectorAll('.dropdown-content').forEach(d => d.classList.remove('show'));\n\n    async function deleteClient(id) {\n        if (!confirm('Are you sure you want to delete this client?')) return;\n        try {\n            const res = await fetch(`${BASE_URL}\/client\/delete`, {\n                method: 'POST',\n                headers: getHeaders(),\n                body: JSON.stringify({ id })\n            });\n            if (res.ok) {\n                allClientsGlobal = [];\n                fetchClients(paginationData.page);\n            } else {\n                alert('Failed to delete client.');\n            }\n        } catch (err) { console.error(err); alert('Error deleting client.'); }\n    }\n\n    function downloadCSV() {\n        const data = allClientsGlobal.length > 0 ? allClientsGlobal : currentPageData;\n        if (!data.length) return alert('No data to export.');\n        const headers = ['ID', 'Name', 'Status'];\n        const rows = data.map(c => [c.id, `\"${c.name.replace(\/\"\/g, '\"\"')}\"`, c.is_active == 1 ? 'Active' : 'Inactive']);\n        const csv = [headers.join(','), ...rows.map(r => r.join(','))].join('\\n');\n        const blob = new Blob([csv], { type: 'text\/csv' });\n        const url = URL.createObjectURL(blob);\n        const a = document.createElement('a');\n        a.href = url;\n        a.download = 'clients.csv';\n        a.click();\n        URL.revokeObjectURL(url);\n    }\n\n    fetchClients();\n<\/script>\n<\/div><\/div>\n\n<\/div><\/div><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Client (0) + Add New Clients Download CSV \u00ab Previous Next \u00bb Showing 0 to 0 of 0 entries New Client Client Name * Client Active * 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-115","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/pages\/115","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=115"}],"version-history":[{"count":1,"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/pages\/115\/revisions"}],"predecessor-version":[{"id":116,"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/pages\/115\/revisions\/116"}],"wp:attachment":[{"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/media?parent=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}