Esempio n. 1
0
 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aEmpresa !== null) {
             if (!$this->aEmpresa->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aEmpresa->getValidationFailures());
             }
         }
         if ($this->aTabla !== null) {
             if (!$this->aTabla->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aTabla->getValidationFailures());
             }
         }
         if ($this->aUsuario !== null) {
             if (!$this->aUsuario->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aUsuario->getValidationFailures());
             }
         }
         if (($retval = AlcancePeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
Esempio n. 2
0
 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUsuario !== null) {
             if (!$this->aUsuario->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aUsuario->getValidationFailures());
             }
         }
         if ($this->aGenero !== null) {
             if (!$this->aGenero->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aGenero->getValidationFailures());
             }
         }
         if (($retval = ListaPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         if ($this->collLista_audiolibros !== null) {
             foreach ($this->collLista_audiolibros as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
 public function store()
 {
     $post = Input::all();
     if (Usuario::find($post['ni'])) {
         $model = Usuario::find($post['ni']);
     } else {
         $model = new Usuario();
     }
     if (isset($post['senha']) && $post['senha'] !== '') {
         $senha = md5($post['senha']);
     } else {
         $senha = md5(123);
     }
     $validator = $model->validate(Input::all());
     if (!$validator) {
         return Redirect::to('usuario/create')->withInput($post)->withErrors($model->errors);
     } else {
         $model->ni = $post['ni'];
         $model->nome = $post['nome'];
         $model->senha = $senha;
         $model->acesso = $post['acesso'];
         $id = $model->ni;
         if ($model->save()) {
             Session::flash('success', 'Usuário cadastrado com sucesso!');
             return Redirect::to('/usuario/' . $id);
         }
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Propietario();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Propietario'])) {
         $model->attributes = $_POST['Propietario'];
         $usuario = new Usuario();
         $model->rut = Tools::removeDots($model->rut);
         $usuario->user = $model->rut;
         $arr = explode("-", $model->rut);
         $usuario->clave = CPasswordHelper::hashPassword($arr[0]);
         $usuario->rol = "propietario";
         $usuario->nombre = $_POST['Propietario']['nombre'];
         $usuario->email = $_POST['Propietario']['email'];
         $usuario->apellido = $_POST['Propietario']['apellido'];
         $model->usuario_id = 1;
         if ($model->validate()) {
             if ($usuario->validate()) {
                 if ($usuario->save()) {
                     $model->usuario_id = $usuario->id;
                     if ($model->save()) {
                         $auth = Yii::app()->authManager;
                         Authassignment::model()->deleteAllByAttributes(array('userid' => $usuario->id));
                         $auth->revoke($usuario->rol, $model->usuario_id);
                         $auth->assign($usuario->rol, $model->usuario_id);
                         $this->redirect(array('view', 'id' => $model->id));
                     }
                 }
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aTabla !== null) {
             if (!$this->aTabla->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aTabla->getValidationFailures());
             }
         }
         if ($this->aUsuarioRelatedByIdUsuario !== null) {
             if (!$this->aUsuarioRelatedByIdUsuario->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aUsuarioRelatedByIdUsuario->getValidationFailures());
             }
         }
         if ($this->aUsuarioRelatedByIdUsuarioCreador !== null) {
             if (!$this->aUsuarioRelatedByIdUsuarioCreador->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aUsuarioRelatedByIdUsuarioCreador->getValidationFailures());
             }
         }
         if (($retval = FormularioPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         if ($this->collItems !== null) {
             foreach ($this->collItems as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collNotificacioness !== null) {
             foreach ($this->collNotificacioness as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collTareas !== null) {
             foreach ($this->collTareas as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
Esempio n. 6
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Usuario();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Usuario'])) {
         $model->attributes = $_POST['Usuario'];
         $model->clave = CPasswordHelper::hashPassword($model->clave);
         if ($model->validate()) {
             if ($model->save()) {
                 $auth = Yii::app()->authManager;
                 $auth->assign($model->rol, $model->id);
                 $this->redirect(array('view', 'id' => $model->id));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
Esempio n. 7
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Usuario();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Usuario'])) {
         $model->attributes = $_POST['Usuario'];
         if ($model->validate()) {
             $model->contrasena = md5($model->contrasena);
             $model->fecha_creacion = date('Y-m-d H:i:s');
             $model->fecha_modificacion = date('Y-m-d H:i:s');
             $model->activo = 1;
             if ($model->save()) {
                 $this->redirect(array('view', 'id' => $model->id));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Cliente();
     $modelUsuario = new Usuario();
     $this->tituloManual = "Cadastrar cliente";
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['Cliente'])) {
         $model->attributes = $_POST['Cliente'];
         $modelUsuario->attributes = $_POST['Usuario'];
         if ($modelUsuario->validate() && $model->validate()) {
             if ($model->save()) {
                 $modelUsuario->cliente_id = $model->id;
                 if ($modelUsuario->save()) {
                     $this->redirect(array('index'));
                 }
             }
         }
     }
     $this->render('create', array('model' => $model, 'modelUsuario' => $modelUsuario));
 }
 public function actionAjaxSave()
 {
     if (Yii::app()->request->isAjaxRequest) {
         $model = new Cliente();
         $model->attributes = $_POST['Cliente'];
         $modelUsuario = new Usuario();
         $modelUsuario->attributes = $_POST['Usuario'];
         $modelUsuario->tipo_cliente = 0;
         if ($modelUsuario->validate() && $model->validate()) {
             if ($model->save()) {
                 $modelUsuario->cliente_id = $model->id;
                 if ($modelUsuario->save()) {
                     Yii::app()->session['id-cliente'] = $model->id;
                     echo true;
                 }
             }
         } else {
             echo false;
         }
         Yii::app()->end();
     } else {
         throw new CHttpException(400);
     }
 }
Esempio n. 10
0
 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aProvincia !== null) {
             if (!$this->aProvincia->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aProvincia->getValidationFailures());
             }
         }
         if ($this->aUsuario !== null) {
             if (!$this->aUsuario->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aUsuario->getValidationFailures());
             }
         }
         if ($this->aTaula1 !== null) {
             if (!$this->aTaula1->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aTaula1->getValidationFailures());
             }
         }
         if (($retval = EmpresaPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         if ($this->collAlcances !== null) {
             foreach ($this->collAlcances as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collTablas !== null) {
             foreach ($this->collTablas as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collCampos !== null) {
             foreach ($this->collCampos as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collTareas !== null) {
             foreach ($this->collTareas as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collDocumentos !== null) {
             foreach ($this->collDocumentos as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collHistoricoDocumentos !== null) {
             foreach ($this->collHistoricoDocumentos as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collEncargados !== null) {
             foreach ($this->collEncargados as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
Esempio n. 11
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     // Capiturar todos os campos
     $input = Input::all();
     // informar o id para o metodo unique
     $input['id'] = $id;
     // Busca validação no model
     $validator = Usuario::validate($input);
     // trata os erros
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator)->with('error', Util::message('MSG004'));
     } else {
         $this->usuario->find($id)->update($input);
         return Redirect::to('usuario')->with('success', Util::message('MSG005'));
     }
 }
Esempio n. 12
0
 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUsuarioRelatedByUsuario_ult_acc !== null) {
             if (!$this->aUsuarioRelatedByUsuario_ult_acc->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aUsuarioRelatedByUsuario_ult_acc->getValidationFailures());
             }
         }
         if ($this->aPrivacidad !== null) {
             if (!$this->aPrivacidad->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aPrivacidad->getValidationFailures());
             }
         }
         if ($this->aGenero !== null) {
             if (!$this->aGenero->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aGenero->getValidationFailures());
             }
         }
         if ($this->aUsuarioRelatedById_usuario !== null) {
             if (!$this->aUsuarioRelatedById_usuario->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aUsuarioRelatedById_usuario->getValidationFailures());
             }
         }
         if (($retval = LibroPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         if ($this->collAudiolibros !== null) {
             foreach ($this->collAudiolibros as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collCalificacions !== null) {
             foreach ($this->collCalificacions as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collComentarios !== null) {
             foreach ($this->collComentarios as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collLibro_colaboradors !== null) {
             foreach ($this->collLibro_colaboradors as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collLibro_versions !== null) {
             foreach ($this->collLibro_versions as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collSolicituds !== null) {
             foreach ($this->collSolicituds as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collSlider_maes !== null) {
             foreach ($this->collSlider_maes as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collPostulantess !== null) {
             foreach ($this->collPostulantess as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collClasificadoss !== null) {
             foreach ($this->collClasificadoss as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
Esempio n. 13
0
 public function actionCreate()
 {
     $model = new Usuario();
     $tecnico = new UsuarioTecnico();
     if (isset($_POST['Usuario'])) {
         $model->attributes = $_POST['Usuario'];
         if (Usuario::model()->findByPk(Yii::app()->user->id)->tipoUsuario->nombre != 'super_admin') {
             $model->empresa_id = Usuario::model()->findByPk(Yii::app()->user->id)->empresa_id;
         }
         if (isset($_POST['UsuarioTecnico'])) {
             $tecnico->attributes = $_POST['UsuarioTecnico'];
             $uploadedFile = CUploadedFile::getInstance($tecnico, 'contrato_adjunto');
             if (isset($uploadedFile->name)) {
                 $fileName = "{$uploadedFile}";
                 // random number + file name
                 $fileName = str_replace(" ", "_", $fileName);
                 if (file_exists(Yii::app()->basePath . '/../images/usuarios/contratos/' . $fileName)) {
                     $ran = rand(100, 999);
                     $fileName = $ran . '_' . $fileName;
                     $tecnico->contrato_adjunto = $fileName;
                 } else {
                     $tecnico->contrato_adjunto = $fileName;
                 }
             }
             $valid = $model->validate();
             $valid = $tecnico->validate() && $valid;
             if ($valid) {
                 //w$model->password = $this->hashPass2($model->password);
                 $model->password = $model->password;
                 $model->activo = 1;
                 if ($model->save()) {
                     $tecnico->usuario_id = $model->id;
                     $tecnico->insert();
                     if (!empty($tecnico->contrato_adjunto)) {
                         $uploadedFile->saveAs(Yii::app()->basePath . '/../images/usuarios/contratos/' . $fileName);
                     }
                     if ($model->tipoUsuario->nombre == 'tecnico' || $model->tipoUsuario->nombre == 'reemplazo') {
                         $titulo = 'Registro - Usuario';
                         $cabeceras = 'MIME-Version: 1.0' . "\r\n";
                         $cabeceras .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
                         $cabeceras .= 'From: SmartCage <*****@*****.**>' . "\r\n";
                         $mensaje = $this->render('emailregistro', array('usuario' => $model->usuario, 'password' => $model->password));
                         mail($model->email, $titulo, $mensaje, $cabeceras);
                     }
                     $this->redirect(array('usuario/admin'));
                 }
             }
         } else {
             if ($model->validate()) {
                 // $model->password = $this->hashPass2($model->password);
                 $model->password = $model->password;
                 $model->activo = 1;
                 if ($model->save()) {
                     $titulo = 'Registro - Usuario';
                     $cabeceras = 'MIME-Version: 1.0' . "\r\n";
                     $cabeceras .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
                     $cabeceras .= 'From: SmartCage <*****@*****.**>' . "\r\n";
                     $mensaje = $this->renderPartial('emailregistro', array('usuario' => $model->usuario, 'password' => $model->password), true);
                     mail($model->email, $titulo, $mensaje, $cabeceras);
                     $this->redirect(array('usuario/admin'));
                 }
             }
         }
     }
     $this->render('create', array('model' => $model, 'tecnico' => $tecnico));
 }
Esempio n. 14
0
 public function actionRegistro()
 {
     $usuario = new Usuario();
     if (isset($_POST['Usuario'])) {
         $usuario->attributes = $_POST['Usuario'];
         $usuario->creado = date('Y-m-d H:i:s', time());
         if ($usuario->validate()) {
             if ($usuario->save()) {
                 $this->redirect(array('admin'));
             }
         }
     }
     $this->render('registro', array('usuario' => $usuario));
 }
Esempio n. 15
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Cliente();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Cliente'])) {
         $model->attributes = $_POST['Cliente'];
         $model->direccion_alternativa = $_POST['Cliente']['direccion_alternativa'];
         $usuario = new Usuario();
         $model->rut = Tools::removeDots($model->rut);
         $usuario->user = $model->rut;
         $arr = explode("-", $model->rut);
         $usuario->clave = CPasswordHelper::hashPassword($arr[0]);
         $usuario->rol = "cliente";
         $usuario->nombre = $_POST['Cliente']['nombre'];
         $usuario->email = $_POST['Cliente']['email'];
         $usuario->apellido = $_POST['Cliente']['apellido'];
         $model->usuario_id = 1;
         if ($model->validate()) {
             if ($usuario->validate()) {
                 if ($usuario->save()) {
                     $model->usuario_id = $usuario->id;
                     if ($model->save()) {
                         $ok = false;
                         $auth = Yii::app()->authManager;
                         Authassignment::model()->deleteAllByAttributes(array('userid' => $usuario->id));
                         $auth->revoke($usuario->rol, $model->usuario_id);
                         $auth->assign($usuario->rol, $model->usuario_id);
                         $fiador = new Fiador();
                         if (isset($_POST['Cliente']['fiador_rut'])) {
                             if (isset($_POST['Cliente']['fiador_rut'])) {
                                 $fiador->rut = $_POST['Cliente']['fiador_rut'];
                                 $fiador->rut = Tools::removeDots($fiador->rut);
                                 $fiador->nombre = $_POST['Cliente']['fiador_nombre'];
                                 $fiador->apellido = $_POST['Cliente']['fiador_apellido'];
                                 $fiador->email = $_POST['Cliente']['fiador_email'];
                                 $fiador->telefono = $_POST['Cliente']['fiador_telefono'];
                                 $fiador->direccion = $_POST['Cliente']['fiador_direccion'];
                                 if ($fiador->validate()) {
                                     if ($fiador->save()) {
                                         $ok = true;
                                     }
                                 } else {
                                     echo "<br>";
                                     echo CHtml::errorSummary($fiador);
                                 }
                             }
                         }
                         if ($ok) {
                             $cliente_fiador = new ClienteFiador();
                             $cliente_fiador->cliente_id = $model->id;
                             $cliente_fiador->fiador_id = $fiador->id;
                             $cliente_fiador->save();
                         }
                         $this->redirect(array('view', 'id' => $model->id));
                     }
                 }
             } else {
                 echo "<br>";
                 echo CHtml::errorSummary($usuario);
             }
         } else {
             echo "<br>";
             echo CHtml::errorSummary($model);
         }
     }
     $this->render('create', array('model' => $model));
 }