diff --git a/www/protected/migrations/m120905_184758_tbl_usuarios.php b/www/protected/migrations/m120905_184758_tbl_usuarios.php index 8a02612..1f92ce1 100644 --- a/www/protected/migrations/m120905_184758_tbl_usuarios.php +++ b/www/protected/migrations/m120905_184758_tbl_usuarios.php @@ -9,15 +9,15 @@ class m120905_184758_tbl_usuarios extends CDbMigration 'id_empresa' => 'integer', 'estado' => 'decimal(1,0)', 'clave_seguridad' => 'string', - 'email' => 'string', + 'email' => 'string NOT NULL', 'nombre' => 'string', 'apellidos' => 'string', 'password' => 'string NOT NULL', 'tipo' => 'string NOT NULL', 'titulo' => 'string', - 'descripcion' => 'text', 'localidad' => 'string', 'telefono' => 'string', + 'descripcion' => 'text', 'last_login_time' => 'datetime', )); diff --git a/www/protected/models/Empresa.php b/www/protected/models/Empresa.php index d03be4f..886fbe7 100644 --- a/www/protected/models/Empresa.php +++ b/www/protected/models/Empresa.php @@ -47,8 +47,7 @@ class Empresa extends CActiveRecord { array('pagina_web', 'url'), array('email', 'email'), array('descripcion', 'safe'), - // The following rule is used by search(). - // Please remove those attributes that should not be searched. + array('id, cif, nombre, email, pagina_web, empleados, direccion, descripcion', 'safe', 'on' => 'search'), ); } @@ -70,13 +69,13 @@ class Empresa extends CActiveRecord { public function attributeLabels() { return array( 'id' => 'ID', - 'cif' => 'Cif', + 'cif' => 'CIF', 'nombre' => 'Nombre', 'email2' => 'Email', - 'pagina_web' => 'Pagina Web', - 'empleados' => 'Empleados', - 'direccion' => 'Direccion', - 'descripcion' => 'Descripcion', + 'pagina_web' => 'Página web', + 'empleados' => 'Nº de empleados', + 'direccion' => 'Dirección', + 'descripcion' => 'Descripción', ); } @@ -90,15 +89,15 @@ class Empresa extends CActiveRecord { $criteria = new CDbCriteria; - $criteria->compare('t.id', $this->id); - $criteria->compare('t.cif', $this->cif, true); - $criteria->compare('t.nombre', $this->nombre, true); - $criteria->compare('t.email', $this->email, true); - $criteria->compare('t.pagina_web', $this->pagina_web, true); - $criteria->compare('t.empleados', $this->empleados); - $criteria->compare('t.direccion', $this->direccion, true); - $criteria->compare('t.descripcion', $this->descripcion, true); - + $criteria->compare('id',$this->id); + $criteria->compare('cif',$this->cif,true); + $criteria->compare('nombre',$this->nombre,true); + $criteria->compare('email',$this->email,true); + $criteria->compare('pagina_web',$this->pagina_web,true); + $criteria->compare('empleados',$this->empleados); + $criteria->compare('direccion',$this->direccion,true); + $criteria->compare('descripcion',$this->descripcion,true); + return new CActiveDataProvider($this, array( 'criteria' => $criteria, )); diff --git a/www/protected/models/Usuario.php b/www/protected/models/Usuario.php index 422be4b..6a1961e 100644 --- a/www/protected/models/Usuario.php +++ b/www/protected/models/Usuario.php @@ -13,11 +13,11 @@ * @property string $password * @property string $tipo * @property string $titulo - * @property text $descripcion * @property string $localidad * @property string $telefono * @property string $last_login_time * @property string $clave_seguridad + * @property string $descripcion * * The followings are the available model relations: * @property Empresa $empresa @@ -54,21 +54,22 @@ class Usuario extends CActiveRecord { /** * @return array validation rules for model attributes. */ - public function rules() { + public function rules() + { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array( - array('email, nombre, apellidos, titulo, localidad, telefono', 'length', 'max' => 255), - array('email', 'required'), + array('email, password, tipo', 'required'), + array('estado', 'length', 'max'=>1), array('email', 'email'), array('email', 'unique'), + array('descripcion', 'safe'), + array('email, nombre, apellidos, password, tipo, titulo, localidad, telefono', 'length', 'max'=>255), - array('password', 'required', 'on' => 'insert'), - - array('id, id_empresa, email, nombre, apellidos, titulo, localidad, telefono', 'safe', 'on' => 'search'), + array('id, id_empresa, estado, email, nombre, apellidos, tipo, titulo, localidad, telefono, descripcion', 'safe', 'on'=>'search'), ); - } - + } + /** * @return array relational rules. */ @@ -86,61 +87,45 @@ class Usuario extends CActiveRecord { public function attributeLabels() { return array( 'id' => 'ID', - 'email' => 'Email', 'estado' => 'Estado', - 'password' => 'Contraseña', - 'password_repeat' => 'Confirmar contraseña', - 'last_login_time' => 'Último acceso', + 'email' => 'Email', 'nombre' => 'Nombre', 'apellidos' => 'Apellidos', - 'titulo' => 'Titulo', + 'password' => 'Password', + 'tipo' => 'Tipo', + 'titulo' => 'Título', 'localidad' => 'Localidad', 'telefono' => 'Teléfono', 'descripcion' => 'Descripción', - ); - } - - public function scopes() { - return array( - 'activo' => array( - 'condition' => 'estado=' . self::ESTADO_ACTIVO - ), - 'noactivo' => array( - 'condition' => 'estado=' . self::ESTADO_NOACTIVO - ), - 'denegado' => array( - 'condition' => 'estado=' . self::ESTADO_DENEGADO - ) - ); + ); } /** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. */ - public function search() { - // Warning: Please modify the following code to remove attributes that - // should not be searched. + public function search() + { + $criteria=new CDbCriteria; - $criteria = new CDbCriteria; - //$criteria->with = array('empresa'); - //$criteria->together = true; - - $criteria->compare('t.email', $this->email, true); - $criteria->compare('t.id_empresa', $this->id_empresa, true); - $criteria->compare('t.nombre', $this->nombre, true); - $criteria->compare('t.apellidos', $this->apellidos, true); - $criteria->compare('t.last_login_time', $this->last_login_time, true); - - $sort = new CSort; - $sort->defaultOrder = 't.apellidos, t.nombre ASC'; + $criteria->compare('id',$this->id); + $criteria->compare('id_empresa',$this->id_empresa); + $criteria->compare('estado',$this->estado,true); + $criteria->compare('email',$this->email,true); + $criteria->compare('nombre',$this->nombre,true); + $criteria->compare('apellidos',$this->apellidos,true); + $criteria->compare('tipo',$this->tipo,true); + $criteria->compare('titulo',$this->titulo,true); + $criteria->compare('localidad',$this->localidad,true); + $criteria->compare('telefono',$this->telefono,true); + $criteria->compare('last_login_time',$this->last_login_time,true); + $criteria->compare('descripcion',$this->descripcion,true); return new CActiveDataProvider($this, array( - 'criteria' => $criteria, - 'sort' => $sort, - )); + 'criteria'=>$criteria, + )); } - + public function encrypt($value) { return md5($value); } diff --git a/www/themes/profind/views/usuario/_form.php b/www/themes/profind/views/usuario/_form.php index b63f801..b7bd4b3 100644 --- a/www/themes/profind/views/usuario/_form.php +++ b/www/themes/profind/views/usuario/_form.php @@ -1,6 +1,6 @@