/**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDelete($id)
 {
     if (Yii::app()->request->isPostRequest) {
         // we only allow deletion via POST request
         $solicitudes = SolicitudPermiso::model()->de_Etapa($id)->findAll();
         if (count($solicitudes) == 0) {
             $this->reordenarPesoDeleted();
             //                $this->loadModel($id)->delete();
             PermismoEtapa::model()->updateByPk($id, array('estado' => PermismoEtapa::ESTADO_INACTIVO), array('id' => $id));
             Yii::app()->user->setFlash('success', "La Etapa ha sido eliminada con exito!.");
         } else {
             Yii::app()->user->setFlash('error', "No se puede eliminar esta Etapa, contiene Solicitudes asignadas.");
         }
         // 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('admin'));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }
 public function actionAjaxUpdateEtapa($id_data = null, $id_etapa = null)
 {
     if (Yii::app()->request->isAjaxRequest) {
         $modelSolicitud = SolicitudPermiso::model()->findByPk($id_data);
         $modelSolicitud->permismo_etapa_id = $id_etapa;
         //            $updated = SolicitudPermiso::model()->updateByPk($id_data, array(
         //                'permismo_etapa_id' => $id_etapa
         //                    )
         //            );
         //            var_dump($modelSolicitud->empleado_id);
         //            die();
         if ($modelSolicitud->save()) {
             ActividadSistema::registrarActividad($modelSolicitud, ActividadSistema::TIPO_RESTORE, Yii::app()->user->id);
             Notificacion::registrarAlertaA($modelSolicitud, Notificacion::TIPO_RESTORE, Empleado::model()->find('id=:idUser', array(':idUser' => $modelSolicitud->empleado_id))->userid);
         }
     }
 }
 /**
  * Devuelve un mensaje formateado segun el tipo de actividad
  * @param Actividad $actividad objeto de tipo Actividad que se quiere formatear
  * @return string mensaje formateado
  */
 public static function getMensaje($actividad)
 {
     // El mensaje
     $mensaje = "";
     $icon = "";
     // Primero buscamos el usuario que realizó la accion
     $usuario = Yii::app()->user->um->loadUserById($actividad['usuario_id']);
     if ($usuario) {
         switch ($actividad['entidad_tipo']) {
             // Si es una actividad sobre un empleado
             case Empleado::model()->tableName():
                 $empleado = Empleado::model()->findByPk($actividad['entidad_id']);
                 $icon = 'group';
                 if ($actividad['tipo'] == self::TIPO_CREATE) {
                     $mensaje = "<b>" . $usuario->username . "</b> creó el empleado " . CHtml::link($empleado->nombre_completo, array('/personal/empleado/view', 'id' => $empleado->id), array('class' => 'btn btn-small btn-silver'));
                 } elseif ($actividad['tipo'] == self::TIPO_UPDATE) {
                     if ($actividad['detalle'] != null) {
                         $mensaje = "<b>" . $usuario->username . "</b>  " . $actividad['detalle'] . " del empleado " . CHtml::link($empleado->nombre_completo, array('/personal/empleado/view', 'id' => $empleado->id), array('class' => 'btn btn-small btn-silver'));
                     } else {
                         $mensaje = $usuario->username . " actualizó los datos del contacto " . CHtml::link($empleado->nombre_completo, array('/personal/empleado/view', 'id' => $empleado->id), array('class' => 'btn btn-small btn-silver'));
                     }
                 } elseif ($actividad['tipo'] == self::TIPO_DELETE) {
                     $mensaje = "<b>" . $usuario->username . "</b>  elimino al empleado \"" . Util::Truncate($empleado->nombre_completo, 15) . "\" ";
                 } elseif ($actividad['tipo'] == self::TIPO_RESTORE) {
                     $mensaje = "<b>" . $usuario->username . "</b>  Asigno como Encargado a " . CHtml::link($empleado->nombre_completo, array('/personal/empleado/view', 'id' => $empleado->id), array('class' => 'btn btn-small btn-silver')) . " de <b> \"" . Util::Truncate(Empleado::model()->findByPk($actividad['detalle'])->nombre_completo, 15) . "\" </b> a ACTIVOS";
                 }
                 break;
                 // Si es una actividad sobre un una Solicitud
             // Si es una actividad sobre un una Solicitud
             case SolicitudPermiso::model()->tableName():
                 $solicitud = SolicitudPermiso::model()->findByPk($actividad['entidad_id']);
                 $icon = 'archive';
                 if ($actividad['tipo'] == self::TIPO_CREATE) {
                     //                        $mensaje = "<b>" . $usuario->username . "</b> ha enviado una solicitud a " . CHtml::link(Empleado::model()->findByPk($solicitud->seccion)->nombre_completo, array('/personal/empleado/view', 'id' => $solicitud->empleado_id), array('class' => 'btn btn-small btn-silver'));
                 } elseif ($actividad['tipo'] == self::TIPO_UPDATE) {
                     if ($actividad['detalle'] != null) {
                         $mensaje = "<b>" . $usuario->username . "</b>  " . $actividad['detalle'] . " del empleado " . CHtml::link(Empleado::model()->findByPk($solicitud->seccion)->nombre_completo, array('/personal/empleado/view', 'id' => $solicitud->empleado_id), array('class' => 'btn btn-small btn-silver'));
                     } else {
                         $mensaje = $usuario->username . " actualizó los datos de la solicitud enviada a  " . CHtml::link(Empleado::model()->findByPk($solicitud->seccion)->nombre_completo, array('/personal/empleado/view', 'id' => $solicitud->empleado_id), array('class' => 'btn btn-small btn-silver'));
                     }
                 } elseif ($actividad['tipo'] == self::TIPO_DELETE) {
                     $mensaje = "<b>" . $usuario->username . "</b> ha cambiado de etapa a la solicitud enviada por  \"" . Util::Truncate(Empleado::model()->findByPk($solicitud->seccion)->nombre_completo, 15);
                 } elseif ($actividad['tipo'] == self::TIPO_RESTORE) {
                     //                        $mensaje = "<b>" . $usuario->username . "</b>  ha cambiado de etapa a la solicitud enviada por " . CHtml::link(Empleado::model()->findByPk($solicitud->seccion)->nombre_completo, array('/personal/empleado/view', 'id' => $solicitud->empleado_id), array('class' => 'btn btn-small btn-silver')) . " <b> \"";
                 }
                 break;
                 // Si es una actividad sobre un deuda
             // Si es una actividad sobre un deuda
             case Informe::model()->tableName():
                 $informe = Informe::model()->findByPk($actividad['entidad_id']);
                 $icon = 'usd';
                 if ($actividad['tipo'] == self::TIPO_CREATE) {
                     $mensaje = "<b>" . $usuario->username . "</b> A enviado un informe a " . CHtml::link(Empleado::model()->findByPk($informe->entidad_id)->nombre_completo, array('/notificacion/informe/view', 'id' => $informe->id), array('class' => 'btn btn-small btn-silver'));
                 } elseif ($actividad['tipo'] == self::TIPO_UPDATE) {
                     if ($actividad['detalle'] != null) {
                         $mensaje = "<b>" . $usuario->username . "</b>  " . $actividad['detalle'] . " del contacto " . CHtml::link($informe->cltCliente->nombre_completo, array('/notificacion/cltCliente/view', 'id' => $informe->id), array('class' => 'btn btn-small btn-silver'));
                     } else {
                         $mensaje = $usuario->username . " actualizó el informe enviado a " . CHtml::link(Empleado::model()->findByPk($informe->entidad_id)->nombre_completo, array('/notificacion/informe/view', 'id' => $informe->cltCliente->id), array('class' => 'btn btn-small btn-silver'));
                     }
                 } elseif ($actividad['tipo'] == self::TIPO_DELETE) {
                     $mensaje = "<b>" . $usuario->username . "</b>  eliminó el informe enviado a \"" . CHtml::link(Empleado::model()->findByPk($informe->entidad_id)->nombre_completo, array('/notificacion/informe/view', 'id' => $informe->cltCliente->id), array('class' => 'btn btn-small btn-silver'));
                 }
                 break;
                 //                // Si es una actividad sobre una Transaccion
             //                // Si es una actividad sobre una Transaccion
             case Tarea::model()->tableName():
                 $tarea = Tarea::model()->findByPk($actividad['entidad_id']);
                 $icon = 'tasks';
                 if ($actividad['tipo'] == self::TIPO_CREATE) {
                     //                        $mensaje = "<b>" . $usuario->username . "</b> asigno la tarea  <b>" . $tarea->nombre . "</b> al empleado/a " . CHtml::link(Empleado::model()->findByPk($tarea->responsable_id)->nombre_completo, array('/tareas/tarea/view', 'id' => $tarea->id), array('class' => 'btn btn-small btn-silver'));
                 } elseif ($actividad['tipo'] == self::TIPO_UPDATE) {
                     if ($actividad['detalle'] != null) {
                         $mensaje = "<b>" . $usuario->username . "</b>  " . $actividad['detalle'] . " del cliente  " . CHtml::link(Empleado::model()->findByPk($tarea->responsable_id)->nombre_completo, array('/cliente/cltCliente/view', 'id' => $tarea->id), array('class' => 'btn btn-small btn-silver'));
                     } else {
                         $mensaje = "<b>" . $usuario->username . "</b> actualizó la tarea  <b>" . $tarea->nombre . "</b> del clienete " . CHtml::link(Empleado::model()->findByPk($tarea->responsable_id)->nombre_completo, array('/cliente/cltCliente/view', 'id' => $tarea->id), array('class' => 'btn btn-small btn-silver'));
                     }
                 } elseif ($actividad['tipo'] == self::TIPO_DELETE) {
                     $mensaje = "<b>" . $usuario->username . "</b>  eliminó la tarea \"" . Util::Truncate($tarea->nombre, 15) . "\" signada a " . Empleado::model()->findByPk($tarea->responsable_id)->nombre_completo;
                 }
                 break;
                 // Si es una actividad sobre un mail
                 //                case Mail::model()->tableName():
                 //                    $mail = Mail::model()->findByPk($actividad['entidad_id']);
                 //                    if (isset($mail)) {
                 //                        $contacto = CltCliente::model()->findByPk($mail->contacto_id);
                 //                        $icon = 'envelope';
                 //
                 //                        if ($actividad['tipo'] == self::TIPO_CREATE) {
                 //                            $mensaje = $usuario->username . " envió un mail a " . CHtml::link($contacto->nombre_completo, array('/cliente/cltCliente/view', 'id' => $contacto->id), array('class' => 'btn btn-small btn-silver'));
                 //                        }
                 //                    }
                 //                    break;
             // Si es una actividad sobre un mail
             //                case Mail::model()->tableName():
             //                    $mail = Mail::model()->findByPk($actividad['entidad_id']);
             //                    if (isset($mail)) {
             //                        $contacto = CltCliente::model()->findByPk($mail->contacto_id);
             //                        $icon = 'envelope';
             //
             //                        if ($actividad['tipo'] == self::TIPO_CREATE) {
             //                            $mensaje = $usuario->username . " envió un mail a " . CHtml::link($contacto->nombre_completo, array('/cliente/cltCliente/view', 'id' => $contacto->id), array('class' => 'btn btn-small btn-silver'));
             //                        }
             //                    }
             //                    break;
             default:
                 break;
         }
         if ($mensaje) {
             return "<div class='metro_tmtime' datetime='2013-04-10 18:30'>\n                            <span class='date'>" . Util::FormatDate($actividad['fecha'], 'd/m/Y') . "</span>\n                            <span class='time'>" . Util::FormatDate($actividad['fecha'], 'H:i') . "</span>\n                        </div>\n                        <div class='metro_tmicon'><i class='aweso-{$icon}'></i></div>\n                        <div class='metro_tmlabel'>{$mensaje}</div>";
         }
     }
 }
Example #4
0
/** @var SolicitudPermisoController $this */
/** @var SolicitudPermiso $model */
/** @var AweActiveForm $form */
$form = $this->beginWidget('ext.AweCrud.components.AweActiveForm', array('id' => 'solicitud-permiso-form', 'type' => 'horizontal', 'enableAjaxValidation' => true, 'clientOptions' => array('validateOnSubmit' => false, 'validateOnChange' => true), 'enableClientValidation' => false));
?>
<div class="row-fluid">
    <div class="span12">
        <!-- widget button -->
        <div class="widget border-cyan" id="widget-button">

            <!-- widget header -->
            <div class="widget-header bg-cyan">
                <!-- widget title -->
                <h4 class="widget-title"><i class="aweso-user"></i> <?php 
echo Yii::t('AweCrud.app', $model->isNewRecord ? 'Create' : 'Update') . ' ' . SolicitudPermiso::label();
?>
</h4>
                <!-- widget action, you can also use btn, btn-group, nav-tabs or nav-pills (also support dropdown). enjoy! -->
                <div class="widget-action">
                    <button data-toggle="collapse" data-collapse="#widget-button" class="btn">
                        <i class="aweso-chevron-up color-cyan" data-toggle-icon="aweso-chevron-down  aweso-chevron-up"></i>
                    </button>
                </div>
            </div><!-- /widget header -->
            <div class="widget-content form bg-white">


                <p class="note">
                    <?php 
echo Yii::t('AweCrud.app', 'Fields with');
Example #5
0
<?php

/** @var SolicitudPermisoController $this */
/** @var SolicitudPermiso $model */
$this->breadcrumbs = array('Solicitud Permisos');
$this->menu = array(array('label' => Yii::t('AweCrud.app', 'Create') . ' ' . SolicitudPermiso::label(), 'icon' => 'plus', 'url' => array('create')), array('label' => Yii::t('AweCrud.app', 'Manage'), 'icon' => 'list-alt', 'url' => array('admin')));
?>

<fieldset>
    <legend>
        <?php 
echo Yii::t('AweCrud.app', 'List');
?>
 <?php 
echo SolicitudPermiso::label(2);
?>
    </legend>

<?php 
$this->widget('bootstrap.widgets.TbListView', array('dataProvider' => $dataProvider, 'itemView' => '_view'));
?>
</fieldset>
Example #6
0
foreach ($etapas as $etapa) {
    ?>
        <div class="kanban-stage">
            <div class="kanban-title"><?php 
    echo $etapa->nombre;
    ?>
</div>
            <ul class="kanban-body" cont-id="<?php 
    echo $etapa->id;
    ?>
">
                <?php 
    if (in_array($id, array_map('SolicitudPermiso::getEncargadoId', $etapa->solicitudPermisos))) {
        ?>
                    <?php 
        $tareas = SolicitudPermiso::model()->findAll('seccion=:idEncargado and permismo_etapa_id=:idEtapa', array(':idEncargado' => $id, ':idEtapa' => $etapa->id));
        ?>
                    <?php 
        foreach ($tareas as $tarea) {
            ?>

                        <li class="kanban-item" data-id="<?php 
            echo $tarea->id;
            ?>
">
                            <!--                        <div class="kanban-item-title">
                            <?php 
            //                            echo CHtml::link($credito->fecha_credito, "");
            //                            echo CHtml::link($cliente->nombre_formato, "", array("id" => $cliente->id, "onClick" => "viewModal('incidencias/incidencia/view/id/" . $cliente->id . "')"));
            ?>
                                                    </div>-->