From c92ff6a15530ba89ce2571fb91b2fd0691da1a41 Mon Sep 17 00:00:00 2001 From: TenerifeProp Dev Date: Mon, 6 Apr 2026 21:17:52 +0100 Subject: [PATCH] fix: initialize DataTables separately for each table with correct column indices - leadsTable (dashboard): 6 columns, sort by date (column 3) - fullLeadsTable (leads section): 9 columns with checkbox, sort by date (column 6) - Fixed JavaScript error from wrong column index - Added separate initialization for each table --- public/admin.html | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/public/admin.html b/public/admin.html index e95af7e..92b1cb0 100644 --- a/public/admin.html +++ b/public/admin.html @@ -2847,15 +2847,35 @@ Ver todos } }); - // Initialize DataTables - $('#leadsTable, #fullLeadsTable').DataTable({ - language: { - url: 'https://cdn.datatables.net/plug-ins/1.13.8/i18n/es-ES.json' - }, - pageLength: 10, - ordering: true, - order: [[3, 'desc']] // Sort by date column (0-indexed) - }); + // Initialize DataTables (separately for each table with correct column indices) + // leadsTable: 6 columns (Cliente, Propiedad, Fuente, Fecha, Estado, Acciones) + // fullLeadsTable: 9 columns (checkbox, Cliente, Contacto, Propiedad, Presupuesto, Fuente, Fecha, Estado, Acciones) + + if ($('#leadsTable').length) { + $('#leadsTable').DataTable({ + language: { + url: 'https://cdn.datatables.net/plug-ins/1.13.8/i18n/es-ES.json' + }, + pageLength: 5, + ordering: true, + order: [[3, 'desc']], // Fecha column + searching: false, + lengthChange: false, + info: false, + paging: false + }); + } + + if ($('#fullLeadsTable').length) { + $('#fullLeadsTable').DataTable({ + language: { + url: 'https://cdn.datatables.net/plug-ins/1.13.8/i18n/es-ES.json' + }, + pageLength: 10, + ordering: true, + order: [[6, 'desc']] // Fecha column (after checkbox = column 0) + }); + } // ============ CHARTS ============ const chartColors = {