Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Mensajes::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'model_id' => $this->model_id, 'created_by' => $this->created_by, 'created_at' => $this->created_at, 'updated_by' => $this->updated_by, 'updated_at' => $this->updated_at, 'estado' => $this->estado]);
     $query->andFilterWhere(['like', 'avisar_a', $this->avisar_a])->andFilterWhere(['like', 'mensaje', $this->mensaje])->andFilterWhere(['like', 'model', $this->model]);
     return $dataProvider;
 }
Example #2
0
 public function actionChange()
 {
     $model = new RangoPersonas();
     $listaCambios = '';
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         // Comienza Transaccion
         $transaction = Yii::$app->db->beginTransaction();
         try {
             $c = Accesos::updateAll(['id_persona' => $model->idPersonaHasta], ['id_persona' => $model->idPersonaDesde]);
             if ($c > 0) {
                 $listaCambios .= '<p><i>Accesos:</i> cantidad de cambios realizados -> ' . $c . '</p>';
             }
             $c = AccesosAutorizantes::updateAll(['id_persona' => $model->idPersonaHasta], ['id_persona' => $model->idPersonaDesde]);
             if ($c > 0) {
                 $listaCambios .= '<p><i>Accesos (autorizantes):</i> cantidad de cambios realizados -> ' . $c . '</p>';
             }
             $c = Autorizantes::updateAll(['id_persona' => $model->idPersonaHasta], ['id_persona' => $model->idPersonaDesde]);
             if ($c > 0) {
                 $listaCambios .= '<p><i>Autorizantes:</i> cantidad de cambios realizados -> ' . $c . '</p>';
             }
             $c = Llaves::updateAll(['id_persona' => $model->idPersonaHasta], ['id_persona' => $model->idPersonaDesde]);
             if ($c > 0) {
                 $listaCambios .= '<p><i>Llaves (personas):</i> cantidad de cambios realizados -> ' . $c . '</p>';
             }
             $c = Llaves::updateAll(['id_autorizante' => $model->idPersonaHasta], ['id_persona' => $model->idPersonaDesde]);
             if ($c > 0) {
                 $listaCambios .= '<p><i>Llaves (autorizantes):</i> cantidad de cambios realizados -> ' . $c . '</p>';
             }
             $c = Mensajes::updateAll(['model_id' => $model->idPersonaHasta], ['model_id' => $model->idPersonaDesde, 'model' => 'frontend\\models\\Personas']);
             if ($c > 0) {
                 $listaCambios .= '<p><i>Mensajes:</i> cantidad de cambios realizados -> ' . $c . '</p>';
             }
             $c = UfTitularidadPersonas::updateAll(['id_persona' => $model->idPersonaHasta], ['id_persona' => $model->idPersonaDesde]);
             if ($c > 0) {
                 $listaCambios .= '<p><i>Titularidad:</i> cantidad de cambios realizados -> ' . $c . '</p>';
             }
             if ($listaCambios == '') {
                 $listaCambios = '<p>No se ha realizado ningún cambio. Controle los IDs de personas utilizados.</p>';
             }
             $transaction->commit();
         } catch (\Exception $e) {
             $transaction->rollBack();
             Yii::$app->session->addFlash('danger', 'Hubo un error en la grabación');
             throw $e;
         }
         // try..catch
     }
     return $this->render('change', ['model' => $model, 'listaCambios' => $listaCambios]);
 }
Example #3
0
    public function refreshListas()
    {
        $response = ['ingpersonas' => '', 'ingvehiculos' => '', 'autorizantes' => '', 'egrpersonas' => '', 'egrvehiculos' => ''];
        foreach ($response as $grupo => $valor) {
            // Se recupera de la sesion
            $sess = \Yii::$app->session->get($grupo);
            if (!empty($sess)) {
                // Se crea el array vacio para el dataprovider
                $dp = [];
                // La session solo contiene los IDs, se recorre el array y se completa $dp con el objeto que corresponda
                foreach ($sess as $p) {
                    switch ($grupo) {
                        case 'ingpersonas':
                            $dp[] = Personas::findOne($p);
                            break;
                        case 'ingvehiculos':
                            $dp[] = Vehiculos::findOne($p);
                            break;
                        case 'autorizantes':
                            $dp[] = Autorizantes::findOne($p);
                            break;
                        case 'egrpersonas':
                            $dp[] = Personas::findOne($p);
                            break;
                        case 'egrvehiculos':
                            $dp[] = Vehiculos::findOne($p);
                            break;
                    }
                }
                $dataProvider = new ArrayDataProvider(['allModels' => $dp]);
            } else {
                // dataProvider vacio
                //return '';
                $response[$grupo] = '';
                continue;
            }
            // if !empty $sess
            switch ($grupo) {
                case 'ingpersonas':
                    $columns = [['header' => '<span class="glyphicon glyphicon-trash"></span>', 'attribute' => 'Acción', 'format' => 'raw', 'value' => function ($model, $index, $widget) {
                        $url = Yii::$app->urlManager->createUrl(['accesos/drop-lista', 'grupo' => 'ingpersonas', 'id' => isset($model->id) ? $model->id : '']);
                        return Html::a('<span class="glyphicon glyphicon-remove"></span>', $url, ['title' => 'Eliminar', 'onclick' => '$.ajax({
															type     : "POST",
															cache    : false,
															url      : $(this).attr("href"),
															success  : function(r) {
																			$("#divlistapersonas").html(r["ingpersonas"]);
																		}
														});return false;']);
                    }], ['header' => '<span class="glyphicon glyphicon-envelope"></span>', 'attribute' => 'Mensajes', 'format' => 'raw', 'value' => function ($model, $index, $widget) {
                        $c = Mensajes::getMensajesByModelId($model->className(), $model->id);
                        if (!empty($c)) {
                            $text = '<span class="glyphicon glyphicon-alert" style="color:#FF8000"></span>';
                            $titl = 'Ver mensaje';
                        } else {
                            $text = '<span class="glyphicon glyphicon-envelope"></span>';
                            $titl = 'Ingresar nuevo mensaje';
                        }
                        $url = Yii::$app->urlManager->createUrl(['mensajes/create-ajax', 'modelName' => $model->className(), 'modelID' => $model->id]);
                        return Html::a($text, $url, ['title' => $titl, 'onclick' => '$.ajax({
													type     :"POST",
													cache    : false,
													url  : $(this).attr("href"),
													success  : function(response) {
																$("#divmensaje").html(response);
																$("#modalmensaje").modal("show");
																}
												});return false;']);
                    }], ['header' => '&nbsp;', 'attribute' => 'venc_vto_seguro', 'visible' => \Yii::$app->session->get('req_seguro'), 'format' => 'raw', 'value' => function ($model, $index, $widget) {
                        if (empty($model->vto_seguro)) {
                            $ic = ' ';
                        } else {
                            // se debe controlar si no está vencido el seguro
                            if ($this->fecVencida($model->vto_seguro)) {
                                $ic = '<span class="glyphicon glyphicon-hourglass" title="Seguro VENCIDO"
														style="color:#FF8000"></span>';
                            } else {
                                // no está vencido, controla si esta por vencer en 2 dias (ver el valor en params.php)
                                if ($this->fecPorVencer($model->vto_seguro, \Yii::$app->params['fecSeguroDias'])) {
                                    $ic = '<span class="glyphicon glyphicon-hourglass" title="Seguro por vencer" 
														></span>';
                                } else {
                                    $ic = ' ';
                                }
                            }
                        }
                        return $ic;
                    }], ['attribute' => 'vto_seguro', 'visible' => \Yii::$app->session->get('req_seguro'), 'format' => 'raw', 'value' => function ($model, $index, $widget) {
                        // intendencia pidio que se pueda modificar siempre
                        $pide = true;
                        /*
                        if (empty($model->vto_seguro)) {
                        	$pide=true;
                        } else {
                        	// se debe controlar si no está vencido el seguro
                        	if ($this->fecVencida($model->vto_seguro)) {												
                        		$pide=true;
                        	} else {
                        		// no está vencido, por lo tanto no se pide, solo se muestra
                        		$pide=false;
                        	}
                        }
                        */
                        if (!$pide) {
                            return Yii::$app->formatter->format($model->vto_seguro, 'date');
                        } else {
                            $url = Yii::$app->urlManager->createUrl(['accesos/pide-seguro', 'idPersona' => $model->id]);
                            return Html::a(empty($model->vto_seguro) ? 'Sin seguro' : Yii::$app->formatter->format($model->vto_seguro, 'date'), $url, ['title' => 'Modificar fecha de vencimiento', 'onclick' => '$.ajax({
														type     :"POST",
														cache    : false,
														url  : $(this).attr("href"),
														success  : function(response) {
																console.log(response);
																$("#divupdseguro").html(response);
																$("#modalupdseguro").modal("show");

																	}
													});return false;']);
                        }
                    }], 'id', 'apellido', 'nombre', 'nombre2', 'nro_doc'];
                    $heading = '<i class="glyphicon glyphicon-user"></i>  Personas (Ingreso)';
                    //$heading='Personas';
                    break;
                case 'egrpersonas':
                    $columns = [['header' => '<span class="glyphicon glyphicon-trash"></span>', 'attribute' => 'Acción', 'format' => 'raw', 'value' => function ($model, $index, $widget) {
                        $url = Yii::$app->urlManager->createUrl(['accesos/drop-lista', 'grupo' => 'egrpersonas', 'id' => isset($model->id) ? $model->id : '']);
                        return Html::a('<span class="glyphicon glyphicon-remove"></span>', $url, ['title' => 'Eliminar', 'onclick' => '$.ajax({
															type     : "POST",
															cache    : false,
															url      : $(this).attr("href"),
															success  : function(r) {
																			$("#divlistapersonas").html(r["egrpersonas"]);
																		}
														});return false;']);
                    }], ['header' => '<span class="glyphicon glyphicon-envelope"></span>', 'attribute' => 'Mensajes', 'format' => 'raw', 'value' => function ($model, $index, $widget) {
                        $c = Mensajes::getMensajesByModelId($model->className(), $model->id);
                        if (!empty($c)) {
                            $text = '<span class="glyphicon glyphicon-alert" style="color:#FF8000"></span>';
                            $titl = 'Ver mensaje';
                        } else {
                            $text = '<span class="glyphicon glyphicon-envelope"></span>';
                            $titl = 'Ingresar nuevo mensaje';
                        }
                        $url = Yii::$app->urlManager->createUrl(['mensajes/create-ajax', 'modelName' => $model->className(), 'modelID' => $model->id]);
                        return Html::a($text, $url, ['title' => $titl, 'onclick' => '$.ajax({
													type     :"POST",
													cache    : false,
													url  : $(this).attr("href"),
													success  : function(response) {
																$("#divmensaje").html(response);
																$("#modalmensaje").modal("show");
																}
												});return false;']);
                    }], ['header' => '', 'attribute' => 'Sin ingreso', 'format' => 'raw', 'value' => function ($model, $index, $widget) {
                        $a = Accesos::find()->where(['id_persona' => $model->id, 'egr_fecha' => null])->orderBy(['id' => SORT_DESC])->one();
                        if (empty($a)) {
                            return '<span class="glyphicon glyphicon-bell" 
															title="Sin ingreso" style="color:#FF8000">
															</span>';
                        } else {
                            return '';
                        }
                    }], 'id', 'apellido', 'nombre', 'nombre2', 'nro_doc'];
                    $heading = '<i class="glyphicon glyphicon-user"></i>  Personas (Egreso)';
                    //$heading='Personas';
                    break;
                case 'ingvehiculos':
                    $columns = [['header' => '<span class="glyphicon glyphicon-trash"></span>', 'attribute' => 'Acción', 'format' => 'raw', 'value' => function ($model, $index, $widget) {
                        $url = Yii::$app->urlManager->createUrl(['accesos/drop-lista', 'grupo' => 'ingvehiculos', 'id' => isset($model->id) ? $model->id : '']);
                        return Html::a('<span class="glyphicon glyphicon-remove"></span>', $url, ['title' => 'Eliminar', 'onclick' => '$.ajax({
															type     : "POST",
															cache    : false,
															url      : $(this).attr("href"),
															success  : function(r) {
																			$("#divlistavehiculos").html(r["ingvehiculos"]);
																		}
														});return false;']);
                    }], ['header' => '<span class="glyphicon glyphicon-envelope"></span>', 'attribute' => 'Mensajes', 'format' => 'raw', 'value' => function ($model, $index, $widget) {
                        $c = Mensajes::getMensajesByModelId($model->className(), $model->id);
                        if (!empty($c)) {
                            $text = '<span class="glyphicon glyphicon-alert" style="color:#FF8000"></span>';
                            $titl = 'Ver mensaje';
                        } else {
                            $text = '<span class="glyphicon glyphicon-envelope"></span>';
                            $titl = 'Ingresar nuevo mensaje';
                        }
                        $url = Yii::$app->urlManager->createUrl(['mensajes/create-ajax', 'modelName' => $model->className(), 'modelID' => $model->id]);
                        return Html::a($text, $url, ['title' => $titl, 'onclick' => '$.ajax({
													type     :"POST",
													cache    : false,
													url  : $(this).attr("href"),
													success  : function(response) {
																$("#divmensaje").html(response);
																$("#modalmensaje").modal("show");
																}
												});return false;']);
                    }], 'id', 'patente', 'marca', 'modelo', 'color'];
                    $heading = '<i class="fa fa-car"></i>  Vehiculos (Ingreso)';
                    //$heading='Vehiculos';
                    break;
                case 'egrvehiculos':
                    $columns = [['header' => '<span class="glyphicon glyphicon-trash"></span>', 'attribute' => 'Acción', 'format' => 'raw', 'value' => function ($model, $index, $widget) {
                        $url = Yii::$app->urlManager->createUrl(['accesos/drop-lista', 'grupo' => 'egrvehiculos', 'id' => isset($model->id) ? $model->id : '']);
                        return Html::a('<span class="glyphicon glyphicon-remove"></span>', $url, ['title' => 'Eliminar', 'onclick' => '$.ajax({
															type     : "POST",
															cache    : false,
															url      : $(this).attr("href"),
															success  : function(r) {
																			$("#divlistavehiculos").html(r["egrvehiculos"]);
																		}
														});return false;']);
                    }], ['header' => '<span class="glyphicon glyphicon-envelope"></span>', 'attribute' => 'Mensajes', 'format' => 'raw', 'value' => function ($model, $index, $widget) {
                        $c = Mensajes::getMensajesByModelId($model->className(), $model->id);
                        if (!empty($c)) {
                            $text = '<span class="glyphicon glyphicon-alert" style="color:#FF8000"></span>';
                            $titl = 'Ver mensaje';
                        } else {
                            $text = '<span class="glyphicon glyphicon-envelope"></span>';
                            $titl = 'Ingresar nuevo mensaje';
                        }
                        $url = Yii::$app->urlManager->createUrl(['mensajes/create-ajax', 'modelName' => $model->className(), 'modelID' => $model->id]);
                        return Html::a($text, $url, ['title' => $titl, 'onclick' => '$.ajax({
													type     :"POST",
													cache    : false,
													url  : $(this).attr("href"),
													success  : function(response) {
																$("#divmensaje").html(response);
																$("#modalmensaje").modal("show");
																}
												});return false;']);
                    }], 'id', 'patente', 'marca', 'modelo', 'color'];
                    $heading = '<i class="fa fa-car"></i>  Vehiculos (Egreso)';
                    //$heading='Vehiculos';
                    break;
                case 'autorizantes':
                    $columns = [['header' => '<span class="glyphicon glyphicon-trash"></span>', 'attribute' => 'Acción', 'format' => 'raw', 'value' => function ($model, $index, $widget) {
                        $url = Yii::$app->urlManager->createUrl(['accesos/drop-lista', 'grupo' => 'autorizantes', 'id' => isset($model->id) ? $model->id : '']);
                        return Html::a('<span class="glyphicon glyphicon-remove"></span>', $url, ['title' => 'Eliminar', 'onclick' => '$.ajax({
															type     : "POST",
															cache    : false,
															url      : $(this).attr("href"),
															success  : function(r) {
																			$("#divlistaautorizantes").html(r["autorizantes"]);
																		}
														});return false;']);
                    }], 'persona.apellido', 'persona.nombre', 'persona.nombre2', 'persona.nro_doc', 'id_uf'];
                    $heading = '<i class="fa fa-key"></i>  Autorizantes (Ingreso)';
                    break;
            }
            if ($grupo == 'egrpersonas' || $grupo == 'egrvehiculos') {
                $gvType = GridView::TYPE_DANGER;
            } else {
                $gvType = GridView::TYPE_INFO;
            }
            $response[$grupo] = GridView::widget(['dataProvider' => $dataProvider, 'layout' => '{items}', 'columns' => $columns, 'panel' => ['type' => $gvType, 'heading' => $heading, 'footer' => false, 'before' => false, 'after' => false], 'panelHeadingTemplate' => '{heading}', 'resizableColumns' => false, 'bordered' => false, 'striped' => true, 'condensed' => true, 'responsive' => true, 'hover' => false, 'toolbar' => false, 'export' => false]);
        }
        //foreach $response
        return $response;
    }
Example #4
0
        $titl = 'Ver mensaje sobre la persona';
    } else {
        $text = '<span class="glyphicon glyphicon-user"></span>';
        $titl = 'Ingresar nuevo mensaje sobre la persona';
    }
    return Html::a($text, $url, ['title' => $titl, 'onclick' => '$.ajax({
								type     :"POST",
								cache    : false,
								url  : $(this).attr("href"),
								success  : function(response) {
											$("#divmensaje").html(response);
											$("#modalmensaje").modal("show");
											}
							});return false;']);
}, 'mensajeV' => function ($url, $model) {
    $c = Mensajes::getMensajesByModelId('frontend\\models\\Vehiculos', $model->ing_id_vehiculo);
    if (!empty($c)) {
        $text = '<i class="fa fa-car" style="color:#FF8000"></i>';
        $titl = 'Ver mensaje sobre el vehiculo';
    } else {
        $text = '<i class="fa fa-car"></i>';
        $titl = 'Ingresar nuevo mensaje sobre el vehiculo';
    }
    return Html::a($text, $url, ['title' => $titl, 'onclick' => '$.ajax({
								type     :"POST",
								cache    : false,
								url  : $(this).attr("href"),
								success  : function(response) {
											$("#divmensaje").html(response);
											$("#modalmensaje").modal("show");
											}
Example #5
0
 /**
  * Finds the Mensajes model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Mensajes the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Mensajes::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #6
0
    } else {
        $text .= '></span>';
        $titl = 'Ingresar nuevo comentario';
    }
    return Html::a($text, $url, ['title' => $titl, 'onclick' => '$.ajax({
							type     :"POST",
							cache    : false,
							url  : $(this).attr("href"),
							success  : function(response) {
										$("#divcomentarionuevo").html(response);
										$("#modalcomentarionuevo").modal("show");
										
										}
						});return false;']);
}, 'mensajeP' => function ($url, $model) {
    $c = Mensajes::getMensajesByModelId('frontend\\models\\Personas', $model->id_persona);
    if (!empty($c)) {
        $text = '<span class="glyphicon glyphicon-envelope" style="color:#FF8000"></span>';
        $titl = 'Ver mensaje sobre la persona';
    } else {
        $text = '<span class="glyphicon glyphicon-envelope"></span>';
        $titl = 'Ingresar nuevo mensaje sobre la persona';
    }
    return Html::a($text, $url, ['title' => $titl, 'onclick' => '$.ajax({
								type     :"POST",
								cache    : false,
								url  : $(this).attr("href"),
								success  : function(response) {
											$("#divmensaje").html(response);
											$("#modalmensaje").modal("show");
											}
Example #7
0
    } else {
        $text .= '></span>';
        $titl = 'Ingresar nuevo comentario';
    }
    return Html::a($text, $url, ['title' => $titl, 'onclick' => '$.ajax({
							type     :"POST",
							cache    : false,
							url  : $(this).attr("href"),
							success  : function(response) {
										$("#divcomentarionuevo").html(response);
										$("#modalcomentarionuevo").modal("show");
										
										}
						});return false;']);
}, 'mensajeP' => function ($url, $model) {
    $c = Mensajes::getMensajesByModelId($model->className(), $model->id);
    if (!empty($c)) {
        $text = '<span class="glyphicon glyphicon-envelope" style="color:#FF8000"></span>';
        $titl = 'Ver mensaje sobre el vehiculo';
    } else {
        $text = '<span class="glyphicon glyphicon-envelope"></span>';
        $titl = 'Ingresar nuevo mensaje sobre el vehiculo';
    }
    return Html::a($text, $url, ['title' => $titl, 'onclick' => '$.ajax({
								type     :"POST",
								cache    : false,
								url  : $(this).attr("href"),
								success  : function(response) {
											$("#divmensaje").html(response);
											$("#modalmensaje").modal("show");
											}