public function actionListaPersonas($id_vehiculo) { $personas = Accesos::getPersonasPorVehiculo($id_vehiculo, false); // Si la persona es nueva o nunca tuvo accesos devuelve una bandera para que no se muestre el modal if (count($personas) == 0) { return 'notFound'; } $dp = []; foreach ($personas as $per) { foreach ($per as $k => $v) { //Yii::trace($personas);die; if ($k == 'id_persona') { $dp[] = Personas::findOne($v); } } } $dataProvider = new ArrayDataProvider(['allModels' => $dp]); return $this->renderAjax('personaslist', ['dataProvider' => $dataProvider]); }
/** * Finds the Accesos model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Accesos the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Accesos::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
$url = Yii::$app->urlManager->createUrl(['accesos/view', 'id' => $model->id_acceso]); return $url; } }], ['attribute' => 'id_acceso', 'format' => 'raw', 'value' => function ($model, $index, $widget) { return Html::a($model->id_acceso, Yii::$app->urlManager->createUrl(['accesos/view', 'id' => $model->id_acceso]), ['title' => 'Ver detalle', 'target' => '_blank', 'data-pjax' => '0']); }], ['attribute' => 'ing_fecha', 'options' => ['style' => 'width:275px;'], 'contentOptions' => ['style' => 'width:275px;'], 'headerOptions' => ['style' => 'width:275px;'], 'format' => ['date'], 'filter' => MaskedInput::widget(['model' => $searchModel, 'attribute' => 'ing_fecha', 'mask' => '99/99/9999'])], ['attribute' => 'ing_hora', 'format' => ['time']], ['attribute' => 'id_persona', 'format' => 'raw', 'value' => function ($model, $index, $widget) { return Html::a($model->id_persona, Yii::$app->urlManager->createUrl(['personas/view', 'id' => $model->id_persona]), ['title' => 'Ver detalle de persona', 'target' => '_blank', 'data-pjax' => '0']); }], 'r_apellido', 'r_nombre', 'r_nombre2', 'r_nro_doc', ['attribute' => 'ing_id_vehiculo', 'format' => 'raw', 'value' => function ($model, $index, $widget) { return Html::a($model->ing_id_vehiculo, Yii::$app->urlManager->createUrl(['vehiculos/view', 'id' => $model->ing_id_vehiculo]), ['title' => 'Ver detalle del vehiculo', 'target' => '_blank', 'data-pjax' => '0']); }], 'r_ing_patente', 'r_ing_marca', 'r_ing_modelo', 'r_ing_color', 'ing_id_porton', 'r_ing_usuario', ['attribute' => 'id_concepto', 'value' => 'desc_concepto', 'filter' => AccesosConceptos::getListaConceptos(true)], 'ing_id_llave', 'motivo', ['attribute' => 'id_autorizante', 'format' => 'raw', 'value' => function ($model, $index, $widget) { return Html::a($model->id_autorizante, Yii::$app->urlManager->createUrl(['personas/view', 'id' => $model->id_autorizante]), ['title' => 'Ver detalle de autorizante', 'target' => '_blank', 'data-pjax' => '0']); }], 'r_aut_apellido', 'r_aut_nombre', 'r_aut_nombre2', 'id_uf', ['attribute' => 'egr_fecha', 'format' => ['date'], 'filter' => MaskedInput::widget(['model' => $searchModel, 'attribute' => 'egr_fecha', 'mask' => '99/99/9999'])], ['attribute' => 'egr_hora', 'format' => ['time']], ['attribute' => 'egr_id_vehiculo', 'format' => 'raw', 'value' => function ($model, $index, $widget) { return Html::a($model->egr_id_vehiculo, Yii::$app->urlManager->createUrl(['vehiculos/view', 'id' => $model->egr_id_vehiculo]), ['title' => 'Ver detalle del vehiculo', 'target' => '_blank', 'data-pjax' => '0']); }], 'r_egr_patente', 'r_egr_marca', 'r_egr_modelo', 'r_egr_color', 'egr_id_porton', 'r_egr_usuario', 'egr_id_llave', 'control', ['attribute' => 'estado', 'value' => function ($data) { return Accesos::getEstados($data->estado); }, 'filter' => Accesos::getEstados()], 'motivo_baja']; if (\Yii::$app->user->can('exportarConsAccesos')) { // contiene la selección inicial de columnas, es decir, todas // por ejemplo [0,1,2,3] $poSel = []; // contiene las descripciones de las columnas // por ejemplo [0=>'Portón', 1=>'Usuario',2=>'Fecha',3=>'Texto'] $poItems = []; $i = -1; foreach ($columns as $c) { $i++; // si es un array busca la clave "attribute" if (is_array($c)) { foreach ($c as $key => $value) { if ($key == 'attribute') { $poSel[] = $i;
/** * @return \yii\db\ActiveQuery */ public function getIdAcceso() { return $this->hasOne(Accesos::className(), ['id' => 'id_acceso']); }
public function actionListaVehiculos($id_persona) { // recupera los vehiculos utilizados por la persona en ingresos/egresos $vehiculos = Accesos::getVehiculosPorPersona($id_persona, true, true); // Si la persona es nueva o nunca tuvo accesos devuelve una bandera para que no se muestre el modal if (count($vehiculos) == 0) { return 'notFound'; } $dp = []; foreach ($vehiculos as $veh) { foreach ($veh as $k => $v) { //Yii::trace($vehiculos);die; $dp[] = Vehiculos::findOne($v); } } $dataProvider = new ArrayDataProvider(['allModels' => $dp]); return $this->renderAjax('vehiculoslist', ['dataProvider' => $dataProvider]); }
public function getUltIngreso() { return $this->hasOne(Accesos::className(), ['id_persona' => 'id'])->orderBy(['id' => SORT_DESC])->limit(1)->one(); }
/** * @return \yii\db\ActiveQuery */ public function getAccesos() { return $this->hasMany(Accesos::className(), ['id_concepto' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getAccesos() { return $this->hasMany(Accesos::className(), ['egr_id_llave' => 'id']); }
if (!$pdf) { echo '<p>'; if ($model->estado == Accesos::ESTADO_ACTIVO) { if (\Yii::$app->user->can('borrarAcceso')) { echo Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger']) . ' '; } } if (\Yii::$app->user->can('exportarConsAccesos')) { echo Html::a('<i class="fa fa-file-pdf-o"></i> PDF', ['pdf', 'id' => $model->id], ['class' => 'btn btn-default']); } echo '</p>'; } ?> <?php echo DetailView::widget(['model' => $model, 'options' => ['class' => 'table table-striped table-bordered table-condensed detail-view'], 'attributes' => ['id', 'ing_fecha:date', 'ing_hora:time', ['attribute' => 'id_persona', 'format' => 'raw', 'value' => Html::a($model->id_persona, Yii::$app->urlManager->createUrl(['personas/view', 'id' => $model->id_persona]), ['title' => 'Ver detalle de persona', 'target' => '_blank', 'data-pjax' => '0'])], 'persona.apellido', 'persona.nombre', 'persona.nombre2', 'persona.tipoDoc.desc_tipo_doc_abr', 'persona.nro_doc', ['attribute' => 'ing_id_vehiculo', 'format' => 'raw', 'value' => Html::a($model->ing_id_vehiculo, Yii::$app->urlManager->createUrl(['vehiculos/view', 'id' => $model->ing_id_vehiculo]), ['title' => 'Ver detalle del vehiculo', 'target' => '_blank', 'data-pjax' => '0'])], 'ingVehiculo.patente', 'ingVehiculo.marca', 'ingVehiculo.modelo', 'ingVehiculo.color', 'ing_id_porton', 'userIngreso.username', 'accesosConcepto.concepto', 'motivo', 'egr_fecha:date', 'egr_hora:time', ['attribute' => 'egr_id_vehiculo', 'format' => 'raw', 'value' => Html::a($model->egr_id_vehiculo, Yii::$app->urlManager->createUrl(['vehiculos/view', 'id' => $model->egr_id_vehiculo]), ['title' => 'Ver detalle del vehiculo', 'target' => '_blank', 'data-pjax' => '0'])], 'egrVehiculo.patente', 'egrVehiculo.marca', 'egrVehiculo.modelo', 'egrVehiculo.color', 'egr_id_porton', 'userEgreso.username', 'control', 'userCreatedBy.username', 'created_at:datetime', 'userUpdatedBy.username', 'updated_at:datetime', ['label' => 'Estado', 'value' => Accesos::getEstados($model->estado)], 'motivo_baja']]); ?> <?php $aut = AccesosAutorizantes::findAll(['id_acceso' => $model->id]); $primeraVez = true; foreach ($aut as $a) { if ($primeraVez) { //echo '<hr/>'; echo '<p>Cantidad de autorizantes/unidades ' . kartik\helpers\Html::badge(count($aut)) . '</p>'; $primeraVez = false; } echo DetailView::widget(['model' => $a, 'options' => ['class' => 'table table-striped table-bordered table-condensed detail-view'], 'attributes' => [['attribute' => 'id_persona', 'format' => 'raw', 'value' => Html::a($a->id_persona, Yii::$app->urlManager->createUrl(['personas/view', 'id' => $a->id_persona]), ['title' => 'Ver detalle de persona', 'target' => '_blank', 'data-pjax' => '0'])], 'persona.apellido', 'persona.nombre', 'persona.nombre2', 'id_uf']]); } ?> <?php