style: Remove espaços em branco

parent e7b99107
...@@ -25,9 +25,9 @@ use vendor\yiisoft\validators\Validator\validateUserBirthDate; ...@@ -25,9 +25,9 @@ use vendor\yiisoft\validators\Validator\validateUserBirthDate;
class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterface class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterface
{ {
use \common\models\traits\ModelSearch; use \common\models\traits\ModelSearch;
public $strSearchModel = '\app\common\models\sistema\SistemaTabUsuariosSearch'; public $strSearchModel = '\app\common\models\sistema\SistemaTabUsuariosSearch';
const STATUS_DELETED = 0; const STATUS_DELETED = 0;
const STATUS_INACTIVE = 2; const STATUS_INACTIVE = 2;
const STATUS_SUSPENDEND = 5; const STATUS_SUSPENDEND = 5;
...@@ -63,7 +63,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -63,7 +63,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
$scenarios[self::SCENARIO_REGISTER] = ['txt_nome', 'txt_email', 'username', 'num_cpf', 'txt_cargo', 'dte_nascimento', 'num_registro_profissional', 'cod_area', 'cod_nivel', 'txt_cep', 'cod_chefia', 'txt_logradouro', 'txt_bairro', 'txt_cidade', 'txt_uf', 'password_reset_token', ]; $scenarios[self::SCENARIO_REGISTER] = ['txt_nome', 'txt_email', 'username', 'num_cpf', 'txt_cargo', 'dte_nascimento', 'num_registro_profissional', 'cod_area', 'cod_nivel', 'txt_cep', 'cod_chefia', 'txt_logradouro', 'txt_bairro', 'txt_cidade', 'txt_uf', 'password_reset_token', ];
$scenarios[self::SCENARIO_UPDATE] = [ 'txt_nome', 'txt_email', 'username', 'num_cpf', 'txt_cargo', 'dte_nascimento', 'num_registro_profissional', 'cod_area', 'cod_nivel', 'cod_chefia', 'txt_cep', 'txt_logradouro', 'txt_bairro', 'txt_cidade', 'txt_uf', 'password_reset_token', 'oldPassword','passwordConfirm','password',]; $scenarios[self::SCENARIO_UPDATE] = [ 'txt_nome', 'txt_email', 'username', 'num_cpf', 'txt_cargo', 'dte_nascimento', 'num_registro_profissional', 'cod_area', 'cod_nivel', 'cod_chefia', 'txt_cep', 'txt_logradouro', 'txt_bairro', 'txt_cidade', 'txt_uf', 'password_reset_token', 'oldPassword','passwordConfirm','password',];
$scenarios[self::SCENARIO_UPDATEADM] = ['txt_nome', 'txt_email', 'username', 'num_cpf', 'txt_cargo', 'num_registro_profissional', 'cod_area', 'cod_nivel', 'cod_chefia', 'txt_logradouro', 'txt_bairro', 'txt_cidade', 'txt_uf', 'password_reset_token',]; $scenarios[self::SCENARIO_UPDATEADM] = ['txt_nome', 'txt_email', 'username', 'num_cpf', 'txt_cargo', 'num_registro_profissional', 'cod_area', 'cod_nivel', 'cod_chefia', 'txt_logradouro', 'txt_bairro', 'txt_cidade', 'txt_uf', 'password_reset_token',];
return $scenarios; return $scenarios;
} }
/** /**
...@@ -73,7 +73,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -73,7 +73,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
{ {
return 'sistema.tab_usuarios'; return 'sistema.tab_usuarios';
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
...@@ -83,7 +83,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -83,7 +83,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
TimestampBehavior::className(), TimestampBehavior::className(),
]; ];
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
...@@ -107,32 +107,32 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -107,32 +107,32 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
// UNIQUE // UNIQUE
[ [
['num_cpf','txt_email','username', 'txt_login_usuario',], ['num_cpf','txt_email','username', 'txt_login_usuario',],
'unique', 'unique',
'message' => 'Campo único já cadastrado.', 'message' => 'Campo único já cadastrado.',
'on' => [self::SCENARIO_REGISTER, self::SCENARIO_UPDATE, self::SCENARIO_UPDATEADM] 'on' => [self::SCENARIO_REGISTER, self::SCENARIO_UPDATE, self::SCENARIO_UPDATEADM]
], ],
// FKS // FKS
// [ // [
// 'cod_area', // 'cod_area',
// 'exist', // 'exist',
// 'message' => 'Código de área inválido', // 'message' => 'Código de área inválido',
// 'targetClass' => 'SistemaOpcAreas' // 'targetClass' => 'SistemaOpcAreas'
// ], // ],
// [ // [
// 'cod_chefia', // 'cod_chefia',
// 'exist', // 'exist',
// 'message' => 'Código de área inválido', // 'message' => 'Código de área inválido',
// // 'targetClass' => '\common\models\sistema\SistemaTabUsuarios', // // 'targetClass' => '\common\models\sistema\SistemaTabUsuarios',
// 'targetAttribute' => 'cod_usuario', // 'targetAttribute' => 'cod_usuario',
// ], // ],
// [ // [
// 'cod_nivel', // 'cod_nivel',
// 'exist', // 'exist',
// 'message' => 'Código de nível inválido', // 'message' => 'Código de nível inválido',
// 'targetClass' => '\common\models\sistema\SistemaOpcNivel' // 'targetClass' => '\common\models\sistema\SistemaOpcNivel'
// ], // ],
[ [
'txt_email', 'txt_email',
'exist', 'exist',
'targetClass' => '\common\models\sistema\SistemaTabUsuarios', 'targetClass' => '\common\models\sistema\SistemaTabUsuarios',
'filter' => ['bln_ativo' => true], 'filter' => ['bln_ativo' => true],
...@@ -164,16 +164,16 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -164,16 +164,16 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
], ],
[ [
[ [
'txt_login_usuario', 'txt_nome', 'num_cpf', 'txt_cargo', 'num_registro_profissional', 'txt_login_usuario', 'txt_nome', 'num_cpf', 'txt_cargo', 'num_registro_profissional',
'txt_email', 'auth_key', 'username', 'password_reset_token', 'txt_logradouro', 'txt_cidade', 'txt_email', 'auth_key', 'username', 'password_reset_token', 'txt_logradouro', 'txt_cidade',
'txt_bairro', 'txt_uf', 'txt_cep', 'txt_preferencias', 'txt_bairro', 'txt_uf', 'txt_cep', 'txt_preferencias',
], ],
'filter', 'filter',
'filter' => 'trim' 'filter' => 'trim'
], ],
// EMAIL // EMAIL
[ [
'txt_email', 'txt_email',
'email', 'email',
'on' => [self::SCENARIO_REGISTER,self::SCENARIO_UPDATE,self::SCENARIO_UPDATEADM] 'on' => [self::SCENARIO_REGISTER,self::SCENARIO_UPDATE,self::SCENARIO_UPDATEADM]
], ],
...@@ -193,90 +193,90 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -193,90 +193,90 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
// return ($.inArray(valArea,['1','2','3','4']) != -1); // return ($.inArray(valArea,['1','2','3','4']) != -1);
// } // }
// ", // ",
// ], // ],
// INTEGER // INTEGER
[ [
['cod_area', 'cod_endereco', 'cod_nivel','status', 'created_at', 'updated_at'], ['cod_area', 'cod_endereco', 'cod_nivel','status', 'created_at', 'updated_at'],
'integer', 'integer',
'message' => 'Campo deve ser um número inteiro', 'message' => 'Campo deve ser um número inteiro',
'on' => [self::SCENARIO_REGISTER,self::SCENARIO_UPDATE,self::SCENARIO_UPDATEADM] 'on' => [self::SCENARIO_REGISTER,self::SCENARIO_UPDATE,self::SCENARIO_UPDATEADM]
], ],
// STRINGS // STRINGS
[ [
['txt_login_usuario', 'oldPassword', 'txt_senha_usuario', 'txt_nome', 'num_cpf', 'txt_cargo', 'num_registro_profissional', 'txt_email', 'auth_key', 'username', 'password_hash', 'password_reset_token', 'txt_logradouro', 'txt_cidade', 'txt_bairro', 'txt_uf', 'txt_cep', ], ['txt_login_usuario', 'oldPassword', 'txt_senha_usuario', 'txt_nome', 'num_cpf', 'txt_cargo', 'num_registro_profissional', 'txt_email', 'auth_key', 'username', 'password_hash', 'password_reset_token', 'txt_logradouro', 'txt_cidade', 'txt_bairro', 'txt_uf', 'txt_cep', ],
'string' , 'string' ,
'on' => [self::SCENARIO_REGISTER,self::SCENARIO_UPDATE,self::SCENARIO_UPDATEADM] 'on' => [self::SCENARIO_REGISTER,self::SCENARIO_UPDATE,self::SCENARIO_UPDATEADM]
], ],
[ [
['password','passwordConfirm'], ['password','passwordConfirm'],
'string', 'string',
'min' => 6, 'min' => 6,
'message' => 'A senha deve ter ao menos 6 caracteres', 'message' => 'A senha deve ter ao menos 6 caracteres',
'on' => [self::SCENARIO_REGISTER,self::SCENARIO_UPDATE] 'on' => [self::SCENARIO_REGISTER,self::SCENARIO_UPDATE]
], ],
[ [
['txt_login_usuario', 'num_registro_profissional'], ['txt_login_usuario', 'num_registro_profissional'],
'string', 'string',
'max' => 30, 'max' => 30,
'message' => 'O campo pode ter no máximo 30 caracteres.', 'message' => 'O campo pode ter no máximo 30 caracteres.',
'on' => [self::SCENARIO_REGISTER,self::SCENARIO_UPDATE,self::SCENARIO_UPDATEADM] 'on' => [self::SCENARIO_REGISTER,self::SCENARIO_UPDATE,self::SCENARIO_UPDATEADM]
], ],
[ [
['auth_key'], ['auth_key'],
'string', 'string',
'max' => 32, 'max' => 32,
'message' => 'O campo pode ter no máximo 32 caracteres', 'message' => 'O campo pode ter no máximo 32 caracteres',
], ],
[ [
['txt_nome', 'txt_email', 'txt_bairro', 'txt_uf'], ['txt_nome', 'txt_email', 'txt_bairro', 'txt_uf'],
'string', 'string',
'max' => 150, 'max' => 150,
'message' => 'O campo pode ter no máximo 150 caracteres', 'message' => 'O campo pode ter no máximo 150 caracteres',
], ],
[ [
['num_cpf'], ['num_cpf'],
'string', 'string',
'max' => 14, 'max' => 14,
'message' => 'O campo pode ter no máximo 14 caracteres', 'message' => 'O campo pode ter no máximo 14 caracteres',
// Verificar como mudar a mensagem global para regra MAX de uma STRING // Verificar como mudar a mensagem global para regra MAX de uma STRING
//'message' => 'O cargo pode ter no máximo {max} caracteres.', //'message' => 'O cargo pode ter no máximo {max} caracteres.',
], ],
[ [
['txt_cargo'], ['txt_cargo'],
'string', 'string',
'max' => 50, 'max' => 50,
'message' => 'O campo pode ter no máximo 50 caracteres', 'message' => 'O campo pode ter no máximo 50 caracteres',
], ],
[ [
['txt_cep'], ['txt_cep'],
'string', 'string',
'max' => 10, 'max' => 10,
'message' => 'O campo pode ter no máximo 50 caracteres', 'message' => 'O campo pode ter no máximo 50 caracteres',
], ],
[ [
['username', 'img_foto', 'txt_logradouro', 'txt_cidade',], ['username', 'img_foto', 'txt_logradouro', 'txt_cidade',],
'string', 'string',
'min' => 2, 'min' => 2,
'max' => 255, 'max' => 255,
'message' => 'O campo deve ter no mínimo 2 e no máximo 255 caracteres', 'message' => 'O campo deve ter no mínimo 2 e no máximo 255 caracteres',
], ],
// VALORES PADRÃO // VALORES PADRÃO
[ [
'status', 'status',
'default', 'default',
'value' => self::STATUS_ACTIVE, 'value' => self::STATUS_ACTIVE,
], ],
// RANGE // RANGE
[ [
'status', 'status',
'in', 'in',
'range' => [self::STATUS_ACTIVE, self::STATUS_DELETED] 'range' => [self::STATUS_ACTIVE, self::STATUS_DELETED]
], ],
// FILE // FILE
[ [
'file', 'file',
'file', 'file',
'skipOnEmpty' => true, 'skipOnEmpty' => true,
'extensions' => 'png, jpg' 'extensions' => 'png, jpg'
], ],
[ [
...@@ -293,27 +293,27 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -293,27 +293,27 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
'passwordConfirm', 'passwordConfirm',
'validateConfirmPassword', 'validateConfirmPassword',
'on' => self::SCENARIO_UPDATE, 'on' => self::SCENARIO_UPDATE,
'skipOnEmpty' => false, 'skipOnEmpty' => false,
'skipOnError' => false 'skipOnError' => false
], ],
]; ];
} }
public function validateUpdateSenha($attribute, $params) { public function validateUpdateSenha($attribute, $params) {
if ( ! $this->validatePassword($this->$attribute)) { if ( ! $this->validatePassword($this->$attribute)) {
$this->addError($attribute,"A senha atual inválida informada é inválida."); $this->addError($attribute,"A senha atual inválida informada é inválida.");
} }
} }
public function validateConfirmPassword($attribute, $params) { public function validateConfirmPassword($attribute, $params) {
if ( if (
(trim($this->password) || trim($this->passwordConfirm)) && (trim($this->password) || trim($this->passwordConfirm)) &&
(strcmp($this->password, $this->passwordConfirm) != 0) (strcmp($this->password, $this->passwordConfirm) != 0)
) { ) {
$this->addError($attribute,"A nova senha e a sua confirmação são não coincidem."); $this->addError($attribute,"A nova senha e a sua confirmação são não coincidem.");
} }
} }
public function validateEmail($attribute, $params) { public function validateEmail($attribute, $params) {
list($user, $dominio) = explode('@', $this->$attribute); list($user, $dominio) = explode('@', $this->$attribute);
if ( if (
...@@ -326,7 +326,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -326,7 +326,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
$this->addError($attribute,"O email deve ser do MDR (@mdr.gov.br)."); $this->addError($attribute,"O email deve ser do MDR (@mdr.gov.br).");
} }
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
...@@ -417,7 +417,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -417,7 +417,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
'dte_cadastro', 'dte_cadastro',
'dte_nascimento', 'dte_nascimento',
]; ];
return $arrFields; return $arrFields;
} }
...@@ -470,7 +470,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -470,7 +470,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
'cod_area', 'cod_area',
]; ];
} }
public function getSistemaOpcNivel() public function getSistemaOpcNivel()
{ {
return $this->hasOne( return $this->hasOne(
...@@ -478,7 +478,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -478,7 +478,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
['cod_nivel' => 'cod_nivel'] ['cod_nivel' => 'cod_nivel']
); );
} }
public function getDeleteColumn(){ public function getDeleteColumn(){
if ($this->bln_ativo) { if ($this->bln_ativo) {
$btn = " $btn = "
...@@ -598,36 +598,36 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -598,36 +598,36 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
{ {
return $this->hasMany(SistemaTabUsuarios::className(), ['cod_chefia' => 'cod_usuario']); return $this->hasMany(SistemaTabUsuarios::className(), ['cod_chefia' => 'cod_usuario']);
} }
public function getMonitoresChefia() { public function getMonitoresChefia() {
if (Yii::$app->user->identity) { if (Yii::$app->user->identity) {
return Yii::$app->db->createCommand(" return Yii::$app->db->createCommand("
WITH RECURSIVE nivelChefia(cod_usuario,username,nivel, chefe) AS ( WITH RECURSIVE nivelChefia(cod_usuario,username,nivel, chefe) AS (
-- Ancora -- Ancora
SELECT SELECT
tab_usuarios.cod_usuario, tab_usuarios.cod_usuario,
tab_usuarios.username, tab_usuarios.username,
1 AS \"nivel\", 1 AS \"nivel\",
NULL::text as chefe NULL::text as chefe
FROM sistema.tab_usuarios FROM sistema.tab_usuarios
WHERE true WHERE true
AND bln_ativo IS TRUE AND bln_ativo IS TRUE
AND username = '". Yii::$app->user->identity->username ."' AND username = '". Yii::$app->user->identity->username ."'
-- AND cod_chefia IS NULL -- AND cod_chefia IS NULL
UNION ALL UNION ALL
-- Parte RECURSIVA -- Parte RECURSIVA
SELECT DISTINCT SELECT DISTINCT
c.cod_usuario, c.cod_usuario,
c.username, c.username,
m.nivel + 1 AS \"nivel\", m.nivel + 1 AS \"nivel\",
m.username::text m.username::text
FROM sistema.tab_usuarios c FROM sistema.tab_usuarios c
INNER JOIN nivelChefia m ON m.cod_usuario = c.cod_chefia INNER JOIN nivelChefia m ON m.cod_usuario = c.cod_chefia
WHERE c.bln_ativo IS TRUE WHERE c.bln_ativo IS TRUE
) )
SELECT DISTINCT SELECT DISTINCT
cc.cod_usuario cc.cod_usuario
--,cc.nivel --,cc.nivel
--,cc.username --,cc.username
...@@ -640,7 +640,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -640,7 +640,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
} }
return []; return [];
} }
public static function getUser() { public static function getUser() {
$ret = null; $ret = null;
if (Yii::$app->user->identity) { if (Yii::$app->user->identity) {
...@@ -648,7 +648,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -648,7 +648,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
} }
return $ret; return $ret;
} }
public function getPreferencias () { public function getPreferencias () {
//return json_decode(json_encode(['a'=>'b']), true); //return json_decode(json_encode(['a'=>'b']), true);
$this->txt_preferencias = (is_array($this->txt_preferencias)) $this->txt_preferencias = (is_array($this->txt_preferencias))
...@@ -656,7 +656,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -656,7 +656,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
: json_decode($this->txt_preferencias, true); : json_decode($this->txt_preferencias, true);
return ($this->txt_preferencias) ? : []; return ($this->txt_preferencias) ? : [];
} }
public static function setPreferencia ($attr, $val) { public static function setPreferencia ($attr, $val) {
if ($objUser = self::getUser()) { if ($objUser = self::getUser()) {
$arrPref = $objUser->getPreferencias(); $arrPref = $objUser->getPreferencias();
...@@ -664,7 +664,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -664,7 +664,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
$objUser->txt_preferencias = json_encode($arrPref); $objUser->txt_preferencias = json_encode($arrPref);
//die_r($objUser->getDirtyAttributes()); //die_r($objUser->getDirtyAttributes());
return $objUser->save(false, ['txt_preferencias']); return $objUser->save(false, ['txt_preferencias']);
} }
// Salvamos também na sessão // Salvamos também na sessão
if (isset($_SESSION)) { if (isset($_SESSION)) {
$_SESSION[$attr] = $val; $_SESSION[$attr] = $val;
...@@ -680,7 +680,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -680,7 +680,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
$objUser->txt_preferencias = json_encode($arrPref); $objUser->txt_preferencias = json_encode($arrPref);
//die_r($objUser->getDirtyAttributes()); //die_r($objUser->getDirtyAttributes());
return $objUser->save(false, ['txt_preferencias']); return $objUser->save(false, ['txt_preferencias']);
} }
// Salvamos também na sessão // Salvamos também na sessão
if (isset($_SESSION)) { if (isset($_SESSION)) {
$_SESSION[$key][$attr] = $val; $_SESSION[$key][$attr] = $val;
...@@ -688,7 +688,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -688,7 +688,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
} }
return false; return false;
} }
public static function getPreferencia ($attr) { public static function getPreferencia ($attr) {
if ($objUser = self::getUser()) { if ($objUser = self::getUser()) {
$arrPref = $objUser->getPreferencias(); $arrPref = $objUser->getPreferencias();
...@@ -738,14 +738,14 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -738,14 +738,14 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
} }
return null; return null;
} }
public static function isAdmin() { public static function isAdmin() {
return ( return (
Yii::$app->user->identity && Yii::$app->user->identity &&
(Yii::$app->user->identity->cod_nivel == 9) (Yii::$app->user->identity->cod_nivel == 9)
); );
} }
/** /**
* @return \yii\db\ActiveQuery * @return \yii\db\ActiveQuery
*/ */
...@@ -761,7 +761,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -761,7 +761,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
{ {
return TabNotificacoes::find()->where(['monitor' => $this->txt_login_usuario, 'bln_lido'=>false])->all(); return TabNotificacoes::find()->where(['monitor' => $this->txt_login_usuario, 'bln_lido'=>false])->all();
} }
/** /**
* @return \yii\db\ActiveQuery * @return \yii\db\ActiveQuery
*/ */
...@@ -769,7 +769,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -769,7 +769,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
{ {
return $this->hasMany(TabMensagens::className(), ['cod_usuario' => 'cod_usuario', 'bln_lido'=>false]); return $this->hasMany(TabMensagens::className(), ['cod_usuario' => 'cod_usuario', 'bln_lido'=>false]);
} }
/** /**
* @return \yii\db\ActiveQuery * @return \yii\db\ActiveQuery
*/ */
...@@ -777,7 +777,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -777,7 +777,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
{ {
return TabMensagens::find()->where( ['cod_usuario' => $this->cod_usuario, 'bln_lido'=>false])->count(); return TabMensagens::find()->where( ['cod_usuario' => $this->cod_usuario, 'bln_lido'=>false])->count();
} }
/** /**
* @return \yii\db\ActiveQuery * @return \yii\db\ActiveQuery
*/ */
...@@ -824,7 +824,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -824,7 +824,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
public static function findIdentity($id) public static function findIdentity($id)
{ {
return static::findOne([ return static::findOne([
'cod_usuario' => $id, 'cod_usuario' => $id,
'bln_ativo' => true, 'bln_ativo' => true,
]); ]);
} }
...@@ -846,7 +846,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -846,7 +846,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
public static function findByUsername($username) public static function findByUsername($username)
{ {
return static::findOne([ return static::findOne([
'username' => $username, 'username' => $username,
'bln_ativo' => true, 'bln_ativo' => true,
]); ]);
} }
...@@ -879,13 +879,13 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -879,13 +879,13 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
if (empty($token)) { if (empty($token)) {
return false; return false;
} }
$expire = Yii::$app->params['user.passwordResetTokenExpire']; $expire = Yii::$app->params['user.passwordResetTokenExpire'];
$parts = explode('_', $token); $parts = explode('_', $token);
$timestamp = (int) end($parts); $timestamp = (int) end($parts);
return $timestamp + $expire >= time(); return $timestamp + $expire >= time();
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
...@@ -934,7 +934,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -934,7 +934,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
// SACI // SACI
$this->txt_senha_usuario = md5($password); $this->txt_senha_usuario = md5($password);
} }
/** /**
* Generates "remember me" authentication key * Generates "remember me" authentication key
*/ */
...@@ -974,9 +974,9 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -974,9 +974,9 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
return Yii::$app->mailer return Yii::$app->mailer
->compose( ->compose(
[ [
'html' => 'passwordResetToken-html', 'html' => 'passwordResetToken-html',
'text' => 'passwordResetToken-text' 'text' => 'passwordResetToken-text'
], ],
['user' => $user] ['user' => $user]
) )
->setFrom(Yii::$app->params['supportEmail']) ->setFrom(Yii::$app->params['supportEmail'])
...@@ -985,12 +985,12 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -985,12 +985,12 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
->send(); ->send();
} }
} }
return false; return false;
} }
//Envia email para a equipe de suporte: usuarios.saci@cidades.gov.br //Envia email para a equipe de suporte: usuarios.saci@cidades.gov.br
public function sendEmailSuporte($title,$msg){ public function sendEmailSuporte($title,$msg){
$emailSuporte = 'cgmi-suporte@cidades.gov.br'; $emailSuporte = 'cgmi-suporte@cidades.gov.br';
//$emailSuporte = 'josecarlos.fernandes@jointecnologia.com.br'; //$emailSuporte = 'josecarlos.fernandes@jointecnologia.com.br';
...@@ -1023,11 +1023,11 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -1023,11 +1023,11 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
$this->created_at = date('U'); $this->created_at = date('U');
$this->updated_at = date('U'); $this->updated_at = date('U');
$this->bln_ativo = 1; $this->bln_ativo = 1;
if ($this->validate()) { if ($this->validate()) {
$this->removePasswordResetToken(); $this->removePasswordResetToken();
$this->setPassword($this->password); $this->setPassword($this->password);
if ($this->save(false)) { if ($this->save(false)) {
$msg = '<h3>Novo usuário CADASTRADO</h3><br/>'. $msg = '<h3>Novo usuário CADASTRADO</h3><br/>'.
'<b>Nome: </b>'.$this->txt_nome. '<br/>'. '<b>Nome: </b>'.$this->txt_nome. '<br/>'.
...@@ -1045,7 +1045,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -1045,7 +1045,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
return $this->getErrors(); return $this->getErrors();
} }
} }
public function atualizar() public function atualizar()
{ {
// Valor padrao // Valor padrao
...@@ -1080,7 +1080,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -1080,7 +1080,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
return $dsc_name; return $dsc_name;
} }
public function getDscByCod($attr, $val) { public function getDscByCod($attr, $val) {
if (strpos($attr, 'bln_') !== false) { if (strpos($attr, 'bln_') !== false) {
$val = ($val)? 'Sim' : 'Não'; $val = ($val)? 'Sim' : 'Não';
} else { } else {
...@@ -1106,7 +1106,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -1106,7 +1106,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
$attr= 'cod_usuario'; $attr= 'cod_usuario';
$all = SistemaTabUsuarios::find() $all = SistemaTabUsuarios::find()
->where([ ->where([
'cod_nivel' => [4,5], 'cod_nivel' => [4,5],
'bln_ativo' => true, 'bln_ativo' => true,
]); ]);
break; break;
...@@ -1119,19 +1119,19 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -1119,19 +1119,19 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
return $all; return $all;
} }
public function generateSelectFilters(){ public function generateSelectFilters(){
$selectFilters = '<select id="select-filters"> $selectFilters = '<select id="select-filters">
<option value="">Escolha um filtro...</option>'; <option value="">Escolha um filtro...</option>';
$arrSelect = SistemaTabUsuarios::getPreferencia("savedFilters"); $arrSelect = SistemaTabUsuarios::getPreferencia("savedFilters");
if (isset($arrSelect)){ if (isset($arrSelect)){
foreach ($arrSelect as $key => $arr){ foreach ($arrSelect as $key => $arr){
$selectFilters.= "<option value='$key'>{$arr['name']}</option>"; $selectFilters.= "<option value='$key'>{$arr['name']}</option>";
} }
} }
$selectFilters.= '</select>'; $selectFilters.= '</select>';
return $selectFilters; return $selectFilters;
} }
public function returnFilterSearchStr($filterName){ public function returnFilterSearchStr($filterName){
...@@ -1145,7 +1145,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -1145,7 +1145,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
'dte_cadastro' 'dte_cadastro'
]; ];
} }
public function getSpecificPageSummary($col){ public function getSpecificPageSummary($col){
switch ($col){ switch ($col){
case 'monitoraContratos': case 'monitoraContratos':
...@@ -1158,7 +1158,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf ...@@ -1158,7 +1158,7 @@ class SistemaTabUsuarios extends \yii\db\ActiveRecord implements IdentityInterf
break; break;
} }
} }
public function getSpecificArrColumns(){ public function getSpecificArrColumns(){
return [ return [
'specific' => [ 'specific' => [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment