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 `
${r.case_parties || ''}
${r.company_name || ''} | ${(r.case_description || '').substring(0, 75)}${(r.case_description && r.case_description.length > 75) ? '...' : ''}
${r.room_name || ''}
${r.officer_name || ''}
Attn: ${r.instructing_attorney || ''}
${r.case_number || ''}
${r.next_hearing_date ? new Date(r.next_hearing_date).toLocaleDateString('en-US', {month:'short', day:'2-digit', year:'numeric'}) : 'Not Scheduled'}
${r.next_step_description ? `
Next Action: ${r.next_step_description}
` : ''} ${st} ${fileHtmlCourt} `; } case 'audit_logs': { let logBadge = 'pending'; if(r.action_type === 'INSERT') logBadge = 'linked'; if(r.action_type === 'UPDATE') logBadge = 'progress'; if(r.action_type === 'DELETE') logBadge = 'error'; return ` ${r.timestamp}
${r.user_name}
Role: ${r.user_role}
${r.action_type} 📁 ${r.module_target}
${r.meta_description} (Ref ID: #${r.record_id})
`; } case 'agreements': { let fileHtmlAgree = '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 : '../'; fileHtmlAgree = files.map(path => ` 📁 `).join(''); } } catch(e) { console.error("File parse error", e); } return `
${r.title || ''}
${r.company_name || ''} | Party B: ${r.party_b || ''}
${r.category_name || ''} ${r.officer_name || ''} ${r.cabinet_location || ''} ${r.expiry_date ? new Date(r.expiry_date).toLocaleDateString('en-US', {month:'short', day:'2-digit', year:'numeric'}) : ''} ${r.initial_status || ''} ${fileHtmlAgree} `; } case 'payments': { let statusClass = (r.status === 'Linked') ? 'linked' : 'error'; let displayStatus = (r.status === 'Linked') ? 'Linked' : 'Unlinked ECF'; return `
${r.description || ''}
${r.company_name || ''} | Linked Source: ${r.source_type || 'N/A'} (#${r.linked_source_id || '0'})
${r.pa_ref_number || '[ No Input ]'} ${r.ecf_ref_number || '[ No Input ]'} ${r.due_date ? new Date(r.due_date).toLocaleDateString('en-US', {month:'short', day:'numeric', year:'numeric'}) : ''} ${r.currency || 'Rs.'} ${parseFloat(r.amount || 0).toLocaleString()} ${displayStatus} `; } case 'physical_archives_master': { let fileData = r.raw_file_field; let hasScan = (fileData && fileData !== '[]' && fileData !== 'null' && fileData !== ''); let statusClass = hasScan ? 'text-success' : 'text-danger'; let statusText = hasScan ? '✔ Digital Scanned' : '⚠ Upload Pending'; let statusColor = hasScan ? '#22c55e' : '#ef4444'; return ` ${r.physical_location || ''} ${r.system_ref_no || ''}
${r.primary_title || ''}
${r.group_company || ''} | ${r.structural_subtext || ''}
${r.module_type || ''} ${statusText} `; } default: return `Unknown table structure`; } }