Commit 3e703aac69131c5854c0c5a999d15602ac2ed106

Authored by Alexey Boroda
1 parent 0e90d9cb

-Order form fixes

controllers/OrderController.php
... ... @@ -128,6 +128,16 @@
128 128  
129 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 141 $model = OrderProduct::findOne($id);
132 142 $orderId = $model->order_id;
133 143 if ($model->delete()) {
... ...
models/OrderPayment.php
... ... @@ -66,6 +66,10 @@
66 66 {
67 67 return [
68 68 [
  69 + [ 'short' ],
  70 + 'string',
  71 + ],
  72 + [
69 73 [ 'status' ],
70 74 'integer',
71 75 ],
... ... @@ -85,6 +89,7 @@
85 89 return [
86 90 'id' => \Yii::t('app', 'ID'),
87 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 30 ],
31 31 ] )) ?>
32 32  
  33 + <?= $form->field($model, 'short')->textInput(); ?>
  34 +
33 35 <?= LanguageForm::widget([
34 36 'modelLangs' => $modelLangs,
35 37 'formView' => '@artweb/artbox/ecommerce/views/order-payment/_form_language',
... ...
views/order-payment/index.php
... ... @@ -25,6 +25,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
25 25 ['class' => 'yii\grid\SerialColumn'],
26 26  
27 27 'status',
  28 + 'short',
28 29 [
29 30 'attribute' => 'title',
30 31 'value' => 'lang.title',
... ...
views/order/_form.php
... ... @@ -163,7 +163,7 @@ JS;
163 163 ),
164 164 [ 'prompt' => \Yii::t('app', 'Выберите доставку ...') ]
165 165 ) ?>
166   -
  166 +
167 167 <?php
168 168  
169 169 if (\Yii::$app->user->identity->isAdmin()) {
... ... @@ -177,63 +177,63 @@ JS;
177 177 'username'
178 178 ),
179 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 237 </div>
238 238 <div class="col-sm-6">
239 239  
... ... @@ -247,12 +247,11 @@ JS;
247 247 ->dropDownList(
248 248 ArrayHelper::map(
249 249 OrderPayment::find()
250   - ->joinWith('lang')
251 250 ->where([ 'status' => OrderPayment::ACTIVE ])
252 251 ->asArray()
253 252 ->all(),
254 253 'id',
255   - 'lang.title'
  254 + 'short'
256 255 ),
257 256 [ 'prompt' => 'Способ оплаты ...' ]
258 257 ); ?>
... ... @@ -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 314 </div>
... ... @@ -359,9 +358,9 @@ JS;
359 358 'class' => 'kartik\grid\EditableColumn',
360 359 'attribute' => 'booking',
361 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 364 'pluginOptions' => [
366 365 'min' => 0,
367 366 'max' => 20,
... ... @@ -377,9 +376,9 @@ JS;
377 376 'class' => 'kartik\grid\EditableColumn',
378 377 'attribute' => 'status',
379 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 382 'pluginOptions' => [
384 383 'min' => 0,
385 384 'max' => 20,
... ... @@ -395,9 +394,9 @@ JS;
395 394 'class' => 'kartik\grid\EditableColumn',
396 395 'attribute' => 'return',
397 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 401 'format' => [
403 402 'boolean',
... ... @@ -407,6 +406,23 @@ JS;
407 406 [
408 407 'class' => 'yii\grid\ActionColumn',
409 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 428 'responsive' => true,
... ...
views/order/index.php
... ... @@ -262,6 +262,7 @@ JS;
262 262 'sms',
263 263 [
264 264 'class' => 'yii\grid\ActionColumn',
  265 + 'template' => \Yii::$app->user->identity->isAdmin() ? '{view} {update} {delete}' : '{view} {update}'
265 266 ],
266 267 ],
267 268 ]
... ...