Commit f4e8e6b49115714df5eeb8cc582b0969a849e288

Authored by Mihail
1 parent f68e7edd

setup data picker to orders page

backend/views/cart/index.php
@@ -10,6 +10,7 @@ use kartik\date\DatePicker; @@ -10,6 +10,7 @@ use kartik\date\DatePicker;
10 10
11 $this->title = Yii::t('app', 'Заказы'); 11 $this->title = Yii::t('app', 'Заказы');
12 $this->params['breadcrumbs'][] = $this->title; 12 $this->params['breadcrumbs'][] = $this->title;
  13 +
13 ?> 14 ?>
14 <div class="cart-bills-index"> 15 <div class="cart-bills-index">
15 16
@@ -25,6 +26,13 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -25,6 +26,13 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
25 26
26 'id', 27 'id',
27 'account_id', 28 'account_id',
  29 + ['label' =>'Информация',
  30 + 'value' =>function ($data) {
  31 + $info = $data->scode . ' /n';
  32 + $info .= $data->name;
  33 + return $info;
  34 + },
  35 + ],
28 'sum', 36 'sum',
29 [ 37 [
30 'label' =>'Статус', 38 'label' =>'Статус',
@@ -34,17 +42,18 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -34,17 +42,18 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
34 'manager_name', 42 'manager_name',
35 [ 43 [
36 'label' =>'Дата', 44 'label' =>'Дата',
  45 + 'value' =>function ($data) {
  46 + return date('Y-m-d', $data->dt);
  47 + },
37 'attribute' => 'dt', 48 'attribute' => 'dt',
38 'filter' => DatePicker::widget([ 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 'type' => DatePicker::TYPE_RANGE, 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,7 +13,7 @@ use common\models\CartBillsView;
13 */ 13 */
14 class CartBillsSearch extends CartBillsView 14 class CartBillsSearch extends CartBillsView
15 { 15 {
16 - 16 +public $date_to;
17 /** 17 /**
18 * @inheritdoc 18 * @inheritdoc
19 */ 19 */
@@ -21,7 +21,7 @@ class CartBillsSearch extends CartBillsView @@ -21,7 +21,7 @@ class CartBillsSearch extends CartBillsView
21 { 21 {
22 return [ 22 return [
23 [['id', 'account_id', 'status'], 'integer'], 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,8 +50,7 @@ class CartBillsSearch extends CartBillsView
50 ]); 50 ]);
51 51
52 $this->load($params); 52 $this->load($params);
53 - //$timestamp= mktime($hours,$minutes,$seconds,$month,$day,$year);  
54 - CustomVarDamp::dumpAndDie(date_timestamp_get($params['data1'])); 53 +
55 if (!$this->validate()) { 54 if (!$this->validate()) {
56 // uncomment the following line if you do not want to return any records when validation fails 55 // uncomment the following line if you do not want to return any records when validation fails
57 // $query->where('0=1'); 56 // $query->where('0=1');
@@ -61,10 +60,20 @@ class CartBillsSearch extends CartBillsView @@ -61,10 +60,20 @@ class CartBillsSearch extends CartBillsView
61 $query->andFilterWhere([ 60 $query->andFilterWhere([
62 'id' => $this->id, 61 'id' => $this->id,
63 'account_id' => $this->account_id, 62 'account_id' => $this->account_id,
64 - 'timestamp' => $this->dt,  
65 'status_id' => $this->status, 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 // $query->andFilterWhere(['like', 'f1', $this->f1]) 77 // $query->andFilterWhere(['like', 'f1', $this->f1])
69 // ->andFilterWhere(['like', 'f2', $this->f2]) 78 // ->andFilterWhere(['like', 'f2', $this->f2])
70 // ->andFilterWhere(['like', 'f3', $this->f3]) 79 // ->andFilterWhere(['like', 'f3', $this->f3])
@@ -73,4 +82,9 @@ class CartBillsSearch extends CartBillsView @@ -73,4 +82,9 @@ class CartBillsSearch extends CartBillsView
73 82
74 return $dataProvider; 83 return $dataProvider;
75 } 84 }
  85 +
  86 + public static function findById($id){
  87 +
  88 + return CartBillsView::find()->where(['id' => $id])->one();
  89 + }
76 } 90 }
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 4 "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5 "This file is @generated automatically" 5 "This file is @generated automatically"
6 ], 6 ],
7 - "hash": "2d5c03f681f1c72d09f36e10af144465", 7 + "hash": "ce73f971f407fe869277da60d0444492",
8 "content-hash": "4c8b69eb2733ca32596e438952d2f182", 8 "content-hash": "4c8b69eb2733ca32596e438952d2f182",
9 "packages": [ 9 "packages": [
10 { 10 {
vendor/composer/installed.json
@@ -1140,57 +1140,6 @@ @@ -1140,57 +1140,6 @@
1140 ] 1140 ]
1141 }, 1141 },
1142 { 1142 {
1143 - "name": "kartik-v/yii2-widget-datepicker",  
1144 - "version": "v1.3.3",  
1145 - "version_normalized": "1.3.3.0",  
1146 - "source": {  
1147 - "type": "git",  
1148 - "url": "https://github.com/kartik-v/yii2-widget-datepicker.git",  
1149 - "reference": "368b181ef658c05707fe41dd16eee4d9ffd9da38"  
1150 - },  
1151 - "dist": {  
1152 - "type": "zip",  
1153 - "url": "https://api.github.com/repos/kartik-v/yii2-widget-datepicker/zipball/368b181ef658c05707fe41dd16eee4d9ffd9da38",  
1154 - "reference": "368b181ef658c05707fe41dd16eee4d9ffd9da38",  
1155 - "shasum": ""  
1156 - },  
1157 - "require": {  
1158 - "kartik-v/yii2-krajee-base": "~1.7"  
1159 - },  
1160 - "time": "2015-07-19 04:49:03",  
1161 - "type": "yii2-extension",  
1162 - "installation-source": "dist",  
1163 - "autoload": {  
1164 - "psr-4": {  
1165 - "kartik\\date\\": ""  
1166 - }  
1167 - },  
1168 - "notification-url": "https://packagist.org/downloads/",  
1169 - "license": [  
1170 - "BSD-3-Clause"  
1171 - ],  
1172 - "authors": [  
1173 - {  
1174 - "name": "Kartik Visweswaran",  
1175 - "email": "kartikv2@gmail.com",  
1176 - "homepage": "http://www.krajee.com/"  
1177 - }  
1178 - ],  
1179 - "description": "Enhanced Yii2 wrapper for the bootstrap datepicker plugin (sub repo split from yii2-widgets).",  
1180 - "homepage": "https://github.com/kartik-v/yii2-widget-datepicker",  
1181 - "keywords": [  
1182 - "date",  
1183 - "extension",  
1184 - "form",  
1185 - "jquery",  
1186 - "picker",  
1187 - "plugin",  
1188 - "select2",  
1189 - "widget",  
1190 - "yii2"  
1191 - ]  
1192 - },  
1193 - {  
1194 "name": "kartik-v/yii2-field-range", 1143 "name": "kartik-v/yii2-field-range",
1195 "version": "v1.3.0", 1144 "version": "v1.3.0",
1196 "version_normalized": "1.3.0.0", 1145 "version_normalized": "1.3.0.0",
@@ -1338,5 +1287,56 @@ @@ -1338,5 +1287,56 @@
1338 "yii", 1287 "yii",
1339 "yii2" 1288 "yii2"
1340 ] 1289 ]
  1290 + },
  1291 + {
  1292 + "name": "kartik-v/yii2-widget-datepicker",
  1293 + "version": "v1.3.3",
  1294 + "version_normalized": "1.3.3.0",
  1295 + "source": {
  1296 + "type": "git",
  1297 + "url": "https://github.com/kartik-v/yii2-widget-datepicker.git",
  1298 + "reference": "368b181ef658c05707fe41dd16eee4d9ffd9da38"
  1299 + },
  1300 + "dist": {
  1301 + "type": "zip",
  1302 + "url": "https://api.github.com/repos/kartik-v/yii2-widget-datepicker/zipball/368b181ef658c05707fe41dd16eee4d9ffd9da38",
  1303 + "reference": "368b181ef658c05707fe41dd16eee4d9ffd9da38",
  1304 + "shasum": ""
  1305 + },
  1306 + "require": {
  1307 + "kartik-v/yii2-krajee-base": "~1.7"
  1308 + },
  1309 + "time": "2015-07-19 04:49:03",
  1310 + "type": "yii2-extension",
  1311 + "installation-source": "dist",
  1312 + "autoload": {
  1313 + "psr-4": {
  1314 + "kartik\\date\\": ""
  1315 + }
  1316 + },
  1317 + "notification-url": "https://packagist.org/downloads/",
  1318 + "license": [
  1319 + "BSD-3-Clause"
  1320 + ],
  1321 + "authors": [
  1322 + {
  1323 + "name": "Kartik Visweswaran",
  1324 + "email": "kartikv2@gmail.com",
  1325 + "homepage": "http://www.krajee.com/"
  1326 + }
  1327 + ],
  1328 + "description": "Enhanced Yii2 wrapper for the bootstrap datepicker plugin (sub repo split from yii2-widgets).",
  1329 + "homepage": "https://github.com/kartik-v/yii2-widget-datepicker",
  1330 + "keywords": [
  1331 + "date",
  1332 + "extension",
  1333 + "form",
  1334 + "jquery",
  1335 + "picker",
  1336 + "plugin",
  1337 + "select2",
  1338 + "widget",
  1339 + "yii2"
  1340 + ]
1341 } 1341 }
1342 ] 1342 ]