DEBUG FASE 2: Identificados problemas críticos en GetRow()

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
This commit is contained in:
2026-01-07 18:43:28 -06:00
parent ee4945578e
commit 3b5bd9c0e9
9 changed files with 472 additions and 21 deletions

View File

@@ -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;
}

71
debug_login.php Normal file
View File

@@ -0,0 +1,71 @@
<?php
/**
* Test simplificado para debug del login dinámico
* Revisa datos reales en base de datos master
*/
require_once 'config.php';
require_once 'classes/db.class.php';
require_once 'classes/error.class.php';
require_once 'classes/util.class.php';
require_once 'classes/main.class.php';
echo "=== DEBUG LOGIN DINÁMICO ===\n\n";
// Paso 1: Verificar conexión a base de datos master
echo "1. Probando conexión a base de datos master...\n";
$masterDb = new DB(true); // true = master connection
$masterDb->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";
?>

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,47 @@
<?php /* Smarty version Smarty3-b7, created on 2026-01-07 18:42:48
compiled from "/var/www/html/ventas/templates/lists/sucursales.tpl" */ ?>
<?php /*%%SmartyHeaderCode:886448351695efd884d2185-21380906%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_smarty_tpl->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%%*/?>
<?php $_template = new Smarty_Internal_Template("{$_smarty_tpl->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();?><?php $_template->updateParentVariables(0);?><?php unset($_template);?>
<?php if (count($_smarty_tpl->getVariable('sucursales')->value)){?>
<?php $_smarty_tpl->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;
?>
<?php if ($_smarty_tpl->getVariable('key')->value%2==0){?>
<?php $_template = new Smarty_Internal_Template("{$_smarty_tpl->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();?><?php $_template->updateParentVariables(0);?><?php unset($_template);?>
<?php }else{ ?>
<?php $_template = new Smarty_Internal_Template("{$_smarty_tpl->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();?><?php $_template->updateParentVariables(0);?><?php unset($_template);?>
<?php }?>
<?php }} ?>
<?php $_template = new Smarty_Internal_Template("{$_smarty_tpl->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();?><?php $_template->updateParentVariables(0);?><?php unset($_template);?>
<?php }else{ ?>
<tr><td colspan="5" align="center">Ning&uacute;n registro encontrado.</td></tr>
<?php }?>
</table>

View File

@@ -0,0 +1,47 @@
<?php /* Smarty version Smarty3-b7, created on 2026-01-07 18:42:48
compiled from "/var/www/html/ventas/templates/lists/pages_ajax.tpl" */ ?>
<?php /*%%SmartyHeaderCode:1966434410695efd885a8455-07878179%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_smarty_tpl->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%%*/?>
<?php if (count($_smarty_tpl->getVariable('pages')->value['numbers'])){?>
<?php $_smarty_tpl->assign("linktpl","{$_smarty_tpl->getVariable('DOC_ROOT')->value}/templates/links/ajax.tpl",null,null);?>
<div class="pages">
<?php if ($_smarty_tpl->getVariable('pages')->value['first']){?><?php $_template = new Smarty_Internal_Template($_smarty_tpl->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();?><?php $_template->updateParentVariables(0);?><?php unset($_template);?>
<?php }?>
<?php if ($_smarty_tpl->getVariable('pages')->value['prev']){?><?php $_template = new Smarty_Internal_Template($_smarty_tpl->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();?><?php $_template->updateParentVariables(0);?><?php unset($_template);?>
<?php }?>
<?php $_smarty_tpl->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;
?>
<?php if ($_smarty_tpl->getVariable('pages')->value['current']==$_smarty_tpl->getVariable('key')->value){?><span class="p"><?php echo $_smarty_tpl->getVariable('key')->value;?>
</span><?php }else{ ?><?php $_template = new Smarty_Internal_Template($_smarty_tpl->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();?><?php $_template->updateParentVariables(0);?><?php unset($_template);?>
<?php }?>
<?php }} ?>
<?php if ($_smarty_tpl->getVariable('pages')->value['next']){?><?php $_template = new Smarty_Internal_Template($_smarty_tpl->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();?><?php $_template->updateParentVariables(0);?><?php unset($_template);?>
<?php }?>
<?php if ($_smarty_tpl->getVariable('pages')->value['last']){?><?php $_template = new Smarty_Internal_Template($_smarty_tpl->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();?><?php $_template->updateParentVariables(0);?><?php unset($_template);?>
<?php }?>
</div>
<?php }?>

View File

@@ -0,0 +1,41 @@
<?php /* Smarty version Smarty3-b7, created on 2026-01-07 18:42:48
compiled from "/var/www/html/ventas/templates/items/sucursales-header.tpl" */ ?>
<?php /*%%SmartyHeaderCode:2065303339695efd88573ed3-73507570%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_smarty_tpl->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%%*/?>
<div align="center">
<span id="addSucursal" style="cursor:pointer"><img src="<?php echo $_smarty_tpl->getVariable('WEB_ROOT')->value;?>
/images/icons/add.png" border="0" />Agregar Sucursal</span>
</div>
<br />
<div class="clear"></div>
<div class="portlet" style="width:95%; padding-left:20px" align="center">
<div class="portlet-content nopadding">
<table width="100%" cellpadding="0" cellspacing="0" id="box-table-a" summary="Employee Pay Sheet">
<thead>
<tr>
<th width="80" scope="col"><div align="center">No.</div></th>
<th width="136" scope="col"><div align="center">RFC</div></th>
<th width="" scope="col"><div align="center">Nombre</div></th>
<th width="109" scope="col"><div align="center">IVA</div></th>
<th width="100" scope="col"><div align="center">Acciones</div></th>
</tr>
</thead>
<tbody>

View File

@@ -0,0 +1,39 @@
<?php /* Smarty version Smarty3-b7, created on 2026-01-07 18:42:48
compiled from "/var/www/html/ventas/templates/items/sucursales-base.tpl" */ ?>
<?php /*%%SmartyHeaderCode:2076211922695efd8857ef52-82516433%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_smarty_tpl->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%%*/?>
<tr>
<td align="center"><?php echo $_smarty_tpl->getVariable('sucursal')->value['sucursalId'];?>
</td>
<td align="center"><?php echo $_smarty_tpl->getVariable('sucursal')->value['rfc'];?>
</td>
<td align="center"><?php echo $_smarty_tpl->getVariable('sucursal')->value['nombre'];?>
</td>
<td align="center"><?php echo $_smarty_tpl->getVariable('sucursal')->value['iva'];?>
%</td>
<td align="center">
<img src="<?php echo $_smarty_tpl->getVariable('WEB_ROOT')->value;?>
/images/icons/details.png" class="spanViewSucursal" id="<?php echo $_smarty_tpl->getVariable('sucursal')->value['sucursalId'];?>
" title="Ver Detalles" />
<img src="<?php echo $_smarty_tpl->getVariable('WEB_ROOT')->value;?>
/images/icons/edit.gif" class="spanEditSucursal" id="<?php echo $_smarty_tpl->getVariable('sucursal')->value['sucursalId'];?>
" title="Editar"/>
<img src="<?php echo $_smarty_tpl->getVariable('WEB_ROOT')->value;?>
/images/icons/delete.gif" class="spanDeleteSucursal" id="<?php echo $_smarty_tpl->getVariable('sucursal')->value['sucursalId'];?>
" title="Eliminar"/>
</td>
</tr>

64
test_login_reales.php Normal file
View File

@@ -0,0 +1,64 @@
<?php
/**
* Test de login dinámico con usuarios reales del sistema
*/
require_once 'config.php';
require_once 'classes/db.class.php';
require_once 'classes/error.class.php';
require_once 'classes/util.class.php';
require_once 'classes/main.class.php';
require_once 'classes/empresa.class.php';
echo "=== TEST LOGIN CON USUARIOS REALES ===\n\n";
// Usuarios reales encontrados en base de datos
$usuariosReales = [
['email' => '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";
?>