public function actionCrearUel() { $model = new EntesOrganos('crearuel'); // uncomment the following code to enable ajax-based validation /* if(isset($_POST['ajax']) && $_POST['ajax']==='entes-organos-crearente-form') { echo CActiveForm::validate($model); Yii::app()->end(); } */ if (isset($_POST['EntesOrganos'])) { $model->attributes = $_POST['EntesOrganos']; $model->creado_por = 'snc'; $model->tipo = 'U'; $model->compra = true; if ($model->save()) { $entesAscritos = new EntesAdscritos(); $usuario = Usuarios::model()->findByPk(Yii::app()->user->getId()); $entesAscritos->padre_id = $usuario->ente_organo_id; $entesAscritos->ente_organo_id = $model->ente_organo_id; $entesAscritos->fecha_desde = date("Y-m-d"); $entesAscritos->fecha_hasta = "2199-12-31"; $entesAscritos->save(); /*$crea_usuario = new Usuarios('crearente'); $crea_usuario->correo = $model->correo; $crea_usuario->contrasena = md5("1236aA"); $crea_usuario->usuario = $model->correo; $crea_usuario->creado_el = date("Y-m-d"); $crea_usuario->actualizado_el = date("Y-m-d"); $crea_usuario->rol = 'normal'; $crea_usuario->ente_organo_id = $usuario->ente_organo_id; $crea_usuario->save();*/ Yii::app()->user->setFlash('success', "Unidad Ejecutora Local creada con éxito!"); Yii::app()->user->setFlash('notice', "Recordando que debe crear usuario a dicha Unidad Ejecutora Local."); // $this->redirect(array('view','id'=>$model->producto_id)); $model = new EntesOrganos('crearuel'); $this->render('crearuel', array('model' => $model)); // form inputs are valid, do something here return; } var_dump($model->getErrors()); die; } $this->render('crearuel', array('model' => $model)); }
<?php echo $form->textFieldGroup($model,'contrasena',array('widgetOptions'=>array('htmlOptions'=>array('class'=>'span5','maxlength'=>50)))); ?> <?php echo $form->textFieldGroup($model,'repetir_contrasena',array('widgetOptions'=>array('htmlOptions'=>array('class'=>'span5','maxlength'=>50)))); ?> <?php echo $form->textFieldGroup($model,'correo',array('widgetOptions'=>array('htmlOptions'=>array('class'=>'span5','maxlength'=>255)))); ?> <?php echo $form->dropDownListGroup( $model, 'ente_organo_id', array( 'wrapperHtmlOptions' => array( 'class' => 'col-sm-5', ), 'label'=>'Selecciona organo u ente', 'widgetOptions' => array( 'data' => CHtml::listData(EntesOrganos::model()->findAllByAttributes(array('tipo'=>'O')), 'ente_organo_id', function($ente){ return CHtml::encode(($ente->tipo=='O'? 'Organo' :'Ente') .' - '.$ente->nombre);}), //'options'=>array($model->proyecto_id => array('selected'=>true)), 'htmlOptions' => array('id'=>'ente','prompt' => 'Seleccionar ente', ), ), 'hint' => 'Ente u Organo asociado a el usuario.' ) ); //echo $form->dropDownList($model,'ente_organo_id',array('widgetOptions'=>array('htmlOptions'=>array('class'=>'span5','maxlength'=>255)))); ?> <?php /*echo $form->textFieldGroup($model,'creado_el',array('widgetOptions'=>array('htmlOptions'=>array('class'=>'span5')))); ?> <?php echo $form->textFieldGroup($model,'actualizado_el',array('widgetOptions'=>array('htmlOptions'=>array('class'=>'span5')))); ?> <?php echo $form->checkBoxGroup($model,'esta_activo'); ?> <?php echo $form->checkBoxGroup($model,'esta_deshabilitado'); ?>
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = EntesOrganos::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }