{"id":91,"date":"2026-03-31T05:18:21","date_gmt":"2026-03-31T05:18:21","guid":{"rendered":"https:\/\/ph-portal.zyneventures.com\/?page_id=91"},"modified":"2026-03-31T05:18:21","modified_gmt":"2026-03-31T05:18:21","slug":"roles","status":"publish","type":"page","link":"https:\/\/ph-portal.zyneventures.com\/index.php\/roles\/","title":{"rendered":"Roles"},"content":{"rendered":"<style>.kadence-column91_de1d2a-72 > .kt-inside-inner-col,.kadence-column91_de1d2a-72 > .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-column91_de1d2a-72 > .kt-inside-inner-col{column-gap:var(--global-kb-gap-sm, 1rem);}.kadence-column91_de1d2a-72 > .kt-inside-inner-col{flex-direction:column;}.kadence-column91_de1d2a-72 > .kt-inside-inner-col > .aligncenter{width:100%;}.kadence-column91_de1d2a-72 > .kt-inside-inner-col:before{opacity:0.3;}.kadence-column91_de1d2a-72{position:relative;}@media all and (max-width: 1024px){.kadence-column91_de1d2a-72 > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}@media all and (max-width: 767px){.kadence-column91_de1d2a-72 > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}<\/style>\n<div class=\"wp-block-kadence-column kadence-column91_de1d2a-72\"><div class=\"kt-inside-inner-col\"><style>.kb-row-layout-id91_8297e2-cc > .kt-row-column-wrap{align-content:start;}:where(.kb-row-layout-id91_8297e2-cc > .kt-row-column-wrap) > .wp-block-kadence-column{justify-content:start;}.kb-row-layout-id91_8297e2-cc > .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-id91_8297e2-cc > .kt-row-layout-overlay{opacity:0.30;}@media all and (max-width: 1024px){.kb-row-layout-id91_8297e2-cc > .kt-row-column-wrap{grid-template-columns:minmax(0, 1fr);}}@media all and (max-width: 767px){.kb-row-layout-id91_8297e2-cc > .kt-row-column-wrap{grid-template-columns:minmax(0, 1fr);}}<\/style><div class=\"kb-row-layout-wrap kb-row-layout-id91_8297e2-cc 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-column91_30cfc3-ea > .kt-inside-inner-col,.kadence-column91_30cfc3-ea > .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-column91_30cfc3-ea > .kt-inside-inner-col{column-gap:var(--global-kb-gap-sm, 1rem);}.kadence-column91_30cfc3-ea > .kt-inside-inner-col{flex-direction:column;}.kadence-column91_30cfc3-ea > .kt-inside-inner-col > .aligncenter{width:100%;}.kadence-column91_30cfc3-ea > .kt-inside-inner-col:before{opacity:0.3;}.kadence-column91_30cfc3-ea{position:relative;}@media all and (max-width: 1024px){.kadence-column91_30cfc3-ea > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}@media all and (max-width: 767px){.kadence-column91_30cfc3-ea > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}<\/style>\n<div class=\"wp-block-kadence-column kadence-column91_30cfc3-ea\"><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-container { \n        display: flex; \n        justify-content: space-between; \n        align-items: center; \n        margin-bottom: 30px; \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-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\n    \/* Filter button \u2014 matches screenshot: light grey bg, no border, icon centered *\/\n    .btn-filter {\n        background: transparent;\n        color: #212529;\n        border: 1px solid;\n        border-color: #F1F3F4;\n        width: 36px;\n        height: 36px;\n        padding: 0;\n        border-radius: 6px;\n        display: flex;\n        align-items: center;\n        justify-content: center;\n        flex-shrink: 0;\n    }\n    .btn-filter:hover { background: transparent; color: #212529;}\n\n    \/* Role grid: 3-column, uniform card height *\/\n    .role-grid { \n        display: grid; \n        grid-template-columns: repeat(3, 1fr); \n        gap: 20px; \n        margin-top: 20px;\n        align-items: start;\n    }\n    .role-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        display: flex;\n        flex-direction: column;\n        min-height: 110px;\n        box-sizing: border-box;\n    }\n    .role-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; 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    .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    .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        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        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 { 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    .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    }\n    \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 { 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    \/* Delete confirm 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-content {\n        background: white;\n        padding: 36px 40px;\n        border-radius: 12px;\n        width: 420px;\n        box-shadow: 0 20px 40px rgba(0,0,0,0.2);\n        text-align: center;\n    }\n    .confirm-modal-content h3 { margin: 0 0 12px 0; font-size: 20px; font-weight: 600; }\n    .confirm-modal-content p { font-size: 13px; color: var(--text-muted); margin: 0 0 30px 0; }\n    .confirm-modal-actions { display: flex; justify-content: center; gap: 14px; }\n    .btn-cancel { \n        background: #F1F3F4; \n        color: #444; \n        padding: 10px 28px; \n        border-radius: 6px; \n        font-size: 12px; \n        font-weight: 500; \n        border: none; \n        cursor: pointer; \n    }\n    .btn-danger { \n        background: var(--error-red); \n        color: white; \n        padding: 10px 28px; \n        border-radius: 6px; \n        font-size: 12px; \n        font-weight: 500; \n        border: none; \n        cursor: pointer; \n    }\n\n    .pagination-footer { \n        margin-top: 50px; \n        display: flex; \n        justify-content: space-between; \n        align-items: center; \n        color: var(--text-muted); font-size: 12px;\n        flex-wrap: wrap;\n        gap: 12px;\n    }\n    .pagination-controls { display: flex; align-items: center; gap: 15px; }\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: 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\n    \/* Responsive *\/\n    @media (max-width: 992px) {\n        .role-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: 16px;\n            margin-bottom: 20px;\n        }\n        .action-group {\n            flex-wrap: wrap;\n            width: 100%;\n            gap: 8px;\n        }\n        .search-wrapper {\n            width: 100%;\n            box-sizing: border-box;\n        }\n        .btn-primary, .btn-filter {\n            font-size: 11px;\n        }\n        .role-grid {\n            grid-template-columns: 1fr;\n        }\n        .card-title {\n            font-size: 15px;\n        }\n    }\n\n    @media (max-width: 480px) {\n        .title-group h2 { font-size: 17px; }\n        .action-group { gap: 6px; }\n        .pagination-footer { flex-direction: column; align-items: flex-start; }\n        #entryInfo { width: 100%; }\n    }\n<\/style>\n\n<div class=\"header-container\">\n    <div class=\"title-group\">\n        <h2>Roles<\/h2>\n        <span class=\"count\" id=\"roleCount\">(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 Role...\" oninput=\"handleSearch()\">\n        <\/div>\n        <!-- Filter button: grey bg, icon only, no border -->\n        <button class=\"btn 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 Role<\/button>\n        <button class=\"btn btn-primary\" onclick=\"downloadCSV()\">Download CSV<\/button>\n    <\/div>\n<\/div>\n\n<div class=\"role-grid\" id=\"roleContainer\"><\/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<!-- Add \/ Edit Role Modal -->\n<div class=\"modal-overlay\" id=\"roleModal\">\n    <div class=\"modal-content\">\n        <h3 id=\"modalTitle\">New Role<\/h3>\n        <form id=\"roleForm\">\n            <input type=\"hidden\" id=\"editRoleId\">\n            <div class=\"form-group\">\n                <label>Role Name <span>*<\/span><\/label>\n                <input type=\"text\" id=\"roleName\" class=\"form-control\" placeholder=\"Enter Role Name\" required>\n            <\/div>\n            \n            <div class=\"toggle-row\">\n                <label id=\"activeToggleLabel\">Role Active <span>*<\/span><\/label>\n                <label class=\"switch\">\n                    <input type=\"checkbox\" id=\"roleActive\" 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-content\">\n        <h3>Delete Role<\/h3>\n        <p>Are you sure you want to delete this role? This action cannot be undone.<\/p>\n        <div class=\"confirm-modal-actions\">\n            <button class=\"btn-cancel\" onclick=\"closeDeleteModal()\">Cancel<\/button>\n            <button class=\"btn-danger\" id=\"confirmDeleteBtn\">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}\/role\/all`,\n        DETAIL: `${BASE_URL}\/role\/detail`,\n        ADD: `${BASE_URL}\/role\/add`,\n        UPDATE: `${BASE_URL}\/role\/update`,\n        DELETE: `${BASE_URL}\/role\/delete`\n    };\n\n    let allRoles = [];\n    let filteredRoles = [];\n    let currentPage = 1;\n    const itemsPerPage = 10;\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 fetchRoles() {\n        try {\n            const res = await fetch(\n                `${ENDPOINTS.ALL}?limit=45`, \n                { headers: getHeaders() }\n            );\n            const result = await res.json();\n            if (result.code === 200) {\n                allRoles = result.data.data;\n                filteredRoles = [...allRoles];\n                updatePaginationData();\n                renderRoles();\n            }\n        } catch (err) { console.error(\"Fetch Error:\", err); }\n    }\n\n    function updatePaginationData() {\n        const total = filteredRoles.length;\n        paginationData.total = total;\n        paginationData.pages = Math.ceil(total \/ itemsPerPage);\n        paginationData.page = currentPage;\n    }\n\n    function renderRoles() {\n        const container = document.getElementById('roleContainer');\n        document.getElementById('roleCount').textContent = `(${paginationData.total})`;\n        \n        const startIdx = (currentPage - 1) * itemsPerPage;\n        const endIdx = startIdx + itemsPerPage;\n        const list = filteredRoles.slice(startIdx, endIdx);\n\n        const startDisplay = paginationData.total === 0 ? 0 : startIdx + 1;\n        const endDisplay = Math.min(endIdx, paginationData.total);\n        document.getElementById('entryInfo').textContent = `Showing ${startDisplay} to ${endDisplay} of ${paginationData.total} entries`;\n\n        container.innerHTML = '';\n        list.forEach(role => {\n            const isActive = role.is_active == 1;\n            const card = document.createElement('div');\n            card.className = 'role-card';\n            card.innerHTML = `\n                <div class=\"card-header\">\n                    <span class=\"card-title\">${role.role}<\/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, ${role.id})\">\u22ee<\/span>\n                            <div class=\"dropdown-content\" id=\"dropdown-${role.id}\">\n                                <div class=\"dropdown-item\" onclick=\"openModal('edit', ${role.id})\">Edit<\/div>\n                                <div class=\"dropdown-item delete-item\" onclick=\"confirmDelete(${role.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\">Role ID: <span class=\"info-value\">${role.id}<\/span><\/div>\n                    <\/div>\n                <\/div>`;\n            container.appendChild(card);\n        });\n        renderPaginationControls();\n    }\n\n    \/* \u2500\u2500 Delete \u2500\u2500 *\/\n    function confirmDelete(id) {\n        pendingDeleteId = id;\n        document.getElementById('deleteModal').style.display = 'flex';\n        document.querySelectorAll('.dropdown-content').forEach(d => d.classList.remove('show'));\n    }\n\n    function closeDeleteModal() {\n        pendingDeleteId = null;\n        document.getElementById('deleteModal').style.display = 'none';\n    }\n\n    document.getElementById('confirmDeleteBtn').onclick = async () => {\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            if (res.ok) {\n                closeDeleteModal();\n                fetchRoles();\n            } else {\n                console.error('Delete failed', await res.text());\n            }\n        } catch (err) {\n            console.error('Delete error:', err);\n        }\n    };\n\n    \/* \u2500\u2500 Download CSV \u2500\u2500 *\/\n    function downloadCSV() {\n        const headers = ['Role ID', 'Role Name', 'Status'];\n        const rows = filteredRoles.map(r => [\n            r.id,\n            `\"${(r.role || '').replace(\/\"\/g, '\"\"')}\"`,\n            r.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 = 'roles.csv';\n        document.body.appendChild(a);\n        a.click();\n        document.body.removeChild(a);\n        URL.revokeObjectURL(url);\n    }\n\n    \/* \u2500\u2500 Modal \u2500\u2500 *\/\n    async function openModal(mode, id = null) {\n        const modal = document.getElementById('roleModal');\n        const form = document.getElementById('roleForm');\n        form.reset();\n        \n        if (mode === 'edit') {\n            document.getElementById('modalTitle').textContent = 'Update Role';\n            document.getElementById('activeToggleLabel').textContent = 'Active Role *';\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('editRoleId').value = data.id;\n                document.getElementById('roleName').value = data.role;\n                document.getElementById('roleActive').checked = (data.is_active == 1);\n            } catch (err) { console.error(err); }\n        } else {\n            document.getElementById('modalTitle').textContent = 'New Role';\n            document.getElementById('activeToggleLabel').textContent = 'Role Active *';\n            document.getElementById('editRoleId').value = '';\n        }\n        modal.style.display = 'flex';\n    }\n\n    function closeModal() { document.getElementById('roleModal').style.display = 'none'; }\n\n    document.getElementById('roleForm').onsubmit = async (e) => {\n        e.preventDefault();\n        const id = document.getElementById('editRoleId').value;\n        const payload = {\n            role: document.getElementById('roleName').value,\n            is_active: document.getElementById('roleActive').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', headers: getHeaders(), body: JSON.stringify(payload)\n            });\n            if (res.ok) { closeModal(); fetchRoles(); }\n        } catch (err) { console.error(err); }\n    };\n\n    \/* \u2500\u2500 Pagination \u2500\u2500 *\/\n    function renderPaginationControls() {\n        const container = document.getElementById('pageNumbers');\n        container.innerHTML = '';\n        \n        document.getElementById('prevBtn').onclick = () => { \n            if(currentPage > 1) { \n                currentPage--; \n                updatePaginationData(); \n                renderRoles(); \n            }};\n        document.getElementById('prevBtn').className = currentPage === 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 === currentPage ? 'page-num active' : 'page-num';\n            span.textContent = i;\n            span.onclick = () => { currentPage = i; updatePaginationData(); renderRoles(); };\n            container.appendChild(span);\n        }\n        \n        document.getElementById('nextBtn').onclick = () => { if(currentPage < paginationData.pages) { currentPage++; updatePaginationData(); renderRoles(); }};\n        document.getElementById('nextBtn').className = currentPage === paginationData.pages || paginationData.pages === 0 ? 'nav-btn disabled' : 'nav-btn';\n    }\n\n    \/* \u2500\u2500 Search \u2500\u2500 *\/\n    function handleSearch() {\n        const q = document.getElementById('searchInput').value.toLowerCase();\n        filteredRoles = allRoles.filter(r => r.role.toLowerCase().includes(q));\n        currentPage = 1;\n        updatePaginationData();\n        renderRoles();\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    fetchRoles();\n<\/script>\n<\/div><\/div>\n\n<\/div><\/div><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Roles (0) + Add New Role Download CSV \u00ab Previous Next \u00bb Showing 0 to 0 of 0 entries New Role Role Name * Role Active * Close Save Delete Role Are you sure you want to delete this role? 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-91","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/pages\/91","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=91"}],"version-history":[{"count":1,"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/pages\/91\/revisions"}],"predecessor-version":[{"id":92,"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/pages\/91\/revisions\/92"}],"wp:attachment":[{"href":"https:\/\/ph-portal.zyneventures.com\/index.php\/wp-json\/wp\/v2\/media?parent=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}