Compare commits

...

2 Commits

Author SHA1 Message Date
4b5ecdfb1a FASE 2 COMPLETADA: Login dinámico funcionando perfectamente
ÉXITOS ALCANZADOS:
 Eliminado hardcodeo empresaId = 15 en ajax/login.php
 Método DoLogin() corregido para obtener empresaId dinámico
 Conexión a BD real (evita MockDatabase problemático)
 Lógica de BD dinámica: empresaId=1→ventas_nm, empresaId>1→ventas_nm{id}

TESTS VERIFICADOS:
 admin@novomoda.com.mx → empresaId:1 → BD:ventas_nm
 sonia.velezquez@novomoda.com.mx → empresaId:15 → BD:ventas_nm15
 gerente@novomoda.com.mx → empresaId:15 → BD:ventas_nm15

CAMBIOS PRINCIPALES:
- classes/empresa.class.php: DoLogin() con DatabaseManager
- classes/system-config.class.php: Lógica BD dinámica
- ajax/login.php: Eliminado hardcodeo
- md/plan-accion-multi-empresa.md: Actualizado con éxito

PRÓXIMO: Fase 3 - Actualización de módulos restantes
2026-01-07 18:56:28 -06:00
3b5bd9c0e9 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
2026-01-07 18:43:28 -06:00
13 changed files with 788 additions and 27 deletions

View File

@@ -1,5 +1,8 @@
<?php <?php
require_once 'main.class.php';
require_once 'database-manager.class.php';
class Empresa extends Main class Empresa extends Main
{ {
protected $username; protected $username;
@@ -374,19 +377,30 @@ $this->Util()->ValidateMail($value, "Email");
function DoLogin() function DoLogin()
{ {
$generalDb = new DB(true); // CAMBIO CRÍTICO: Usar DatabaseManager para conexión real (evitar MockDatabase)
$dbManager = DatabaseManager::getInstance();
$masterConnection = $dbManager->getMasterConnection();
// CAMBIO CRÍTICO: Obtener empresaId dinámicamente del usuario // Verificar conexión real
// Buscar usuario por email y password sin filtrar por empresaId fijo if ($masterConnection->connect_error) {
unset($_SESSION["loginKey"]);
unset($_SESSION["empresaId"]);
$this->Util()->setError(10006, "error");
if($this->Util()->PrintErrors()) {
return false;
}
}
// CAMBIO CRÍTICO: Obtener empresaId dinámicamente del usuario con BD real
$sql = "SELECT usuarioId, empresaId FROM usuario $sql = "SELECT usuarioId, empresaId FROM usuario
WHERE email = '".$this->email."' WHERE email = '".$this->email."'
AND password = '".$this->password."' AND password = '".$this->password."'
AND baja = '0'"; AND baja = '0'";
$generalDb->setQuery($sql);
$result = $generalDb->GetSingle();
// GetSingle puede devolver un string o array, manejar ambos casos $result = $masterConnection->query($sql);
if(!$result)
// Validar que se encontró el usuario
if(!$result || !($row = $result->fetch_assoc()))
{ {
unset($_SESSION["loginKey"]); unset($_SESSION["loginKey"]);
unset($_SESSION["empresaId"]); unset($_SESSION["empresaId"]);
@@ -399,34 +413,24 @@ $this->Util()->ValidateMail($value, "Email");
} }
// Si result es array, obtener valores; si es string, es usuarioId viejo // Obtener datos del usuario de forma segura
if(is_array($result)) $usuarioId = $row['usuarioId'];
{ $empresaIdFromUser = $row['empresaId'];
$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();
}
// Establecer el empresaId real del usuario // Establecer el empresaId real del usuario
$this->empresaId = $empresaIdFromUser; $this->empresaId = $empresaIdFromUser;
$sql = "SELECT * FROM usuario // Obtener información adicional del usuario
$sql2 = "SELECT * FROM usuario
LEFT JOIN empresa ON usuario.empresaId = empresa.empresaId LEFT JOIN empresa ON usuario.empresaId = empresa.empresaId
WHERE usuarioId = '".$usuarioId."'"; WHERE usuarioId = '".$usuarioId."'";
$generalDb->setQuery($sql); $result2 = $masterConnection->query($sql2);
$info = $generalDb->GetRow(); $info = $result2 ? $result2->fetch_assoc() : [];
$_SESSION["loginKey"] = $usuarioId; $_SESSION["loginKey"] = $usuarioId;
$_SESSION["idSuc"] = $info['sucursalId']; $_SESSION["idSuc"] = isset($info['sucursalId']) ? $info['sucursalId'] : 0;
$_SESSION["empresaId"] = $this->empresaId; $_SESSION["empresaId"] = $this->empresaId;
$_SESSION["version"] = $info["version"]; $_SESSION["version"] = isset($info["version"]) ? $info["version"] : '';
return true; 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";
?>

59
debug_passwords.php Normal file
View File

@@ -0,0 +1,59 @@
<?php
/**
* Debug de contraseñas en base de datos real
*/
require_once 'config.php';
require_once 'classes/system-config.class.php';
require_once 'classes/database-manager.class.php';
echo "=== DEBUG CONTRASEÑAS BD REAL ===\n\n";
// Usar directamente DatabaseManager para conexión real
$dbManager = DatabaseManager::getInstance();
$masterConnection = $dbManager->getMasterConnection();
// Paso 1: Verificar contraseñas de usuarios
echo "1. Verificando contraseñas almacenadas:\n";
$result = $masterConnection->query("SELECT usuarioId, email, password, empresaId, nombre FROM usuario LIMIT 5");
while ($row = $result->fetch_assoc()) {
echo " ID: {$row['usuarioId']}, Email: {$row['email']}, Pass: '{$row['password']}', EmpresaID: {$row['empresaId']}\n";
}
// Paso 2: Probar diferentes contraseñas comunes
echo "\n2. Probando diferentes contraseñas para admin@novomoda.com.mx:\n";
$commonPasswords = ['1234', 'password', 'admin', '12345', 'admin123'];
$email = 'admin@novomoda.com.mx';
foreach ($commonPasswords as $pass) {
$sql = "SELECT usuarioId, empresaId FROM usuario
WHERE email = '$email'
AND password = '$pass'
AND baja = '0'";
$result = $masterConnection->query($sql);
if ($result && $row = $result->fetch_assoc()) {
echo " ✅ Contraseña '$pass' funciona:\n";
echo " usuarioId: {$row['usuarioId']}\n";
echo " empresaId: {$row['empresaId']}\n";
} else {
echo " ❌ Contraseña '$pass' falla\n";
}
}
// Paso 3: Probar login sin verificar contraseña primero
echo "\n3. Verificando si usuario existe (sin password):\n";
$sql = "SELECT usuarioId, email, password, empresaId FROM usuario WHERE email = 'admin@novomoda.com.mx'";
$result = $masterConnection->query($sql);
if ($result && $row = $result->fetch_assoc()) {
echo " ✅ Usuario encontrado:\n";
echo " usuarioId: {$row['usuarioId']}\n";
echo " email: {$row['email']}\n";
echo " password: '{$row['password']}'\n";
echo " empresaId: {$row['empresaId']}\n";
echo " baja: (no verificado en esta consulta)\n";
}
echo "\n=== FIN DEBUG CONTRASEÑAS ===\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: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: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: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,69 @@ El login debe:
- Ajustar compatibilidad en consulta SQL - Ajustar compatibilidad en consulta SQL
- Corregir manejo de nulos - 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
## ✅ FASE 2 COMPLETADA CON ÉXITO
### 🎯 Problema Resuelto
- **GetRow() devuelve null** → Solucionado usando DatabaseManager directamente
- **MockDatabase incompatible** → Evitado usando conexión mysqli real
- **empresaId = 0 siempre** → Corregido a empresaId dinámico real
### 🔧 Cambios Realizados
1. **ajax/login.php**: Eliminado hardcodeo `empresaId = 15`
2. **classes/empresa.class.php**:
- Método `DoLogin()` actualizado para usar DatabaseManager
- Conexión directa a mysqli (evita MockDatabase)
- Obtener empresaId dinámico del usuario
3. **classes/system-config.class.php**: Lógica de base de datos dinámica
- empresaId=1 → `ventas_nm`
- empresaId>1 → `ventas_nm{id}`
### ✅ Resultados Verificados
```
admin@novomoda.com.mx (MiPo6425@@) → empresaId: 1 → BD: ventas_nm ✅
sonia.velezquez@novomoda.com.mx → empresaId: 15 → BD: ventas_nm15 ✅
gerente@novomoda.com.mx → empresaId: 15 → BD: ventas_nm15 ✅
```
### 📊 Tests Realizados
-`test_login_bd_real.php` - Conexión BD real
-`debug_passwords.php` - Contraseñas reales
-`test_login_dinamico_final.php` - Lógica BD dinámica
-`test_login_final.php` - Login completo funcionando
--- ---
**Estado**: Fase 2 en progreso - Problemas de compatibilidad detectados **Estado**: FASE 2 COMPLETADA EXITOSAMENTE
**Creado**: 07-01-2026 **Creado**: 07-01-2026
**Última actualización**: 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>

71
test_login_bd_real.php Normal file
View File

@@ -0,0 +1,71 @@
<?php
/**
* Test de login con conexión a base de datos real (ignorar MockDatabase)
*/
require_once 'config.php';
require_once 'classes/system-config.class.php';
require_once 'classes/database-manager.class.php';
// Usar directamente DatabaseManager para conexión real
$dbManager = DatabaseManager::getInstance();
$masterConnection = $dbManager->getMasterConnection();
echo "=== TEST LOGIN BD REAL ===\n\n";
// Paso 1: Verificar conexión real
echo "1. Verificando conexión a base de datos master...\n";
if ($masterConnection->connect_error) {
echo " ❌ Error de conexión: " . $masterConnection->connect_error . "\n";
exit;
} else {
echo " ✅ Conexión exitosa\n";
}
// Paso 2: Contar usuarios
echo "\n2. Contando usuarios en base de datos master...\n";
$result = $masterConnection->query("SELECT COUNT(*) as total FROM usuario");
$row = $result->fetch_assoc();
echo " Total usuarios: " . $row['total'] . "\n";
// Paso 3: Mostrar usuarios reales
echo "\n3. Usuarios encontrados en base de datos:\n";
$result = $masterConnection->query("SELECT usuarioId, email, empresaId, nombre FROM usuario LIMIT 5");
while ($row = $result->fetch_assoc()) {
echo " ID: {$row['usuarioId']}, Email: {$row['email']}, EmpresaID: {$row['empresaId']}, Nombre: {$row['nombre']}\n";
}
// Paso 4: Probar consulta del login con usuarios reales
echo "\n4. Probando consulta SQL del login:\n";
$testUsers = [
['email' => 'admin@novomoda.com.mx', 'password' => '1234'],
['email' => 'sonia.velezquez@novomoda.com.mx', 'password' => '1234'],
['email' => 'gerente@novomoda.com.mx', 'password' => '1234']
];
foreach ($testUsers as $user) {
echo "\n Probando: {$user['email']}\n";
$sql = "SELECT usuarioId, empresaId FROM usuario
WHERE email = '{$user['email']}'
AND password = '{$user['password']}'
AND baja = '0'";
$result = $masterConnection->query($sql);
if ($result && $row = $result->fetch_assoc()) {
echo " ✅ Login exitoso:\n";
echo " usuarioId: {$row['usuarioId']}\n";
echo " empresaId: {$row['empresaId']}\n";
// Verificar base de datos que debería usar
$config = SystemConfig::getEmpresaDatabaseConfig($row['empresaId']);
echo " BD empresa: {$config['database']}\n";
} else {
echo " ❌ Login fallido\n";
}
}
echo "\n=== FIN TEST BD REAL ===\n";
?>

View File

@@ -0,0 +1,69 @@
<?php
/**
* Test final de login con contraseñas correctas y BD real
*/
require_once 'config.php';
require_once 'classes/system-config.class.php';
require_once 'classes/database-manager.class.php';
echo "=== TEST FINAL LOGIN BD REAL ===\n\n";
// Usar directamente DatabaseManager para conexión real
$dbManager = DatabaseManager::getInstance();
$masterConnection = $dbManager->getMasterConnection();
// Usuarios con contraseñas correctas
$usuariosCorrectos = [
['email' => 'admin@novomoda.com.mx', 'password' => 'MiPo6425@@', 'expectedEmpresaId' => 1],
['email' => 'cedis@novomoda.com.mx', 'password' => 'cedis', 'expectedEmpresaId' => 1],
['email' => 'sonia.velezquez@novomoda.com.mx', 'password' => 'sonia.v', 'expectedEmpresaId' => 15],
['email' => 'gerente@novomoda.com.mx', 'password' => 'gerente', 'expectedEmpresaId' => 15],
];
foreach ($usuariosCorrectos as $user) {
echo "Probando: {$user['email']}\n";
$sql = "SELECT usuarioId, empresaId FROM usuario
WHERE email = '{$user['email']}'
AND password = '{$user['password']}'
AND baja = '0'";
$result = $masterConnection->query($sql);
if ($result && $row = $result->fetch_assoc()) {
echo "✅ Login exitoso:\n";
echo " usuarioId: {$row['usuarioId']}\n";
echo " empresaId obtenido: {$row['empresaId']}\n";
echo " empresaId esperado: {$user['expectedEmpresaId']}\n";
// Verificar base de datos que debería usar
$config = SystemConfig::getEmpresaDatabaseConfig($row['empresaId']);
echo " BD empresa: {$config['database']}\n";
if ($row['empresaId'] == $user['expectedEmpresaId']) {
echo "✅ CORRECTO: empresaId coincide\n";
} else {
echo "❌ ERROR: empresaId no coincide\n";
}
} else {
echo "❌ Login fallido\n";
}
echo str_repeat("-", 50) . "\n";
}
echo "\n=== PRUEBA DE LÓGICA DE BASE DE DATOS ===\n";
echo "Regla: empresaId=1 usa 'ventas_nm', empresaId>1 usa 'ventas_nm{id}'\n\n";
$config1 = SystemConfig::getEmpresaDatabaseConfig(1);
$config15 = SystemConfig::getEmpresaDatabaseConfig(15);
$config2 = SystemConfig::getEmpresaDatabaseConfig(2);
echo "empresaId=1 → BD: {$config1['database']}\n";
echo "empresaId=15 → BD: {$config15['database']}\n";
echo "empresaId=2 → BD: {$config2['database']}\n";
echo "\n=== FIN TEST FINAL ===\n";
?>

75
test_login_final.php Normal file
View File

@@ -0,0 +1,75 @@
<?php
/**
* Test final del login dinámico con Empresa.class.php corregido
*/
require_once 'config.php';
require_once 'classes/error.class.php';
require_once 'classes/util.class.php';
require_once 'classes/main.class.php';
require_once 'classes/database-manager.class.php';
require_once 'classes/empresa.class.php';
echo "=== TEST FINAL LOGIN DINÁMICO ===\n\n";
// Usuarios con contraseñas correctas
$usuariosCorrectos = [
['email' => 'admin@novomoda.com.mx', 'password' => 'MiPo6425@@', 'expectedEmpresaId' => 1],
['email' => 'sonia.velezquez@novomoda.com.mx', 'password' => 'sonia.v', 'expectedEmpresaId' => 15],
['email' => 'gerente@novomoda.com.mx', 'password' => 'gerente', 'expectedEmpresaId' => 15],
];
foreach ($usuariosCorrectos as $test) {
echo "Test con email: {$test['email']}\n";
// Crear instancia de empresa con método corregido
$empresa = new Empresa();
$empresa->setEmail($test['email']);
$empresa->setPassword($test['password']);
// Intentar login con el método DoLogin() actualizado
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("-", 60) . "\n";
}
echo "\n=== VERIFICACIÓN DE LÓGICA DE BASE DE DATOS ===\n";
require_once 'classes/system-config.class.php';
echo "Regla implementada: empresaId=1 usa 'ventas_nm', empresaId>1 usa 'ventas_nm{id}'\n\n";
$testIds = [1, 2, 15, 20];
foreach ($testIds as $id) {
$config = SystemConfig::getEmpresaDatabaseConfig($id);
echo "empresaId=$id → BD: {$config['database']}\n";
}
echo "\n=== FIN DEL TEST FINAL ===\n";
?>

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";
?>