{"id":101,"date":"2026-03-31T05:34:17","date_gmt":"2026-03-31T05:34:17","guid":{"rendered":"https:\/\/ph-portal.zyneventures.com\/?page_id=101"},"modified":"2026-03-31T05:36:17","modified_gmt":"2026-03-31T05:36:17","slug":"project","status":"publish","type":"page","link":"https:\/\/ph-portal.zyneventures.com\/index.php\/project\/","title":{"rendered":"Project"},"content":{"rendered":"<style>.kadence-column101_380d80-f4 > .kt-inside-inner-col,.kadence-column101_380d80-f4 > .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-column101_380d80-f4 > .kt-inside-inner-col{column-gap:var(--global-kb-gap-sm, 1rem);}.kadence-column101_380d80-f4 > .kt-inside-inner-col{flex-direction:column;}.kadence-column101_380d80-f4 > .kt-inside-inner-col > .aligncenter{width:100%;}.kadence-column101_380d80-f4 > .kt-inside-inner-col:before{opacity:0.3;}.kadence-column101_380d80-f4{position:relative;}@media all and (max-width: 1024px){.kadence-column101_380d80-f4 > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}@media all and (max-width: 767px){.kadence-column101_380d80-f4 > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}<\/style>\n<div class=\"wp-block-kadence-column kadence-column101_380d80-f4\"><div class=\"kt-inside-inner-col\"><style>.kb-row-layout-id101_3b1bbd-21 > .kt-row-column-wrap{align-content:start;}:where(.kb-row-layout-id101_3b1bbd-21 > .kt-row-column-wrap) > .wp-block-kadence-column{justify-content:start;}.kb-row-layout-id101_3b1bbd-21 > .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-id101_3b1bbd-21 > .kt-row-layout-overlay{opacity:0.30;}@media all and (max-width: 1024px){.kb-row-layout-id101_3b1bbd-21 > .kt-row-column-wrap{grid-template-columns:minmax(0, 1fr);}}@media all and (max-width: 767px){.kb-row-layout-id101_3b1bbd-21 > .kt-row-column-wrap{grid-template-columns:minmax(0, 1fr);}}<\/style><div class=\"kb-row-layout-wrap kb-row-layout-id101_3b1bbd-21 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-column101_f14a6a-d6 > .kt-inside-inner-col,.kadence-column101_f14a6a-d6 > .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-column101_f14a6a-d6 > .kt-inside-inner-col{column-gap:var(--global-kb-gap-sm, 1rem);}.kadence-column101_f14a6a-d6 > .kt-inside-inner-col{flex-direction:column;}.kadence-column101_f14a6a-d6 > .kt-inside-inner-col > .aligncenter{width:100%;}.kadence-column101_f14a6a-d6 > .kt-inside-inner-col:before{opacity:0.3;}.kadence-column101_f14a6a-d6{position:relative;}@media all and (max-width: 1024px){.kadence-column101_f14a6a-d6 > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}@media all and (max-width: 767px){.kadence-column101_f14a6a-d6 > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}<\/style>\n<div class=\"wp-block-kadence-column kadence-column101_f14a6a-d6\"><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        }\n        \n        \/* Header Section *\/\n        .header-container { \n            display: flex; \n            justify-content: space-between; \n            align-items: center; \n            margin-bottom: 30px;\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        \/* 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: 260px; \n            gap: 10px;\n        }\n        .search-icon { \n            width: 16px; \n            height: 16px; \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        \/* Filter Button*\/\n        .filter-btn {\n            width: 36px;\n            height: 36px;\n            border-radius: 6px;\n            background: transparent; color: #212529;\n            border: 1px solid;\n            border-color: #F1F3F4;\n            cursor: pointer;\n            display: flex;\n            align-items: center;\n            justify-content: center;\n            flex-shrink: 0;\n            transition: background 0.2s;\n        }\n        .filter-btn:hover { background: transparent; color: #212529;}\n        .filter-btn svg { color: #5f6368; }\n\n        .btn { \n            padding: 8px 16px; \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            white-space: nowrap;\n            font-family: 'Sora', sans-serif;\n        }\n        .btn-primary { background: var(--primary-blue); color: white; }\n        .btn-primary:hover { background: var(--hover-blue); }\n        .btn-outline { background: #F1F3F4; color: #5f6368; border: none; }\n\n        \/* Project Cards Grid *\/\n        .project-grid { \n            display: grid; \n            grid-template-columns: repeat(3, 1fr); \n            gap: 16px; \n            margin-top: 10px; \n        }\n        .project-card { \n            border: 1px solid var(--border-color); \n            border-radius: 12px; \n            padding: 20px 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: flex-start; \n            margin-bottom: 16px; \n            gap: 8px;\n        }\n        .card-title { \n            font-weight: 500; \n            font-size: 16px; \n            color: var(--text-dark);\n            line-height: 1.4;\n            flex: 1;\n            min-width: 0;\n        }\n        \n        \/* Badge container: flex-shrink:0 prevents badge from shrinking due to long titles *\/\n        .badge-container { \n            display: flex; \n            align-items: center; \n            gap: 8px; \n            flex-shrink: 0;\n        }\n        \n        \/* Fixed size badges \u2014 consistent regardless of title length *\/\n        .status-badge { \n            border-radius: 20px; \n            font-size: 11px; \n            font-weight: 500; \n            display: inline-flex; \n            align-items: center; \n            justify-content: center;\n            gap: 5px; \n            \/* Fixed dimensions \u2014 never shrink or grow *\/\n            width: 80px;\n            height: 26px;\n            flex-shrink: 0;\n            box-sizing: border-box;\n            white-space: nowrap;\n        }\n        .status-active { background: #E6F4EA; color: var(--success-green); }\n        .status-inactive { background: #FCE8E6; color: var(--error-red); }\n\n        .status-dot {\n            width: 7px;\n            height: 7px;\n            border-radius: 50%;\n            flex-shrink: 0;\n        }\n        .status-active .status-dot { background: var(--success-green); }\n        .status-inactive .status-dot { background: var(--error-red); }\n\n        .card-body { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }\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        .info-link { color: var(--primary-blue); text-decoration: underline; cursor: pointer; }\n\n        \/* Dropdown Menu *\/\n        .menu-container { \n            position: relative; \n            display: flex; \n            align-items: center; \n        }\n        .menu-dots { \n            cursor: pointer; \n            color: #212529; \n            font-size: 20px; \n            line-height: 1; \n            padding: 2px 4px;\n            border-radius: 4px;\n            flex-shrink: 0;\n        }\n        .menu-dots:hover { background: #f1f3f4; }\n        .dropdown-content { \n            display: none; \n            position: absolute; \n            right: 0; \n            top: 28px; \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 { \n            padding: 10px 16px; \n            font-size: 12px; \n            cursor: pointer; \n            color: #444; \n        }\n        .dropdown-item:hover { background-color: #f8f9fa; color: var(--primary-blue); }\n        .dropdown-item.delete-item { color: var(--error-red); }\n        .dropdown-item.delete-item:hover { background-color: #fce8e6; color: var(--error-red); }\n\n        \/* Modal Overlay *\/\n        .modal-overlay { \n            display: none; \n            position: fixed; \n            top: 0; left: 0; width: 100%; 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            max-width: calc(100vw - 40px);\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; }\n        \n        .form-group { margin-bottom: 25px; }\n        .form-group label { \n            display: block; \n            font-size: 12px; \n            font-weight: 500; \n            margin-bottom: 12px; \n        }\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        \/* Close Button *\/\n        .btn-close { \n            background: transparent; \n            color: #212529; \n            padding: 8px 15px; \n            font-size: 12px;\n            font-weight: 500;\n            border: none;\n            cursor: pointer;\n            font-family: 'Sora', sans-serif;\n        }\n        .btn-close:hover { \n            color: #212529;\n            background-color: transparent; \n        }\n        \n        \/* Toggle Switch *\/\n        .toggle-row { \n            display: flex; \n            justify-content: space-between; \n            align-items: center; \n            margin-top: 10px; \n        }\n        .switch { \n            position: relative; \n            display: inline-block; \n            width: 44px; \n            height: 22px; \n        }\n        .switch input { opacity: 0; width: 0; height: 0; }\n        .slider { \n            position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; \n            background-color: #ccc; transition: .4s; border-radius: 34px; \n        }\n        .slider:before { \n            position: absolute; content: \"\"; height: 16px; width: 16px; \n            left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; \n        }\n        input:checked + .slider { background-color: var(--primary-blue); }\n        input:checked + .slider:before { transform: translateX(22px); }\n\n        \/* Pagination Footer *\/\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            gap: 12px;\n        }\n        .pagination-controls { display: flex; align-items: center; gap: 12px; }\n        .page-num { \n            cursor: pointer; width: 32px; height: 32px; \n            display: flex; align-items: center; justify-content: center; \n            border-radius: 50%; font-weight: 500; font-size: 13px;\n        }\n        .page-num.active { background: var(--primary-blue); color: white; }\n        .page-num:not(.active):hover { background: #f1f3f4; }\n        .nav-btn { \n            cursor: pointer; \n            color: var(--text-dark); \n            font-weight: 500; \n            font-size: 13px;\n        }\n        .nav-btn.disabled { color: #ccc; pointer-events: none; }\n\n        \/* Confirm Delete Modal *\/\n        .confirm-modal-overlay {\n            display: none;\n            position: fixed;\n            top: 0; left: 0; width: 100%; height: 100%;\n            background: rgba(0,0,0,0.4);\n            z-index: 2000;\n            justify-content: center;\n            align-items: center;\n        }\n        .confirm-modal {\n            background: white;\n            padding: 36px 40px;\n            border-radius: 12px;\n            width: 420px;\n            max-width: calc(100vw - 40px);\n            box-shadow: 0 20px 40px rgba(0,0,0,0.2);\n        }\n        .confirm-modal h3 { margin: 0 0 12px 0; font-size: 20px; font-weight: 600; }\n        .confirm-modal p { margin: 0 0 28px 0; font-size: 13px; color: var(--text-muted); }\n        .confirm-actions { display: flex; justify-content: flex-end; gap: 12px; }\n        .btn-danger { background: var(--error-red); color: white; padding: 10px 24px; }\n        .btn-danger:hover { background: #c0271f; }\n\n        \/* ===== RESPONSIVE ===== *\/\n        @media (max-width: 1024px) {\n            .project-grid {\n                grid-template-columns: repeat(2, 1fr);\n            }\n        }\n\n        @media (max-width: 768px) {\n            body {\n                padding: 20px 16px;\n            }\n            .header-container {\n                flex-direction: column;\n                align-items: flex-start;\n                gap: 12px;\n            }\n            .action-group {\n                width: 100%;\n            }\n            .search-wrapper {\n                width: 100%;\n                flex: 1;\n            }\n            .project-grid {\n                grid-template-columns: 1fr;\n                gap: 12px;\n            }\n            \/* Mobile pagination: entry info wraps below *\/\n            .pagination-footer {\n                flex-wrap: wrap;\n            }\n            .pagination-controls {\n                order: 1;\n                width: 100%;\n                justify-content: flex-start;\n                gap: 8px;\n            }\n            #entryInfo {\n                order: 2;\n                width: 100%;\n                text-align: left;\n            }\n        }\n\n        @media (max-width: 480px) {\n            .action-group {\n                gap: 8px;\n            }\n            .btn {\n                font-size: 11px;\n                padding: 8px 12px;\n            }\n        }\n    <\/style>\n\n\n<div class=\"header-container\">\n    <div class=\"title-group\">\n        <h2>Project<\/h2>\n        <span class=\"count\" id=\"projectCount\">(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 Project...\" oninput=\"handleSearch()\">\n        <\/div>\n        <!-- Filter button styled to match original screenshot -->\n        <button class=\"filter-btn\" 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=\"7\" y1=\"12\" x2=\"17\" y2=\"12\"><\/line>\n                <line x1=\"10\" y1=\"18\" x2=\"14\" y2=\"18\"><\/line>\n            <\/svg>\n        <\/button>\n        <button class=\"btn btn-primary\" onclick=\"openModal('add')\">+ Add New Project<\/button>\n        <button class=\"btn btn-primary\" onclick=\"downloadCSV()\">Download CSV<\/button>\n    <\/div>\n<\/div>\n\n<div class=\"project-grid\" id=\"projectContainer\"><\/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:6px;\"><\/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<!-- Add \/ Edit Project Modal -->\n<div class=\"modal-overlay\" id=\"projectModal\">\n    <div class=\"modal-content\">\n        <h3 id=\"modalTitle\">New Project<\/h3>\n        <form id=\"projectForm\">\n            <input type=\"hidden\" id=\"editProjectId\">\n            <div class=\"form-group\">\n                <label>Project Name <span>*<\/span><\/label>\n                <input type=\"text\" id=\"projectName\" class=\"form-control\" placeholder=\"Enter Project Name\" required>\n            <\/div>\n            \n            <div class=\"toggle-row\">\n                <label style=\"font-size:12px; font-weight:500;\">Project Active <span style=\"color:var(--error-red)\">*<\/span><\/label>\n                <label class=\"switch\">\n                    <input type=\"checkbox\" id=\"projectActive\" checked>\n                    <span class=\"slider\"><\/span>\n                <\/label>\n            <\/div>\n\n            <div style=\"display:flex; justify-content:flex-end; gap:15px; margin-top:40px;\">\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<!-- Delete Confirmation Modal -->\n<div class=\"confirm-modal-overlay\" id=\"deleteModal\">\n    <div class=\"confirm-modal\">\n        <h3>Delete Project<\/h3>\n        <p>Are you sure you want to delete this project? This action cannot be undone.<\/p>\n        <div class=\"confirm-actions\">\n            <button class=\"btn btn-close\" onclick=\"closeDeleteModal()\">Cancel<\/button>\n            <button class=\"btn btn-danger\" onclick=\"confirmDelete()\">Delete<\/button>\n        <\/div>\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}\/project\/all`,\n        DETAIL: `${BASE_URL}\/project\/detail`,\n        ADD: `${BASE_URL}\/project\/add`,\n        UPDATE: `${BASE_URL}\/project\/update`,\n        DELETE: `${BASE_URL}\/project\/delete`\n    };\n\n    let allProjects = [];\n    let paginationData = { page: 1, limit: 10, total: 0, pages: 0 };\n    let pendingDeleteId = null;\n\n    const getHeaders = () => ({\n        'Content-Type': 'application\/json',\n        'Authorization': `Bearer ${localStorage.getItem(\"TOKEN\")}`\n    });\n\n    async function fetchProjects(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                allProjects = result.data.data;\n                paginationData = result.data.pagination;\n                renderProjects();\n                renderPagination();\n            }\n        } catch (err) { console.error(\"Fetch Error:\", err); }\n    }\n\n    function renderProjects(filtered = null) {\n        const container = document.getElementById('projectContainer');\n        const list = filtered || allProjects;\n        document.getElementById('projectCount').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(proj => {\n            const isActive = proj.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\">${proj.name}<\/span>\n                    <div class=\"badge-container\">\n                        <span class=\"status-badge ${isActive ? 'status-active' : 'status-inactive'}\">\n                            <span class=\"status-dot\"><\/span>\n                            ${isActive ? 'Active' : 'Inactive'}\n                        <\/span>\n                        <div class=\"menu-container\">\n                            <span class=\"menu-dots\" onclick=\"toggleMenu(event, ${proj.id})\">\u22ee<\/span>\n                            <div class=\"dropdown-content\" id=\"dropdown-${proj.id}\">\n                                <div class=\"dropdown-item\" onclick=\"openModal('edit', ${proj.id})\">Edit<\/div>\n                                <div class=\"dropdown-item delete-item\" onclick=\"openDeleteModal(${proj.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\">Project ID: ${proj.id}<\/div><\/div>\n                    <div class=\"info-group\">\n                        <div class=\"info-label\">No. of members<\/div>\n                        <div class=\"info-value info-link\">${proj.member_count || 0}<\/div>\n                    <\/div>\n                <\/div>`;\n            container.appendChild(card);\n        });\n    }\n\n    async function openModal(mode, id = null) {\n        const modal = document.getElementById('projectModal');\n        const form = document.getElementById('projectForm');\n        form.reset();\n        \n        if (mode === 'edit') {\n            document.getElementById('modalTitle').textContent = 'Update Project';\n            try {\n                const res = await fetch(ENDPOINTS.DETAIL, { \n                    method: 'POST', headers: getHeaders(), body: JSON.stringify({ id }) \n                });\n                const result = await res.json();\n                const data = result.data;\n                document.getElementById('editProjectId').value = data.id;\n                document.getElementById('projectName').value = data.name;\n                document.getElementById('projectActive').checked = (data.is_active == 1);\n            } catch (err) { console.error(err); }\n        } else {\n            document.getElementById('modalTitle').textContent = 'New Project';\n            document.getElementById('editProjectId').value = '';\n        }\n        modal.style.display = 'flex';\n    }\n\n    function closeModal() { document.getElementById('projectModal').style.display = 'none'; }\n\n    document.getElementById('projectForm').onsubmit = async (e) => {\n        e.preventDefault();\n        const id = document.getElementById('editProjectId').value;\n        const payload = {\n            name: document.getElementById('projectName').value,\n            is_active: document.getElementById('projectActive').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(); fetchProjects(paginationData.page); }\n        } catch (err) { console.error(err); }\n    };\n\n    \/* \u2500\u2500 Delete \u2500\u2500 *\/\n    function openDeleteModal(id) {\n        pendingDeleteId = id;\n        document.querySelectorAll('.dropdown-content').forEach(d => d.classList.remove('show'));\n        document.getElementById('deleteModal').style.display = 'flex';\n    }\n\n    function closeDeleteModal() {\n        pendingDeleteId = null;\n        document.getElementById('deleteModal').style.display = 'none';\n    }\n\n    async function confirmDelete() {\n        if (!pendingDeleteId) return;\n        try {\n            const res = await fetch(ENDPOINTS.DELETE, {\n                method: 'POST',\n                headers: getHeaders(),\n                body: JSON.stringify({ id: pendingDeleteId })\n            });\n            const result = await res.json();\n            closeDeleteModal();\n            \/\/ Go to page 1 if last item on current page was deleted\n            const newPage = (allProjects.length === 1 && paginationData.page > 1)\n                ? paginationData.page - 1\n                : paginationData.page;\n            fetchProjects(newPage);\n        } catch (err) {\n            console.error(\"Delete error:\", err);\n            closeDeleteModal();\n        }\n    }\n\n    \/* \u2500\u2500 Pagination \u2500\u2500 *\/\n    function renderPagination() {\n        const container = document.getElementById('pageNumbers');\n        container.innerHTML = '';\n        const { page, pages } = paginationData;\n\n        document.getElementById('prevBtn').onclick = () => { if (page > 1) fetchProjects(page - 1); };\n        document.getElementById('prevBtn').className = page === 1 ? 'nav-btn disabled' : 'nav-btn';\n\n        \/\/ Ellipsis pagination\n        const pageList = buildPageList(page, pages);\n        pageList.forEach(p => {\n            const span = document.createElement('span');\n            if (p === '...') {\n                span.className = 'page-num';\n                span.textContent = '\u2026';\n                span.style.cursor = 'default';\n            } else {\n                span.className = p === page ? 'page-num active' : 'page-num';\n                span.textContent = p;\n                span.onclick = () => fetchProjects(p);\n            }\n            container.appendChild(span);\n        });\n\n        document.getElementById('nextBtn').onclick = () => { if (page < pages) fetchProjects(page + 1); };\n        document.getElementById('nextBtn').className = page === pages ? 'nav-btn disabled' : 'nav-btn';\n    }\n\n    function buildPageList(current, total) {\n        if (total <= 5) return Array.from({ length: total }, (_, i) => i + 1);\n        const pages = [];\n        if (current <= 3) {\n            pages.push(1, 2, 3, 4, '...', total);\n        } else if (current >= total - 2) {\n            pages.push(1, '...', total - 3, total - 2, total - 1, total);\n        } else {\n            pages.push(1, '...', current - 1, current, current + 1, '...', total);\n        }\n        return pages;\n    }\n\n    \/* \u2500\u2500 Search \u2500\u2500 *\/\n    function handleSearch() {\n        const q = document.getElementById('searchInput').value.toLowerCase();\n        const filtered = allProjects.filter(p => p.name.toLowerCase().includes(q));\n        renderProjects(filtered);\n    }\n\n    \/* \u2500\u2500 Dropdown \u2500\u2500 *\/\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    \/* \u2500\u2500 Download CSV \u2500\u2500 *\/\n    function downloadCSV() {\n        if (!allProjects.length) return;\n\n        const headers = ['Project ID', 'Project Name', 'Status', 'No. of Members'];\n        const rows = allProjects.map(p => [\n            p.id,\n            `\"${(p.name || '').replace(\/\"\/g, '\"\"')}\"`,\n            p.is_active == 1 ? 'Active' : 'Inactive',\n            p.member_count || 0\n        ]);\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 = `projects_page${paginationData.page}.csv`;\n        document.body.appendChild(a);\n        a.click();\n        document.body.removeChild(a);\n        URL.revokeObjectURL(url);\n    }\n\n    fetchProjects();\n<\/script>\n<\/div><\/div>\n\n<\/div><\/div><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Project (0) + Add New Project Download CSV \u00ab Previous Next \u00bb Showing 0 to 0 of 0 entries New Project Project Name * Project Active * Close Save Delete Project Are you sure you want to delete this project? This action cannot be undone. Cancel Delete<\/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-101","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/pages\/101","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=101"}],"version-history":[{"count":4,"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/pages\/101\/revisions"}],"predecessor-version":[{"id":108,"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/pages\/101\/revisions\/108"}],"wp:attachment":[{"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/media?parent=101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}