Fix usuarios module: resolve PHP 8 warnings and fatal errors
- Fixed undefined array key warnings in usuarios-agregar.php - Fixed undefined variable warnings (, , ) - Fixed null array offset warnings in db.class.php GetSingle() - Added default parameter to ValidateMail() in util.class.php - Fixed PrintErrors() return value for proper error handling - Fixed integer constraint errors for codigoPostal and sucursalId - Added missing identificacion and comprobante fields to INSERT query - Fixed undefined variable in IsEmailTaked()
This commit is contained in:
@@ -205,10 +205,8 @@ public function DatabaseConnect()
|
|||||||
} else {
|
} else {
|
||||||
$row = mysqli_fetch_array($this->sqlResult);
|
$row = mysqli_fetch_array($this->sqlResult);
|
||||||
}
|
}
|
||||||
$rs = $row[0];
|
|
||||||
|
|
||||||
if(!$rs)
|
$rs = ($row && isset($row[0])) ? $row[0] : 0;
|
||||||
$rs = 0;
|
|
||||||
|
|
||||||
$this->CleanQuery();
|
$this->CleanQuery();
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ class Usuario extends Main
|
|||||||
public function setCodigoPostal($value)
|
public function setCodigoPostal($value)
|
||||||
{
|
{
|
||||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Codigo Postal");
|
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Codigo Postal");
|
||||||
$this->codigoPostal = $value;
|
$this->codigoPostal = empty($value) ? 0 : $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTelefono($value)
|
public function setTelefono($value)
|
||||||
@@ -159,7 +159,7 @@ class Usuario extends Main
|
|||||||
public function setSucursalId($value)
|
public function setSucursalId($value)
|
||||||
{
|
{
|
||||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 0, 'Sucursal');
|
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 0, 'Sucursal');
|
||||||
$this->sucursalId = $value;
|
$this->sucursalId = empty($value) ? 0 : $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setEmail($value)
|
public function setEmail($value)
|
||||||
@@ -231,6 +231,9 @@ class Usuario extends Main
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$identificacion = isset($this->identificacion) ? $this->identificacion : '';
|
||||||
|
$comprobante = isset($this->comprobante) ? $this->comprobante : '';
|
||||||
|
|
||||||
$db = new DB(true);
|
$db = new DB(true);
|
||||||
$db->setQuery("
|
$db->setQuery("
|
||||||
INSERT INTO usuario (
|
INSERT INTO usuario (
|
||||||
@@ -252,6 +255,8 @@ class Usuario extends Main
|
|||||||
noImss,
|
noImss,
|
||||||
curp,
|
curp,
|
||||||
rfc,
|
rfc,
|
||||||
|
identificacion,
|
||||||
|
comprobante,
|
||||||
email,
|
email,
|
||||||
password,
|
password,
|
||||||
`type`,
|
`type`,
|
||||||
@@ -276,11 +281,12 @@ class Usuario extends Main
|
|||||||
'".$this->noImss."',
|
'".$this->noImss."',
|
||||||
'".$this->curp."',
|
'".$this->curp."',
|
||||||
'".$this->rfc."',
|
'".$this->rfc."',
|
||||||
|
'".$identificacion."',
|
||||||
|
'".$comprobante."',
|
||||||
'".$this->email."',
|
'".$this->email."',
|
||||||
'".$this->passwd."',
|
'".$this->passwd."',
|
||||||
'".$this->tipo."',
|
'".$this->tipo."',
|
||||||
'".$this->sucursalId."')"
|
'".$this->sucursalId."')");
|
||||||
);
|
|
||||||
$usuarioId = $db->InsertData();
|
$usuarioId = $db->InsertData();
|
||||||
|
|
||||||
$this->Util()->setError(20017, "complete");
|
$this->Util()->setError(20017, "complete");
|
||||||
@@ -495,6 +501,8 @@ class Usuario extends Main
|
|||||||
|
|
||||||
function IsEmailTaked(){
|
function IsEmailTaked(){
|
||||||
|
|
||||||
|
$sqlAdd = '';
|
||||||
|
|
||||||
if($this->usuarioId)
|
if($this->usuarioId)
|
||||||
$sqlAdd = ' AND usuarioId <> "'.$this->usuarioId.'"';
|
$sqlAdd = ' AND usuarioId <> "'.$this->usuarioId.'"';
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ class Util extends SystemError
|
|||||||
}
|
}
|
||||||
}//ValidateFloat
|
}//ValidateFloat
|
||||||
|
|
||||||
function ValidateMail($mail, $field)
|
function ValidateMail($mail, $field = 'Email')
|
||||||
{
|
{
|
||||||
$mail = strtolower($mail);
|
$mail = strtolower($mail);
|
||||||
if (!preg_match('/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',trim($mail)))
|
if (!preg_match('/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',trim($mail)))
|
||||||
@@ -477,11 +477,15 @@ class Util extends SystemError
|
|||||||
|
|
||||||
function PrintErrors()
|
function PrintErrors()
|
||||||
{
|
{
|
||||||
|
if(empty($this->error)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$errorStr = "<div id='error-box'>";
|
$errorStr = "<div id='error-box'>";
|
||||||
foreach($this->error as $key => $val)
|
foreach($this->error as $key => $val)
|
||||||
{
|
{
|
||||||
$msg = $this->errorMessage($val);
|
$msg = $this->errorMessage($val);
|
||||||
$field = $this->errorField[$key];
|
$field = isset($this->errorField[$key]) ? $this->errorField[$key] : '';
|
||||||
|
|
||||||
$errorStr .= "<div class='error-item'>";
|
$errorStr .= "<div class='error-item'>";
|
||||||
if($field != "")
|
if($field != "")
|
||||||
@@ -493,6 +497,7 @@ class Util extends SystemError
|
|||||||
}
|
}
|
||||||
$errorStr .= "</div>";
|
$errorStr .= "</div>";
|
||||||
echo $errorStr;
|
echo $errorStr;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function errorMessage($code)
|
function errorMessage($code)
|
||||||
|
|||||||
@@ -7,10 +7,10 @@
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_POST['type'] == 'saveUsuario'){
|
if(isset($_POST['type']) && $_POST['type'] == 'saveUsuario'){
|
||||||
|
|
||||||
$tipo = $_POST['tipo'];
|
$tipo = $_POST['tipo'];
|
||||||
$idSuc = $_POST['idSuc'];
|
$idSuc = isset($_POST['idSuc']) ? $_POST['idSuc'] : array();
|
||||||
|
|
||||||
$usuario->setTipo($tipo);
|
$usuario->setTipo($tipo);
|
||||||
$usuario->setNombre($_POST['nombre']);
|
$usuario->setNombre($_POST['nombre']);
|
||||||
@@ -110,6 +110,10 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$nomSuc = '';
|
||||||
|
$info = array('type' => '', 'sucursalId' => '');
|
||||||
|
$post = array('sucursalId' => '');
|
||||||
|
|
||||||
if($Usr['type'] == 'gerente'){
|
if($Usr['type'] == 'gerente'){
|
||||||
$sucursal->setSucursalId($Usr['sucursalId']);
|
$sucursal->setSucursalId($Usr['sucursalId']);
|
||||||
$nomSuc = $sucursal->GetNameById();
|
$nomSuc = $sucursal->GetNameById();
|
||||||
@@ -117,12 +121,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sucursales = $sucursal->GetSucursalesByEmpresaId();
|
$sucursales = $sucursal->GetSucursalesByEmpresaId();
|
||||||
foreach ($sucursales as $key => $sucursal ){
|
$sucursalesFiltered = array();
|
||||||
$sucursales[$key]['nombre'] = utf8_decode(urldecode($sucursal['nombre']));
|
foreach ($sucursales as $item ){
|
||||||
|
if($item){
|
||||||
|
$item['nombre'] = utf8_decode(urldecode($item['nombre']));
|
||||||
|
$sucursalesFiltered[] = $item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$smarty->assign('info', $info);
|
||||||
|
$smarty->assign('post', $post);
|
||||||
$smarty->assign('nomSuc', $nomSuc);
|
$smarty->assign('nomSuc', $nomSuc);
|
||||||
$smarty->assign('usuarios', $usuarios);
|
$smarty->assign('sucursales', $sucursalesFiltered);
|
||||||
$smarty->assign('sucursales', $sucursales);
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user