Commit 42883b835bd566a5e2afdfe48eb3eb6edc451aa4
1 parent
b8e6a5c4
-Order form beta test
Showing
3 changed files
with
593 additions
and
489 deletions
Show diff stats
controllers/OrderController.php
| ... | ... | @@ -136,16 +136,16 @@ |
| 136 | 136 | return $this->redirect([ 'index' ]); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - public function actionDeleteProduct($id) | |
| 140 | - { | |
| 141 | - $model = OrderProduct::findOne($id); | |
| 142 | - $model->removed = true; | |
| 143 | - $orderId = $model->order_id; | |
| 144 | - if ($model->save()) { | |
| 145 | - $model->order->totalRecount(); | |
| 146 | - return $this->actionUpdate($orderId); | |
| 147 | - } | |
| 148 | - } | |
| 139 | + // public function actionDeleteProduct($id) | |
| 140 | + // { | |
| 141 | + // $model = OrderProduct::findOne($id); | |
| 142 | + // $model->removed = true; | |
| 143 | + // $orderId = $model->order_id; | |
| 144 | + // if ($model->save()) { | |
| 145 | + // $model->order->totalRecount(); | |
| 146 | + // return $this->actionUpdate($orderId); | |
| 147 | + // } | |
| 148 | + // } | |
| 149 | 149 | |
| 150 | 150 | public function actionAdd() |
| 151 | 151 | { |
| ... | ... | @@ -330,7 +330,8 @@ |
| 330 | 330 | $dataProvider = new ActiveDataProvider( |
| 331 | 331 | [ |
| 332 | 332 | 'query' => $model->getProducts() |
| 333 | - ->joinWith('productVariant.product.brand'), | |
| 333 | + ->joinWith('productVariant.product.brand') | |
| 334 | + ->with('productVariant.variantStocks'), | |
| 334 | 335 | 'sort' => [ 'defaultOrder' => [ 'id' => SORT_ASC ] ], |
| 335 | 336 | ] |
| 336 | 337 | ); |
| ... | ... | @@ -402,16 +403,19 @@ |
| 402 | 403 | return $phone . $content . $result; |
| 403 | 404 | } |
| 404 | 405 | |
| 405 | - // public function actionDeleteProduct($id, $order_id) | |
| 406 | - // { | |
| 407 | - // $model = OrderProduct::findOne($id); | |
| 408 | - // $model->delete(); | |
| 409 | - // \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |
| 410 | - // return [ | |
| 411 | - // 'result' => 'success', | |
| 412 | - // 'id' => $id, | |
| 413 | - // ]; | |
| 414 | - // } | |
| 406 | + public function actionDeleteProduct($id, $order_id) | |
| 407 | + { | |
| 408 | + $model = OrderProduct::findOne($id); | |
| 409 | + $model->removed = true; | |
| 410 | + $model->save(); | |
| 411 | + $order = Order::findOne($order_id); | |
| 412 | + $order->totalRecount(); | |
| 413 | + \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |
| 414 | + return [ | |
| 415 | + 'status' => 'success', | |
| 416 | + 'id' => $id, | |
| 417 | + ]; | |
| 418 | + } | |
| 415 | 419 | |
| 416 | 420 | protected function findModel($id) |
| 417 | 421 | { | ... | ... |
models/ProductVariant.php
| ... | ... | @@ -35,6 +35,7 @@ |
| 35 | 35 | * @property Stock[] $stocks |
| 36 | 36 | * @property TaxGroup[] $properties |
| 37 | 37 | * @property TaxGroup[] $taxGroupsByLevel |
| 38 | + * @property string $size | |
| 38 | 39 | * * From language behavior * |
| 39 | 40 | * @property ProductVariantLang $lang |
| 40 | 41 | * @property ProductVariantLang[] $langs |
| ... | ... | @@ -70,7 +71,6 @@ |
| 70 | 71 | |
| 71 | 72 | public $customOption = []; |
| 72 | 73 | |
| 73 | - | |
| 74 | 74 | /** |
| 75 | 75 | * @var int[] $options |
| 76 | 76 | */ |
| ... | ... | @@ -104,8 +104,8 @@ |
| 104 | 104 | 'directory' => 'products', |
| 105 | 105 | 'column' => 'image', |
| 106 | 106 | 'links' => [ |
| 107 | - 'product_id' => 'product_id', | |
| 108 | - 'id' => 'product_variant_id', | |
| 107 | + 'product_id' => 'product_id', | |
| 108 | + 'id' => 'product_variant_id', | |
| 109 | 109 | ], |
| 110 | 110 | 'model' => ProductImage::className(), |
| 111 | 111 | ], |
| ... | ... | @@ -240,7 +240,7 @@ |
| 240 | 240 | } else { |
| 241 | 241 | $quantity = $this->getProductStocks() |
| 242 | 242 | ->sum('quantity'); |
| 243 | - if (empty( $quantity )) { | |
| 243 | + if (empty($quantity)) { | |
| 244 | 244 | $this->stock = 0; |
| 245 | 245 | } else { |
| 246 | 246 | $this->stock = (int) $quantity; |
| ... | ... | @@ -279,7 +279,7 @@ |
| 279 | 279 | return $this->hasMany(TaxOption::className(), [ 'id' => 'option_id' ]) |
| 280 | 280 | ->viaTable('product_variant_option', [ 'product_variant_id' => 'id' ]); |
| 281 | 281 | } |
| 282 | - | |
| 282 | + | |
| 283 | 283 | /** |
| 284 | 284 | * Get one variant's option whith needed conditions, or random if condition is empty |
| 285 | 285 | * |
| ... | ... | @@ -290,11 +290,9 @@ |
| 290 | 290 | public function getOption(array $conditions = []) |
| 291 | 291 | { |
| 292 | 292 | $query = $this->hasOne(TaxOption::className(), [ 'id' => 'option_id' ]) |
| 293 | - ->viaTable('product_variant_option', [ 'product_variant_id' => 'id' ]); | |
| 294 | - foreach ($conditions as $condition) | |
| 295 | - { | |
| 296 | - if (!empty($condition) && is_array($condition)) | |
| 297 | - { | |
| 293 | + ->viaTable('product_variant_option', [ 'product_variant_id' => 'id' ]); | |
| 294 | + foreach ($conditions as $condition) { | |
| 295 | + if (!empty($condition) && is_array($condition)) { | |
| 298 | 296 | $query->andFilterWhere($condition); |
| 299 | 297 | } |
| 300 | 298 | } |
| ... | ... | @@ -333,7 +331,7 @@ |
| 333 | 331 | { |
| 334 | 332 | $this->options = $values; |
| 335 | 333 | } |
| 336 | - | |
| 334 | + | |
| 337 | 335 | /** |
| 338 | 336 | * Get all TaxGroups for current ProductVariant filled with $customOptions that satisfy current ProductVariant |
| 339 | 337 | * |
| ... | ... | @@ -362,12 +360,11 @@ |
| 362 | 360 | $query->andFilterWhere($condition); |
| 363 | 361 | } |
| 364 | 362 | } |
| 365 | - foreach ( | |
| 366 | - $query->all() as $group) { | |
| 363 | + foreach ($query->all() as $group) { | |
| 367 | 364 | /** |
| 368 | 365 | * @var TaxGroup $group |
| 369 | 366 | */ |
| 370 | - if (!empty( $options[ $group->id ] )) { | |
| 367 | + if (!empty($options[ $group->id ])) { | |
| 371 | 368 | $group->customOptions = $options[ $group->id ]; |
| 372 | 369 | $groups[] = $group; |
| 373 | 370 | } |
| ... | ... | @@ -421,7 +418,7 @@ |
| 421 | 418 | public function afterSave($insert, $changedAttributes) |
| 422 | 419 | { |
| 423 | 420 | parent::afterSave($insert, $changedAttributes); |
| 424 | - if (!empty( $this->options )) { | |
| 421 | + if (!empty($this->options)) { | |
| 425 | 422 | $options = TaxOption::findAll($this->options); |
| 426 | 423 | $this->unlinkAll('options', true); |
| 427 | 424 | foreach ($options as $option) { |
| ... | ... | @@ -429,7 +426,7 @@ |
| 429 | 426 | } |
| 430 | 427 | } |
| 431 | 428 | |
| 432 | - if (!empty( $this->stocks )) { | |
| 429 | + if (!empty($this->stocks)) { | |
| 433 | 430 | ProductStock::deleteAll([ 'product_variant_id' => $this->id ]); |
| 434 | 431 | foreach ($this->stocks as $id => $quantity) { |
| 435 | 432 | /** |
| ... | ... | @@ -448,4 +445,25 @@ |
| 448 | 445 | } |
| 449 | 446 | } |
| 450 | 447 | } |
| 448 | + | |
| 449 | + /** | |
| 450 | + * @return string | |
| 451 | + */ | |
| 452 | + public function getSize() | |
| 453 | + { | |
| 454 | + $option = $this->getOptions() | |
| 455 | + ->with('lang') | |
| 456 | + ->joinWith('group') | |
| 457 | + ->where( | |
| 458 | + [ | |
| 459 | + 'tax_group.position' => 1, | |
| 460 | + ] | |
| 461 | + ) | |
| 462 | + ->one(); | |
| 463 | + if (empty($option)) { | |
| 464 | + return ''; | |
| 465 | + } else { | |
| 466 | + return $option->lang->value; | |
| 467 | + } | |
| 468 | + } | |
| 451 | 469 | } | ... | ... |
views/order/_form.php
| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | use backend\models\SmsTemplate; |
| 8 | 8 | use common\models\User; |
| 9 | 9 | use kartik\grid\GridView; |
| 10 | + use kartik\grid\SerialColumn; | |
| 10 | 11 | use kartik\widgets\DatePicker; |
| 11 | 12 | use kartik\widgets\Select2; |
| 12 | 13 | use kartik\widgets\SwitchInput; |
| ... | ... | @@ -15,8 +16,10 @@ |
| 15 | 16 | use yii\bootstrap\ActiveForm; |
| 16 | 17 | use yii\helpers\ArrayHelper; |
| 17 | 18 | use artweb\artbox\ecommerce\models\Delivery; |
| 19 | + use yii\helpers\StringHelper; | |
| 18 | 20 | use yii\web\View; |
| 19 | 21 | use yii\web\JsExpression; |
| 22 | + use yii\widgets\Pjax; | |
| 20 | 23 | |
| 21 | 24 | /** |
| 22 | 25 | * @var View $this |
| ... | ... | @@ -39,7 +42,23 @@ $(document).on('submit', '#add-product-form', function(e) { |
| 39 | 42 | data: addFormData, |
| 40 | 43 | success: function (data) { |
| 41 | 44 | if (data.status === "success") { |
| 42 | - $.pjax.reload({container:"#order-products-grid"}); //Reload GridView | |
| 45 | + $.pjax.reload({container:"#order-products-grid"}); | |
| 46 | + } | |
| 47 | + }, | |
| 48 | + error: function () { | |
| 49 | + } | |
| 50 | + }); | |
| 51 | +}); | |
| 52 | +$(document).on('click', '.delete-button', function(e) { | |
| 53 | + e.preventDefault(); | |
| 54 | + var link = $(this).attr('href') + '&order_id=' + {$model->id}; | |
| 55 | + $.ajax({ | |
| 56 | + url: link, | |
| 57 | + type: "GET", | |
| 58 | + success: function (data) { | |
| 59 | + if (data.status === "success") { | |
| 60 | + $.pjax.reload({container:"#order-products-grid"}); | |
| 61 | + $('[data-toggle="popover"]').popover(); | |
| 43 | 62 | } |
| 44 | 63 | }, |
| 45 | 64 | error: function () { |
| ... | ... | @@ -54,6 +73,11 @@ JS; |
| 54 | 73 | $('#order-phone, #order-phone2').mask('+38(000)000-00-00', { |
| 55 | 74 | placeholder: '+38(___)___-__-__' |
| 56 | 75 | }); |
| 76 | +$('[data-toggle="popover"]').popover(); | |
| 77 | +$(document).on('pjax:end', '#order-products-grid', function() { | |
| 78 | + $('[data-toggle="popover"]').popover(); | |
| 79 | + $.pjax.reload({container: '#total-cost'}); | |
| 80 | +}); | |
| 57 | 81 | JS; |
| 58 | 82 | |
| 59 | 83 | $this->registerJs($js, View::POS_READY); |
| ... | ... | @@ -120,480 +144,538 @@ JS; |
| 120 | 144 | |
| 121 | 145 | <?php $form = ActiveForm::begin([ 'id' => 'main-form' ]); ?> |
| 122 | 146 | <div class="container"> |
| 123 | - <div class="form-group"> | |
| 124 | - <br> | |
| 125 | - <div class="row"> | |
| 126 | - <div class="col-sm-6"> | |
| 127 | - | |
| 128 | - <?= $form->field($model, 'deadline') | |
| 129 | - ->widget( | |
| 130 | - DatePicker::className(), | |
| 131 | - [ | |
| 132 | - | |
| 133 | - ] | |
| 134 | - ) ?> | |
| 135 | - | |
| 136 | - <?php | |
| 137 | - if ($user->isAdmin()) { | |
| 138 | - echo $form->field($model, 'pay') | |
| 139 | - ->widget( | |
| 140 | - SwitchInput::className(), | |
| 141 | - [ | |
| 142 | - 'name' => 'pay', | |
| 143 | - 'pluginOptions' => [ | |
| 144 | - 'onText' => \Yii::t('app', 'Оплачено'), | |
| 145 | - 'offText' => \Yii::t('app', 'Не оплачено'), | |
| 146 | - ], | |
| 147 | - ] | |
| 148 | - ); | |
| 149 | - } | |
| 150 | - ?> | |
| 151 | - | |
| 152 | - <?= $form->field($model, 'reason') | |
| 153 | - ->dropDownList( | |
| 154 | - Order::REASONS, | |
| 155 | - [ 'prompt' => 'Выберите причину' ] | |
| 156 | - ) ?> | |
| 157 | - | |
| 158 | - <?= $form->field($model, 'label') | |
| 159 | - ->dropDownList( | |
| 160 | - ArrayHelper::map( | |
| 161 | - Label::find() | |
| 162 | - ->asArray() | |
| 163 | - ->all(), | |
| 164 | - 'id', | |
| 165 | - 'label' | |
| 166 | - ), | |
| 167 | - [ 'prompt' => 'Выберите метку' ] | |
| 168 | - ); ?> | |
| 169 | - | |
| 170 | - <?= $form->field($model, 'name') ?> | |
| 171 | - | |
| 172 | - <?= $form->field($model, 'phone') | |
| 173 | - ->textInput([ 'readonly' => $user->isAdmin() ? false : true ]) ?> | |
| 174 | - | |
| 175 | - <?= $form->field($model, 'phone2') ?> | |
| 176 | - | |
| 177 | - <?= $form->field($model, 'email') | |
| 178 | - ->textInput([ 'readonly' => $user->isAdmin() ? false : true ]) ?> | |
| 179 | - | |
| 180 | - <?= $form->field( | |
| 181 | - $model, | |
| 182 | - 'numbercard' | |
| 183 | - ) | |
| 184 | - ->textInput([ 'readonly' => true ]) ?> | |
| 185 | - | |
| 186 | - <?= $form->field($model, 'comment') | |
| 187 | - ->textarea([ 'rows' => '3' ]) ?> | |
| 188 | - <?= $form->field($model, 'delivery') | |
| 189 | - ->dropDownList( | |
| 190 | - ArrayHelper::map( | |
| 191 | - Delivery::find() | |
| 192 | - ->joinWith('lang') | |
| 193 | - ->asArray() | |
| 194 | - ->all(), | |
| 195 | - 'id', | |
| 196 | - 'lang.title' | |
| 197 | - ), | |
| 198 | - [ 'prompt' => \Yii::t('app', 'Выберите доставку ...') ] | |
| 199 | - ) ?> | |
| 200 | - | |
| 201 | - <?php | |
| 202 | - | |
| 203 | - if ($user->isAdmin()) { | |
| 204 | - echo $form->field($model, 'manager_id') | |
| 205 | - ->dropDownList( | |
| 206 | - ArrayHelper::map( | |
| 207 | - User::find() | |
| 208 | - ->asArray() | |
| 209 | - ->all(), | |
| 210 | - 'id', | |
| 211 | - 'username' | |
| 212 | - ), | |
| 213 | - [ 'prompt' => \Yii::t('app', 'Менеджер') ] | |
| 214 | - ); | |
| 215 | - } | |
| 216 | - ?> | |
| 217 | - | |
| 218 | - <h2><?php echo \Yii::t('app', 'Отправить смс'); ?></h2> | |
| 219 | - <?php | |
| 220 | - echo Select2::widget( | |
| 221 | - [ | |
| 222 | - 'id' => 'sms-template-selector', | |
| 223 | - 'name' => 'select-sms-template', | |
| 224 | - 'data' => ArrayHelper::map( | |
| 225 | - SmsTemplate::find() | |
| 226 | - ->asArray() | |
| 227 | - ->all(), | |
| 228 | - 'text', | |
| 229 | - 'title' | |
| 230 | - ), | |
| 231 | - 'options' => [ 'placeholder' => \Yii::t('app', 'Выберите шаблон') ], | |
| 232 | - 'pluginOptions' => [ | |
| 233 | - 'allowClear' => true, | |
| 234 | - ], | |
| 235 | - ] | |
| 236 | - ); | |
| 237 | - | |
| 238 | - ?> | |
| 239 | - <br> | |
| 240 | - <?php | |
| 241 | - echo Html::textarea( | |
| 242 | - 'sms-text', | |
| 243 | - '', | |
| 244 | - [ | |
| 245 | - 'rows' => 3, | |
| 246 | - 'id' => 'sms-text-area', | |
| 247 | - 'class' => 'form-control', | |
| 248 | - ] | |
| 249 | - ); | |
| 250 | - ?> | |
| 251 | - <br> | |
| 252 | - <div class="row"> | |
| 253 | - <div class="col-md-6"> | |
| 254 | - <?php | |
| 255 | - if ($model->isNewRecord) { | |
| 256 | - echo Html::button( | |
| 257 | - \Yii::t('app', 'Отправить'), | |
| 258 | - [ | |
| 259 | - 'class' => 'btn btn-warning disabled', | |
| 260 | - ] | |
| 261 | - ); | |
| 262 | - } else { | |
| 263 | - echo Html::button( | |
| 264 | - \Yii::t('app', 'Отправить'), | |
| 265 | - [ | |
| 266 | - 'class' => 'btn btn-warning', | |
| 267 | - 'id' => 'send-sms-action', | |
| 268 | - ] | |
| 269 | - ); | |
| 270 | - } | |
| 271 | - ?> | |
| 272 | - </div> | |
| 273 | - <div class="col-md-6"> | |
| 274 | - <?php | |
| 275 | - echo Html::radioList( | |
| 276 | - 'send-phone', | |
| 277 | - '1', | |
| 147 | + <div class="form-group"> | |
| 148 | + <br> | |
| 149 | + <div class="row"> | |
| 150 | + <div class="col-sm-6"> | |
| 151 | + | |
| 152 | + <?= $form->field($model, 'deadline') | |
| 153 | + ->widget( | |
| 154 | + DatePicker::className(), | |
| 155 | + [ | |
| 156 | + | |
| 157 | + ] | |
| 158 | + ) ?> | |
| 159 | + | |
| 160 | + <?php | |
| 161 | + if ($user->isAdmin()) { | |
| 162 | + echo $form->field($model, 'pay') | |
| 163 | + ->widget( | |
| 164 | + SwitchInput::className(), | |
| 278 | 165 | [ |
| 279 | - '1' => 'Первый номер', | |
| 280 | - '2' => 'Второй номер', | |
| 166 | + 'name' => 'pay', | |
| 167 | + 'pluginOptions' => [ | |
| 168 | + 'onText' => \Yii::t('app', 'Оплачено'), | |
| 169 | + 'offText' => \Yii::t('app', 'Не оплачено'), | |
| 170 | + ], | |
| 281 | 171 | ] |
| 282 | 172 | ); |
| 283 | - ?> | |
| 284 | - </div> | |
| 285 | - </div> | |
| 286 | - | |
| 287 | - </div> | |
| 288 | - <div class="col-sm-6"> | |
| 289 | - | |
| 290 | - <?= $form->field($model, 'declaration') ?> | |
| 291 | - | |
| 292 | - <?= $form->field($model, 'stock') ?> | |
| 293 | - | |
| 294 | - <?= $form->field($model, 'consignment') ?> | |
| 295 | - | |
| 296 | - <?= $form->field($model, 'payment') | |
| 297 | - ->dropDownList( | |
| 298 | - ArrayHelper::map( | |
| 299 | - OrderPayment::find() | |
| 300 | - ->where([ 'status' => OrderPayment::ACTIVE ]) | |
| 301 | - ->asArray() | |
| 302 | - ->all(), | |
| 303 | - 'id', | |
| 304 | - 'short' | |
| 305 | - ), | |
| 306 | - [ 'prompt' => 'Способ оплаты ...' ] | |
| 307 | - ); ?> | |
| 308 | - | |
| 309 | - <?= $form->field($model, 'insurance') ?> | |
| 310 | - | |
| 311 | - <?= $form->field($model, 'amount_imposed') ?> | |
| 312 | - | |
| 313 | - <?= $form->field($model, 'shipping_by') | |
| 314 | - ->dropDownList( | |
| 315 | - ArrayHelper::getColumn(Order::SHIPPING_BY, 'label'), | |
| 316 | - [ 'prompt' => 'Оплата доставки ...' ] | |
| 317 | - ); ?> | |
| 318 | - | |
| 319 | - <?= $form->field($model, 'city') ?> | |
| 320 | - | |
| 321 | - <?= $form->field($model, 'adress') ?> | |
| 322 | - | |
| 323 | - <?= $form->field($model, 'body') | |
| 324 | - ->textarea([ 'rows' => '3' ]) ?> | |
| 325 | - | |
| 326 | - <?= $form->field($model, 'check') ?> | |
| 327 | - | |
| 328 | - <?= $form->field($model, 'sms') ?> | |
| 329 | - | |
| 330 | - <?= $form->field($model, 'delivery_cost') ?> | |
| 331 | - | |
| 332 | - </div> | |
| 173 | + } | |
| 174 | + ?> | |
| 175 | + | |
| 176 | + <?= $form->field($model, 'reason') | |
| 177 | + ->dropDownList( | |
| 178 | + Order::REASONS, | |
| 179 | + [ 'prompt' => 'Выберите причину' ] | |
| 180 | + ) ?> | |
| 181 | + | |
| 182 | + <?= $form->field($model, 'label') | |
| 183 | + ->dropDownList( | |
| 184 | + ArrayHelper::map( | |
| 185 | + Label::find() | |
| 186 | + ->asArray() | |
| 187 | + ->all(), | |
| 188 | + 'id', | |
| 189 | + 'label' | |
| 190 | + ), | |
| 191 | + [ 'prompt' => 'Выберите метку' ] | |
| 192 | + ); ?> | |
| 193 | + | |
| 194 | + <?= $form->field($model, 'name') ?> | |
| 195 | + | |
| 196 | + <?= $form->field($model, 'phone') | |
| 197 | + ->textInput([ 'readonly' => $user->isAdmin() ? false : true ]) ?> | |
| 198 | + | |
| 199 | + <?= $form->field($model, 'phone2') ?> | |
| 200 | + | |
| 201 | + <?= $form->field($model, 'email') | |
| 202 | + ->textInput([ 'readonly' => $user->isAdmin() ? false : true ]) ?> | |
| 203 | + | |
| 204 | + <?= $form->field( | |
| 205 | + $model, | |
| 206 | + 'numbercard' | |
| 207 | + ) | |
| 208 | + ->textInput([ 'readonly' => true ]) ?> | |
| 209 | + | |
| 210 | + <?= $form->field($model, 'comment') | |
| 211 | + ->textarea([ 'rows' => '3' ]) ?> | |
| 212 | + <?= $form->field($model, 'delivery') | |
| 213 | + ->dropDownList( | |
| 214 | + ArrayHelper::map( | |
| 215 | + Delivery::find() | |
| 216 | + ->joinWith('lang') | |
| 217 | + ->asArray() | |
| 218 | + ->all(), | |
| 219 | + 'id', | |
| 220 | + 'lang.title' | |
| 221 | + ), | |
| 222 | + [ 'prompt' => \Yii::t('app', 'Выберите доставку ...') ] | |
| 223 | + ) ?> | |
| 224 | + | |
| 225 | + <?php | |
| 226 | + | |
| 227 | + if ($user->isAdmin()) { | |
| 228 | + echo $form->field($model, 'manager_id') | |
| 229 | + ->dropDownList( | |
| 230 | + ArrayHelper::map( | |
| 231 | + User::find() | |
| 232 | + ->asArray() | |
| 233 | + ->all(), | |
| 234 | + 'id', | |
| 235 | + 'username' | |
| 236 | + ), | |
| 237 | + [ 'prompt' => \Yii::t('app', 'Менеджер') ] | |
| 238 | + ); | |
| 239 | + } | |
| 240 | + ?> | |
| 241 | + | |
| 242 | + <h2><?php echo \Yii::t('app', 'Отправить смс'); ?></h2> | |
| 243 | + <?php | |
| 244 | + echo Select2::widget( | |
| 245 | + [ | |
| 246 | + 'id' => 'sms-template-selector', | |
| 247 | + 'name' => 'select-sms-template', | |
| 248 | + 'data' => ArrayHelper::map( | |
| 249 | + SmsTemplate::find() | |
| 250 | + ->asArray() | |
| 251 | + ->all(), | |
| 252 | + 'text', | |
| 253 | + 'title' | |
| 254 | + ), | |
| 255 | + 'options' => [ 'placeholder' => \Yii::t('app', 'Выберите шаблон') ], | |
| 256 | + 'pluginOptions' => [ | |
| 257 | + 'allowClear' => true, | |
| 258 | + ], | |
| 259 | + ] | |
| 260 | + ); | |
| 261 | + | |
| 262 | + ?> | |
| 263 | + <br> | |
| 264 | + <?php | |
| 265 | + echo Html::textarea( | |
| 266 | + 'sms-text', | |
| 267 | + '', | |
| 268 | + [ | |
| 269 | + 'rows' => 3, | |
| 270 | + 'id' => 'sms-text-area', | |
| 271 | + 'class' => 'form-control', | |
| 272 | + ] | |
| 273 | + ); | |
| 274 | + ?> | |
| 275 | + <br> | |
| 276 | + <div class="row"> | |
| 277 | + <div class="col-md-6"> | |
| 278 | + <?php | |
| 279 | + if ($model->isNewRecord) { | |
| 280 | + echo Html::button( | |
| 281 | + \Yii::t('app', 'Отправить'), | |
| 282 | + [ | |
| 283 | + 'class' => 'btn btn-warning disabled', | |
| 284 | + ] | |
| 285 | + ); | |
| 286 | + } else { | |
| 287 | + echo Html::button( | |
| 288 | + \Yii::t('app', 'Отправить'), | |
| 289 | + [ | |
| 290 | + 'class' => 'btn btn-warning', | |
| 291 | + 'id' => 'send-sms-action', | |
| 292 | + ] | |
| 293 | + ); | |
| 294 | + } | |
| 295 | + ?> | |
| 296 | + </div> | |
| 297 | + <div class="col-md-6"> | |
| 298 | + <?php | |
| 299 | + echo Html::radioList( | |
| 300 | + 'send-phone', | |
| 301 | + '1', | |
| 302 | + [ | |
| 303 | + '1' => 'Первый номер', | |
| 304 | + '2' => 'Второй номер', | |
| 305 | + ] | |
| 306 | + ); | |
| 307 | + ?> | |
| 308 | + </div> | |
| 333 | 309 | </div> |
| 310 | + | |
| 311 | + </div> | |
| 312 | + <div class="col-sm-6"> | |
| 313 | + | |
| 314 | + <?= $form->field($model, 'declaration') ?> | |
| 315 | + | |
| 316 | + <?= $form->field($model, 'stock') ?> | |
| 317 | + | |
| 318 | + <?= $form->field($model, 'consignment') ?> | |
| 319 | + | |
| 320 | + <?= $form->field($model, 'payment') | |
| 321 | + ->dropDownList( | |
| 322 | + ArrayHelper::map( | |
| 323 | + OrderPayment::find() | |
| 324 | + ->where([ 'status' => OrderPayment::ACTIVE ]) | |
| 325 | + ->asArray() | |
| 326 | + ->all(), | |
| 327 | + 'id', | |
| 328 | + 'short' | |
| 329 | + ), | |
| 330 | + [ 'prompt' => 'Способ оплаты ...' ] | |
| 331 | + ); ?> | |
| 332 | + | |
| 333 | + <?= $form->field($model, 'insurance') ?> | |
| 334 | + | |
| 335 | + <?= $form->field($model, 'amount_imposed') ?> | |
| 336 | + | |
| 337 | + <?= $form->field($model, 'shipping_by') | |
| 338 | + ->dropDownList( | |
| 339 | + ArrayHelper::getColumn(Order::SHIPPING_BY, 'label'), | |
| 340 | + [ 'prompt' => 'Оплата доставки ...' ] | |
| 341 | + ); ?> | |
| 342 | + | |
| 343 | + <?= $form->field($model, 'city') ?> | |
| 344 | + | |
| 345 | + <?= $form->field($model, 'adress') ?> | |
| 346 | + | |
| 347 | + <?= $form->field($model, 'body') | |
| 348 | + ->textarea([ 'rows' => '3' ]) ?> | |
| 349 | + | |
| 350 | + <?= $form->field($model, 'check') ?> | |
| 351 | + | |
| 352 | + <?= $form->field($model, 'sms') ?> | |
| 353 | + | |
| 354 | + <?= $form->field($model, 'delivery_cost') ?> | |
| 355 | + | |
| 356 | + </div> | |
| 334 | 357 | </div> |
| 358 | + </div> | |
| 335 | 359 | </div> |
| 336 | 360 | |
| 337 | 361 | <?php ActiveForm::end(); ?> |
| 338 | 362 | <br> |
| 339 | 363 | <br> |
| 340 | 364 | <div class="container"> |
| 341 | - <div class="row"> | |
| 342 | - <?php | |
| 343 | - echo GridView::widget( | |
| 344 | - [ | |
| 345 | - 'dataProvider' => $dataProvider, | |
| 346 | - 'rowOptions' => function($model) { | |
| 347 | - if ($model->removed) { | |
| 348 | - return [ 'class' => 'danger' ]; | |
| 349 | - } else { | |
| 350 | - return []; | |
| 351 | - } | |
| 352 | - }, | |
| 353 | - 'layout' => '{items}{pager}', | |
| 354 | - 'columns' => [ | |
| 355 | - 'id', | |
| 356 | - 'sku', | |
| 357 | - 'product_name', | |
| 358 | - 'productVariant.product.brand.lang.title', | |
| 359 | - 'productVariant.lang.title', | |
| 360 | - 'price', | |
| 361 | - [ | |
| 362 | - 'class' => 'kartik\grid\EditableColumn', | |
| 363 | - 'attribute' => 'count', | |
| 364 | - 'editableOptions' => [ | |
| 365 | - 'header' => \Yii::t('app', 'Количество'), | |
| 366 | - 'inputType' => kartik\editable\Editable::INPUT_SPIN, | |
| 367 | - 'options' => [ | |
| 368 | - 'pluginOptions' => [ | |
| 369 | - 'min' => 0, | |
| 370 | - 'max' => 5000, | |
| 371 | - ], | |
| 372 | - ], | |
| 373 | - 'pluginEvents' => [ | |
| 374 | - 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 375 | - ], | |
| 376 | - ], | |
| 377 | - 'format' => [ | |
| 378 | - 'decimal', | |
| 379 | - 0, | |
| 380 | - ], | |
| 381 | - 'pageSummary' => false, | |
| 382 | - ], | |
| 383 | - 'sum_cost', | |
| 384 | - [ | |
| 385 | - 'class' => 'kartik\grid\EditableColumn', | |
| 386 | - 'attribute' => 'booking', | |
| 387 | - 'editableOptions' => [ | |
| 388 | - 'header' => \Yii::t('app', 'Бронь'), | |
| 389 | - 'inputType' => kartik\editable\Editable::INPUT_TEXT, | |
| 390 | - 'options' => [ | |
| 391 | - 'class' => 'booking-typeahead', | |
| 392 | - 'pluginOptions' => [ | |
| 393 | - 'min' => 0, | |
| 394 | - 'max' => 20, | |
| 395 | - ], | |
| 396 | - ], | |
| 397 | - 'pluginEvents' => [ | |
| 398 | - 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 399 | - ], | |
| 400 | - ], | |
| 401 | - 'format' => [ | |
| 402 | - 'text', | |
| 403 | - ], | |
| 404 | - 'pageSummary' => false, | |
| 405 | - ], | |
| 406 | - [ | |
| 407 | - 'class' => 'kartik\grid\EditableColumn', | |
| 408 | - 'attribute' => 'status', | |
| 409 | - 'editableOptions' => [ | |
| 410 | - 'header' => \Yii::t('app', 'Статус'), | |
| 411 | - 'inputType' => kartik\editable\Editable::INPUT_TEXT, | |
| 412 | - 'options' => [ | |
| 413 | - 'class' => 'status-typeahead', | |
| 414 | - 'pluginOptions' => [ | |
| 415 | - 'min' => 0, | |
| 416 | - 'max' => 20, | |
| 417 | - ], | |
| 418 | - ], | |
| 419 | - 'pluginEvents' => [ | |
| 420 | - 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 421 | - ], | |
| 422 | - ], | |
| 423 | - 'format' => [ | |
| 424 | - 'text', | |
| 425 | - ], | |
| 426 | - 'pageSummary' => false, | |
| 427 | - ], | |
| 428 | - [ | |
| 429 | - 'class' => 'kartik\grid\EditableColumn', | |
| 430 | - 'attribute' => 'return', | |
| 431 | - 'editableOptions' => [ | |
| 432 | - 'header' => \Yii::t('app', 'Возврат'), | |
| 433 | - 'inputType' => kartik\editable\Editable::INPUT_CHECKBOX, | |
| 434 | - 'options' => [], | |
| 435 | - 'pluginEvents' => [ | |
| 436 | - 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 437 | - ], | |
| 438 | - ], | |
| 439 | - 'format' => [ | |
| 440 | - 'boolean', | |
| 441 | - ], | |
| 442 | - 'pageSummary' => false, | |
| 443 | - ], | |
| 444 | - [ | |
| 445 | - 'class' => 'yii\grid\ActionColumn', | |
| 446 | - 'template' => '{delete}', | |
| 447 | - 'buttons' => [ | |
| 448 | - 'delete' => function($url, $model) { | |
| 449 | - if ($model->removed) { | |
| 450 | - return ''; | |
| 451 | - } else { | |
| 452 | - return Html::a( | |
| 453 | - Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-trash' ]), | |
| 454 | - [ | |
| 455 | - 'delete-product', | |
| 456 | - 'id' => $model->id, | |
| 457 | - ], | |
| 458 | - [ | |
| 459 | - 'data' => [ | |
| 460 | - 'confirm' => 'Вы уверены, что хотите удалить этот элемент?', | |
| 461 | - 'method' => 'POST', | |
| 462 | - ], | |
| 463 | - ] | |
| 464 | - ); | |
| 465 | - } | |
| 466 | - }, | |
| 467 | - ], | |
| 468 | - ], | |
| 469 | - ], | |
| 470 | - 'responsive' => true, | |
| 471 | - 'hover' => true, | |
| 472 | - 'pjax' => true, | |
| 473 | - 'pjaxSettings' => [ | |
| 474 | - 'options' => [ | |
| 475 | - 'scrollTo' => 'false', | |
| 476 | - 'id' => 'order-products-grid', | |
| 477 | - ], | |
| 478 | - ], | |
| 479 | - ] | |
| 480 | - ); | |
| 481 | - ?> | |
| 482 | - </div> | |
| 365 | + <div class="row"> | |
| 366 | + <?php | |
| 367 | + echo GridView::widget( | |
| 368 | + [ | |
| 369 | + 'dataProvider' => $dataProvider, | |
| 370 | + 'rowOptions' => function($model) { | |
| 371 | + if ($model->removed) { | |
| 372 | + return [ 'class' => 'danger' ]; | |
| 373 | + } else { | |
| 374 | + return []; | |
| 375 | + } | |
| 376 | + }, | |
| 377 | + 'layout' => '{items}{pager}', | |
| 378 | + 'columns' => [ | |
| 379 | + [ | |
| 380 | + 'class' => SerialColumn::className(), | |
| 381 | + ], | |
| 382 | + 'sku', | |
| 383 | + [ | |
| 384 | + 'attribute' => 'product_name', | |
| 385 | + 'content' => function($model) { | |
| 386 | + if (!empty($model->product_name)) { | |
| 387 | + return Html::a( | |
| 388 | + StringHelper::truncate($model->product_name, 10, '...'), | |
| 389 | + '#', | |
| 390 | + [ | |
| 391 | + 'data-toggle' => 'tooltip', | |
| 392 | + 'title' => $model->product_name, | |
| 393 | + 'onclick' => 'event.preventDefault();', | |
| 394 | + ] | |
| 395 | + ); | |
| 396 | + } else { | |
| 397 | + return ''; | |
| 398 | + } | |
| 399 | + }, | |
| 400 | + ], | |
| 401 | + 'productVariant.product.brand.lang.title', | |
| 402 | + [ | |
| 403 | + 'attribute' => 'productVariant.lang.title', | |
| 404 | + 'label' => \Yii::t('app', 'Цвет'), | |
| 405 | + 'content' => function($model) { | |
| 406 | + if (preg_match('@.*\.(png|jpg|gif)@i', $model->productVariant->lang->title)) { | |
| 407 | + return ''; | |
| 408 | + } else { | |
| 409 | + return $model->productVariant->lang->title; | |
| 410 | + } | |
| 411 | + }, | |
| 412 | + ], | |
| 413 | + 'productVariant.size', | |
| 414 | + 'price', | |
| 415 | + [ | |
| 416 | + 'class' => 'kartik\grid\EditableColumn', | |
| 417 | + 'attribute' => 'count', | |
| 418 | + 'editableOptions' => [ | |
| 419 | + 'header' => \Yii::t('app', 'Количество'), | |
| 420 | + 'inputType' => kartik\editable\Editable::INPUT_SPIN, | |
| 421 | + 'options' => [ | |
| 422 | + 'pluginOptions' => [ | |
| 423 | + 'min' => 0, | |
| 424 | + 'max' => 5000, | |
| 425 | + ], | |
| 426 | + ], | |
| 427 | + 'pluginEvents' => [ | |
| 428 | + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 429 | + ], | |
| 430 | + ], | |
| 431 | + 'format' => [ | |
| 432 | + 'decimal', | |
| 433 | + 0, | |
| 434 | + ], | |
| 435 | + 'pageSummary' => false, | |
| 436 | + ], | |
| 437 | + 'sum_cost', | |
| 438 | + [ | |
| 439 | + 'class' => 'kartik\grid\EditableColumn', | |
| 440 | + 'attribute' => 'booking', | |
| 441 | + 'editableOptions' => [ | |
| 442 | + 'header' => \Yii::t('app', 'Бронь'), | |
| 443 | + 'inputType' => kartik\editable\Editable::INPUT_TEXT, | |
| 444 | + 'options' => [ | |
| 445 | + 'class' => 'booking-typeahead', | |
| 446 | + 'pluginOptions' => [ | |
| 447 | + 'min' => 0, | |
| 448 | + 'max' => 20, | |
| 449 | + ], | |
| 450 | + ], | |
| 451 | + 'pluginEvents' => [ | |
| 452 | + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 453 | + ], | |
| 454 | + ], | |
| 455 | + 'format' => [ | |
| 456 | + 'text', | |
| 457 | + ], | |
| 458 | + 'pageSummary' => false, | |
| 459 | + ], | |
| 460 | + [ | |
| 461 | + 'class' => 'kartik\grid\EditableColumn', | |
| 462 | + 'attribute' => 'status', | |
| 463 | + 'editableOptions' => [ | |
| 464 | + 'header' => \Yii::t('app', 'Статус'), | |
| 465 | + 'inputType' => kartik\editable\Editable::INPUT_TEXT, | |
| 466 | + 'options' => [ | |
| 467 | + 'class' => 'status-typeahead', | |
| 468 | + 'pluginOptions' => [ | |
| 469 | + 'min' => 0, | |
| 470 | + 'max' => 20, | |
| 471 | + ], | |
| 472 | + ], | |
| 473 | + 'pluginEvents' => [ | |
| 474 | + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 475 | + ], | |
| 476 | + ], | |
| 477 | + 'format' => [ | |
| 478 | + 'text', | |
| 479 | + ], | |
| 480 | + 'pageSummary' => false, | |
| 481 | + ], | |
| 482 | + [ | |
| 483 | + 'class' => 'kartik\grid\EditableColumn', | |
| 484 | + 'attribute' => 'return', | |
| 485 | + 'editableOptions' => [ | |
| 486 | + 'header' => \Yii::t('app', 'Возврат'), | |
| 487 | + 'inputType' => kartik\editable\Editable::INPUT_CHECKBOX, | |
| 488 | + 'options' => [], | |
| 489 | + 'pluginEvents' => [ | |
| 490 | + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 491 | + ], | |
| 492 | + ], | |
| 493 | + 'format' => [ | |
| 494 | + 'boolean', | |
| 495 | + ], | |
| 496 | + 'pageSummary' => false, | |
| 497 | + ], | |
| 498 | + [ | |
| 499 | +// 'label' => \Yii::t('app', 'Склады'), | |
| 500 | + 'content' => function($model) { | |
| 501 | + $content = '<table class="table"><tbody><tr><th>Склад</th><th>кол.</th></tr>'; | |
| 502 | + foreach ($model->productVariant->variantStocks as $stock) { | |
| 503 | + $content .= '<tr><td>' . $stock->stock->title . '</td><td>' . $stock->quantity . '</td></tr>'; | |
| 504 | + } | |
| 505 | + return Html::a( | |
| 506 | + '<i class="glyphicon glyphicon-home"></i>', | |
| 507 | + '#', | |
| 508 | + [ | |
| 509 | + 'onclick' => 'event.preventDefault();', | |
| 510 | + 'data-toggle' => 'popover', | |
| 511 | + 'data-placement' => 'left', | |
| 512 | + 'data-html' => 'true', | |
| 513 | + 'data-content' => $content . '</tbody></table>', | |
| 514 | + ] | |
| 515 | + ); | |
| 516 | + }, | |
| 517 | + ], | |
| 518 | + [ | |
| 519 | + 'class' => 'yii\grid\ActionColumn', | |
| 520 | + 'template' => '{delete}', | |
| 521 | + 'buttons' => [ | |
| 522 | + 'delete' => function($url, $product) { | |
| 523 | + if ($product->removed) { | |
| 524 | + return ''; | |
| 525 | + } else { | |
| 526 | + return Html::a( | |
| 527 | + Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-trash' ]), | |
| 528 | + [ | |
| 529 | + 'delete-product', | |
| 530 | + 'id' => $product->id, | |
| 531 | + ], | |
| 532 | + [ | |
| 533 | + 'class' => 'delete-button', | |
| 534 | + // 'data' => [ | |
| 535 | + // 'confirm' => 'Вы уверены, что хотите удалить этот элемент?', | |
| 536 | + // 'method' => 'GET', | |
| 537 | + // ], | |
| 538 | + ] | |
| 539 | + ); | |
| 540 | + } | |
| 541 | + }, | |
| 542 | + ], | |
| 543 | + ], | |
| 544 | + ], | |
| 545 | + 'responsive' => true, | |
| 546 | + 'hover' => true, | |
| 547 | + 'pjax' => true, | |
| 548 | + 'pjaxSettings' => [ | |
| 549 | + 'options' => [ | |
| 550 | + 'scrollTo' => 'false', | |
| 551 | + 'id' => 'order-products-grid', | |
| 552 | + ], | |
| 553 | + ], | |
| 554 | + ] | |
| 555 | + ); | |
| 556 | + ?> | |
| 557 | + </div> | |
| 483 | 558 | </div> |
| 484 | - | |
| 485 | 559 | <div class="container"> |
| 486 | - <div class="row"> | |
| 487 | - <?php $newProductForm = ActiveForm::begin( | |
| 488 | - [ | |
| 489 | - 'action' => yii\helpers\Url::to([ 'add' ]), | |
| 490 | - 'id' => 'add-product-form', | |
| 491 | - ] | |
| 492 | - ); | |
| 493 | - $newOrderProduct = new OrderProduct(); | |
| 494 | - ?> | |
| 495 | - <div class="col-md-8"> | |
| 496 | - <?php echo $newProductForm->field($newOrderProduct, 'id') | |
| 497 | - ->widget( | |
| 498 | - Select2::className(), | |
| 499 | - [ | |
| 500 | - 'options' => [ 'placeholder' => 'Search for a product ...' ], | |
| 501 | - 'pluginOptions' => [ | |
| 502 | - 'allowClear' => true, | |
| 503 | - 'disabled' => $model->isNewRecord ? true : false, | |
| 504 | - 'minimumInputLength' => 3, | |
| 505 | - 'language' => [ | |
| 506 | - 'errorLoading' => new JsExpression( | |
| 507 | - "function () { return 'Waiting for results...'; }" | |
| 508 | - ), | |
| 509 | - ], | |
| 510 | - 'ajax' => [ | |
| 511 | - 'url' => \yii\helpers\Url::to([ 'find-product' ]), | |
| 512 | - 'dataType' => 'json', | |
| 513 | - 'data' => new JsExpression( | |
| 514 | - 'function(params) { return {q:params.term}; }' | |
| 515 | - ), | |
| 516 | - ], | |
| 517 | - 'escapeMarkup' => new JsExpression( | |
| 518 | - 'function (markup) { return markup; }' | |
| 519 | - ), | |
| 520 | - 'templateResult' => new JsExpression( | |
| 521 | - 'function(data) { return data.sku; }' | |
| 560 | + <?php Pjax::begin([ 'id' => 'total-cost' ]); ?> | |
| 561 | + <h2>Сумма заказа : <span class="label label-success"><?php echo $model->total; ?><?php echo \Yii::t( | |
| 562 | + 'app', | |
| 563 | + 'грн' | |
| 564 | + ) ?></span></h2> | |
| 565 | + <?php Pjax::end(); ?> | |
| 566 | +</div> | |
| 567 | +<div class="container"> | |
| 568 | + <div class="row"> | |
| 569 | + <?php $newProductForm = ActiveForm::begin( | |
| 570 | + [ | |
| 571 | + 'action' => yii\helpers\Url::to([ 'add' ]), | |
| 572 | + 'id' => 'add-product-form', | |
| 573 | + ] | |
| 574 | + ); | |
| 575 | + $newOrderProduct = new OrderProduct(); | |
| 576 | + ?> | |
| 577 | + <div class="col-md-8"> | |
| 578 | + <?php echo $newProductForm->field($newOrderProduct, 'id') | |
| 579 | + ->widget( | |
| 580 | + Select2::className(), | |
| 581 | + [ | |
| 582 | + 'options' => [ 'placeholder' => 'Search for a product ...' ], | |
| 583 | + 'pluginOptions' => [ | |
| 584 | + 'allowClear' => true, | |
| 585 | + 'disabled' => $model->isNewRecord ? true : false, | |
| 586 | + 'minimumInputLength' => 3, | |
| 587 | + 'language' => [ | |
| 588 | + 'errorLoading' => new JsExpression( | |
| 589 | + "function () { return 'Waiting for results...'; }" | |
| 522 | 590 | ), |
| 523 | - 'templateSelection' => new JsExpression( | |
| 524 | - 'function (data) { return data.sku; }' | |
| 591 | + ], | |
| 592 | + 'ajax' => [ | |
| 593 | + 'url' => \yii\helpers\Url::to([ 'find-product' ]), | |
| 594 | + 'dataType' => 'json', | |
| 595 | + 'data' => new JsExpression( | |
| 596 | + 'function(params) { return {q:params.term}; }' | |
| 525 | 597 | ), |
| 526 | 598 | ], |
| 527 | - ] | |
| 528 | - ); | |
| 529 | - | |
| 530 | - ?> | |
| 531 | - </div> | |
| 532 | - <div class="col-md-2"> | |
| 533 | - <?php echo $newProductForm->field( | |
| 534 | - $newOrderProduct, | |
| 535 | - 'count' | |
| 536 | - ) | |
| 537 | - ->input( | |
| 538 | - 'number', | |
| 539 | - [ | |
| 540 | - 'disabled' => $model->isNewRecord ? true : false, | |
| 541 | - ] | |
| 542 | - ); ?> | |
| 543 | - </div> | |
| 544 | - <div class="col-md-2" style="margin-top: 23px"> | |
| 545 | - <?php echo Html::submitButton( | |
| 546 | - 'Add', | |
| 547 | - [ | |
| 548 | - 'class' => $model->isNewRecord ? 'btn btn-primary disabled' : 'btn btn-primary', | |
| 549 | - ] | |
| 550 | - ) ?> | |
| 551 | - </div> | |
| 552 | - <?php echo $newProductForm->field($newOrderProduct, 'order_id') | |
| 553 | - ->hiddenInput( | |
| 599 | + 'escapeMarkup' => new JsExpression( | |
| 600 | + 'function (markup) { return markup; }' | |
| 601 | + ), | |
| 602 | + 'templateResult' => new JsExpression( | |
| 603 | + 'function(data) { return data.sku; }' | |
| 604 | + ), | |
| 605 | + 'templateSelection' => new JsExpression( | |
| 606 | + 'function (data) { return data.sku; }' | |
| 607 | + ), | |
| 608 | + ], | |
| 609 | + ] | |
| 610 | + ); | |
| 611 | + | |
| 612 | + ?> | |
| 613 | + </div> | |
| 614 | + <div class="col-md-2"> | |
| 615 | + <?php echo $newProductForm->field( | |
| 616 | + $newOrderProduct, | |
| 617 | + 'count' | |
| 618 | + ) | |
| 619 | + ->input( | |
| 620 | + 'number', | |
| 554 | 621 | [ |
| 555 | - 'value' => $model->id, | |
| 622 | + 'disabled' => $model->isNewRecord ? true : false, | |
| 556 | 623 | ] |
| 557 | - ) | |
| 558 | - ->label(false) ?> | |
| 559 | - <?php ActiveForm::end(); ?> | |
| 624 | + ); ?> | |
| 560 | 625 | </div> |
| 561 | - | |
| 562 | - <br> | |
| 563 | - <div class="row"> | |
| 564 | - <?= Html::button( | |
| 565 | - $model->isNewRecord ? \Yii::t('app', 'Создать') : \Yii::t('app', 'Сохранить'), | |
| 566 | - [ | |
| 567 | - 'class' => $model->isNewRecord ? 'btn btn-success btn-lg' : 'btn btn-primary btn-lg', | |
| 568 | - 'id' => 'page-submit', | |
| 569 | - ] | |
| 570 | - ) ?> | |
| 571 | - <?= Html::a( | |
| 572 | - \Yii::t('app', 'Печать'), | |
| 573 | - yii\helpers\Url::to( | |
| 574 | - [ | |
| 575 | - 'order/print', | |
| 576 | - 'order_id' => $model->id, | |
| 577 | - ] | |
| 578 | - ), | |
| 626 | + <div class="col-md-2" style="margin-top: 23px"> | |
| 627 | + <?php echo Html::submitButton( | |
| 628 | + 'Add', | |
| 579 | 629 | [ |
| 580 | - 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | |
| 581 | - 'target' => '_blank', | |
| 582 | - ] | |
| 583 | - ) ?> | |
| 584 | - <?= Html::a( | |
| 585 | - \Yii::t('app', 'Выйти'), | |
| 586 | - yii\helpers\Url::to( | |
| 587 | - [ | |
| 588 | - 'exit-order', | |
| 589 | - 'id' => $model->id, | |
| 590 | - ] | |
| 591 | - ), | |
| 592 | - [ | |
| 593 | - 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | |
| 630 | + 'class' => $model->isNewRecord ? 'btn btn-primary disabled' : 'btn btn-primary', | |
| 594 | 631 | ] |
| 595 | 632 | ) ?> |
| 596 | 633 | </div> |
| 634 | + <?php echo $newProductForm->field($newOrderProduct, 'order_id') | |
| 635 | + ->hiddenInput( | |
| 636 | + [ | |
| 637 | + 'value' => $model->id, | |
| 638 | + ] | |
| 639 | + ) | |
| 640 | + ->label(false) ?> | |
| 641 | + <?php ActiveForm::end(); ?> | |
| 642 | + </div> | |
| 643 | + | |
| 644 | + <br> | |
| 645 | + <div class="row"> | |
| 646 | + <?= Html::button( | |
| 647 | + $model->isNewRecord ? \Yii::t('app', 'Создать') : \Yii::t('app', 'Сохранить'), | |
| 648 | + [ | |
| 649 | + 'class' => $model->isNewRecord ? 'btn btn-success btn-lg' : 'btn btn-primary btn-lg', | |
| 650 | + 'id' => 'page-submit', | |
| 651 | + ] | |
| 652 | + ) ?> | |
| 653 | + <?= Html::a( | |
| 654 | + \Yii::t('app', 'Печать'), | |
| 655 | + yii\helpers\Url::to( | |
| 656 | + [ | |
| 657 | + 'order/print', | |
| 658 | + 'order_id' => $model->id, | |
| 659 | + ] | |
| 660 | + ), | |
| 661 | + [ | |
| 662 | + 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | |
| 663 | + 'target' => '_blank', | |
| 664 | + ] | |
| 665 | + ) ?> | |
| 666 | + <?= Html::a( | |
| 667 | + \Yii::t('app', 'Выйти'), | |
| 668 | + yii\helpers\Url::to( | |
| 669 | + [ | |
| 670 | + 'exit-order', | |
| 671 | + 'id' => $model->id, | |
| 672 | + ] | |
| 673 | + ), | |
| 674 | + [ | |
| 675 | + 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | |
| 676 | + ] | |
| 677 | + ) ?> | |
| 678 | + </div> | |
| 597 | 679 | |
| 598 | 680 | </div> |
| 599 | 681 | <br> | ... | ... |