diff --git a/www/protected/controllers/EquipoController.php b/www/protected/controllers/EquipoController.php index a72d887..65f1e44 100644 --- a/www/protected/controllers/EquipoController.php +++ b/www/protected/controllers/EquipoController.php @@ -69,8 +69,9 @@ class EquipoController extends Controller { } public function actionDelete($id) { - $agente = Usuario::model()->equipo()->findByPk($id); - + $agente = $this->loadModel($id); + if ($agente) $agente->delete(); + // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if(!isset($_GET['ajax'])) $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index')); @@ -107,7 +108,7 @@ class EquipoController extends Controller { * @param integer the ID of the model to be loaded */ public function loadModel($id) { - $model = Usuario::model()->findByPk($id); + $model = Usuario::model()->equipo()->findByPk($id); if ($model === null) throw new CHttpException(404, Yii::t('profind', 'La página solicitada no existe.')); return $model; diff --git a/www/protected/models/Usuario.php b/www/protected/models/Usuario.php index 366f6c7..c6e3d52 100644 --- a/www/protected/models/Usuario.php +++ b/www/protected/models/Usuario.php @@ -65,12 +65,17 @@ class Usuario extends CActiveRecord { // will receive user inputs. return array( array('email, password', 'required'), + array('email, nombre, apellidos, password, tipo, titulo, localidad, telefono', 'length', 'max' => 255), + array('estado', 'length', 'max' => 1), + array('email', 'email'), array('email', 'unique'), + array('descripcion', 'safe'), + array('tipo', 'default', 'value' => self::TIPO_USUARIO_COORDINADOR), - array('email, nombre, apellidos, password, tipo, titulo, localidad, telefono', 'length', 'max' => 255), + array('ficheroFotografia', 'file', 'types' => 'jpg', 'maxSize' => 1024 * 1024 * 1, // 1MB como máximo @@ -78,6 +83,7 @@ class Usuario extends CActiveRecord { 'wrongType' => Yii::t('profind', 'Sólo se permiten imágenes en formato JPG.'), 'allowEmpty' => 'true', ), + array('id, id_empresa, estado, email, nombre, apellidos, tipo, titulo, localidad, telefono, descripcion', 'safe', 'on' => 'search'), ); } diff --git a/www/themes/profind/views/equipo/_invitacion_form.php b/www/themes/profind/views/equipo/_invitacion_form.php index 5831780..f6f67be 100644 --- a/www/themes/profind/views/equipo/_invitacion_form.php +++ b/www/themes/profind/views/equipo/_invitacion_form.php @@ -13,7 +13,6 @@
- beginWidget('CActiveForm', array( 'id' => 'invitacion-agente-form', diff --git a/www/themes/profind/views/equipo/index.php b/www/themes/profind/views/equipo/index.php index 4d973dc..74316e8 100644 --- a/www/themes/profind/views/equipo/index.php +++ b/www/themes/profind/views/equipo/index.php @@ -1,50 +1,20 @@ pageTitle = Yii::t('profind', 'Lista de agentes'); ?> -clientScript->registerScript('ajax-link-handler', " - $('a.delete').live('click', function(event){ - $.ajax({ - 'type':'get', - 'url':$(this).attr('href') + '&ajax', - 'dataType': 'html', - 'success':function(data){ - $('#display').html(data); - } - }); - event.preventDefault(); - }); - ");*/ +clientScript->registerScript('delete-link-handler', " + $('.user_list a.delete').click(function(e) { + e.preventDefault(); + var id = $(this).data('id'); + var boton = $('#msg_confirm_delete a.btn-danger'); + var href = boton.attr('href'); + boton.attr('href', href.replace(/&id=\d*/, '&id=' + id)); + $('#msg_confirm_delete').modal('show'); + }); + ", CClientScript::POS_END); ?> -

- - -
  • @@ -73,22 +43,20 @@ email, $agente->email); ?>
    - 'icon-trash')), - 'holaaaaa', - array('delete', 'id' => $agente->id), - array('class' => 'close pull-right delete') - ); + 'icon-trash')), + '#', array( + 'data-id' => $agente->id, + 'class' => 'close pull-right delete', + )); ?> -
     
  • - +
- renderPartial('_invitacion_form', array('invitacion' => $invitacion), false, true); ?> + renderPartial('_invitacion_form', array('invitacion' => $invitacion)); ?>

Añadir un nuevo agente

@@ -117,3 +85,20 @@
+