Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Infracciones::find()->joinWith(['concepto', 'multaUnidad']);
     $pageSize = isset($_GET['per-page']) ? $_GET['per-page'] : \Yii::$app->params['infracciones.defaultPageSize'];
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize], 'sort' => ['defaultOrder' => ['id' => SORT_DESC], 'enableMultiSort' => true]]);
     // Agregado a mano, para que incluya el ordenamiento por concepto y unidad
     $dataProvider->sort->attributes['rConcepto'] = ['asc' => ['infrac_conceptos.concepto' => SORT_ASC], 'desc' => ['infrac_conceptos.concepto' => SORT_DESC]];
     $dataProvider->sort->attributes['rUnidad'] = ['asc' => ['infrac_unidades.unidad' => SORT_ASC], 'desc' => ['infrac_unidades.unidad' => SORT_DESC]];
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['infracciones.id' => $this->id, 'id_uf' => $this->id_uf, 'id_vehiculo' => $this->id_vehiculo, 'id_persona' => $this->id_persona, 'fecha' => $this->fecSP2EN($this->fecha), 'hora' => $this->hora, 'id_concepto' => $this->rConcepto, 'id_informante' => $this->id_informante, 'notificado' => $this->notificado, 'fecha_verif' => $this->fecSP2EN($this->fecha_verif), 'verificado' => $this->verificado, 'multa_unidad' => $this->rUnidad, 'multa_monto' => str_replace(",", ".", $this->multa_monto), 'multa_pers_cant' => $this->multa_pers_cant, 'multa_pers_monto' => str_replace(",", ".", $this->multa_pers_monto), 'multa_pers_total' => str_replace(",", ".", $this->multa_pers_total), 'multa_total' => str_replace(",", ".", $this->multa_total), 'created_by' => $this->created_by, 'created_at' => $this->created_at, 'updated_by' => $this->updated_by, 'updated_at' => $this->updated_at, 'infracciones.estado' => $this->estado]);
     $query->andFilterWhere(['like', 'nro_acta', $this->nro_acta])->andFilterWhere(['like', 'lugar', $this->lugar])->andFilterWhere(['like', 'descripcion', $this->descripcion])->andFilterWhere(['like', 'foto', $this->foto])->andFilterWhere(['like', 'motivo_baja', $this->motivo_baja]);
     if (isset($params['resetFechas'])) {
         \Yii::$app->session->remove('infracFecDesde');
         \Yii::$app->session->remove('infracFecHasta');
         $this->fecdesde = null;
         $this->fechasta = null;
         unset($params['resetFechas']);
     }
     if (!empty($this->fecdesde) && !empty($this->fechasta)) {
         // cada vez que se envia el form con el rango de fechas se guardan las fechas en sesion
         \Yii::$app->session->set('infracFecDesde', $this->fecdesde);
         \Yii::$app->session->set('infracFecHasta', $this->fechasta);
         // para el between entre datetimes se debe agregar un dia mas a la fecha hasta
         $f = new \DateTime($this->fechasta);
         //$f->add(new \DateInterval('P1D'));
         $query->andFilterWhere(['between', 'fecha', $this->fecdesde, $f->format('Y-m-d')]);
     } else {
         $sfd = \Yii::$app->session->get('infracFecDesde') ? \Yii::$app->session->get('infracFecDesde') : '';
         $sfh = \Yii::$app->session->get('infracFecHasta') ? \Yii::$app->session->get('infracFecHasta') : '';
         // si todavia están en sesion las variables del rango de fechas se hace el between y se elimina created_at
         if ($sfd && $sfh) {
             // para el between entre datetimes se debe agregar un dia mas a la fecha hasta
             $f = new \DateTime(\Yii::$app->session->get('infracFecHasta'));
             //$f->add(new \DateInterval('P1D'));
             $query->andFilterWhere(['between', 'fecha', \Yii::$app->session->get('infracFecDesde'), $f->format('Y-m-d')]);
             $this->fecha = '';
         } else {
             //$query->andFilterWhere(['like', 'fecha', $this->fecha]);
         }
     }
     return $dataProvider;
 }
Пример #2
0
    return $model->informante->apellido . ' ' . $model->informante->nombre;
}], 'multaUnidad.unidad', ['attribute' => 'multa_total', 'hAlign' => 'right', 'format' => ['decimal', 2], 'pageSummary' => true], ['attribute' => 'foto', 'value' => function ($model, $index, $widget) {
    return empty($model->foto) ? 'No' : 'Si';
}]];
$toolbar = ['{export}'];
$lbl1 = 'Informe para el cobro de multas';
$lbl2 = '(' . Yii::$app->formatter->asDate($fd) . ' - ' . Yii::$app->formatter->asDate($fh) . ')';
$pdfHeader = ['L' => ['content' => Html::img(Yii::$app->homeUrl . 'images/logoreportes.png')], 'C' => ['content' => $lbl1 . ' ' . $lbl2, 'font-style' => 'B'], 'R' => ['content' => \Yii::$app->params['lblName']]];
$pdfFooter = ['L' => ['content' => \Yii::$app->params['lblName2']], 'C' => ['content' => 'página {PAGENO} de {nb}'], 'R' => ['content' => 'Fecha:{DATE d/m/Y}']];
echo "<h3>{$lbl1} {$lbl2}</h3>";
echo GridView::widget(['dataProvider' => $dataProvider, 'options' => ['id' => 'gridInfracciones'], 'columns' => $columns, 'condensed' => true, 'showPageSummary' => true, 'layout' => '{toolbar}{items}', 'export' => ['label' => 'Exportar', 'fontAwesome' => true, 'showConfirmAlert' => true, 'target' => GridView::TARGET_BLANK], 'toolbar' => $toolbar, 'exportConfig' => [GridView::PDF => ['filename' => $lbl1, 'config' => ['destination' => 'D', 'methods' => ['SetHeader' => [['odd' => $pdfHeader, 'even' => $pdfHeader]], 'SetFooter' => [['odd' => $pdfFooter, 'even' => $pdfFooter]]], 'options' => ['title' => $lbl1, 'subject' => '', 'keywords' => ''], 'contentBefore' => '', 'contentAfter' => '']], GridView::EXCEL => ['filename' => $lbl1, 'config' => ['worksheet' => $lbl1, 'cssFile' => '']], GridView::CSV => ['filename' => $lbl1, 'config' => ['colDelimiter' => ";", 'rowDelimiter' => "\r\n"]]]]);
// Detalle de reincidencias para expensas-------------------------------------------------------------
$columnsR = [['attribute' => 'concepto.concepto', 'group' => true], 'id_uf', 'cant', ['attribute' => 'tot', 'hAlign' => 'right', 'format' => ['decimal', 2]], ['label' => 'Cant.Reincidencias', 'value' => function ($m) use($fd) {
    // cuenta todas las multas para la unidad funcional desde la fecha de reinc hasta el dia anterior al periodo informado
    $fh = date('Y-m-d', mktime(0, 0, 0, date('m', strtotime($fd)), 0, date('Y', strtotime($fd))));
    $cantMultas = Infracciones::find()->where(['id_uf' => $m->id_uf, 'estado' => Infracciones::ESTADO_ACTIVO, 'id_concepto' => $m->id_concepto])->andWhere(['between', 'fecha', $m->multa_fec_reinc, $fh])->count();
    if ($cantMultas > 1) {
        $cantMultas = $cantMultas - 1;
    }
    $gfd = Yii::$app->formatter->asDate($m->multa_fec_reinc);
    $gfh = Yii::$app->formatter->asDate($fh);
    return "desde {$gfd} hasta {$gfh}: {$cantMultas}";
}]];
$toolbar = ['{export}'];
$lbl1 = 'Detalle de reincidencias';
$lbl2 = '(' . Yii::$app->formatter->asDate($fd) . ' - ' . Yii::$app->formatter->asDate($fh) . ')';
$pdfHeader = ['L' => ['content' => Html::img(Yii::$app->homeUrl . 'images/logoreportes.png')], 'C' => ['content' => $lbl1 . ' ' . $lbl2, 'font-style' => 'B'], 'R' => ['content' => \Yii::$app->params['lblName']]];
$pdfFooter = ['L' => ['content' => \Yii::$app->params['lblName2']], 'C' => ['content' => 'página {PAGENO} de {nb}'], 'R' => ['content' => 'Fecha:{DATE d/m/Y}']];
echo "<h3>{$lbl1} {$lbl2}</h3>";
echo GridView::widget(['dataProvider' => $dataProviderR, 'options' => ['id' => 'gridReinc'], 'columns' => $columnsR, 'condensed' => true, 'layout' => '{toolbar}{items}', 'export' => ['label' => 'Exportar', 'fontAwesome' => true, 'showConfirmAlert' => true, 'target' => GridView::TARGET_BLANK], 'toolbar' => $toolbar, 'exportConfig' => [GridView::PDF => ['filename' => $lbl1, 'config' => ['destination' => 'D', 'methods' => ['SetHeader' => [['odd' => $pdfHeader, 'even' => $pdfHeader]], 'SetFooter' => [['odd' => $pdfFooter, 'even' => $pdfFooter]]], 'options' => ['title' => $lbl1, 'subject' => '', 'keywords' => ''], 'contentBefore' => '', 'contentAfter' => '']], GridView::EXCEL => ['filename' => $lbl1, 'config' => ['worksheet' => $lbl1, 'cssFile' => '']], GridView::CSV => ['filename' => $lbl1, 'config' => ['colDelimiter' => ";", 'rowDelimiter' => "\r\n"]]]]);
?>
Пример #3
0
	<div class='container'>
		
		<div class='row'>

			<div class="col-md-6">

				<?php 
$imgClass = $pdf ? 'pull-right' : 'img-thumbnail pull-right';
$sinImg = Yii::$app->urlManager->createUrl('images/sinmulta.jpg');
if (!empty($model->foto)) {
    $imgFile = Yii::$app->urlManager->createUrl('images/multas/' . $model->foto);
    $imgFoto = Html::img($imgFile, ['class' => $imgClass, 'onerror' => "this.src='{$sinImg}'"]);
} else {
    $imgFoto = Html::img($sinImg, ['class' => $imgClass]);
}
echo DetailView::widget(['model' => $model, 'options' => ['class' => 'table table-striped table-bordered table-condensed detail-view'], 'attributes' => ['id', 'nro_acta', 'fecha:date', 'hora:time', 'id_uf', 'concepto.concepto', 'id_vehiculo', 'vehiculo.patente', 'vehiculo.marca', 'vehiculo.modelo', 'vehiculo.color', 'id_persona', 'persona.apellido', 'persona.nombre', 'persona.nro_doc', 'lugar', 'id_informante', 'informante.apellido', 'informante.nombre', 'descripcion', ['attribute' => 'notificado', 'value' => Infracciones::getSiNo($model->notificado)], 'fecha_verif', ['attribute' => 'verificado', 'value' => Infracciones::getSiNo($model->verificado)], 'multaUnidad.unidad', 'multa_fec_reinc:date', 'multa_monto', 'multa_pers_cant', 'multa_pers_monto', 'multa_pers_total', 'multa_total', 'userCreatedBy.username', 'created_at:datetime', 'userUpdatedBy.username', 'updated_at:datetime', ['label' => 'Estado', 'value' => Infracciones::getEstados($model->estado), 'visible' => $pdf ? false : true], ['attribute' => 'motivo_baja', 'visible' => $pdf ? false : true], ['label' => 'Foto', 'value' => $imgFoto, 'format' => 'raw', 'visible' => $pdf]]]);
?>
				
			</div>
			<div class="col-md-6">
				<?php 
if (!$pdf) {
    echo $imgFoto;
}
?>

			</div>	
		</div>
	</div>

</div>
Пример #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getInfracciones()
 {
     return $this->hasMany(Infracciones::className(), ['multa_unidad' => 'id']);
 }
Пример #5
0
if (\Yii::$app->session->get('infracFecDesde')) {
    $lbl2 = ' (' . Yii::$app->formatter->asDate(\Yii::$app->session->get('infracFecDesde')) . '-' . Yii::$app->formatter->asDate(\Yii::$app->session->get('infracFecHasta')) . ')';
} else {
    $lbl2 = '';
}
$pdfHeader = ['L' => ['content' => Html::img(Yii::$app->homeUrl . 'images/logoreportes.png')], 'C' => ['content' => $this->title . $lbl2, 'font-style' => 'B'], 'R' => ['content' => \Yii::$app->params['lblName']]];
$pdfFooter = ['L' => ['content' => \Yii::$app->params['lblName2']], 'C' => ['content' => 'página {PAGENO} de {nb}'], 'R' => ['content' => 'Fecha:{DATE d/m/Y}']];
$columns = ['id', ['attribute' => 'id_uf', 'format' => 'raw', 'value' => function ($model, $index, $widget) {
    return Html::a($model->id_uf, Yii::$app->urlManager->createUrl(['uf/view', 'id' => $model->id_uf]), ['title' => 'Ver detalle de la unidad funcional', 'target' => '_blank', 'data-pjax' => '0']);
}], ['attribute' => 'fecha', 'format' => 'date'], ['attribute' => 'hora', 'format' => 'time'], 'nro_acta', 'lugar', ['attribute' => 'rConcepto', 'value' => 'concepto.concepto', 'filter' => InfracConceptos::getLista()], 'descripcion', ['attribute' => 'notificado', 'value' => function ($model) {
    return Infracciones::getSiNo($model->notificado);
}, 'filter' => Infracciones::getSiNo()], ['attribute' => 'fecha_verif', 'format' => 'date'], ['attribute' => 'verificado', 'value' => function ($model) {
    return Infracciones::getSiNo($model->verificado);
}, 'filter' => Infracciones::getSiNo()], ['attribute' => 'rUnidad', 'value' => 'multaUnidad.unidad', 'filter' => InfracUnidades::getLista()], 'multa_total', ['attribute' => 'estado', 'value' => function ($model) {
    return Infracciones::getEstados($model->estado);
}, 'filter' => Infracciones::getEstados()], ['class' => 'kartik\\grid\\ActionColumn', 'header' => Html::a('<span class="glyphicon glyphicon-plus-sign"></span>', ['create'], ['class' => 'btn-sm btn-primary', 'title' => Yii::t('app', 'Alta de infracción/multa')]), 'template' => '{view} {comentario}', 'buttons' => ['comentario' => function ($url, $model) {
    $c = Comentarios::getComentariosByModelId($model->className(), $model->id);
    $text = '<span class="glyphicon glyphicon-copyright-mark"';
    if (!empty($c)) {
        $text .= ' style="color:#FF8000"></span>';
        $titl = 'Ingresar nuevo/Ver comentarios';
    } 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);
Пример #6
0
 /**
  * Finds the Infracciones model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Infracciones the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Infracciones::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }