1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace dynamikaweb\grid; |
4
|
|
|
|
5
|
|
|
use Yii; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* DateColumn |
9
|
|
|
* |
10
|
|
|
* @property string|array $format Cell Date Format |
11
|
|
|
* |
12
|
|
|
* @property string|array $format_raw Uses when attribute not is a date |
13
|
|
|
* |
14
|
|
|
* @property string $format_filter Filter input mask |
15
|
|
|
* |
16
|
|
|
* @property string $format_filter Filter options |
17
|
|
|
* |
18
|
|
|
* @property string $format_filter Cell options |
19
|
|
|
* |
20
|
|
|
* @property string $placeholder Prompt filter option |
21
|
|
|
* |
22
|
|
|
*/ |
23
|
|
|
class DateColumn extends \yii\grid\DataColumn |
24
|
|
|
{ |
25
|
|
|
public $format = 'short'; |
26
|
|
|
|
27
|
|
|
public $format_raw = null; |
28
|
|
|
|
29
|
|
|
public $format_filter = 'dd/MM/yyyy'; |
30
|
|
|
|
31
|
|
|
public $options = []; |
32
|
|
|
|
33
|
|
|
public $filterOptions = []; |
34
|
|
|
|
35
|
|
|
public $placeholder = 'Selecione {attribute}'; |
36
|
|
|
|
37
|
|
|
public function init () |
38
|
|
|
{ |
39
|
|
|
$this->format = empty($this->format_raw)? ['date', $this->format]: $this->format_raw; |
40
|
|
|
$this->placeholder = strtr(Yii::t('app', $this->placeholder), ['{attribute}' => $this->grid->filterModel->getAttributeLabel($this->attribute)]); |
41
|
|
|
$this->filter = \yii\jui\DatePicker::widget([ |
42
|
|
|
'model'=> $this->grid->filterModel, |
43
|
|
|
'attribute' => $this->attribute, |
44
|
|
|
'language' => Yii::$app->language, |
45
|
|
|
'dateFormat' => $this->format_filter, |
46
|
|
|
'options' => array_merge(['class' => 'form-control', 'placeholder' => $this->placeholder], $this->filterOptions) |
47
|
|
|
]); |
48
|
|
|
$this->options = array_merge(['width' => '150px'], $this->options); |
49
|
|
|
|
50
|
|
|
parent::init(); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|