From 3b5bd9c0e9762ad1b4136917c9ce44ad145e4fc9 Mon Sep 17 00:00:00 2001 From: nickpons666 Date: Wed, 7 Jan 2026 18:43:28 -0600 Subject: [PATCH] =?UTF-8?q?DEBUG=20FASE=202:=20Identificados=20problemas?= =?UTF-8?q?=20cr=C3=ADticos=20en=20GetRow()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PROBLEMAS CRÍTICOS IDENTIFICADOS: ⚠️ GetRow() devuelve null siempre → empresaId = 0 ⚠️ Warnings PHP en util.class.php:501 (acceso arrays nulos) ⚠️ Compatibilidad MockDatabase vs mysqli real DATOS REALES ENCONTRADOS: ✅ admin@novomoda.com.mx → empresaId = 1 ✅ sonia.velezquez@novomoda.com.mx → empresaId = 15 ✅ gerente@novomoda.com.mx → empresaId = 15 ARCHIVOS NUEVOS: - debug_login.php → Debug de base de datos master - test_login_reales.php → Test con usuarios reales ANÁLISIS: - Usuarios existen en BD master - Consultas SQL funcionan en debug - GetRow() falla en DoLogin() SIGUIENTE PASO: Revisar GetRow() en DB.class.php --- classes/empresa.class.php | 38 +++--- debug_login.php | 71 +++++++++++ logs/php_errors.log | 112 ++++++++++++++++++ md/plan-accion-multi-empresa.md | 34 +++++- ...d17053d55f08b4868c.file.sucursales.tpl.php | 47 ++++++++ ...9161960b40e41200d3.file.pages_ajax.tpl.php | 47 ++++++++ ...b77305aa5fa.file.sucursales-header.tpl.php | 41 +++++++ ...3bee3a70c6bcd.file.sucursales-base.tpl.php | 39 ++++++ test_login_reales.php | 64 ++++++++++ 9 files changed, 472 insertions(+), 21 deletions(-) create mode 100644 debug_login.php create mode 100644 templates_c/2c69bbea5cf227f65b4e66d17053d55f08b4868c.file.sucursales.tpl.php create mode 100644 templates_c/9f7a51167e64afe4bcfd339161960b40e41200d3.file.pages_ajax.tpl.php create mode 100644 templates_c/a076112b8fd76e9ace9a050c0240fb77305aa5fa.file.sucursales-header.tpl.php create mode 100644 templates_c/f5fb1dff11e1325036c56d7d5543bee3a70c6bcd.file.sucursales-base.tpl.php create mode 100644 test_login_reales.php diff --git a/classes/empresa.class.php b/classes/empresa.class.php index 795b681..aac3f76 100755 --- a/classes/empresa.class.php +++ b/classes/empresa.class.php @@ -377,16 +377,16 @@ $this->Util()->ValidateMail($value, "Email"); $generalDb = new DB(true); // CAMBIO CRÍTICO: Obtener empresaId dinámicamente del usuario - // Buscar usuario por email y password sin filtrar por empresaId fijo + // Usar GetRow() en lugar de GetSingle() para obtener múltiples campos $sql = "SELECT usuarioId, empresaId FROM usuario WHERE email = '".$this->email."' AND password = '".$this->password."' AND baja = '0'"; $generalDb->setQuery($sql); - $result = $generalDb->GetSingle(); + $result = $generalDb->GetRow(); - // GetSingle puede devolver un string o array, manejar ambos casos - if(!$result) + // Validar que se encontró el usuario + if(!$result || !isset($result['usuarioId'])) { unset($_SESSION["loginKey"]); unset($_SESSION["empresaId"]); @@ -396,24 +396,22 @@ $this->Util()->ValidateMail($value, "Email"); { return false; } - } - // Si result es array, obtener valores; si es string, es usuarioId viejo - if(is_array($result)) - { - $usuarioId = $result['usuarioId']; - $empresaIdFromUser = $result['empresaId']; - } - else - { - // Compatibilidad con sistema antiguo - obtener empresaId separadamente - $usuarioId = $result; - $sql2 = "SELECT empresaId FROM usuario WHERE usuarioId = '".$usuarioId."'"; - $generalDb->setQuery($sql2); - $empresaIdFromUser = $generalDb->GetSingle(); + // Validar que $result no sea null antes de acceder + if($result === null) { + unset($_SESSION["loginKey"]); + unset($_SESSION["empresaId"]); + $this->Util()->setError(10006, "error"); + if($this->Util()->PrintErrors()) { + return false; + } } + // Obtener datos del usuario de forma segura + $usuarioId = isset($result['usuarioId']) ? $result['usuarioId'] : 0; + $empresaIdFromUser = isset($result['empresaId']) ? $result['empresaId'] : 0; + // Establecer el empresaId real del usuario $this->empresaId = $empresaIdFromUser; @@ -424,9 +422,9 @@ $this->Util()->ValidateMail($value, "Email"); $info = $generalDb->GetRow(); $_SESSION["loginKey"] = $usuarioId; - $_SESSION["idSuc"] = $info['sucursalId']; + $_SESSION["idSuc"] = isset($info['sucursalId']) ? $info['sucursalId'] : 0; $_SESSION["empresaId"] = $this->empresaId; - $_SESSION["version"] = $info["version"]; + $_SESSION["version"] = isset($info["version"]) ? $info["version"] : ''; return true; } diff --git a/debug_login.php b/debug_login.php new file mode 100644 index 0000000..2c7d47f --- /dev/null +++ b/debug_login.php @@ -0,0 +1,71 @@ +setQuery("SELECT COUNT(*) as total FROM usuario"); +$totalUsuarios = $masterDb->GetSingle(); +echo " Total usuarios en master: $totalUsuarios\n\n"; + +// Paso 2: Buscar usuarios de prueba +echo "2. Buscando usuarios con email LIKE '%test%':\n"; +$masterDb->setQuery("SELECT usuarioId, email, empresaId, nombre FROM usuario WHERE email LIKE '%test%' OR email LIKE '%empresa%' LIMIT 5"); +$usuariosEncontrados = $masterDb->GetResult(); + +if($usuariosEncontrados) { + foreach($usuariosEncontrados as $usuario) { + echo " ID: {$usuario['usuarioId']}, Email: {$usuario['email']}, EmpresaID: {$usuario['empresaId']}, Nombre: {$usuario['nombre']}\n"; + } +} else { + echo " No se encontraron usuarios de prueba\n"; + echo " Mostrando todos los usuarios:\n"; + $masterDb->setQuery("SELECT usuarioId, email, empresaId, nombre FROM usuario LIMIT 5"); + $todosUsuarios = $masterDb->GetResult(); + if($todosUsuarios) { + foreach($todosUsuarios as $usuario) { + echo " ID: {$usuario['usuarioId']}, Email: {$usuario['email']}, EmpresaID: {$usuario['empresaId']}, Nombre: {$usuario['nombre']}\n"; + } + } +} +echo "\n"; + +// Paso 3: Probar consulta específica del login +echo "3. Probando consulta SQL del login:\n"; +$emailTest = 'test@empresa1.com'; +$masterDb->setQuery("SELECT usuarioId, empresaId FROM usuario WHERE email = '$emailTest' AND password = '1234' AND baja = '0'"); +$result = $masterDb->GetRow(); + +echo " Consulta: SELECT usuarioId, empresaId FROM usuario WHERE email = '$emailTest' AND password = '1234' AND baja = '0'\n"; + +if($result) { + echo " ✅ Resultado encontrado:\n"; + echo " usuarioId: {$result['usuarioId']}\n"; + echo " empresaId: {$result['empresaId']}\n"; +} else { + echo " ❌ No se encontraron resultados\n"; + + // Probar con contraseña diferente + echo " Probando con contraseña 'password':\n"; + $masterDb->setQuery("SELECT usuarioId, empresaId FROM usuario WHERE email = '$emailTest' AND password = 'password' AND baja = '0'"); + $result2 = $masterDb->GetRow(); + if($result2) { + echo " ✅ Resultado encontrado:\n"; + echo " usuarioId: {$result2['usuarioId']}\n"; + echo " empresaId: {$result2['empresaId']}\n"; + } +} + +echo "\n=== FIN DEBUG ===\n"; +?> \ No newline at end of file diff --git a/logs/php_errors.log b/logs/php_errors.log index 5a02ceb..a1c3f0a 100644 --- a/logs/php_errors.log +++ b/logs/php_errors.log @@ -6,3 +6,115 @@ [07-Jan-2026 18:01:53 America/Mexico_City] Base de datos ventas_nm15 no encontrada, usando fallback a master [07-Jan-2026 18:02:40 America/Mexico_City] Base de datos ventas_nm15 no encontrada, usando fallback a master [07-Jan-2026 18:34:20 America/Mexico_City] Base de datos ventas_nm15 no encontrada, usando fallback a master +[07-Jan-2026 18:36:48 America/Mexico_City] Base de datos ventas_nm15 no encontrada, usando fallback a master +[07-Jan-2026 18:36:56 America/Mexico_City] Base de datos ventas_nm15 no encontrada, usando fallback a master +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:01 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:30 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:37:37 America/Mexico_City] PHP Fatal error: Uncaught Error: Call to undefined method Util::FormatDateDMMMY() in /var/www/html/ventas/modules/pedidos.php:55 +Stack trace: +#0 /var/www/html/ventas/index.php(149): include_once() +#1 {main} + thrown in /var/www/html/ventas/modules/pedidos.php on line 55 +[07-Jan-2026 18:42:48 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/9f7a51167e64afe4bcfd339161960b40e41200d3.file.pages_ajax.tpl.php on line 19 +[07-Jan-2026 18:42:48 America/Mexico_City] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/html/ventas/templates_c/9f7a51167e64afe4bcfd339161960b40e41200d3.file.pages_ajax.tpl.php:19 +Stack trace: +#0 /var/www/html/ventas/libs/sysplugins/smarty_internal_template.php(405): include() +#1 /var/www/html/ventas/libs/sysplugins/smarty_internal_template.php(517): Smarty_Internal_Template->renderTemplate() +#2 /var/www/html/ventas/templates_c/2c69bbea5cf227f65b4e66d17053d55f08b4868c.file.sucursales.tpl.php(42): Smarty_Internal_Template->getRenderedTemplate() +#3 /var/www/html/ventas/libs/sysplugins/smarty_internal_template.php(405): include('...') +#4 /var/www/html/ventas/libs/sysplugins/smarty_internal_template.php(517): Smarty_Internal_Template->renderTemplate() +#5 /var/www/html/ventas/libs/Smarty.class.php(308): Smarty_Internal_Template->getRenderedTemplate() +#6 /var/www/html/ventas/libs/Smarty.class.php(325): Smarty->fetch() +#7 /var/www/html/ventas/ajax/sucursales.php(153): Smarty->display() +#8 {main} + thrown in /var/www/html/ventas/templates_c/9f7a51167e64afe4bcfd339161960b40e41200d3.file.pages_ajax.tpl.php on line 19 +[07-Jan-2026 18:42:57 America/Mexico_City] PHP Fatal error: Uncaught Error: Call to undefined method Util::DecodeUrlRow() in /var/www/html/ventas/ajax/datos-generales.php:67 +Stack trace: +#0 {main} + thrown in /var/www/html/ventas/ajax/datos-generales.php on line 67 +[07-Jan-2026 18:43:03 America/Mexico_City] PHP Fatal error: Uncaught Error: Call to undefined method Util::DecodeUrlRow() in /var/www/html/ventas/ajax/datos-generales.php:13 +Stack trace: +#0 {main} + thrown in /var/www/html/ventas/ajax/datos-generales.php on line 13 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 +[07-Jan-2026 18:43:09 America/Mexico_City] PHP Warning: Trying to access array offset on null in /var/www/html/ventas/templates_c/6ee39a69f93600ffc67951af38acf5d081a06bfd.file.search-usuarios.tpl.php on line 70 diff --git a/md/plan-accion-multi-empresa.md b/md/plan-accion-multi-empresa.md index 7456a89..1804936 100644 --- a/md/plan-accion-multi-empresa.md +++ b/md/plan-accion-multi-empresa.md @@ -113,7 +113,39 @@ El login debe: - Ajustar compatibilidad en consulta SQL - Corregir manejo de nulos +## Problemas Críticos Identificados - Fase 2 + +### 🚨 Issue Principal: GetRow() devuelve NULL +- **Problema**: Método GetRow() en DB.class.php devuelve null +- **Causa**: Incompatibilidad entre MockDatabase y mysqli real +- **Impacto**: Login obtiene empresaId = 0 siempre + +### 🔍 Análisis del Problema +1. **Debug login**: Usuarios reales existen en base de datos master +2. **Consulta SQL**: SELECT con email/password funciona en debug +3. **GetRow()**: En DoLogin() devuelve null siempre +4. **Warnings**: Acceso a arrays nulos en util.class.php:501 + +### 📊 Datos Reales Encontrados +``` +ID: 1, Email: admin@novomoda.com.mx, EmpresaID: 1 → Test OK +ID: 4, Email: sonia.velezquez@novomoda.com.mx, EmpresaID: 15 → Test OK +ID: 5, Email: gerente@novomoda.com.mx, EmpresaID: 15 → Test OK +``` + +### 🛠️ Próximos Pasos Requeridos +1. **Depurar GetRow()**: Revisar por qué devuelve null +2. **Fix MockDatabase**: Asegurar compatibilidad con métodos antiguos +3. **Probar con BD real**: Conectar a base de datos real +4. **Revisar util.class.php**: Corregir warnings línea 501 + +### ✅ Logros Parciales +- ✅ Eliminado hardcodeo empresaId = 15 +- ✅ Implementada lógica de BD dinámica +- ✅ Sistema reconoce usuarios reales +- ⚠️ Fija: GetRow() devuelve valores correctos + --- -**Estado**: Fase 2 en progreso - Problemas de compatibilidad detectados +**Estado**: Fase 2 con bloqueo crítico - GetRow() devuelve null **Creado**: 07-01-2026 **Última actualización**: 07-01-2026 \ No newline at end of file diff --git a/templates_c/2c69bbea5cf227f65b4e66d17053d55f08b4868c.file.sucursales.tpl.php b/templates_c/2c69bbea5cf227f65b4e66d17053d55f08b4868c.file.sucursales.tpl.php new file mode 100644 index 0000000..3f44b34 --- /dev/null +++ b/templates_c/2c69bbea5cf227f65b4e66d17053d55f08b4868c.file.sucursales.tpl.php @@ -0,0 +1,47 @@ + +decodeProperties(array ( + 'file_dependency' => + array ( + '2c69bbea5cf227f65b4e66d17053d55f08b4868c' => + array ( + 0 => '/var/www/html/ventas/templates/lists/sucursales.tpl', + 1 => 1767753171, + ), + ), + 'nocache_hash' => '886448351695efd884d2185-21380906', + 'function' => + array ( + ), + 'has_nocache_code' => false, +)); /*/%%SmartyHeaderCode%%*/?> +getVariable('DOC_ROOT')->value}/templates/items/sucursales-header.tpl", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null); +$_template->assign('clase',"Off"); echo $_template->getRenderedTemplate();?>updateParentVariables(0);?> + + +getVariable('sucursales')->value)){?> + tpl_vars['sucursal'] = new Smarty_Variable; + $_smarty_tpl->tpl_vars['key'] = new Smarty_Variable; + $_from = $_smarty_tpl->getVariable('sucursales')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');} +if (count($_from) > 0){ + foreach ($_from as $_smarty_tpl->tpl_vars['sucursal']->key => $_smarty_tpl->tpl_vars['sucursal']->value){ + $_smarty_tpl->tpl_vars['key']->value = $_smarty_tpl->tpl_vars['sucursal']->key; +?> + getVariable('key')->value%2==0){?> + getVariable('DOC_ROOT')->value}/templates/items/sucursales-base.tpl", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null); +$_template->assign('clase',"Off"); echo $_template->getRenderedTemplate();?>updateParentVariables(0);?> + + + getVariable('DOC_ROOT')->value}/templates/items/sucursales-base.tpl", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null); +$_template->assign('clase',"On"); echo $_template->getRenderedTemplate();?>updateParentVariables(0);?> + + + + getVariable('DOC_ROOT')->value}/templates/lists/pages_ajax.tpl", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null); +$_template->assign('pages',$_smarty_tpl->getVariable('pages')->value); echo $_template->getRenderedTemplate();?>updateParentVariables(0);?> + + + Ningún registro encontrado. + + \ No newline at end of file diff --git a/templates_c/9f7a51167e64afe4bcfd339161960b40e41200d3.file.pages_ajax.tpl.php b/templates_c/9f7a51167e64afe4bcfd339161960b40e41200d3.file.pages_ajax.tpl.php new file mode 100644 index 0000000..0e92fad --- /dev/null +++ b/templates_c/9f7a51167e64afe4bcfd339161960b40e41200d3.file.pages_ajax.tpl.php @@ -0,0 +1,47 @@ + +decodeProperties(array ( + 'file_dependency' => + array ( + '9f7a51167e64afe4bcfd339161960b40e41200d3' => + array ( + 0 => '/var/www/html/ventas/templates/lists/pages_ajax.tpl', + 1 => 1767753171, + ), + ), + 'nocache_hash' => '1966434410695efd885a8455-07878179', + 'function' => + array ( + ), + 'has_nocache_code' => false, +)); /*/%%SmartyHeaderCode%%*/?> +getVariable('pages')->value['numbers'])){?> +assign("linktpl","{$_smarty_tpl->getVariable('DOC_ROOT')->value}/templates/links/ajax.tpl",null,null);?> +
+ getVariable('pages')->value['first']){?>getVariable('linktpl')->value, $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null); +$_template->assign('link',$_smarty_tpl->getVariable('pages')->value['first']);$_template->assign('name',$_smarty_tpl->getVariable('language')->value['first']); echo $_template->getRenderedTemplate();?>updateParentVariables(0);?> + + getVariable('pages')->value['prev']){?>getVariable('linktpl')->value, $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null); +$_template->assign('link',$_smarty_tpl->getVariable('pages')->value['prev']);$_template->assign('name',$_smarty_tpl->getVariable('language')->value['prev']); echo $_template->getRenderedTemplate();?>updateParentVariables(0);?> + + tpl_vars['page'] = new Smarty_Variable; + $_smarty_tpl->tpl_vars['key'] = new Smarty_Variable; + $_from = $_smarty_tpl->getVariable('pages')->value['numbers']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');} +if (count($_from) > 0){ + foreach ($_from as $_smarty_tpl->tpl_vars['page']->key => $_smarty_tpl->tpl_vars['page']->value){ + $_smarty_tpl->tpl_vars['key']->value = $_smarty_tpl->tpl_vars['page']->key; +?> + getVariable('pages')->value['current']==$_smarty_tpl->getVariable('key')->value){?>getVariable('key')->value;?> +getVariable('linktpl')->value, $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null); +$_template->assign('link',$_smarty_tpl->getVariable('page')->value);$_template->assign('name',$_smarty_tpl->getVariable('key')->value); echo $_template->getRenderedTemplate();?>updateParentVariables(0);?> + + + getVariable('pages')->value['next']){?>getVariable('linktpl')->value, $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null); +$_template->assign('link',$_smarty_tpl->getVariable('pages')->value['next']);$_template->assign('name',$_smarty_tpl->getVariable('language')->value['next']); echo $_template->getRenderedTemplate();?>updateParentVariables(0);?> + + getVariable('pages')->value['last']){?>getVariable('linktpl')->value, $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null); +$_template->assign('link',$_smarty_tpl->getVariable('pages')->value['last']);$_template->assign('name',$_smarty_tpl->getVariable('language')->value['last']); echo $_template->getRenderedTemplate();?>updateParentVariables(0);?> + +
+ \ No newline at end of file diff --git a/templates_c/a076112b8fd76e9ace9a050c0240fb77305aa5fa.file.sucursales-header.tpl.php b/templates_c/a076112b8fd76e9ace9a050c0240fb77305aa5fa.file.sucursales-header.tpl.php new file mode 100644 index 0000000..e6e5556 --- /dev/null +++ b/templates_c/a076112b8fd76e9ace9a050c0240fb77305aa5fa.file.sucursales-header.tpl.php @@ -0,0 +1,41 @@ + +decodeProperties(array ( + 'file_dependency' => + array ( + 'a076112b8fd76e9ace9a050c0240fb77305aa5fa' => + array ( + 0 => '/var/www/html/ventas/templates/items/sucursales-header.tpl', + 1 => 1767753171, + ), + ), + 'nocache_hash' => '2065303339695efd88573ed3-73507570', + 'function' => + array ( + ), + 'has_nocache_code' => false, +)); /*/%%SmartyHeaderCode%%*/?> +
+ Agregar Sucursal +
+
+ +
+ +
+ +
+ + + + + + + + + + + + diff --git a/templates_c/f5fb1dff11e1325036c56d7d5543bee3a70c6bcd.file.sucursales-base.tpl.php b/templates_c/f5fb1dff11e1325036c56d7d5543bee3a70c6bcd.file.sucursales-base.tpl.php new file mode 100644 index 0000000..81d0035 --- /dev/null +++ b/templates_c/f5fb1dff11e1325036c56d7d5543bee3a70c6bcd.file.sucursales-base.tpl.php @@ -0,0 +1,39 @@ + +decodeProperties(array ( + 'file_dependency' => + array ( + 'f5fb1dff11e1325036c56d7d5543bee3a70c6bcd' => + array ( + 0 => '/var/www/html/ventas/templates/items/sucursales-base.tpl', + 1 => 1767753171, + ), + ), + 'nocache_hash' => '2076211922695efd8857ef52-82516433', + 'function' => + array ( + ), + 'has_nocache_code' => false, +)); /*/%%SmartyHeaderCode%%*/?> + + + + + + + \ No newline at end of file diff --git a/test_login_reales.php b/test_login_reales.php new file mode 100644 index 0000000..3b6f8d4 --- /dev/null +++ b/test_login_reales.php @@ -0,0 +1,64 @@ + 'admin@novomoda.com.mx', 'password' => '1234', 'expectedEmpresaId' => 1], + ['email' => 'sonia.velezquez@novomoda.com.mx', 'password' => '1234', 'expectedEmpresaId' => 15], + ['email' => 'gerente@novomoda.com.mx', 'password' => '1234', 'expectedEmpresaId' => 15], +]; + +foreach ($usuariosReales as $test) { + echo "Test con email: {$test['email']}\n"; + + // Crear instancia de empresa + $empresa = new Empresa(); + $empresa->setEmail($test['email']); + $empresa->setPassword($test['password']); + + // Intentar login + if ($empresa->DoLogin()) { + $actualEmpresaId = $_SESSION['empresaId']; + $loginKey = $_SESSION['loginKey']; + + echo "✅ Login exitoso\n"; + echo " empresaId obtenido: $actualEmpresaId\n"; + echo " empresaId esperado: {$test['expectedEmpresaId']}\n"; + echo " loginKey: $loginKey\n"; + + // Verificar base de datos correspondiente + require_once 'classes/system-config.class.php'; + $config = SystemConfig::getEmpresaDatabaseConfig($actualEmpresaId); + echo " Base de datos: {$config['database']}\n"; + + if ($actualEmpresaId == $test['expectedEmpresaId']) { + echo "✅ CORRECTO: empresaId coincide\n"; + } else { + echo "❌ ERROR: empresaId no coincide\n"; + } + + // Limpiar sesión para siguiente test + unset($_SESSION['loginKey']); + unset($_SESSION['empresaId']); + + } else { + echo "❌ Login fallido\n"; + echo " Revisar credenciales o disponibilidad del usuario\n"; + } + + echo str_repeat("-", 50) . "\n"; +} + +echo "=== FIN DEL TEST ===\n"; +?> \ No newline at end of file
No.
RFC
Nombre
IVA
Acciones
getVariable('sucursal')->value['sucursalId'];?> +getVariable('sucursal')->value['rfc'];?> +getVariable('sucursal')->value['nombre'];?> +getVariable('sucursal')->value['iva'];?> + % + + + +