Commit e861ae9248b7545815537eb453a0cf68050a7858
1 parent
1f2fdc61
-Add column to payment
Showing
4 changed files
with
189 additions
and
185 deletions
Show diff stats
controllers/OrderController.php
@@ -290,7 +290,7 @@ | @@ -290,7 +290,7 @@ | ||
290 | } | 290 | } |
291 | 291 | ||
292 | $model = $this->findModel($id); | 292 | $model = $this->findModel($id); |
293 | - | 293 | + |
294 | /** | 294 | /** |
295 | * @var User $user | 295 | * @var User $user |
296 | */ | 296 | */ |
@@ -388,7 +388,7 @@ | @@ -388,7 +388,7 @@ | ||
388 | throw new NotFoundHttpException('The requested page does not exist.'); | 388 | throw new NotFoundHttpException('The requested page does not exist.'); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | - | 391 | + |
392 | public function actionExitOrder($id) | 392 | public function actionExitOrder($id) |
393 | { | 393 | { |
394 | $this->unblockOrder($id); | 394 | $this->unblockOrder($id); |
@@ -413,7 +413,10 @@ | @@ -413,7 +413,10 @@ | ||
413 | 'time' => $date, | 413 | 'time' => $date, |
414 | ]; | 414 | ]; |
415 | } else { | 415 | } else { |
416 | - return [ 'success' => false ]; | 416 | + return [ |
417 | + 'success' => false, | ||
418 | + 'errors' => $model->errors, | ||
419 | + ]; | ||
417 | } | 420 | } |
418 | } | 421 | } |
419 | } | 422 | } |
models/Order.php
@@ -110,6 +110,7 @@ | @@ -110,6 +110,7 @@ | ||
110 | ], | 110 | ], |
111 | [ | 111 | [ |
112 | [ | 112 | [ |
113 | + 'shipping_by', | ||
113 | 'created_at', | 114 | 'created_at', |
114 | 'updated_at', | 115 | 'updated_at', |
115 | 'deleted_at', | 116 | 'deleted_at', |
@@ -159,7 +160,6 @@ | @@ -159,7 +160,6 @@ | ||
159 | 'consignment', | 160 | 'consignment', |
160 | 'insurance', | 161 | 'insurance', |
161 | 'amount_imposed', | 162 | 'amount_imposed', |
162 | - 'shipping_by', | ||
163 | 'city', | 163 | 'city', |
164 | 'adress', | 164 | 'adress', |
165 | 'status', | 165 | 'status', |
models/OrderPayment.php
1 | <?php | 1 | <?php |
2 | - | ||
3 | -namespace artweb\artbox\ecommerce\models; | ||
4 | - | ||
5 | -use artweb\artbox\language\behaviors\LanguageBehavior; | ||
6 | -use yii\db\ActiveQuery; | ||
7 | -use yii\web\Request; | ||
8 | -/** | ||
9 | - * This is the model class for table "order_payment". | ||
10 | - * | ||
11 | - * @property integer $id | ||
12 | - * @property integer $status | ||
13 | - * | ||
14 | - * @property OrderPaymentLang[] $orderPaymentLangs | ||
15 | - * | ||
16 | - * * From language behavior * | ||
17 | - * @property orderPaymentLang $lang | ||
18 | - * @property orderPaymentLang[] $langs | ||
19 | - * @property orderPaymentLang $objectLang | ||
20 | - * @property string $ownerKey | ||
21 | - * @property string $langKey | ||
22 | - * @property orderPaymentLang[] $modelLangs | ||
23 | - * @property bool $transactionStatus | ||
24 | - * @method string getOwnerKey() | ||
25 | - * @method void setOwnerKey( string $value ) | ||
26 | - * @method string getLangKey() | ||
27 | - * @method void setLangKey( string $value ) | ||
28 | - * @method ActiveQuery getLangs() | ||
29 | - * @method ActiveQuery getLang( integer $language_id ) | ||
30 | - * @method OrderPaymentLang[] generateLangs() | ||
31 | - * @method void loadLangs( Request $request ) | ||
32 | - * @method bool linkLangs() | ||
33 | - * @method bool saveLangs() | ||
34 | - * @method bool getTransactionStatus() | ||
35 | - * * End language behavior | ||
36 | - */ | ||
37 | -class OrderPayment extends \yii\db\ActiveRecord | ||
38 | -{ | ||
39 | - | ||
40 | - | ||
41 | - const ACTIVE = 1; | ||
42 | - const INACTIVE = 2; | 2 | + |
3 | + namespace artweb\artbox\ecommerce\models; | ||
4 | + | ||
5 | + use artweb\artbox\language\behaviors\LanguageBehavior; | ||
6 | + use yii\db\ActiveQuery; | ||
7 | + use yii\web\Request; | ||
8 | + | ||
43 | /** | 9 | /** |
44 | - * @inheritdoc | 10 | + * This is the model class for table "order_payment". |
11 | + * | ||
12 | + * @property integer $id | ||
13 | + * @property integer $status | ||
14 | + * @property string $short | ||
15 | + * @property OrderPaymentLang[] $orderPaymentLangs | ||
16 | + * * From language behavior * | ||
17 | + * @property orderPaymentLang $lang | ||
18 | + * @property orderPaymentLang[] $langs | ||
19 | + * @property orderPaymentLang $objectLang | ||
20 | + * @property string $ownerKey | ||
21 | + * @property string $langKey | ||
22 | + * @property orderPaymentLang[] $modelLangs | ||
23 | + * @property bool $transactionStatus | ||
24 | + * @method string getOwnerKey() | ||
25 | + * @method void setOwnerKey( string $value ) | ||
26 | + * @method string getLangKey() | ||
27 | + * @method void setLangKey( string $value ) | ||
28 | + * @method ActiveQuery getLangs() | ||
29 | + * @method ActiveQuery getLang( integer $language_id ) | ||
30 | + * @method OrderPaymentLang[] generateLangs() | ||
31 | + * @method void loadLangs( Request $request ) | ||
32 | + * @method bool linkLangs() | ||
33 | + * @method bool saveLangs() | ||
34 | + * @method bool getTransactionStatus() | ||
35 | + * * End language behavior | ||
45 | */ | 36 | */ |
46 | - public static function tableName() | 37 | + class OrderPayment extends \yii\db\ActiveRecord |
47 | { | 38 | { |
48 | - return 'order_payment'; | 39 | + |
40 | + const ACTIVE = 1; | ||
41 | + const INACTIVE = 2; | ||
42 | + /** | ||
43 | + * @inheritdoc | ||
44 | + */ | ||
45 | + public static function tableName() | ||
46 | + { | ||
47 | + return 'order_payment'; | ||
48 | + } | ||
49 | + | ||
50 | + public function behaviors() | ||
51 | + { | ||
52 | + return [ | ||
53 | + 'language' => [ | ||
54 | + 'class' => LanguageBehavior::className(), | ||
55 | + 'objectLang' => OrderPaymentLang::className(), | ||
56 | + 'ownerKey' => 'id', | ||
57 | + 'langKey' => 'order_payment_id', | ||
58 | + ], | ||
59 | + ]; | ||
60 | + } | ||
61 | + | ||
62 | + /** | ||
63 | + * @inheritdoc | ||
64 | + */ | ||
65 | + public function rules() | ||
66 | + { | ||
67 | + return [ | ||
68 | + [ | ||
69 | + [ 'status' ], | ||
70 | + 'integer', | ||
71 | + ], | ||
72 | + [ | ||
73 | + [ 'status' ], | ||
74 | + 'default', | ||
75 | + 'value' => 1, | ||
76 | + ], | ||
77 | + ]; | ||
78 | + } | ||
79 | + | ||
80 | + /** | ||
81 | + * @inheritdoc | ||
82 | + */ | ||
83 | + public function attributeLabels() | ||
84 | + { | ||
85 | + return [ | ||
86 | + 'id' => \Yii::t('app', 'ID'), | ||
87 | + 'status' => \Yii::t('app', 'Статус'), | ||
88 | + ]; | ||
89 | + } | ||
90 | + | ||
91 | + /** | ||
92 | + * @return \yii\db\ActiveQuery | ||
93 | + */ | ||
94 | + public function getOrderPaymentLangs() | ||
95 | + { | ||
96 | + return $this->hasMany(OrderPaymentLang::className(), [ 'order_payment_id' => 'id' ]); | ||
97 | + } | ||
49 | } | 98 | } |
50 | - | ||
51 | - | ||
52 | - public function behaviors() | ||
53 | - { | ||
54 | - return [ | ||
55 | - 'language' => [ | ||
56 | - 'class' => LanguageBehavior::className(), | ||
57 | - 'objectLang' => OrderPaymentLang::className(), | ||
58 | - 'ownerKey' => 'id', | ||
59 | - 'langKey' => 'order_payment_id', | ||
60 | - ], | ||
61 | - ]; | ||
62 | - } | ||
63 | - | ||
64 | - /** | ||
65 | - * @inheritdoc | ||
66 | - */ | ||
67 | - public function rules() | ||
68 | - { | ||
69 | - return [ | ||
70 | - [['status'], 'integer'], | ||
71 | - [ | ||
72 | - [ 'status' ], | ||
73 | - 'default', | ||
74 | - 'value' => 1, | ||
75 | - ], | ||
76 | - ]; | ||
77 | - } | ||
78 | - | ||
79 | - /** | ||
80 | - * @inheritdoc | ||
81 | - */ | ||
82 | - public function attributeLabels() | ||
83 | - { | ||
84 | - return [ | ||
85 | - 'id' => \Yii::t('app','ID'), | ||
86 | - 'status' => \Yii::t('app','Статус'), | ||
87 | - ]; | ||
88 | - } | ||
89 | - | ||
90 | - /** | ||
91 | - * @return \yii\db\ActiveQuery | ||
92 | - */ | ||
93 | - public function getOrderPaymentLangs() | ||
94 | - { | ||
95 | - return $this->hasMany(OrderPaymentLang::className(), ['order_payment_id' => 'id']); | ||
96 | - } | ||
97 | -} |
views/order/_form.php
@@ -92,37 +92,6 @@ JS; | @@ -92,37 +92,6 @@ JS; | ||
92 | <?php $form = ActiveForm::begin(); ?> | 92 | <?php $form = ActiveForm::begin(); ?> |
93 | <div class="container"> | 93 | <div class="container"> |
94 | <div class="form-group"> | 94 | <div class="form-group"> |
95 | - <div class="row"> | ||
96 | - <?= Html::submitButton( | ||
97 | - $model->isNewRecord ? \Yii::t('app', 'Создать') : \Yii::t('app', 'Обновить'), | ||
98 | - [ 'class' => $model->isNewRecord ? 'btn btn-success btn-lg' : 'btn btn-primary btn-lg' ] | ||
99 | - ) ?> | ||
100 | - <?= Html::a( | ||
101 | - \Yii::t('app', 'Печать'), | ||
102 | - yii\helpers\Url::to( | ||
103 | - [ | ||
104 | - 'order/print', | ||
105 | - 'order_id' => $model->id, | ||
106 | - ] | ||
107 | - ), | ||
108 | - [ | ||
109 | - 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | ||
110 | - 'target' => '_blank', | ||
111 | - ] | ||
112 | - ) ?> | ||
113 | - <?= Html::a( | ||
114 | - \Yii::t('app', 'Выйти'), | ||
115 | - yii\helpers\Url::to( | ||
116 | - [ | ||
117 | - 'exit-order', | ||
118 | - 'id' => $model->id, | ||
119 | - ] | ||
120 | - ), | ||
121 | - [ | ||
122 | - 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | ||
123 | - ] | ||
124 | - ) ?> | ||
125 | - </div> | ||
126 | <br> | 95 | <br> |
127 | <div class="row"> | 96 | <div class="row"> |
128 | <div class="col-sm-6"> | 97 | <div class="col-sm-6"> |
@@ -196,6 +165,7 @@ JS; | @@ -196,6 +165,7 @@ JS; | ||
196 | ) ?> | 165 | ) ?> |
197 | 166 | ||
198 | <?php | 167 | <?php |
168 | + | ||
199 | if (\Yii::$app->user->identity->isAdmin()) { | 169 | if (\Yii::$app->user->identity->isAdmin()) { |
200 | echo $form->field($model, 'manager_id') | 170 | echo $form->field($model, 'manager_id') |
201 | ->dropDownList( | 171 | ->dropDownList( |
@@ -210,7 +180,60 @@ JS; | @@ -210,7 +180,60 @@ JS; | ||
210 | ) ; | 180 | ) ; |
211 | } | 181 | } |
212 | ?> | 182 | ?> |
183 | + | ||
184 | + <h2><?php echo \Yii::t('app', 'Отправить смс'); ?></h2> | ||
185 | + <?php | ||
186 | + echo Select2::widget( | ||
187 | + [ | ||
188 | + 'id' => 'sms-template-selector', | ||
189 | + 'name' => 'select-sms-template', | ||
190 | + 'data' => ArrayHelper::map( | ||
191 | + SmsTemplate::find() | ||
192 | + ->asArray() | ||
193 | + ->all(), | ||
194 | + 'text', | ||
195 | + 'title' | ||
196 | + ), | ||
197 | + 'options' => [ 'placeholder' => \Yii::t('app', 'Выберите шаблон') ], | ||
198 | + 'pluginOptions' => [ | ||
199 | + 'allowClear' => true, | ||
200 | + ], | ||
201 | + ] | ||
202 | + ); | ||
213 | 203 | ||
204 | + ?> | ||
205 | + <br> | ||
206 | + <?php | ||
207 | + echo Html::textarea( | ||
208 | + 'sms-text', | ||
209 | + '', | ||
210 | + [ | ||
211 | + 'rows' => 3, | ||
212 | + 'id' => 'sms-text-area', | ||
213 | + 'class' => 'form-control', | ||
214 | + ] | ||
215 | + ); | ||
216 | + ?> | ||
217 | + <br> | ||
218 | + <?php | ||
219 | + if ($model->isNewRecord) { | ||
220 | + echo Html::button( | ||
221 | + \Yii::t('app', 'Отправить'), | ||
222 | + [ | ||
223 | + 'class' => 'btn btn-warning disabled', | ||
224 | + ] | ||
225 | + ); | ||
226 | + } else { | ||
227 | + echo Html::button( | ||
228 | + \Yii::t('app', 'Отправить'), | ||
229 | + [ | ||
230 | + 'class' => 'btn btn-warning', | ||
231 | + 'id' => 'send-sms-action', | ||
232 | + ] | ||
233 | + ); | ||
234 | + } | ||
235 | + ?> | ||
236 | + | ||
214 | </div> | 237 | </div> |
215 | <div class="col-sm-6"> | 238 | <div class="col-sm-6"> |
216 | 239 | ||
@@ -258,10 +281,43 @@ JS; | @@ -258,10 +281,43 @@ JS; | ||
258 | </div> | 281 | </div> |
259 | </div> | 282 | </div> |
260 | </div> | 283 | </div> |
284 | + <br> | ||
285 | + <div class="row"> | ||
286 | + <?= Html::submitButton( | ||
287 | + $model->isNewRecord ? \Yii::t('app', 'Создать') : \Yii::t('app', 'Обновить'), | ||
288 | + [ 'class' => $model->isNewRecord ? 'btn btn-success btn-lg' : 'btn btn-primary btn-lg' ] | ||
289 | + ) ?> | ||
290 | + <?= Html::a( | ||
291 | + \Yii::t('app', 'Печать'), | ||
292 | + yii\helpers\Url::to( | ||
293 | + [ | ||
294 | + 'order/print', | ||
295 | + 'order_id' => $model->id, | ||
296 | + ] | ||
297 | + ), | ||
298 | + [ | ||
299 | + 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | ||
300 | + 'target' => '_blank', | ||
301 | + ] | ||
302 | + ) ?> | ||
303 | + <?= Html::a( | ||
304 | + \Yii::t('app', 'Выйти'), | ||
305 | + yii\helpers\Url::to( | ||
306 | + [ | ||
307 | + 'exit-order', | ||
308 | + 'id' => $model->id, | ||
309 | + ] | ||
310 | + ), | ||
311 | + [ | ||
312 | + 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | ||
313 | + ] | ||
314 | + ) ?> | ||
315 | + </div> | ||
261 | </div> | 316 | </div> |
262 | -<?php ActiveForm::end(); ?> | ||
263 | - | ||
264 | 317 | ||
318 | +<?php ActiveForm::end(); ?> | ||
319 | +<br> | ||
320 | +<br> | ||
265 | <div class="container"> | 321 | <div class="container"> |
266 | <div class="row"> | 322 | <div class="row"> |
267 | <?php | 323 | <?php |
@@ -447,59 +503,3 @@ JS; | @@ -447,59 +503,3 @@ JS; | ||
447 | </div> | 503 | </div> |
448 | <br> | 504 | <br> |
449 | <br> | 505 | <br> |
450 | -<div class="container"> | ||
451 | - <h2><?php echo \Yii::t('app', 'Отправить смс'); ?></h2> | ||
452 | - <div class="row"> | ||
453 | - <?php | ||
454 | - echo Select2::widget( | ||
455 | - [ | ||
456 | - 'id' => 'sms-template-selector', | ||
457 | - 'name' => 'select-sms-template', | ||
458 | - 'data' => ArrayHelper::map( | ||
459 | - SmsTemplate::find() | ||
460 | - ->asArray() | ||
461 | - ->all(), | ||
462 | - 'text', | ||
463 | - 'title' | ||
464 | - ), | ||
465 | - 'options' => [ 'placeholder' => \Yii::t('app', 'Выберите шаблон') ], | ||
466 | - 'pluginOptions' => [ | ||
467 | - 'allowClear' => true, | ||
468 | - ], | ||
469 | - ] | ||
470 | - ); | ||
471 | - | ||
472 | - ?> | ||
473 | - <br> | ||
474 | - <?php | ||
475 | - echo Html::textarea( | ||
476 | - 'sms-text', | ||
477 | - '', | ||
478 | - [ | ||
479 | - 'rows' => 3, | ||
480 | - 'id' => 'sms-text-area', | ||
481 | - 'class' => 'form-control', | ||
482 | - ] | ||
483 | - ); | ||
484 | - ?> | ||
485 | - <br> | ||
486 | - <?php | ||
487 | - if ($model->isNewRecord) { | ||
488 | - echo Html::button( | ||
489 | - \Yii::t('app', 'Отправить'), | ||
490 | - [ | ||
491 | - 'class' => 'btn btn-warning disabled', | ||
492 | - ] | ||
493 | - ); | ||
494 | - } else { | ||
495 | - echo Html::button( | ||
496 | - \Yii::t('app', 'Отправить'), | ||
497 | - [ | ||
498 | - 'class' => 'btn btn-warning', | ||
499 | - 'id' => 'send-sms-action', | ||
500 | - ] | ||
501 | - ); | ||
502 | - } | ||
503 | - ?> | ||
504 | - </div> | ||
505 | -</div> |