Filtros

Versión 5 (Guillermo Zdanowicz, 22/03/2016 23:49)

1 1 Guillermo Zdanowicz
h1. Filtros
2 1 Guillermo Zdanowicz
3 1 Guillermo Zdanowicz
en seccion required del composer
4 1 Guillermo Zdanowicz
5 1 Guillermo Zdanowicz
<pre>
6 1 Guillermo Zdanowicz
“kartik-v/yii2-date-range”: “dev-master”
7 1 Guillermo Zdanowicz
</pre>
8 2 Guillermo Zdanowicz
9 2 Guillermo Zdanowicz
10 2 Guillermo Zdanowicz
en models/comprasSearch.php
11 2 Guillermo Zdanowicz
12 4 Guillermo Zdanowicz
<pre>
13 4 Guillermo Zdanowicz
Allí, deberemos agregar una nueva propiedad pública:
14 5 Guillermo Zdanowicz
</pre>
15 5 Guillermo Zdanowicz
*$public $rango_fecha;*
16 5 Guillermo Zdanowicz
<pre>
17 4 Guillermo Zdanowicz
Estamos declarando la variable que contendrá el rango de fechas a partir del cual realizaremos la búsqueda.
18 4 Guillermo Zdanowicz
19 4 Guillermo Zdanowicz
Recordemos, que para que este nuevo atributo pueda ser usado en las búsquedas, debemos declararlo como “safe”.
20 4 Guillermo Zdanowicz
</pre>
21 3 Guillermo Zdanowicz
22 2 Guillermo Zdanowicz
<pre>
23 2 Guillermo Zdanowicz
    public function rules()
24 2 Guillermo Zdanowicz
25 2 Guillermo Zdanowicz
  [['descripcion', 'fecha_factura', 'fecha_recepcion', 'imputacion_compra', 'comprobante', 'modo_pago', 'rango_fecha', 'fecha_desde', 'fecha_hasta'], 'safe'],
26 2 Guillermo Zdanowicz
</pre>
27 2 Guillermo Zdanowicz
28 2 Guillermo Zdanowicz
en /views/compras/index.php
29 2 Guillermo Zdanowicz
30 2 Guillermo Zdanowicz
<pre>
31 2 Guillermo Zdanowicz
use kartik\daterange\DateRangePicker;
32 2 Guillermo Zdanowicz
33 2 Guillermo Zdanowicz
</pre>
34 2 Guillermo Zdanowicz
<pre>
35 2 Guillermo Zdanowicz
[
36 2 Guillermo Zdanowicz
            'attribute' => 'rango_fecha',
37 2 Guillermo Zdanowicz
            'value' => 'fecha',
38 2 Guillermo Zdanowicz
            'format'=>'raw',
39 2 Guillermo Zdanowicz
            'options' => ['style' => 'width: 25%;'],
40 2 Guillermo Zdanowicz
            'filter' => DateRangePicker::widget([
41 2 Guillermo Zdanowicz
                'model' => $searchModel,
42 2 Guillermo Zdanowicz
                'attribute' => 'rango_fecha',
43 2 Guillermo Zdanowicz
                'useWithAddon'=>false,
44 2 Guillermo Zdanowicz
                'convertFormat'=>true,
45 2 Guillermo Zdanowicz
                'pluginOptions'=>[
46 2 Guillermo Zdanowicz
                    'locale'=>['format'=>'Y-m-d']
47 2 Guillermo Zdanowicz
                ],
48 2 Guillermo Zdanowicz
            ])
49 2 Guillermo Zdanowicz
        ],
50 2 Guillermo Zdanowicz
</pre>
Redmine Appliance - Powered by TurnKey Linux