Fix systematic errors in pagination, sucursal warnings, and fatal count() errors across multiple modules

This commit is contained in:
2026-01-07 01:06:27 -06:00
parent aaa77e870e
commit 3a5afa82fe
354 changed files with 9022 additions and 15093 deletions

View File

@@ -2,7 +2,8 @@
$empresa->AuthUser();
$atributo->SetPage($_GET["p"]);
$p = intval($_GET["p"] ?? 0);
$atributo->SetPage($p);
$atributos = $atributo->Enumerate();
$items = array();

View File

@@ -2,7 +2,8 @@
$empresa->AuthUser();
$bonificacion->SetPage($_GET["p"]);
$p = intval($_GET["p"] ?? 0);
$bonificacion->SetPage($p);
$politicas = $politica->Enumerate();

View File

@@ -2,7 +2,8 @@
$empresa->AuthUser();
$cliente->SetPage($_GET["p"]);
$p = intval($_GET["p"] ?? 0);
$cliente->SetPage($p);
$clientes = $cliente->Enumerate();
$smarty->assign("clientes", $clientes);

View File

@@ -2,7 +2,8 @@
$empresa->AuthUser();
$atributo->SetPage($_GET["p"]);
$p = intval($_GET["p"] ?? 0);
$comision->SetPage($p);
$comisiones = $comision->Enumerate();
foreach($comisiones['items'] as $key => $resComision)

View File

@@ -7,7 +7,8 @@
exit;
}
$cuentaBancaria->SetPage($_GET["p"]);
$p = intval($_GET["p"] ?? 0);
$cuentaBancaria->SetPage($p);
$cuentasBancarias = $cuentaBancaria->Enumerate();
$smarty->assign('cuentasBancarias', $cuentasBancarias);

View File

@@ -1,8 +1,9 @@
<?php
$empresa->Util()->DB()->setQuery("SELECT * FROM empresa");
$result = $empresa->Util()->DB->GetResult();
$db = new DB(true); // Usar master connection
$db->setQuery("SELECT * FROM empresa");
$result = $db->GetResult();
$smarty->assign("empresas", $result);
?>

View File

@@ -7,7 +7,8 @@
exit;
}
$material->SetPage($_GET["p"]);
$p = intval($_GET["p"] ?? 0);
$material->SetPage($p);
$materiales = $material->Enumerate();
$smarty->assign('materiales', $materiales);

View File

@@ -7,7 +7,8 @@
exit;
}
$metodoPago->SetPage($_GET["p"]);
$p = intval($_GET["p"] ?? 0);
$metodoPago->SetPage($p);
$metodosPago = $metodoPago->Enumerate();
$smarty->assign('metodosPago', $metodosPago);

View File

@@ -2,7 +2,8 @@
$empresa->AuthUser();
$motivo->SetPage($_GET["p"]);
$p = intval($_GET["p"] ?? 0);
$motivo->SetPage($p);
$motivos = $motivo->Enumerate();
$smarty->assign('motivos', $motivos);

View File

@@ -10,7 +10,7 @@
$_SESSION['prodsPed'] = array();
unset($_SESSION['prodsPed']);
$pedido->setPage($_GET['p']);
$pedido->setPage($_GET['p'] ?? 0);
$pedidos = $pedido->Enumerate2();

View File

@@ -2,7 +2,8 @@
$empresa->AuthUser();
$producto->SetPage($_GET["p"]);
$p = intval($_GET["p"] ?? 0);
$producto->SetPage($p);
$productos = $producto->Enumerate();
$items = array();

View File

@@ -2,7 +2,8 @@
$empresa->AuthUser();
$promocion->setPage($_GET["p"]);
$p = intval($_GET["p"] ?? 0);
$promocion->setPage($p);
$promociones = $promocion->Enumerate();
$smarty->assign('promociones', $promociones);

View File

@@ -7,7 +7,8 @@
exit;
}
$proveedor->SetPage($_GET["p"]);
$p = intval($_GET["p"] ?? 0);
$proveedor->SetPage($p);
$proveedores = $proveedor->Enumerate();
$smarty->assign("proveedores", $proveedores);

View File

@@ -7,7 +7,8 @@
exit;
}
$temporada->SetPage($_GET["p"]);
$p = intval($_GET["p"] ?? 0);
$temporada->SetPage($p);
$temporadas = $temporada->Enumerate();
$smarty->assign('temporadas', $temporadas);

View File

@@ -1,17 +1,25 @@
<?php
if($_SESSION['tipoUsr'] == 'Cliente'){
$tipoUsr = $_SESSION['tipoUsr'] ?? '';
if($tipoUsr == 'Cliente'){
$Usr['type'] = 'cliente';
}else{
$Usr = $user->Info();
if(!is_array($Usr)) {
$Usr = array();
$Usr['type'] = '';
$Usr['nombre'] = 'Visitante';
$Usr['sucursal'] = '';
}
if( $Usr['type'] == 'gerente' ||
if( isset($Usr['type']) && ($Usr['type'] == 'gerente' ||
$Usr['type'] == 'facturacion' ||
$Usr['type'] == 'vendedor' ||
$Usr['type'] == 'cajero'
$Usr['type'] == 'cajero')
){
$sucursal->setSucursalId($_SESSION['idSuc']);
$Usr['sucursal'] = utf8_decode(urldecode($sucursal->GetNameById()));

View File

@@ -18,6 +18,8 @@
$sucursal->setSucursalId($info['sucursalId'] );
$nomSucursal = $sucursal->GetNameById();
$info['sucursal'] = strtoupper(utf8_decode(urldecode($nomSucursal)));
} else {
$info['sucursal'] = ''; // Initialize for users without sucursal
}
$resSuc = $sucursal->GetSucursalesByEmpresaId();

View File

@@ -9,7 +9,7 @@
$usuarioId = intval($_GET['id']);
if($_POST['type'] == 'saveEditUsuario'){
if(isset($_POST['type']) && $_POST['type'] == 'saveEditUsuario'){
$tipo = $_POST['tipo'];
$idSuc = $_POST['idSuc'];
@@ -165,7 +165,6 @@
}
$smarty->assign('info', $info);
$smarty->assign('usuarios', $usuarios);
$smarty->assign('sucursales', $sucursales);
?>

View File

@@ -9,6 +9,8 @@
$usuario->setEmpresaId($_SESSION["empresaId"]);
$nomSuc = ''; // Initialize nomSuc
if($Usr['type'] == 'gerente'){
$usuario->setSucursalId($Usr['sucursalId']);
$usuario->setTipo('vendedor');
@@ -31,7 +33,9 @@
$sucursal->setSucursalId($res['sucursalId'] );
$nomSucursal = $sucursal->GetNameById();
$card['sucursal'] = strtoupper(utf8_decode(urldecode($nomSucursal)));
}
} else {
$card['sucursal'] = ''; // Default value
}
$usuarios[] = $card;
}
@@ -40,12 +44,23 @@
$resSuc2 = $util->DecodeUrlResult($resSuc);
$sucursales = $util->DecodeResult($resSuc2);
$msg = $_SESSION['msgU'];
$msg = isset($_SESSION['msgU']) ? $_SESSION['msgU'] : ''; // Check if set
$_SESSION['msgU'] = '';
// Dummy pagination to prevent fatal error in pages_new.tpl
$pages = array(
'numbers' => array(),
'first' => false,
'prev' => false,
'next' => false,
'last' => false,
'current' => 1
);
$smarty->assign('msg', $msg);
$smarty->assign('nomSuc', $nomSuc);
$smarty->assign('usuarios', $usuarios);
$smarty->assign('sucursales', $sucursales);
$smarty->assign('pages', $pages);
?>