コード例 #1
0
ファイル: VehiculosSearch.php プロジェクト: ibergonzi/country
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Vehiculos::find();
     $pageSize = isset($_GET['per-page']) ? $_GET['per-page'] : \Yii::$app->params['vehiculos.defaultPageSize'];
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize], 'sort' => ['defaultOrder' => ['id' => SORT_DESC], 'enableMultiSort' => true]]);
     $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(['vehiculos.id' => $this->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', 'modelo', $this->modelo])->andFilterWhere(['like', 'patente', $this->patente])->andFilterWhere(['like', 'marca', $this->marca])->andFilterWhere(['like', 'color', $this->color])->andFilterWhere(['like', 'motivo_baja', $this->motivo_baja]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: Accesos.php プロジェクト: ibergonzi/country
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIngVehiculo()
 {
     return $this->hasOne(Vehiculos::className(), ['id' => 'ing_id_vehiculo'])->from(Vehiculos::tableName() . ' ving');
 }
コード例 #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;
    }
コード例 #4
0
 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]);
 }
コード例 #5
0
ファイル: vehiculoslist.php プロジェクト: ibergonzi/country
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use frontend\models\Vehiculos;
/* @var $this yii\web\View */
/* @var $searchModel frontend\models\VehiculosSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Vehiculos');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="vehiculos-index">

<?php 
$columns = ['id', 'patente', 'marca', 'modelo', 'color', ['attribute' => 'estado', 'value' => function ($data) {
    return Vehiculos::getEstados($data->estado);
}]];
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => $columns, 'layout' => '{items}{pager}']);
?>


</div>
コード例 #6
0
ファイル: _formajax.php プロジェクト: ibergonzi/country
?>

				<?php 
echo $form->field($model, 'patente')->textInput(['maxlength' => true, 'style' => 'text-transform: uppercase', 'autofocus' => true]);
?>

				<?php 
echo $form->field($model, 'marca')->widget(AutoComplete::className(), ['model' => $model, 'attribute' => 'marca', 'options' => ['style' => 'text-transform: uppercase', 'class' => 'form-control', 'max-height' => '100px', 'overflow-y' => 'auto', 'overflow-x' => 'hidden', 'z-index' => '5000'], 'clientOptions' => ['source' => Vehiculos::getMarcasVehiculos(), 'minLength' => 1, 'appendTo' => '#form-vehiculonuevo-ajax']]);
?>

				<?php 
echo $form->field($model, 'modelo')->widget(AutoComplete::className(), ['model' => $model, 'attribute' => 'modelo', 'options' => ['style' => 'text-transform: uppercase', 'class' => 'form-control', 'max-height' => '100px', 'overflow-y' => 'auto', 'overflow-x' => 'hidden', 'z-index' => '5000'], 'clientOptions' => ['source' => Vehiculos::getModelosVehiculos(), 'minLength' => 1, 'appendTo' => '#form-vehiculonuevo-ajax']]);
?>

				<?php 
echo $form->field($model, 'color')->widget(AutoComplete::className(), ['model' => $model, 'attribute' => 'color', 'options' => ['style' => 'text-transform: uppercase', 'class' => 'form-control', 'max-height' => '100px', 'overflow-y' => 'auto', 'overflow-x' => 'hidden', 'z-index' => '5000'], 'clientOptions' => ['source' => Vehiculos::getColoresVehiculos(), 'minLength' => 1, 'appendTo' => '#form-vehiculonuevo-ajax']]);
?>
				
				<?php 
echo $form->field($model, 'estado')->hiddenInput()->label(false);
?>


				<div class="form-group">
					<?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
				</div>

				<?php 
ActiveForm::end();
コード例 #7
0
ファイル: _form.php プロジェクト: ibergonzi/country
?>

    <?php 
echo $form->field($model, 'patente')->textInput(['maxlength' => true, 'style' => 'text-transform: uppercase']);
?>

    <?php 
echo $form->field($model, 'marca')->widget(AutoComplete::className(), ['model' => $model, 'attribute' => 'marca', 'options' => ['style' => 'text-transform: uppercase', 'class' => 'form-control', 'max-height' => '100px', 'overflow-y' => 'auto', 'overflow-x' => 'hidden'], 'clientOptions' => ['source' => Vehiculos::getMarcasVehiculos()]]);
?>

     <?php 
echo $form->field($model, 'modelo')->widget(AutoComplete::className(), ['model' => $model, 'attribute' => 'modelo', 'options' => ['style' => 'text-transform: uppercase', 'class' => 'form-control', 'max-height' => '100px', 'overflow-y' => 'auto', 'overflow-x' => 'hidden'], 'clientOptions' => ['source' => Vehiculos::getModelosVehiculos()]]);
?>

     <?php 
echo $form->field($model, 'color')->widget(AutoComplete::className(), ['model' => $model, 'attribute' => 'color', 'options' => ['style' => 'text-transform: uppercase', 'class' => 'form-control', 'max-height' => '100px', 'overflow-y' => 'auto', 'overflow-x' => 'hidden'], 'clientOptions' => ['source' => Vehiculos::getColoresVehiculos()]]);
?>
    
    <?php 
echo $form->field($model, 'estado')->hiddenInput()->label(false);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
コード例 #8
0
ファイル: Infracciones.php プロジェクト: ibergonzi/country
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getVehiculo()
 {
     return $this->hasOne(Vehiculos::className(), ['id' => 'id_vehiculo']);
 }
コード例 #9
0
 public function actionVehiculoslist($q = null, $id = null)
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $out = ['results' => ['id' => '', 'text' => '']];
     if (!is_null($q)) {
         $q = str_replace(' ', '%', $q);
         $sp = 'CALL vehiculos_busca(:query)';
         $command = Yii::$app->db->createCommand($sp);
         $q = trim($q);
         $command->bindParam(":query", $q);
         $data = $command->queryAll();
         // el command devuelve un array de array con forma id=>n,text=>''
         // se recorre todo el array, se detecta el key id y con su valor se busca el vehiculo
         // y se agrega a un nuevo array para despues ordenarlo por text y devolverlo
         $aux = ['id' => '', 'text' => ''];
         foreach ($data as $cadauno) {
             foreach ($cadauno as $key => $valor) {
                 if ($key == 'id') {
                     $t = Vehiculos::formateaVehiculoSelect2($valor);
                     $aux[] = ['id' => $valor, 'text' => $t];
                 }
             }
         }
         asort($aux);
         $out['results'] = array_values($aux);
     } elseif ($id > 0) {
         $out['results'] = ['id' => $id, 'text' => Vehiculos::formateaVehiculoSelect2($id)];
     }
     return $out;
 }
コード例 #10
0
ファイル: Vehiculos.php プロジェクト: ibergonzi/country
 public static function formateaVehiculoSelect2($id)
 {
     $p = Vehiculos::findOne($id);
     $r = $p->patente . ' ' . $p->marca . ' ' . $p->modelo . ' ' . $p->color . ' (' . $id . ')';
     return $r;
 }
コード例 #11
0
ファイル: view.php プロジェクト: ibergonzi/country
if (\Yii::$app->user->can('accederConsAccesos')) {
    if (isset($model->ultIngreso->id)) {
        echo ' ' . Html::a('Ult.Ingreso', ['accesos/view', 'id' => $model->ultIngreso->id], ['class' => 'btn btn-default', 'title' => 'Ver último ingreso']);
    }
}
if ($model->id !== \Yii::$app->params['sinVehiculo.id'] && $model->id !== \Yii::$app->params['bicicleta.id'] && $model->id !== \Yii::$app->params['generico.id']) {
    echo ' ' . Html::a('Personas', ['lista-personas', 'id_vehiculo' => $model->id], ['class' => 'btn btn-default', 'title' => 'Personas que utilizaron el vehiculo', 'onclick' => '$.ajax({
				type     :"POST",
				cache    : false,
				url  : $(this).attr("href"),
				success  : function(response) {
							if (response=="notFound") {return false;}
							$("#divpersonas").html(response);
							$("#modalpersonas").modal("show");
							}
			});
			return false;']);
}
echo '</p>';
?>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'patente', 'marca', 'modelo', 'color', 'userCreatedBy.username', 'created_at:datetime', 'userUpdatedBy.username', 'updated_at:datetime', ['label' => 'Estado', 'value' => Vehiculos::getEstados($model->estado)], 'motivo_baja']]);
?>
	<?php 
Modal::begin(['id' => 'modalpersonas', 'header' => '<span class="btn-warning">&nbsp;Personas que usaron el vehiculo&nbsp;</span>']);
echo '<div id="divpersonas"></div>';
Modal::end();
?>
</div>