{"id":90,"date":"2026-03-31T05:18:58","date_gmt":"2026-03-31T05:18:58","guid":{"rendered":"https:\/\/ph-portal.zyneventures.com\/?page_id=90"},"modified":"2026-03-31T05:18:58","modified_gmt":"2026-03-31T05:18:58","slug":"entities","status":"publish","type":"page","link":"https:\/\/ph-portal.zyneventures.com\/index.php\/entities\/","title":{"rendered":"Entities"},"content":{"rendered":"<style>.kadence-column90_089322-97 > .kt-inside-inner-col,.kadence-column90_089322-97 > .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-column90_089322-97 > .kt-inside-inner-col{column-gap:var(--global-kb-gap-sm, 1rem);}.kadence-column90_089322-97 > .kt-inside-inner-col{flex-direction:column;}.kadence-column90_089322-97 > .kt-inside-inner-col > .aligncenter{width:100%;}.kadence-column90_089322-97 > .kt-inside-inner-col:before{opacity:0.3;}.kadence-column90_089322-97{position:relative;}@media all and (max-width: 1024px){.kadence-column90_089322-97 > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}@media all and (max-width: 767px){.kadence-column90_089322-97 > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}<\/style>\n<div class=\"wp-block-kadence-column kadence-column90_089322-97\"><div class=\"kt-inside-inner-col\"><style>.kb-row-layout-id90_044132-cf > .kt-row-column-wrap{align-content:start;}:where(.kb-row-layout-id90_044132-cf > .kt-row-column-wrap) > .wp-block-kadence-column{justify-content:start;}.kb-row-layout-id90_044132-cf > .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-id90_044132-cf > .kt-row-layout-overlay{opacity:0.30;}@media all and (max-width: 1024px){.kb-row-layout-id90_044132-cf > .kt-row-column-wrap{grid-template-columns:minmax(0, 1fr);}}@media all and (max-width: 767px){.kb-row-layout-id90_044132-cf > .kt-row-column-wrap{grid-template-columns:minmax(0, 1fr);}}<\/style><div class=\"kb-row-layout-wrap kb-row-layout-id90_044132-cf 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-column90_50720a-c4 > .kt-inside-inner-col,.kadence-column90_50720a-c4 > .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-column90_50720a-c4 > .kt-inside-inner-col{column-gap:var(--global-kb-gap-sm, 1rem);}.kadence-column90_50720a-c4 > .kt-inside-inner-col{flex-direction:column;}.kadence-column90_50720a-c4 > .kt-inside-inner-col > .aligncenter{width:100%;}.kadence-column90_50720a-c4 > .kt-inside-inner-col:before{opacity:0.3;}.kadence-column90_50720a-c4{position:relative;}@media all and (max-width: 1024px){.kadence-column90_50720a-c4 > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}@media all and (max-width: 767px){.kadence-column90_50720a-c4 > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}<\/style>\n<div class=\"wp-block-kadence-column kadence-column90_50720a-c4\"><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: #1E8E3E;\n        --error-red: #D93025;\n    }\n\n    body { \n        margin: 0; \n        font-family: 'Sora', sans-serif; \n        color: var(--text-dark); \n        background-color: #fff;\n        box-sizing: border-box;\n    }\n    \n    \/* Header Section - 100% Match with Projects *\/\n    .header-container { \n        display: flex; \n        justify-content: space-between; \n        align-items: center; \n        margin-bottom: 28px; \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: 12px; \n        align-items: center; \n    }\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-outline { background: #F1F3F4; color: #5f6368; border: none; }\n    .btn-filter {\n        background: transparent;\n        border: 1px solid;\n        border-color: #F1F3F4;\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        padding: 0;\n        flex-shrink: 0;\n        transition: background 0.2s;\n    }\n    .btn-filter:hover { background: transparent; }\n    .btn-filter svg { color: #5f6368; }\n\n    \/* \u2500\u2500 Filter Button wrapper \u2500\u2500 *\/\n    .filter-wrapper { position: relative; }\n\n    \/* Grid & Cards - 100% Match with Projects *\/\n    .project-grid { \n        display: grid; \n        grid-template-columns: repeat(3, 1fr); \n        gap: 20px; \n        margin-top: 20px; \n    }\n    @media (max-width: 1100px) {\n        .project-grid { grid-template-columns: repeat(2, 1fr); }\n    }\n    @media (max-width: 700px) {\n        .project-grid { grid-template-columns: 1fr; }\n        body { padding: 20px; }\n        .action-group { flex-wrap: wrap; }\n        .search-wrapper { width: 100%; box-sizing: border-box; }\n    }\n    .project-card { \n        border: 1px solid var(--border-color); \n        border-radius: 12px; \n        padding: 24px; \n        background: #fff;\n        transition: box-shadow 0.3s;\n    }\n    .project-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.05); }\n    \n    .card-header { \n        display: flex; \n        justify-content: space-between; \n        align-items: center; \n        margin-bottom: 20px; \n    }\n    .card-title { \n        font-weight: 500; \n        font-size: 18px; \n        color: var(--text-dark); \n    }\n    \n    .badge-container { display: flex; align-items: center; gap: 10px; }\n    \n    .status-badge { \n        padding: 4px 12px; \n        border-radius: 20px; \n        font-size: 12px; \n        font-weight: 500; \n        display: flex; \n        align-items: center; \n        justify-content: center;\n        gap: 6px; \n        min-width: 80px; \n        height: 24px;\n        box-sizing: border-box;\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    .card-body { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }\n    .info-label { color: var(--text-muted); font-size: 12px; margin-bottom: 4px; }\n    .info-value { font-size: 13px; font-weight: 500; color: #333; }\n\n    \/* Dropdown *\/\n    .menu-container { position: relative; display: flex; align-items: center; gap: 8px; }\n    .menu-dots { cursor: pointer; color: #212529; font-size: 21px; line-height: 1; padding: 0 4px; }\n    .dropdown-content { \n        display: none; \n        position: absolute; \n        right: 0; \n        top: 25px; \n        background: white; \n        min-width: 120px; \n        box-shadow: 0 8px 16px rgba(0,0,0,0.1); \n        z-index: 100; \n        border-radius: 8px; \n        border: 1px solid #eee; \n        overflow: hidden;\n    }\n    .dropdown-content.show { display: block; }\n    .dropdown-item { padding: 12px 16px; font-size: 12px; cursor: pointer; color: #444; }\n    .dropdown-item:hover { background-color: #f8f9fa; color: var(--primary-blue); }\n\n    \/* Modal - 100% Match *\/\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: 500px; \n        box-shadow: 0 20px 40px rgba(0,0,0,0.2);\n    }\n    .form-group { margin-bottom: 25px; }\n    .form-group label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 12px; }\n    .form-group label span { color: var(--error-red); }\n    .form-control { \n        width: 100%; \n        padding: 14px; \n        border: 1px solid #E0E0E0; \n        border-radius: 8px; \n        box-sizing: border-box; \n        font-family: 'Sora'; \n        font-size: 12px;\n    }\n\n    \/* Toggle *\/\n    .toggle-row { \n        display: flex; \n        justify-content: space-between; \n        align-items: center; \n        margin-top: 10px; \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 - 100% Match *\/\n    .pagination-footer { \n        margin-top: 50px; \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: 15px; }\n    @media (max-width: 700px) {\n        .pagination-footer { flex-direction: column; align-items: flex-start; }\n        #entryInfo { width: 100%; order: 2; }\n        .pagination-controls { order: 1; }\n    }\n    .page-num { \n        cursor: pointer; \n        width: 35px; height: 35px; \n        display: flex; \n        align-items: center; \n        justify-content: center; \n        border-radius: 50%; \n        font-weight: 500;\n    }\n    .page-num.active { background: var(--primary-blue); color: white; }\n    .nav-btn { cursor: pointer; color: var(--text-dark); font-weight: 500; text-decoration: none; }\n    .nav-btn.disabled { color: #ccc; pointer-events: none; }\n<\/style>\n\n<div class=\"header-container\">\n    <div class=\"title-group\">\n        <h2>Entities<\/h2>\n        <span class=\"count\" id=\"entityCount\">(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 Entity...\" oninput=\"handleSearch()\">\n        <\/div>\n        <!-- Filter Button (no dropdown) -->\n        <div class=\"filter-wrapper\">\n            <button class=\"btn-filter\" title=\"Filter\">\n                <svg width=\"17\" height=\"17\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n                    <line x1=\"4\" y1=\"6\" x2=\"20\" y2=\"6\"\/>\n                    <line x1=\"7\" y1=\"12\" x2=\"17\" y2=\"12\"\/>\n                    <line x1=\"10\" y1=\"18\" x2=\"14\" y2=\"18\"\/>\n                <\/svg>\n            <\/button>\n        <\/div>\n        <button class=\"btn btn-primary\" onclick=\"openModal('add')\">+ Add New Entity<\/button>\n        <button class=\"btn btn-primary\" onclick=\"downloadCSV()\">Download CSV<\/button>\n    <\/div>\n<\/div>\n\n<div class=\"project-grid\" id=\"entityContainer\"><\/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: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=\"entityModal\">\n    <div class=\"modal-content\">\n        <h3 id=\"modalTitle\" style=\"margin: 0 0 30px 0; font-size: 24px; font-weight: 500;\">New Entity<\/h3>\n        <form id=\"entityForm\">\n            <input type=\"hidden\" id=\"editEntityId\">\n            <div class=\"form-group\">\n                <label>Entity Name <span>*<\/span><\/label>\n                <input type=\"text\" id=\"entityName\" class=\"form-control\" placeholder=\"Enter Entity Name\" required>\n            <\/div>\n            <div class=\"form-group\">\n                <label>Client <span>*<\/span><\/label>\n                <select id=\"clientSelect\" class=\"form-control\" required>\n                    <option value=\"\">Select Client<\/option>\n                    <option value=\"14\">CBO<\/option>\n                    <option value=\"23\">AZ Internal Medicine<\/option>\n                <\/select>\n            <\/div>\n            <div class=\"toggle-row\">\n                <label id=\"activeLabel\" style=\"font-size:12px; font-weight:500;\">Entity Active <span>*<\/span><\/label>\n                <label class=\"switch\">\n                    <input type=\"checkbox\" id=\"entityActive\" checked>\n                    <span class=\"slider\"><\/span>\n                <\/label>\n            <\/div>\n            <div style=\"display:flex; justify-content:flex-end; gap:15px; margin-top:40px;\">\n                <button type=\"button\" class=\"btn\" style=\"background:transparent; color:#212529;\" 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}\/entity\/all`,\n        DETAIL: `${BASE_URL}\/entity\/detail`,\n        ADD: `${BASE_URL}\/entity\/add`,\n        UPDATE: `${BASE_URL}\/entity\/update`,\n        DELETE: `${BASE_URL}\/entity\/delete`\n    };\n\n    let allEntities = [];\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 fetchEntities(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                allEntities = result.data.data;\n                \/\/ Calculate total pages based on provided perPage\n                paginationData = {\n                    page: result.data.page,\n                    limit: result.data.perPage,\n                    total: result.data.total,\n                    pages: Math.ceil(result.data.total \/ result.data.perPage)\n                };\n                renderEntities();\n                renderPagination();\n            }\n        } catch (err) { console.error(\"Fetch Error:\", err); }\n    }\n\n    function renderEntities(filtered = null) {\n        const container = document.getElementById('entityContainer');\n        const list = filtered || allEntities;\n        document.getElementById('entityCount').textContent = `(${paginationData.total})`;\n        \n        const start = \n            paginationData.total === 0 ? 0 : ((paginationData.page - 1) * paginationData.limit) + 1;\n        const end = \n            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(ent => {\n            const isActive = ent.is_active == 1;\n            const card = document.createElement('div');\n            card.className = 'project-card';\n            card.innerHTML = `\n                <div class=\"card-header\">\n                    <span class=\"card-title\">${ent.entity}<\/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, ${ent.id})\">\u22ee<\/span>\n                            <div class=\"dropdown-content\" id=\"dropdown-${ent.id}\">\n                                <div class=\"dropdown-item\" onclick=\"openModal('edit', ${ent.id})\">Edit<\/div>\n                                <div class=\"dropdown-item\" style=\"color:var(--error-red)\" onclick=\"deleteEntity(${ent.id})\">Delete<\/div>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n                <\/div>\n                <div class=\"card-body\">\n                    <div class=\"info-group\">\n                        <div class=\"info-label\">Entity ID: ${ent.id}<\/div>\n                    <\/div>\n                    <div class=\"info-group\">\n                        <div class=\"info-label\">Client<\/div>\n                        <div class=\"info-value\">${ent.client_name || 'N\/A'}<\/div>\n                    <\/div>\n                <\/div>`;\n            container.appendChild(card);\n        });\n    }\n\n    async function openModal(mode, id = null) {\n        const modal = document.getElementById('entityModal');\n        const form = document.getElementById('entityForm');\n        const activeLabel = document.getElementById('activeLabel');\n        form.reset();\n        \n        if (mode === 'edit') {\n            document.getElementById('modalTitle').textContent = 'Update Entity';\n            activeLabel.textContent = 'Active Role *';\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('editEntityId').value = data.id;\n                document.getElementById('entityName').value = data.entity;\n                document.getElementById('clientSelect').value = data.client_id;\n                document.getElementById('entityActive').checked = (data.is_active == 1);\n            } catch (err) { console.error(err); }\n        } else {\n            document.getElementById('modalTitle').textContent = 'New Entity';\n            activeLabel.textContent = 'Entity Active *';\n            document.getElementById('editEntityId').value = '';\n        }\n        modal.style.display = 'flex';\n    }\n\n    function closeModal() { document.getElementById('entityModal').style.display = 'none'; }\n\n    document.getElementById('entityForm').onsubmit = async (e) => {\n        e.preventDefault();\n        const id = document.getElementById('editEntityId').value;\n        const payload = {\n            entity: document.getElementById('entityName').value,\n            client_id: document.getElementById('clientSelect').value,\n            is_active: document.getElementById('entityActive').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) { closeModal(); fetchEntities(paginationData.page); }\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 = () => fetchEntities(page - 1);\n        document.getElementById('prevBtn').className = page === 1 ? 'nav-btn disabled' : 'nav-btn';\n\n        \/\/ Build set of page numbers to show: always first, last, current, and current\u00b11\n        \/\/ Cap to exactly 5 visible numbers\n        const toShow = new Set();\n        toShow.add(1);\n        toShow.add(pages);\n        toShow.add(page);\n        if (page - 1 >= 1) toShow.add(page - 1);\n        if (page + 1 <= pages) toShow.add(page + 1);\n\n        \/\/ If still under 5, fill inward\n        if (toShow.size < 5) {\n            if (page - 2 >= 1) toShow.add(page - 2);\n        }\n        if (toShow.size < 5) {\n            if (page + 2 <= pages) toShow.add(page + 2);\n        }\n\n        const sorted = Array.from(toShow).sort((a, b) => a - b);\n\n        sorted.forEach((num, idx) => {\n            \/\/ Add ellipsis if gap between consecutive shown numbers\n            if (idx > 0 && num - sorted[idx - 1] > 1) {\n                const dot = document.createElement('span');\n                dot.textContent = '...';\n                dot.style.cssText = 'display:flex;align-items:center;color:var(--text-muted);font-size:12px;padding:0 2px;';\n                container.appendChild(dot);\n            }\n            const span = document.createElement('span');\n            span.className = num === page ? 'page-num active' : 'page-num';\n            span.textContent = num;\n            span.onclick = () => fetchEntities(num);\n            container.appendChild(span);\n        });\n\n        document.getElementById('nextBtn').onclick = () => fetchEntities(page + 1);\n        document.getElementById('nextBtn').className = (page === pages || paginationData.total === 0) ? 'nav-btn disabled' : 'nav-btn';\n    }\n\n    function handleSearch() {\n        const q = document.getElementById('searchInput').value.toLowerCase();\n        const filtered = allEntities.filter(e => e.entity.toLowerCase().includes(q));\n        renderEntities(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    window.onclick = () => \n        document.querySelectorAll('.dropdown-content').forEach(d => d.classList.remove('show'));\n\n    async function deleteEntity(id) {\n        if (!confirm('Are you sure you want to delete this entity? This action cannot be undone.')) return;\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 || result.success)) {\n                fetchEntities(paginationData.page);\n            } else {\n                alert(result.message || 'Failed to delete entity.');\n            }\n        } catch (err) {\n            console.error('Delete error:', err);\n            alert('An error occurred while deleting the entity.');\n        }\n    }\n\n    function downloadCSV() {\n        if (!allEntities || allEntities.length === 0) {\n            alert('No data available to export.');\n            return;\n        }\n        const headers = ['Entity Name', 'Client', 'Status'];\n        const rows = allEntities.map(e => [\n            `\"${(e.entity || '').replace(\/\"\/g, '\"\"')}\"`,\n            `\"${(e.client_name || 'N\/A').replace(\/\"\/g, '\"\"')}\"`,\n            e.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 link = document.createElement('a');\n        link.href = url;\n        link.download = 'entities.csv';\n        document.body.appendChild(link);\n        link.click();\n        document.body.removeChild(link);\n        URL.revokeObjectURL(url);\n    }\n\n    fetchEntities();\n<\/script>\n<\/div><\/div>\n\n<\/div><\/div><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Entities (0) + Add New Entity Download CSV \u00ab Previous Next \u00bb Showing 0 to 0 of 0 entries New Entity Entity Name * Client * Select ClientCBOAZ Internal Medicine Entity 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-90","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/pages\/90","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=90"}],"version-history":[{"count":1,"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/pages\/90\/revisions"}],"predecessor-version":[{"id":93,"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/pages\/90\/revisions\/93"}],"wp:attachment":[{"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/media?parent=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}