/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $this->layout = 'main'; $model = new UsuarioEstudiante(); $modelTipoCarrera = new TipoCarrera(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['NombreEstudiante'], $_POST['email'], $_POST['NumeroDeCuenta'])) { if (UsuarioEstudiante::model()->VerificarDuplicidadUsuario($_POST['username']) == "") { $model->Nombre = strtoupper($_POST['NombreEstudiante']); $model->PrimerApellido = strtoupper($_POST['PrimerApellido']); $model->SegundoApellido = strtoupper($_POST['SegundoApellido']); $model->Email = strtolower($_POST['email']); $model->Contrasena = $_POST['password']; $model->Usuario = strtolower($_POST['username']); $model->NumeroDeCuenta = $_POST['NumeroDeCuenta']; if (Yii::app()->user->isGuest) { $model->CreadoPor = "Invitado"; $model->ModificadoPor = "Invitado"; } if (!Yii::app()->user->isGuest) { // usted ha creado un usuario , se ha enviado un correo //electronico a la persona de quien se ha creado el usuario $model->CreadoPor = Yii::app()->user->name; $model->ModificadoPor = Yii::app()->user->name; } $model->Activo = 0; $model->FechaCreacion = date('Y-m-d H:i:s'); $model->FechaModificacion = date('Y-m-d H:i:s'); $model->Rol_IdRol = 2; $model->Carrera_IdCarrera = $_POST['FiltroCarrerasPorTipo']; if ($model->save()) { Yii::app()->user->setFlash("success", "<strong>Excelente!</strong> Su USUARIO ha sido creado exitosamente. Inicie sesion para ver su perfil"); $this->redirect(array('site/loginEstudiante')); } } else { Yii::app()->user->setFlash("warning", "<strong>Ummmm...</strong> El NOMBRE DE USUARIO O NÚMERO DE CUENTA se encuentra asociado con una cuenta existente"); } } $this->render('create', array('model' => $model, 'modelTipoCarrera' => $modelTipoCarrera)); }