/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); if (isset($_POST['Usuario'])) { $model->attributes = $_POST['Usuario']; $model->password = $model->hashPassword($model->password, $model->salt); if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $model->password = NULL; $roles = Rol::model()->findAll(array('condition' => 'id<>1')); $dps = Dependencia::model()->findAll(array('condition' => 'sede_id=1')); $this->render('update', array('model' => $model, 'roles' => $roles, 'dps' => $dps)); }
/** * 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. */ public function loadModel() { if ($this->_model === null) { if (isset($_GET['id'])) { $this->_model = Rol::model()->findbyPk($_GET['id']); } if ($this->_model === null) { throw new CHttpException(404, Yii::t('App', 'The requested page does not exist.')); } } return $this->_model; }
<div class="container"> <?php if ($this->panel) { ?> <div class="span-4"> <?php if (!Yii::app()->user->isGuest) { ?> <div class="mainmenu"> <?php $rol = Rol::model()->findByPk(Yii::app()->user->rol); $modulos = explode(',', $rol->modulos); ?> <?php $this->widget('zii.widgets.CMenu', array('id' => 'qm0', 'htmlOptions' => array('class' => 'qmmc'), 'items' => array(array('label' => Yii::t('App', 'Groups'), 'url' => array('/grupo/admin'), 'visible' => in_array('grupo', $modulos), 'items' => array(array('label' => Yii::t('App', 'Create'), 'url' => array('/grupo/create')), array('label' => Yii::t('App', 'Manage'), 'url' => array('/grupo/admin')))), array('label' => Yii::t('App', 'Contacts'), 'url' => array('/contacto/admin'), 'visible' => in_array('contacto', $modulos), 'items' => array(array('label' => Yii::t('App', 'Import CSV'), 'url' => array('/importcsv/default/index')), array('label' => Yii::t('App', 'Create'), 'url' => array('/contacto/create')), array('label' => Yii::t('App', 'Manage'), 'url' => array('/contacto/admin')))), array('label' => 'Enviar SMS', 'url' => array('/envio/admin'), 'visible' => in_array('envio', $modulos), 'items' => array(array('label' => Yii::t('App', 'Envio Instantaneo'), 'url' => array('/envio/create/?type=1')), array('label' => Yii::t('App', 'Envio Programado'), 'url' => array('/envio/create/?type=2')), array('label' => Yii::t('App', 'Conversaciones'), 'url' => array('/conversacion/admin')))), array('label' => 'Keywords', 'url' => array('/infosms/admin'), 'visible' => in_array('keywords', $modulos), 'items' => array(array('label' => Yii::t('App', 'Encuestas'), 'url' => array('/encuesta/admin')), array('label' => Yii::t('App', 'InfoSMS'), 'url' => array('/infosms/admin/')), array('label' => Yii::t('App', 'Variables'), 'url' => array('/varkeywords/admin/')))), array('label' => Yii::t('App', 'Administracion'), 'url' => array('#'), 'visible' => in_array('administracion', $modulos), 'items' => array(array('label' => Yii::t('App', 'Estados'), 'url' => array('/estado/admin'), 'visible' => Yii::app()->user->nivel == 1), array('label' => Yii::t('App', 'Niveles de Usuario'), 'url' => array('/nivel/admin'), 'visible' => Yii::app()->user->nivel == 1), array('label' => Yii::t('App', 'Roles'), 'url' => array('/rol/admin')), array('label' => Yii::t('App', 'Usuarios'), 'url' => array('/usuario/admin')), array('label' => Yii::t('App', 'Variables'), 'url' => array('/variable/admin')))), array('label' => Yii::t('App', 'Report'), 'url' => array('/enviosInstantaneos/admin'), 'visible' => in_array('reportes', $modulos), 'items' => array(array('label' => Yii::t('App', 'Historico de Envios'), 'url' => array('/enviosInstantaneos/admin')), array('label' => Yii::t('App', 'Envio por Operador'), 'url' => array('/EnviosOperadora/admin'), 'visible' => Yii::app()->user->nivel < 3), array('label' => Yii::t('App', 'Conversaciones'), 'url' => array('/conversaciones/admin')), array('label' => Yii::t('App', 'Keywords'), 'url' => array('/enviosKeywords/admin')), array('label' => Yii::t('App', 'Notificaciones'), 'url' => array('/envioNotificacion/admin')))), array('label' => Yii::t('App', 'Contact us'), 'url' => array('/site/contact'), 'visible' => !Yii::app()->user->isGuest)))); } ?> </div> <!-- mainmenu --> </div>
/** * Get the recent forms from rol. * @param type $id_rol * @return array */ public function getRecentForms($id_rol) { return Rol::model()->getRecentForms($id_rol); }
/** * 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 $id the ID of the model to be loaded * @return Rol the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Rol::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
</div> <div class="row"> <?php echo $form->labelEx($model, 'id_rol'); ?> <?php //echo $form->textField($model,'id_rol'); ?> <?php //echo $form->error($model,'id_rol'); ?> <?php echo $form->dropDownList($model, 'id_rol', CHtml::listData(Rol::model()->findAll(), 'id_rol', 'nombre_rol')); ?> </div> <fieldset> <legend>RIF:</legend> <div class="row"> <?php echo $form->labelEx($model, 'letra_id'); ?> <?php echo $form->textField($model, 'letra_id', array('size' => 1, 'maxlength' => 1)); ?> <?php echo $form->error($model, 'letra_id'); ?> </div>
?> </div> <?php } ?> <?php if (Yii::app()->user->hasFlash('notice')) { ?> <div class="flash-notice"> <?php echo Yii::app()->user->getFlash('notice'); ?> </div> <?php } ?> <?php if (Yii::app()->user->hasFlash('error')) { ?> <div class="flash-error"> <?php echo Yii::app()->user->getFlash('error'); ?> </div> <?php } ?> </div> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'usuario-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('class' => 'CCheckBoxColumn'), array('name' => 'id', 'value' => $data->id, 'htmlOptions' => array('style' => 'width:50px')), array('name' => 'nombre', 'value' => $data->nombre, 'htmlOptions' => array('style' => 'width:90px')), array('name' => 'apellido', 'value' => $data->apellido, 'htmlOptions' => array('style' => 'width:100px')), array('name' => 'username', 'value' => '$data->username', 'htmlOptions' => array('style' => 'width:80px;text-align:center;')), array('name' => 'rolid', 'value' => '$data->rol->rol', 'filter' => CHtml::listData(Rol::model()->findAll(), 'id', 'rol')), array('name' => 'activo', 'value' => '$data->activo?Yii::t("App","Yes"):Yii::t("App","No")', 'filter' => array('0' => Yii::t("App", "No"), '1' => Yii::t("App", "Yes")), 'htmlOptions' => array('style' => 'text-align:center;')), array('type' => 'raw', 'value' => 'CHtml::link("Enviar Clave","#", array("submit"=>array(\'/usuario/sendkeybyemail\', \'id\'=>$data->id),"class"=>"viewsms"))', 'visible' => Yii::app()->user->nivel == 1, 'htmlOptions' => array('style' => 'width:65px;text-align:center;')), array('class' => 'CButtonColumn', 'template' => '{update} {delete}'))));
<div class="row"> <?php echo $form->label($model, 'email'); ?> <?php echo $form->textField($model, 'email', array('size' => 60, 'maxlength' => 60)); ?> </div> <div class="row"> <?php echo $form->label($model, 'rolid'); ?> <?php echo CHtml::activeDropDownList($model, 'rolid', CHtml::listData(Rol::model()->findAll(), 'id', 'rol')); ?> </div> <div class="row"> <?php echo $form->label($model, 'nivelid'); ?> <?php echo CHtml::activeDropDownList($model, 'nivelid', CHtml::listData(Nivel::model()->findAll(), 'id', 'nombre')); ?> </div> <div class="row"> <?php echo $form->label($model, 'activo');
</div> <?php } else { echo CHtml::hiddenField('Usuario[activo]', '1'); } ?> </div> <div class="span-9 last"> <fieldset> <legend>Roles y Niveles</legend> <div class="row"> <?php echo $form->labelEx($model, 'rolid'); ?> <?php echo CHtml::activeDropDownList($model, 'rolid', CHtml::listData(Rol::model()->findAll(), 'id', 'rol'), array('prompt' => 'Seleccione un rol...', 'class' => 'cboselect')); ?> <?php echo $form->error($model, 'rolid'); ?> </div> <div class="row" <?php if (!$model->isNewRecord && Yii::app()->user->nivel > 1) { echo "style='display:none;'"; } ?> > <?php echo $form->labelEx($model, 'nivelid'); $condition = !$model->isNewRecord && Yii::app()->user->id == $model->id ? 'id>=' . Yii::app()->user->nivel : 'id>' . Yii::app()->user->nivel;