Commit b4f26fcbb847c5a20caeee62ddf49fc65c28d7b6
1 parent
6c07dc8e
setup data picker to orders page
Showing
3 changed files
with
37 additions
and
14 deletions
Show diff stats
backend/views/cart/index.php
... | ... | @@ -10,6 +10,7 @@ use kartik\date\DatePicker; |
10 | 10 | |
11 | 11 | $this->title = Yii::t('app', 'Заказы'); |
12 | 12 | $this->params['breadcrumbs'][] = $this->title; |
13 | + | |
13 | 14 | ?> |
14 | 15 | <div class="cart-bills-index"> |
15 | 16 | |
... | ... | @@ -25,6 +26,13 @@ $this->params['breadcrumbs'][] = $this->title; |
25 | 26 | |
26 | 27 | 'id', |
27 | 28 | 'account_id', |
29 | + ['label' =>'Информация', | |
30 | + 'value' =>function ($data) { | |
31 | + $info = $data->scode . ' /n'; | |
32 | + $info .= $data->name; | |
33 | + return $info; | |
34 | + }, | |
35 | + ], | |
28 | 36 | 'sum', |
29 | 37 | [ |
30 | 38 | 'label' =>'Статус', |
... | ... | @@ -34,17 +42,18 @@ $this->params['breadcrumbs'][] = $this->title; |
34 | 42 | 'manager_name', |
35 | 43 | [ |
36 | 44 | 'label' =>'Дата', |
45 | + 'value' =>function ($data) { | |
46 | + return date('Y-m-d', $data->dt); | |
47 | + }, | |
37 | 48 | 'attribute' => 'dt', |
38 | 49 | 'filter' => DatePicker::widget([ |
39 | - 'name' => 'data1', | |
40 | - // 'value' => '01-Feb-2015', | |
50 | + 'model' =>$searchModel, | |
51 | + 'language' =>'ru', | |
52 | + 'size' =>'xs', | |
53 | + 'separator' =>'по', | |
54 | + 'attribute' => 'dt', | |
41 | 55 | 'type' => DatePicker::TYPE_RANGE, |
42 | - 'name2' => 'data2', | |
43 | - // 'value2' => '27-Feb-2015', | |
44 | - 'pluginOptions' => [ | |
45 | - 'autoclose'=>true, | |
46 | - 'format' => 'dd-M-yyyy' | |
47 | - ] | |
56 | + 'attribute2' => 'date_to', | |
48 | 57 | ]), |
49 | 58 | ], |
50 | 59 | ... | ... |
common/models/CartBillsSearch.php
... | ... | @@ -13,7 +13,7 @@ use common\models\CartBillsView; |
13 | 13 | */ |
14 | 14 | class CartBillsSearch extends CartBillsView |
15 | 15 | { |
16 | - | |
16 | +public $date_to; | |
17 | 17 | /** |
18 | 18 | * @inheritdoc |
19 | 19 | */ |
... | ... | @@ -21,7 +21,7 @@ class CartBillsSearch extends CartBillsView |
21 | 21 | { |
22 | 22 | return [ |
23 | 23 | [['id', 'account_id', 'status'], 'integer'], |
24 | - [['data1,data2'], 'safe'], | |
24 | + [['dt', 'date_to'], 'string', 'max' => 10], | |
25 | 25 | ]; |
26 | 26 | } |
27 | 27 | |
... | ... | @@ -50,8 +50,7 @@ class CartBillsSearch extends CartBillsView |
50 | 50 | ]); |
51 | 51 | |
52 | 52 | $this->load($params); |
53 | - //$timestamp= mktime($hours,$minutes,$seconds,$month,$day,$year); | |
54 | - CustomVarDamp::dumpAndDie(date_timestamp_get($params['data1'])); | |
53 | + | |
55 | 54 | if (!$this->validate()) { |
56 | 55 | // uncomment the following line if you do not want to return any records when validation fails |
57 | 56 | // $query->where('0=1'); |
... | ... | @@ -61,10 +60,20 @@ class CartBillsSearch extends CartBillsView |
61 | 60 | $query->andFilterWhere([ |
62 | 61 | 'id' => $this->id, |
63 | 62 | 'account_id' => $this->account_id, |
64 | - 'timestamp' => $this->dt, | |
65 | 63 | 'status_id' => $this->status, |
66 | 64 | ]); |
67 | 65 | |
66 | + if($this->dt !== null || $this->date_to !== null){ | |
67 | + $date_from = mktime(0,0,0,(int)substr($this->dt,4,2),(int)substr($this->dt,1,2),(int)substr($this->dt,7,4)); | |
68 | + $date_to = mktime(23,59,59,(int)substr($this->date_to,4,2),(int)substr($this->date_to,1,2),(int)substr($this->date_to,7,4)); | |
69 | + | |
70 | + $query->andFilterWhere([ | |
71 | + 'between', 'dt', $date_from, $date_to | |
72 | + ]); | |
73 | + } | |
74 | + | |
75 | + | |
76 | + | |
68 | 77 | // $query->andFilterWhere(['like', 'f1', $this->f1]) |
69 | 78 | // ->andFilterWhere(['like', 'f2', $this->f2]) |
70 | 79 | // ->andFilterWhere(['like', 'f3', $this->f3]) |
... | ... | @@ -73,4 +82,9 @@ class CartBillsSearch extends CartBillsView |
73 | 82 | |
74 | 83 | return $dataProvider; |
75 | 84 | } |
85 | + | |
86 | + public static function findById($id){ | |
87 | + | |
88 | + return CartBillsView::find()->where(['id' => $id])->one(); | |
89 | + } | |
76 | 90 | } | ... | ... |
composer.lock
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", |
5 | 5 | "This file is @generated automatically" |
6 | 6 | ], |
7 | - "hash": "2d5c03f681f1c72d09f36e10af144465", | |
7 | + "hash": "ce73f971f407fe869277da60d0444492", | |
8 | 8 | "content-hash": "4c8b69eb2733ca32596e438952d2f182", |
9 | 9 | "packages": [ |
10 | 10 | { | ... | ... |