Commit 28b51b308e7ce68791676e10f8962d1e6ac841ca
1 parent
93c49762
-Order module bug fixes
Showing
5 changed files
with
218 additions
and
159 deletions
Show diff stats
controllers/OrderController.php
@@ -139,8 +139,10 @@ | @@ -139,8 +139,10 @@ | ||
139 | public function actionDeleteProduct($id) | 139 | public function actionDeleteProduct($id) |
140 | { | 140 | { |
141 | $model = OrderProduct::findOne($id); | 141 | $model = OrderProduct::findOne($id); |
142 | + $model->removed = true; | ||
142 | $orderId = $model->order_id; | 143 | $orderId = $model->order_id; |
143 | - if ($model->delete()) { | 144 | + if ($model->save()) { |
145 | + $model->order->totalRecount(); | ||
144 | return $this->actionUpdate($orderId); | 146 | return $this->actionUpdate($orderId); |
145 | } | 147 | } |
146 | } | 148 | } |
@@ -156,7 +158,7 @@ | @@ -156,7 +158,7 @@ | ||
156 | $count = 1; | 158 | $count = 1; |
157 | } | 159 | } |
158 | $productVariant = ProductVariant::findOne($id); | 160 | $productVariant = ProductVariant::findOne($id); |
159 | - | 161 | + |
160 | $model = OrderProduct::find() | 162 | $model = OrderProduct::find() |
161 | ->where( | 163 | ->where( |
162 | [ | 164 | [ |
@@ -186,6 +188,7 @@ | @@ -186,6 +188,7 @@ | ||
186 | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | 188 | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; |
187 | 189 | ||
188 | if ($model->save()) { | 190 | if ($model->save()) { |
191 | + $model->order->totalRecount(); | ||
189 | return [ 'status' => 'success' ]; | 192 | return [ 'status' => 'success' ]; |
190 | } else { | 193 | } else { |
191 | return [ 'status' => 'fail' ]; | 194 | return [ 'status' => 'fail' ]; |
models/Order.php
@@ -18,6 +18,7 @@ | @@ -18,6 +18,7 @@ | ||
18 | * @property integer $deleted_at | 18 | * @property integer $deleted_at |
19 | * @property integer $deadline | 19 | * @property integer $deadline |
20 | * @property boolean $wasted | 20 | * @property boolean $wasted |
21 | + * @property string $delivery_cost | ||
21 | * @property integer $reason | 22 | * @property integer $reason |
22 | * @property string $check | 23 | * @property string $check |
23 | * @property string $sms | 24 | * @property string $sms |
@@ -165,6 +166,7 @@ | @@ -165,6 +166,7 @@ | ||
165 | 'status', | 166 | 'status', |
166 | 'check', | 167 | 'check', |
167 | 'sms', | 168 | 'sms', |
169 | + 'delivery_cost', | ||
168 | ], | 170 | ], |
169 | 'string', | 171 | 'string', |
170 | 'max' => 255, | 172 | 'max' => 255, |
@@ -204,19 +206,20 @@ | @@ -204,19 +206,20 @@ | ||
204 | public function attributeLabels() | 206 | public function attributeLabels() |
205 | { | 207 | { |
206 | return [ | 208 | return [ |
207 | - 'name' => Yii::t('app', 'order_name'), | ||
208 | - 'phone' => Yii::t('app', 'order_phone'), | ||
209 | - 'email' => Yii::t('app', 'order_email'), | ||
210 | - 'comment' => Yii::t('app', 'order_comment'), | ||
211 | - 'created_at' => Yii::t('app', 'Дата добавления'), | ||
212 | - 'updated_at' => Yii::t('app', 'Дата обновления'), | ||
213 | - 'deleted_at' => Yii::t('app', 'Дата удаления'), | ||
214 | - 'deadline' => Yii::t('app', 'Дедлайн'), | ||
215 | - 'reason' => Yii::t('app', 'Причина'), | ||
216 | - 'check' => Yii::t('app', 'Чек'), | ||
217 | - 'sms' => Yii::t('app', 'СМС'), | ||
218 | - 'consignment' => Yii::t('app', 'Номер накладной'), | ||
219 | - 'manager_id' => Yii::t('app', 'Менеджер'), | 209 | + 'name' => Yii::t('app', 'order_name'), |
210 | + 'phone' => Yii::t('app', 'order_phone'), | ||
211 | + 'email' => Yii::t('app', 'order_email'), | ||
212 | + 'comment' => Yii::t('app', 'order_comment'), | ||
213 | + 'created_at' => Yii::t('app', 'Дата добавления'), | ||
214 | + 'updated_at' => Yii::t('app', 'Дата обновления'), | ||
215 | + 'deleted_at' => Yii::t('app', 'Дата удаления'), | ||
216 | + 'deadline' => Yii::t('app', 'Дедлайн'), | ||
217 | + 'reason' => Yii::t('app', 'Причина'), | ||
218 | + 'check' => Yii::t('app', 'Чек'), | ||
219 | + 'sms' => Yii::t('app', 'СМС'), | ||
220 | + 'consignment' => Yii::t('app', 'Номер накладной'), | ||
221 | + 'manager_id' => Yii::t('app', 'Менеджер'), | ||
222 | + 'delivery_cost' => Yii::t('app', 'Стоимость доставки'), | ||
220 | ]; | 223 | ]; |
221 | } | 224 | } |
222 | 225 | ||
@@ -308,4 +311,16 @@ | @@ -308,4 +311,16 @@ | ||
308 | } | 311 | } |
309 | } | 312 | } |
310 | } | 313 | } |
314 | + | ||
315 | + public function totalRecount() | ||
316 | + { | ||
317 | + $products = $this->products; | ||
318 | + $newTotal = 0; | ||
319 | + foreach ($products as $product) { | ||
320 | + if ($product->removed) continue; | ||
321 | + $newTotal += $product->count * $product->price; | ||
322 | + } | ||
323 | + $this->total = $newTotal; | ||
324 | + $this->save(); | ||
325 | + } | ||
311 | } | 326 | } |
312 | \ No newline at end of file | 327 | \ No newline at end of file |
models/OrderProduct.php
@@ -21,6 +21,7 @@ | @@ -21,6 +21,7 @@ | ||
21 | * @property int $count | 21 | * @property int $count |
22 | * @property double $sum_cost | 22 | * @property double $sum_cost |
23 | * @property Order $order | 23 | * @property Order $order |
24 | + * @property boolean $removed | ||
24 | * @property ProductVariant $productVariant | 25 | * @property ProductVariant $productVariant |
25 | * @package artweb\artbox\ecommerce\models | 26 | * @package artweb\artbox\ecommerce\models |
26 | */ | 27 | */ |
@@ -47,7 +48,10 @@ | @@ -47,7 +48,10 @@ | ||
47 | 'required', | 48 | 'required', |
48 | ], | 49 | ], |
49 | [ | 50 | [ |
50 | - [ 'return' ], | 51 | + [ |
52 | + 'return', | ||
53 | + 'removed', | ||
54 | + ], | ||
51 | 'boolean', | 55 | 'boolean', |
52 | ], | 56 | ], |
53 | [ | 57 | [ |
views/order/_form.php
@@ -23,8 +23,11 @@ | @@ -23,8 +23,11 @@ | ||
23 | * @var Order $model | 23 | * @var Order $model |
24 | * @var ActiveForm $form | 24 | * @var ActiveForm $form |
25 | * @var ActiveDataProvider $dataProvider | 25 | * @var ActiveDataProvider $dataProvider |
26 | + * @var User $user | ||
26 | */ | 27 | */ |
27 | 28 | ||
29 | + $user = \Yii::$app->user->identity; | ||
30 | + | ||
28 | $js = <<< JS | 31 | $js = <<< JS |
29 | $(document).on('submit', '#add-product-form', function(e) { | 32 | $(document).on('submit', '#add-product-form', function(e) { |
30 | e.preventDefault(); | 33 | e.preventDefault(); |
@@ -119,17 +122,20 @@ JS; | @@ -119,17 +122,20 @@ JS; | ||
119 | ) ?> | 122 | ) ?> |
120 | 123 | ||
121 | <?php | 124 | <?php |
122 | - echo $form->field($model, 'pay') | ||
123 | - ->widget( | ||
124 | - SwitchInput::className(), | ||
125 | - [ | ||
126 | - 'name' => 'pay', | ||
127 | - 'pluginOptions' => [ | ||
128 | - 'onText' => \Yii::t('app', 'Оплачено'), | ||
129 | - 'offText' => \Yii::t('app', 'Не оплачено'), | ||
130 | - ], | ||
131 | - ] | ||
132 | - ); ?> | 125 | + if ($user->isAdmin()) { |
126 | + echo $form->field($model, 'pay') | ||
127 | + ->widget( | ||
128 | + SwitchInput::className(), | ||
129 | + [ | ||
130 | + 'name' => 'pay', | ||
131 | + 'pluginOptions' => [ | ||
132 | + 'onText' => \Yii::t('app', 'Оплачено'), | ||
133 | + 'offText' => \Yii::t('app', 'Не оплачено'), | ||
134 | + ], | ||
135 | + ] | ||
136 | + ); | ||
137 | + } | ||
138 | + ?> | ||
133 | 139 | ||
134 | <?= $form->field($model, 'reason') | 140 | <?= $form->field($model, 'reason') |
135 | ->dropDownList( | 141 | ->dropDownList( |
@@ -151,11 +157,13 @@ JS; | @@ -151,11 +157,13 @@ JS; | ||
151 | 157 | ||
152 | <?= $form->field($model, 'name') ?> | 158 | <?= $form->field($model, 'name') ?> |
153 | 159 | ||
154 | - <?= $form->field($model, 'phone') ?> | 160 | + <?= $form->field($model, 'phone') |
161 | + ->textInput([ 'readonly' => $user->isAdmin() ? false : true ]) ?> | ||
155 | 162 | ||
156 | <?= $form->field($model, 'phone2') ?> | 163 | <?= $form->field($model, 'phone2') ?> |
157 | 164 | ||
158 | - <?= $form->field($model, 'email') ?> | 165 | + <?= $form->field($model, 'email') |
166 | + ->textInput([ 'readonly' => $user->isAdmin() ? false : true ]) ?> | ||
159 | 167 | ||
160 | <?= $form->field( | 168 | <?= $form->field( |
161 | $model, | 169 | $model, |
@@ -180,7 +188,7 @@ JS; | @@ -180,7 +188,7 @@ JS; | ||
180 | 188 | ||
181 | <?php | 189 | <?php |
182 | 190 | ||
183 | - if (\Yii::$app->user->identity->isAdmin()) { | 191 | + if ($user->isAdmin()) { |
184 | echo $form->field($model, 'manager_id') | 192 | echo $form->field($model, 'manager_id') |
185 | ->dropDownList( | 193 | ->dropDownList( |
186 | ArrayHelper::map( | 194 | ArrayHelper::map( |
@@ -306,6 +314,8 @@ JS; | @@ -306,6 +314,8 @@ JS; | ||
306 | <?= $form->field($model, 'check') ?> | 314 | <?= $form->field($model, 'check') ?> |
307 | 315 | ||
308 | <?= $form->field($model, 'sms') ?> | 316 | <?= $form->field($model, 'sms') ?> |
317 | + | ||
318 | + <?= $form->field($model, 'delivery_cost') ?> | ||
309 | 319 | ||
310 | </div> | 320 | </div> |
311 | </div> | 321 | </div> |
@@ -321,6 +331,13 @@ JS; | @@ -321,6 +331,13 @@ JS; | ||
321 | echo GridView::widget( | 331 | echo GridView::widget( |
322 | [ | 332 | [ |
323 | 'dataProvider' => $dataProvider, | 333 | 'dataProvider' => $dataProvider, |
334 | + 'rowOptions' => function($model) { | ||
335 | + if ($model->removed) { | ||
336 | + return [ 'class' => 'danger' ]; | ||
337 | + } else { | ||
338 | + return []; | ||
339 | + } | ||
340 | + }, | ||
324 | 'layout' => '{items}{pager}', | 341 | 'layout' => '{items}{pager}', |
325 | 'columns' => [ | 342 | 'columns' => [ |
326 | 'id', | 343 | 'id', |
@@ -356,10 +373,10 @@ JS; | @@ -356,10 +373,10 @@ JS; | ||
356 | 'class' => 'kartik\grid\EditableColumn', | 373 | 'class' => 'kartik\grid\EditableColumn', |
357 | 'attribute' => 'booking', | 374 | 'attribute' => 'booking', |
358 | 'editableOptions' => [ | 375 | 'editableOptions' => [ |
359 | - 'header' => \Yii::t('app', 'Бронь'), | ||
360 | - 'inputType' => kartik\editable\Editable::INPUT_TEXT, | ||
361 | - 'options' => [ | ||
362 | - 'class' => 'booking-typeahead', | 376 | + 'header' => \Yii::t('app', 'Бронь'), |
377 | + 'inputType' => kartik\editable\Editable::INPUT_TEXT, | ||
378 | + 'options' => [ | ||
379 | + 'class' => 'booking-typeahead', | ||
363 | 'pluginOptions' => [ | 380 | 'pluginOptions' => [ |
364 | 'min' => 0, | 381 | 'min' => 0, |
365 | 'max' => 20, | 382 | 'max' => 20, |
@@ -378,10 +395,10 @@ JS; | @@ -378,10 +395,10 @@ JS; | ||
378 | 'class' => 'kartik\grid\EditableColumn', | 395 | 'class' => 'kartik\grid\EditableColumn', |
379 | 'attribute' => 'status', | 396 | 'attribute' => 'status', |
380 | 'editableOptions' => [ | 397 | 'editableOptions' => [ |
381 | - 'header' => \Yii::t('app', 'Статус'), | ||
382 | - 'inputType' => kartik\editable\Editable::INPUT_TEXT, | ||
383 | - 'options' => [ | ||
384 | - 'class' => 'status-typeahead', | 398 | + 'header' => \Yii::t('app', 'Статус'), |
399 | + 'inputType' => kartik\editable\Editable::INPUT_TEXT, | ||
400 | + 'options' => [ | ||
401 | + 'class' => 'status-typeahead', | ||
385 | 'pluginOptions' => [ | 402 | 'pluginOptions' => [ |
386 | 'min' => 0, | 403 | 'min' => 0, |
387 | 'max' => 20, | 404 | 'max' => 20, |
@@ -414,19 +431,23 @@ JS; | @@ -414,19 +431,23 @@ JS; | ||
414 | 'template' => '{delete}', | 431 | 'template' => '{delete}', |
415 | 'buttons' => [ | 432 | 'buttons' => [ |
416 | 'delete' => function($url, $model) { | 433 | 'delete' => function($url, $model) { |
417 | - return Html::a( | ||
418 | - Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-trash' ]), | ||
419 | - [ | ||
420 | - 'delete-product', | ||
421 | - 'id' => $model->id, | ||
422 | - ], | ||
423 | - [ | ||
424 | - 'data' => [ | ||
425 | - 'confirm' => 'Вы уверены, что хотите удалить этот элемент?', | ||
426 | - 'method' => 'POST', | 434 | + if ($model->removed) { |
435 | + return ''; | ||
436 | + } else { | ||
437 | + return Html::a( | ||
438 | + Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-trash' ]), | ||
439 | + [ | ||
440 | + 'delete-product', | ||
441 | + 'id' => $model->id, | ||
427 | ], | 442 | ], |
428 | - ] | ||
429 | - ); | 443 | + [ |
444 | + 'data' => [ | ||
445 | + 'confirm' => 'Вы уверены, что хотите удалить этот элемент?', | ||
446 | + 'method' => 'POST', | ||
447 | + ], | ||
448 | + ] | ||
449 | + ); | ||
450 | + } | ||
430 | }, | 451 | }, |
431 | ], | 452 | ], |
432 | ], | 453 | ], |
views/order/index.php
@@ -60,116 +60,122 @@ JS; | @@ -60,116 +60,122 @@ JS; | ||
60 | ) ?> | 60 | ) ?> |
61 | 61 | ||
62 | </p> | 62 | </p> |
63 | - | ||
64 | -<?php | ||
65 | - echo $searchForm->field($searchModel, 'label') | ||
66 | - ->widget( | ||
67 | - Select2::className(), | ||
68 | - [ | ||
69 | - 'data' => Label::find() | ||
70 | - ->joinWith('lang') | ||
71 | - ->select( | ||
72 | - [ | ||
73 | - 'CONCAT(order_label.label,order_label_lang.title) AS name', | ||
74 | - 'id', | ||
75 | - ] | ||
76 | - ) | ||
77 | - ->indexBy('id') | ||
78 | - ->asArray() | ||
79 | - ->column(), | ||
80 | - 'options' => [ 'placeholder' => 'Select a state ...' ], | ||
81 | - 'pluginOptions' => [ | ||
82 | - 'allowClear' => true, | ||
83 | - 'multiple' => true, | ||
84 | - ], | ||
85 | - ] | ||
86 | - ); | ||
87 | -?> | ||
88 | -<br> | ||
89 | -<?php | ||
90 | - echo $searchForm->field($searchModel, 'delivery') | ||
91 | - ->widget( | ||
92 | - Select2::className(), | ||
93 | - [ | ||
94 | - 'data' => Delivery::find() | ||
95 | - ->joinWith('lang') | ||
96 | - ->select('order_delivery_lang.title, id') | ||
97 | - ->indexBy('id') | ||
98 | - ->asArray() | ||
99 | - ->column(), | ||
100 | - 'options' => [ 'placeholder' => 'Select a state ...' ], | ||
101 | - 'pluginOptions' => [ | ||
102 | - 'allowClear' => true, | ||
103 | - 'multiple' => true, | ||
104 | - ], | ||
105 | - ] | ||
106 | - ); | ||
107 | -?> | ||
108 | - | ||
109 | -<?php | ||
110 | - $query = new JsExpression( | ||
111 | - 'function(params) { return {q:params.term}; }' | ||
112 | - ); | ||
113 | - echo $searchForm->field($searchModel, 'sku') | ||
114 | - ->widget( | ||
115 | - Select2::className(), | ||
116 | - [ | ||
117 | - 'options' => [ 'placeholder' => 'Search for a product ...' ], | ||
118 | - 'pluginOptions' => [ | ||
119 | - 'allowClear' => true, | ||
120 | - 'minimumInputLength' => 3, | ||
121 | - 'language' => [ | ||
122 | - 'errorLoading' => new JsExpression( | ||
123 | - "function () { return 'Waiting for results...'; }" | ||
124 | - ), | ||
125 | - ], | ||
126 | - 'ajax' => [ | ||
127 | - 'url' => \yii\helpers\Url::to([ 'find-product' ]), | ||
128 | - 'dataType' => 'json', | ||
129 | - 'data' => $query, | ||
130 | - ], | ||
131 | - 'escapeMarkup' => new JsExpression( | ||
132 | - 'function (markup) { return markup; }' | ||
133 | - ), | ||
134 | - 'templateResult' => new JsExpression( | ||
135 | - 'function(data) { return data.sku; }' | ||
136 | - ), | ||
137 | - 'templateSelection' => new JsExpression( | ||
138 | - 'function (data) { | 63 | +<div class="row"> |
64 | + <div class="col-md-4"> | ||
65 | + <?php | ||
66 | + echo $searchForm->field($searchModel, 'label') | ||
67 | + ->widget( | ||
68 | + Select2::className(), | ||
69 | + [ | ||
70 | + 'data' => Label::find() | ||
71 | + ->joinWith('lang') | ||
72 | + ->select( | ||
73 | + [ | ||
74 | + 'CONCAT(order_label.label,order_label_lang.title) AS name', | ||
75 | + 'id', | ||
76 | + ] | ||
77 | + ) | ||
78 | + ->indexBy('id') | ||
79 | + ->asArray() | ||
80 | + ->column(), | ||
81 | + 'options' => [ 'placeholder' => 'Select a state ...' ], | ||
82 | + 'pluginOptions' => [ | ||
83 | + 'allowClear' => true, | ||
84 | + 'multiple' => true, | ||
85 | + ], | ||
86 | + ] | ||
87 | + ); | ||
88 | + ?> | ||
89 | + <?php | ||
90 | + echo $searchForm->field($searchModel, 'delivery') | ||
91 | + ->widget( | ||
92 | + Select2::className(), | ||
93 | + [ | ||
94 | + 'data' => Delivery::find() | ||
95 | + ->joinWith('lang') | ||
96 | + ->select('order_delivery_lang.title, id') | ||
97 | + ->indexBy('id') | ||
98 | + ->asArray() | ||
99 | + ->column(), | ||
100 | + 'options' => [ 'placeholder' => 'Select a state ...' ], | ||
101 | + 'pluginOptions' => [ | ||
102 | + 'allowClear' => true, | ||
103 | + 'multiple' => true, | ||
104 | + ], | ||
105 | + ] | ||
106 | + ); | ||
107 | + ?> | ||
108 | + | ||
109 | + <?php | ||
110 | + $query = new JsExpression( | ||
111 | + 'function(params) { return {q:params.term}; }' | ||
112 | + ); | ||
113 | + echo $searchForm->field($searchModel, 'sku') | ||
114 | + ->widget( | ||
115 | + Select2::className(), | ||
116 | + [ | ||
117 | + 'options' => [ 'placeholder' => 'Search for a product ...' ], | ||
118 | + 'pluginOptions' => [ | ||
119 | + 'allowClear' => true, | ||
120 | + 'minimumInputLength' => 3, | ||
121 | + 'language' => [ | ||
122 | + 'errorLoading' => new JsExpression( | ||
123 | + "function () { return 'Waiting for results...'; }" | ||
124 | + ), | ||
125 | + ], | ||
126 | + 'ajax' => [ | ||
127 | + 'url' => \yii\helpers\Url::to([ 'find-product' ]), | ||
128 | + 'dataType' => 'json', | ||
129 | + 'data' => $query, | ||
130 | + ], | ||
131 | + 'escapeMarkup' => new JsExpression( | ||
132 | + 'function (markup) { return markup; }' | ||
133 | + ), | ||
134 | + 'templateResult' => new JsExpression( | ||
135 | + 'function(data) { return data.sku; }' | ||
136 | + ), | ||
137 | + 'templateSelection' => new JsExpression( | ||
138 | + 'function (data) { | ||
139 | if(data.sku == undefined) { | 139 | if(data.sku == undefined) { |
140 | return "sku"; | 140 | return "sku"; |
141 | } else { | 141 | } else { |
142 | return data.sku; | 142 | return data.sku; |
143 | } | 143 | } |
144 | }' | 144 | }' |
145 | - ), | ||
146 | - ], | ||
147 | - ] | ||
148 | - ); | ||
149 | - | ||
150 | -?> | ||
151 | - | ||
152 | -<?= $searchForm->field($searchModel, 'manager_id') | ||
153 | - ->dropDownList( | ||
154 | - ArrayHelper::map( | ||
155 | - User::find() | ||
156 | - ->asArray() | ||
157 | - ->all(), | ||
158 | - 'id', | ||
159 | - 'username' | ||
160 | - ), | ||
161 | - [ 'prompt' => \Yii::t('app', 'Выберите менеджера ...') ] | ||
162 | - ) ?> | ||
163 | - | ||
164 | -<?= $searchForm->field($searchModel, 'email') | ||
165 | - ->textInput() ?> | ||
166 | - | ||
167 | -<?= $searchForm->field($searchModel, 'declaration') | ||
168 | - ->textInput() ?> | ||
169 | - | ||
170 | -<?= $searchForm->field($searchModel, 'consignment') | ||
171 | - ->textInput() ?> | ||
172 | - | 145 | + ), |
146 | + ], | ||
147 | + ] | ||
148 | + ); | ||
149 | + | ||
150 | + ?> | ||
151 | + </div> | ||
152 | + | ||
153 | + | ||
154 | + <div class="col-md-4"> | ||
155 | + <?= $searchForm->field($searchModel, 'manager_id') | ||
156 | + ->dropDownList( | ||
157 | + ArrayHelper::map( | ||
158 | + User::find() | ||
159 | + ->asArray() | ||
160 | + ->all(), | ||
161 | + 'id', | ||
162 | + 'username' | ||
163 | + ), | ||
164 | + [ 'prompt' => \Yii::t('app', 'Выберите менеджера ...') ] | ||
165 | + ) ?> | ||
166 | + | ||
167 | + <?= $searchForm->field($searchModel, 'email') | ||
168 | + ->textInput() ?> | ||
169 | + | ||
170 | + </div> | ||
171 | + <div class="col-md-4"> | ||
172 | + <?= $searchForm->field($searchModel, 'declaration') | ||
173 | + ->textInput() ?> | ||
174 | + | ||
175 | + <?= $searchForm->field($searchModel, 'consignment') | ||
176 | + ->textInput() ?> | ||
177 | + </div> | ||
178 | +</div> | ||
173 | 179 | ||
174 | <p> | 180 | <p> |
175 | <?php | 181 | <?php |
@@ -189,14 +195,14 @@ JS; | @@ -189,14 +195,14 @@ JS; | ||
189 | 'attribute' => 'id', | 195 | 'attribute' => 'id', |
190 | 'filter' => $searchForm->field($searchModel, 'id') | 196 | 'filter' => $searchForm->field($searchModel, 'id') |
191 | ->textInput(), | 197 | ->textInput(), |
192 | - 'content' => function($model) { | 198 | + 'content' => function($model) { |
193 | $manager = $model->manager; | 199 | $manager = $model->manager; |
194 | - if (empty($manager)) { | 200 | + if (empty( $manager )) { |
195 | return $model->id; | 201 | return $model->id; |
196 | } else { | 202 | } else { |
197 | return $model->id . ' ' . $manager->username; | 203 | return $model->id . ' ' . $manager->username; |
198 | } | 204 | } |
199 | - } | 205 | + }, |
200 | ], | 206 | ], |
201 | [ | 207 | [ |
202 | 'attribute' => 'created_at', | 208 | 'attribute' => 'created_at', |
@@ -269,8 +275,18 @@ JS; | @@ -269,8 +275,18 @@ JS; | ||
269 | ], | 275 | ], |
270 | 'sms', | 276 | 'sms', |
271 | [ | 277 | [ |
272 | - 'class' => 'yii\grid\ActionColumn', | ||
273 | - 'template' => \Yii::$app->user->identity->isAdmin() ? '{view} {update} {delete}' : '{view} {update}' | 278 | + 'class' => 'yii\grid\ActionColumn', |
279 | + 'template' => \Yii::$app->user->identity->isAdmin( | ||
280 | + ) ? '{view} {update} {delete}' : '{view} {update}', | ||
281 | + 'buttons' => [ | ||
282 | + 'update' => function($url, $model) { | ||
283 | + return Html::a( | ||
284 | + Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-pencil' ]), | ||
285 | + $url, | ||
286 | + [ 'target' => '_blank' ] | ||
287 | + ); | ||
288 | + }, | ||
289 | + ], | ||
274 | ], | 290 | ], |
275 | ], | 291 | ], |
276 | ] | 292 | ] |