index:
'fecha' => [
'attribute' => 'fecha',
'value' => 'fecha',
'headerOptions' => ['style' => 'text-align:center; width:10%; text-color:white;'],
'contentOptions' => ['style' => 'text-align:center; vertical-align:middle;'],
'format' => 'raw',
'filter' => DateRangePicker::widget([
'model' => $searchModel,
'attribute' => 'rango_fecha',
'useWithAddon' => false,
'convertFormat' => true,
'pluginOptions' => [
//'startDate' => date('01-01-2024'),
//'endDate' => date('01-01-2024'),
'autoclose' => true,
'timePicker' => true,
'locale' => ['format' => 'd-m-Y'],
'viewMode' => 'years', // Muestra la vista de años
'minViewMode' => 'years' // Permite seleccionar solo años
],
])
],
agregar estas tres variables en el modelSearch
public $rango_fecha;
public $fecha_desde;
public $fecha_hasta;
MontosIndicSearch:
[['rango_fecha'], 'filter', 'filter' => function($value) {
if (isset($value) && !empty($value)) {
$values = explode(' - ', $value);
if (count($values) == 2) {
list($this->fecha_desde, $this->fecha_hasta) = $values;
}
}
}],
y tambien agregar esto en el filter de search:
->andFilterWhere(['>=', 'fecha', $this->fecha_desde])
->andFilterWhere(['<=', 'fecha', $this->fecha_hasta]);
Comments