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:
@@ -117,7 +117,7 @@ class Usuario extends Main
|
||||
public function setCodigoPostal($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Codigo Postal");
|
||||
$this->codigoPostal = $value;
|
||||
$this->codigoPostal = empty($value) ? 0 : $value;
|
||||
}
|
||||
|
||||
public function setTelefono($value)
|
||||
@@ -156,10 +156,10 @@ class Usuario extends Main
|
||||
$this->tipo = $value;
|
||||
}
|
||||
|
||||
public function setSucursalId($value)
|
||||
public function setSucursalId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 0, 'Sucursal');
|
||||
$this->sucursalId = $value;
|
||||
$this->sucursalId = empty($value) ? 0 : $value;
|
||||
}
|
||||
|
||||
public function setEmail($value)
|
||||
@@ -227,40 +227,45 @@ class Usuario extends Main
|
||||
|
||||
public function Save()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$identificacion = isset($this->identificacion) ? $this->identificacion : '';
|
||||
$comprobante = isset($this->comprobante) ? $this->comprobante : '';
|
||||
|
||||
$db = new DB(true);
|
||||
$db->setQuery("
|
||||
INSERT INTO usuario (
|
||||
INSERT INTO usuario (
|
||||
empresaId,
|
||||
nombre,
|
||||
apellidos,
|
||||
apellidos,
|
||||
calle,
|
||||
noInt,
|
||||
noExt,
|
||||
referencia,
|
||||
colonia,
|
||||
localidad,
|
||||
municipio,
|
||||
noInt,
|
||||
noExt,
|
||||
referencia,
|
||||
colonia,
|
||||
localidad,
|
||||
municipio,
|
||||
estado,
|
||||
pais,
|
||||
pais,
|
||||
codigoPostal,
|
||||
telefono,
|
||||
celular,
|
||||
noImss,
|
||||
curp,
|
||||
rfc,
|
||||
email,
|
||||
password,
|
||||
identificacion,
|
||||
comprobante,
|
||||
email,
|
||||
password,
|
||||
`type`,
|
||||
sucursalId
|
||||
)
|
||||
sucursalId
|
||||
)
|
||||
VALUES (
|
||||
'".$_SESSION["empresaId"]."',
|
||||
'".$this->nombre."',
|
||||
'".$this->apellidos."',
|
||||
'".$this->apellidos."',
|
||||
'".$this->calle."',
|
||||
'".$this->noInt."',
|
||||
'".$this->noExt."',
|
||||
@@ -276,11 +281,12 @@ class Usuario extends Main
|
||||
'".$this->noImss."',
|
||||
'".$this->curp."',
|
||||
'".$this->rfc."',
|
||||
'".$identificacion."',
|
||||
'".$comprobante."',
|
||||
'".$this->email."',
|
||||
'".$this->passwd."',
|
||||
'".$this->tipo."',
|
||||
'".$this->sucursalId."')"
|
||||
);
|
||||
'".$this->sucursalId."')");
|
||||
$usuarioId = $db->InsertData();
|
||||
|
||||
$this->Util()->setError(20017, "complete");
|
||||
@@ -494,10 +500,12 @@ class Usuario extends Main
|
||||
}
|
||||
|
||||
function IsEmailTaked(){
|
||||
|
||||
|
||||
$sqlAdd = '';
|
||||
|
||||
if($this->usuarioId)
|
||||
$sqlAdd = ' AND usuarioId <> "'.$this->usuarioId.'"';
|
||||
|
||||
|
||||
$sql = 'SELECT usuarioId FROM usuario
|
||||
WHERE email = "'.$this->email.'"
|
||||
'.$sqlAdd.'
|
||||
|
||||
Reference in New Issue
Block a user