Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/monara/public_html/test.athavaneng.com/themes.php on line 99
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 226
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 227
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 228
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 229
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 230
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 231
// A global state object to keep track of pages for different tables
const paginationState = {};
function initPagination(table, containerId) {
// Locate target table body container node
const tbody = document.getElementById(containerId);
if (!tbody) return;
// Safely look up the outer card wrapper layout element structure
const parentCard = tbody.closest('.data-ledger-card');
if (!parentCard) return;
// Create the controls container cleanly
const controlsWrapper = document.createElement('div');
controlsWrapper.style.cssText = "text-align: center; margin: 20px;";
controlsWrapper.innerHTML = `
Page 1
`;
// Append it safely below the layout table grid
parentCard.appendChild(controlsWrapper);
}
function paginate(table, containerId, pageNumber) {
// 1. Calculate the target page number cleanly
let newPage;
if (typeof pageNumber === 'number' && Math.abs(pageNumber) === 1 && !paginationState[containerId]) {
newPage = 1;
} else if (pageNumber === 1 || pageNumber === -1) {
newPage = (paginationState[containerId] || 1) + pageNumber;
} else {
newPage = pageNumber;
}
if (newPage < 1) return;
// --- READ ALL ACTIVE URL BAR FILTERS ---
const urlParams = new URLSearchParams(window.location.search);
// Core parameters shared across multiple templates
const activeEntityFilter = urlParams.get('entity') || '';
const activeOfficerFilter = urlParams.get('officer') || '';
const activeStatusFilter = urlParams.get('status') || '';
const activeSearchFilter = urlParams.get('search') || '';
// Agreement specific parameters
const activeCategoryFilter = urlParams.get('category') || '';
const activeCabinetFilter = urlParams.get('cabinet') || '';
// Litigation (Court Cases) specific parameters
const activeCourtFilter = urlParams.get('court') || '';
const activeCaseNumFilter = urlParams.get('case_number') || '';
// Payment specific URL filters
const activePaRefFilter = urlParams.get('pa_ref') || '';
const activeEcfRefFilter = urlParams.get('ecf_ref') || '';
const activeSourceFilter = urlParams.get('source_type') || '';
// Archive Master specific URL filter variables
const activeCabinetLocation = urlParams.get('cabinet') || '';
const activeFileCheckFilter = urlParams.get('file_check') || '';
const activeModuleFilter = urlParams.get('module_type') || '';
const fd = new FormData();
fd.append('action', 'fetch_paginated_data');
fd.append('table', table);
fd.append('page', newPage);
// 1. Map global entity and structural filters
if (activeEntityFilter) fd.append('group_company_id', activeEntityFilter);
if (activeOfficerFilter) fd.append('assigned_officer_id', activeOfficerFilter);
if (activeSearchFilter) fd.append('search_term', activeSearchFilter);
// 1b. Map Physical Archive module constraints dynamically
if (table === 'physical_archives_master') {
if (activeCabinetLocation) fd.append('cabinet_location', activeCabinetLocation);
if (activeFileCheckFilter) fd.append('file_check', activeFileCheckFilter);
if (activeModuleFilter) fd.append('module_type', activeModuleFilter);
}
// 2. Map Agreement modular payload variants
if (activeCategoryFilter) fd.append('category_id', activeCategoryFilter);
if (activeCabinetFilter) fd.append('cabinet_id', activeCabinetFilter);
// 3. Map Litigation context variables accurately depending on routing paths
if (activeCourtFilter) fd.append('court_id', activeCourtFilter);
if (activeCaseNumFilter) fd.append('case_number', activeCaseNumFilter);
// Map Payment modular payload variants
if (activePaRefFilter) fd.append('pa_ref_number', activePaRefFilter);
if (activeEcfRefFilter) fd.append('ecf_ref_number', activeEcfRefFilter);
if (activeSourceFilter) fd.append('source_type', activeSourceFilter);
// 4. Status mapping logic across distinct tables
if (activeStatusFilter) {
if (table === 'court_cases') {
fd.append('case_status', activeStatusFilter);
} else {
fd.append('initial_status', activeStatusFilter);
}
}
const endpoint = (typeof BASE_URL !== 'undefined') ? BASE_URL + 'config/router.php' : '../config/router.php';
fetch(endpoint, { method: 'POST', body: fd })
.then(async r => {
const rawText = await r.text();
try {
return JSON.parse(rawText);
} catch (e) {
console.error("❌ Failed to parse JSON response:", rawText);
return { success: false, data: [] };
}
})
.then(res => {
const body = document.getElementById(containerId);
if (!body) return;
if (res.success && res.data && res.data.length > 0) {
paginationState[containerId] = newPage;
const pageEl = document.getElementById(`page-${containerId}`);
if (pageEl) pageEl.textContent = `Page ${newPage}`;
body.innerHTML = '';
res.data.forEach(row => {
body.innerHTML += renderRow(table, row);
});
} else {
if (newPage === 1) {
body.innerHTML = '
No matching records found.
';
}
}
})
.catch(err => console.error("❌ Pagination processing error:", err));
}
// Centralized Renderer
function renderRow(table, r) {
switch(table) {
case 'court_cases': {
let st = r.case_status || 'Filing Stage';
let badge = 'progress';
if (st === 'Settled') badge = 'linked';
if (st === 'Filing Stage') badge = 'pending';
if (st === 'Appealed') badge = 'error';
if (st === 'In Progress') badge = 'progress';
let fileHtmlCourt = 'None';
try {
let files = JSON.parse(r.file_attachment_path || '[]');
if (Array.isArray(files) && files.length > 0) {
const rootPath = (typeof BASE_URL !== 'undefined') ? BASE_URL : '../';
fileHtmlCourt = files.map(path => `
📁
`).join('');
}
} catch(e) { console.error("File parse error", e); }
return `