Commit 3e703aac69131c5854c0c5a999d15602ac2ed106
1 parent
0e90d9cb
-Order form fixes
Showing
6 changed files
with
103 additions
and
68 deletions
Show diff stats
controllers/OrderController.php
| @@ -128,6 +128,16 @@ | @@ -128,6 +128,16 @@ | ||
| 128 | 128 | ||
| 129 | public function actionDelete($id) | 129 | public function actionDelete($id) |
| 130 | { | 130 | { |
| 131 | + if (\Yii::$app->user->identity->isAdmin()) { | ||
| 132 | + $this->findModel($id) | ||
| 133 | + ->delete(); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + return $this->redirect([ 'index' ]); | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + public function actionDeleteProduct($id) | ||
| 140 | + { | ||
| 131 | $model = OrderProduct::findOne($id); | 141 | $model = OrderProduct::findOne($id); |
| 132 | $orderId = $model->order_id; | 142 | $orderId = $model->order_id; |
| 133 | if ($model->delete()) { | 143 | if ($model->delete()) { |
models/OrderPayment.php
| @@ -66,6 +66,10 @@ | @@ -66,6 +66,10 @@ | ||
| 66 | { | 66 | { |
| 67 | return [ | 67 | return [ |
| 68 | [ | 68 | [ |
| 69 | + [ 'short' ], | ||
| 70 | + 'string', | ||
| 71 | + ], | ||
| 72 | + [ | ||
| 69 | [ 'status' ], | 73 | [ 'status' ], |
| 70 | 'integer', | 74 | 'integer', |
| 71 | ], | 75 | ], |
| @@ -85,6 +89,7 @@ | @@ -85,6 +89,7 @@ | ||
| 85 | return [ | 89 | return [ |
| 86 | 'id' => \Yii::t('app', 'ID'), | 90 | 'id' => \Yii::t('app', 'ID'), |
| 87 | 'status' => \Yii::t('app', 'Статус'), | 91 | 'status' => \Yii::t('app', 'Статус'), |
| 92 | + 'short' => \Yii::t('app', 'Название'), | ||
| 88 | ]; | 93 | ]; |
| 89 | } | 94 | } |
| 90 | 95 |
views/order-payment/_form.php
| @@ -30,6 +30,8 @@ use yii\widgets\ActiveForm; | @@ -30,6 +30,8 @@ use yii\widgets\ActiveForm; | ||
| 30 | ], | 30 | ], |
| 31 | ] )) ?> | 31 | ] )) ?> |
| 32 | 32 | ||
| 33 | + <?= $form->field($model, 'short')->textInput(); ?> | ||
| 34 | + | ||
| 33 | <?= LanguageForm::widget([ | 35 | <?= LanguageForm::widget([ |
| 34 | 'modelLangs' => $modelLangs, | 36 | 'modelLangs' => $modelLangs, |
| 35 | 'formView' => '@artweb/artbox/ecommerce/views/order-payment/_form_language', | 37 | 'formView' => '@artweb/artbox/ecommerce/views/order-payment/_form_language', |
views/order-payment/index.php
| @@ -25,6 +25,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -25,6 +25,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 25 | ['class' => 'yii\grid\SerialColumn'], | 25 | ['class' => 'yii\grid\SerialColumn'], |
| 26 | 26 | ||
| 27 | 'status', | 27 | 'status', |
| 28 | + 'short', | ||
| 28 | [ | 29 | [ |
| 29 | 'attribute' => 'title', | 30 | 'attribute' => 'title', |
| 30 | 'value' => 'lang.title', | 31 | 'value' => 'lang.title', |
views/order/_form.php
| @@ -163,7 +163,7 @@ JS; | @@ -163,7 +163,7 @@ JS; | ||
| 163 | ), | 163 | ), |
| 164 | [ 'prompt' => \Yii::t('app', 'Выберите доставку ...') ] | 164 | [ 'prompt' => \Yii::t('app', 'Выберите доставку ...') ] |
| 165 | ) ?> | 165 | ) ?> |
| 166 | - | 166 | + |
| 167 | <?php | 167 | <?php |
| 168 | 168 | ||
| 169 | if (\Yii::$app->user->identity->isAdmin()) { | 169 | if (\Yii::$app->user->identity->isAdmin()) { |
| @@ -177,63 +177,63 @@ JS; | @@ -177,63 +177,63 @@ JS; | ||
| 177 | 'username' | 177 | 'username' |
| 178 | ), | 178 | ), |
| 179 | [ 'prompt' => \Yii::t('app', 'Менеджер') ] | 179 | [ 'prompt' => \Yii::t('app', 'Менеджер') ] |
| 180 | - ) ; | ||
| 181 | - } | 180 | + ); |
| 181 | + } | ||
| 182 | ?> | 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 | - ); | ||
| 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 | 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 | + ); | ||
| 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 | + | ||
| 237 | </div> | 237 | </div> |
| 238 | <div class="col-sm-6"> | 238 | <div class="col-sm-6"> |
| 239 | 239 | ||
| @@ -247,12 +247,11 @@ JS; | @@ -247,12 +247,11 @@ JS; | ||
| 247 | ->dropDownList( | 247 | ->dropDownList( |
| 248 | ArrayHelper::map( | 248 | ArrayHelper::map( |
| 249 | OrderPayment::find() | 249 | OrderPayment::find() |
| 250 | - ->joinWith('lang') | ||
| 251 | ->where([ 'status' => OrderPayment::ACTIVE ]) | 250 | ->where([ 'status' => OrderPayment::ACTIVE ]) |
| 252 | ->asArray() | 251 | ->asArray() |
| 253 | ->all(), | 252 | ->all(), |
| 254 | 'id', | 253 | 'id', |
| 255 | - 'lang.title' | 254 | + 'short' |
| 256 | ), | 255 | ), |
| 257 | [ 'prompt' => 'Способ оплаты ...' ] | 256 | [ 'prompt' => 'Способ оплаты ...' ] |
| 258 | ); ?> | 257 | ); ?> |
| @@ -309,7 +308,7 @@ JS; | @@ -309,7 +308,7 @@ JS; | ||
| 309 | ] | 308 | ] |
| 310 | ), | 309 | ), |
| 311 | [ | 310 | [ |
| 312 | - 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | 311 | + 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', |
| 313 | ] | 312 | ] |
| 314 | ) ?> | 313 | ) ?> |
| 315 | </div> | 314 | </div> |
| @@ -359,9 +358,9 @@ JS; | @@ -359,9 +358,9 @@ JS; | ||
| 359 | 'class' => 'kartik\grid\EditableColumn', | 358 | 'class' => 'kartik\grid\EditableColumn', |
| 360 | 'attribute' => 'booking', | 359 | 'attribute' => 'booking', |
| 361 | 'editableOptions' => [ | 360 | 'editableOptions' => [ |
| 362 | - 'header' => \Yii::t('app', 'Бронь'), | ||
| 363 | - 'inputType' => kartik\editable\Editable::INPUT_TEXT, | ||
| 364 | - 'options' => [ | 361 | + 'header' => \Yii::t('app', 'Бронь'), |
| 362 | + 'inputType' => kartik\editable\Editable::INPUT_TEXT, | ||
| 363 | + 'options' => [ | ||
| 365 | 'pluginOptions' => [ | 364 | 'pluginOptions' => [ |
| 366 | 'min' => 0, | 365 | 'min' => 0, |
| 367 | 'max' => 20, | 366 | 'max' => 20, |
| @@ -377,9 +376,9 @@ JS; | @@ -377,9 +376,9 @@ JS; | ||
| 377 | 'class' => 'kartik\grid\EditableColumn', | 376 | 'class' => 'kartik\grid\EditableColumn', |
| 378 | 'attribute' => 'status', | 377 | 'attribute' => 'status', |
| 379 | 'editableOptions' => [ | 378 | 'editableOptions' => [ |
| 380 | - 'header' => \Yii::t('app', 'Статус'), | ||
| 381 | - 'inputType' => kartik\editable\Editable::INPUT_TEXT, | ||
| 382 | - 'options' => [ | 379 | + 'header' => \Yii::t('app', 'Статус'), |
| 380 | + 'inputType' => kartik\editable\Editable::INPUT_TEXT, | ||
| 381 | + 'options' => [ | ||
| 383 | 'pluginOptions' => [ | 382 | 'pluginOptions' => [ |
| 384 | 'min' => 0, | 383 | 'min' => 0, |
| 385 | 'max' => 20, | 384 | 'max' => 20, |
| @@ -395,9 +394,9 @@ JS; | @@ -395,9 +394,9 @@ JS; | ||
| 395 | 'class' => 'kartik\grid\EditableColumn', | 394 | 'class' => 'kartik\grid\EditableColumn', |
| 396 | 'attribute' => 'return', | 395 | 'attribute' => 'return', |
| 397 | 'editableOptions' => [ | 396 | 'editableOptions' => [ |
| 398 | - 'header' => \Yii::t('app', 'Возврат'), | ||
| 399 | - 'inputType' => kartik\editable\Editable::INPUT_CHECKBOX, | ||
| 400 | - 'options' => [], | 397 | + 'header' => \Yii::t('app', 'Возврат'), |
| 398 | + 'inputType' => kartik\editable\Editable::INPUT_CHECKBOX, | ||
| 399 | + 'options' => [], | ||
| 401 | ], | 400 | ], |
| 402 | 'format' => [ | 401 | 'format' => [ |
| 403 | 'boolean', | 402 | 'boolean', |
| @@ -407,6 +406,23 @@ JS; | @@ -407,6 +406,23 @@ JS; | ||
| 407 | [ | 406 | [ |
| 408 | 'class' => 'yii\grid\ActionColumn', | 407 | 'class' => 'yii\grid\ActionColumn', |
| 409 | 'template' => '{delete}', | 408 | 'template' => '{delete}', |
| 409 | + 'buttons' => [ | ||
| 410 | + 'delete' => function($url, $model) { | ||
| 411 | + return Html::a( | ||
| 412 | + Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-trash' ]), | ||
| 413 | + [ | ||
| 414 | + 'delete-product', | ||
| 415 | + 'id' => $model->id, | ||
| 416 | + ], | ||
| 417 | + [ | ||
| 418 | + 'data' => [ | ||
| 419 | + 'confirm' => 'Вы уверены, что хотите удалить этот элемент?', | ||
| 420 | + 'method' => 'POST', | ||
| 421 | + ], | ||
| 422 | + ] | ||
| 423 | + ); | ||
| 424 | + }, | ||
| 425 | + ], | ||
| 410 | ], | 426 | ], |
| 411 | ], | 427 | ], |
| 412 | 'responsive' => true, | 428 | 'responsive' => true, |
views/order/index.php
| @@ -262,6 +262,7 @@ JS; | @@ -262,6 +262,7 @@ JS; | ||
| 262 | 'sms', | 262 | 'sms', |
| 263 | [ | 263 | [ |
| 264 | 'class' => 'yii\grid\ActionColumn', | 264 | 'class' => 'yii\grid\ActionColumn', |
| 265 | + 'template' => \Yii::$app->user->identity->isAdmin() ? '{view} {update} {delete}' : '{view} {update}' | ||
| 265 | ], | 266 | ], |
| 266 | ], | 267 | ], |
| 267 | ] | 268 | ] |