Commit a2051ae60e2182bff0ae53db9926e89efb61b10a
Merge remote-tracking branch 'origin/master'
Showing
9 changed files
with
192 additions
and
188 deletions
Show diff stats
controllers/OrderController.php
| @@ -315,22 +315,14 @@ | @@ -315,22 +315,14 @@ | ||
| 315 | * @var Variant[] $variants | 315 | * @var Variant[] $variants |
| 316 | */ | 316 | */ |
| 317 | $variants = Variant::find() | 317 | $variants = Variant::find() |
| 318 | - ->joinWith('lang', false) | ||
| 319 | ->joinWith('product.lang', false) | 318 | ->joinWith('product.lang', false) |
| 320 | - ->andWhere( | 319 | + ->where( |
| 321 | [ | 320 | [ |
| 322 | 'like', | 321 | 'like', |
| 323 | 'product_lang.title', | 322 | 'product_lang.title', |
| 324 | $q, | 323 | $q, |
| 325 | ] | 324 | ] |
| 326 | ) | 325 | ) |
| 327 | - ->orWhere( | ||
| 328 | - [ | ||
| 329 | - 'like', | ||
| 330 | - 'variant_lang.title', | ||
| 331 | - $q, | ||
| 332 | - ] | ||
| 333 | - ) | ||
| 334 | ->orWhere([ 'variant.sku' => $q ]) | 326 | ->orWhere([ 'variant.sku' => $q ]) |
| 335 | ->all(); | 327 | ->all(); |
| 336 | foreach ($variants as $variant) { | 328 | foreach ($variants as $variant) { |
labels/controllers/DeliveryController.php
| @@ -153,6 +153,10 @@ | @@ -153,6 +153,10 @@ | ||
| 153 | 'type' => Form::BOOL, | 153 | 'type' => Form::BOOL, |
| 154 | ], | 154 | ], |
| 155 | [ | 155 | [ |
| 156 | + 'name' => 'default', | ||
| 157 | + 'type' => Form::BOOL, | ||
| 158 | + ], | ||
| 159 | + [ | ||
| 156 | 'name' => 'sort', | 160 | 'name' => 'sort', |
| 157 | 'type' => Form::NUMBER, | 161 | 'type' => Form::NUMBER, |
| 158 | ], | 162 | ], |
| @@ -160,11 +164,6 @@ | @@ -160,11 +164,6 @@ | ||
| 160 | 'name' => 'value', | 164 | 'name' => 'value', |
| 161 | 'type' => Form::NUMBER, | 165 | 'type' => Form::NUMBER, |
| 162 | ], | 166 | ], |
| 163 | - [ | ||
| 164 | - 'name' => 'default', | ||
| 165 | - 'type' => Form::BOOL, | ||
| 166 | - ], | ||
| 167 | - | ||
| 168 | ], | 167 | ], |
| 169 | ]; | 168 | ]; |
| 170 | } | 169 | } |
views/delivery/_form.php
| @@ -22,13 +22,13 @@ | @@ -22,13 +22,13 @@ | ||
| 22 | 'form' => $form, | 22 | 'form' => $form, |
| 23 | ] | 23 | ] |
| 24 | ) ?> | 24 | ) ?> |
| 25 | - | 25 | + |
| 26 | <?= $form->field($model, 'sort') | 26 | <?= $form->field($model, 'sort') |
| 27 | ->textInput() ?> | 27 | ->textInput() ?> |
| 28 | - | 28 | + |
| 29 | <?= $form->field($model, 'value') | 29 | <?= $form->field($model, 'value') |
| 30 | ->textInput() ?> | 30 | ->textInput() ?> |
| 31 | - | 31 | + |
| 32 | <?= $form->field($model, 'status') | 32 | <?= $form->field($model, 'status') |
| 33 | ->checkbox( | 33 | ->checkbox( |
| 34 | [ | 34 | [ |
views/order/_form.php
| @@ -13,133 +13,145 @@ | @@ -13,133 +13,145 @@ | ||
| 13 | * @var array $deliveries | 13 | * @var array $deliveries |
| 14 | * @var array $payments | 14 | * @var array $payments |
| 15 | * @var ActiveForm $form | 15 | * @var ActiveForm $form |
| 16 | + * @var bool $isCreate | ||
| 16 | */ | 17 | */ |
| 17 | ?> | 18 | ?> |
| 18 | 19 | ||
| 19 | <div class="order-form"> | 20 | <div class="order-form"> |
| 20 | 21 | ||
| 21 | <?php $form = ActiveForm::begin(); ?> | 22 | <?php $form = ActiveForm::begin(); ?> |
| 22 | - | 23 | + <div class="x_panel"> |
| 24 | + | ||
| 25 | + | ||
| 23 | <?php | 26 | <?php |
| 24 | // if ($model->isNewRecord) { | 27 | // if ($model->isNewRecord) { |
| 25 | // echo $form->field($model, 'user_id') | 28 | // echo $form->field($model, 'user_id') |
| 26 | // ->textInput(); | 29 | // ->textInput(); |
| 27 | // } | 30 | // } |
| 28 | ?> | 31 | ?> |
| 29 | - | ||
| 30 | - <?= $form->field($model, 'name') | ||
| 31 | - ->textInput([ 'maxlength' => true ]) ?> | ||
| 32 | - | ||
| 33 | - <?= $form->field($model, 'phone') | ||
| 34 | - ->textInput([ 'maxlength' => true ]) ?> | ||
| 35 | - | ||
| 36 | - <?= $form->field($model, 'email') | ||
| 37 | - ->textInput([ 'maxlength' => true ]) ?> | ||
| 38 | - | ||
| 39 | - <?= $form->field($model, 'city') | ||
| 40 | - ->textInput([ 'maxlength' => true ]) ?> | ||
| 41 | - | ||
| 42 | - <?= $form->field($model, 'address') | ||
| 43 | - ->textInput([ 'maxlength' => true ]) ?> | ||
| 44 | - | ||
| 45 | - <?= $form->field($model, 'comment') | ||
| 46 | - ->textarea() ?> | ||
| 47 | - | ||
| 48 | - <?= $form->field($model, 'label_id') | ||
| 49 | - ->dropDownList($labels) ?> | ||
| 50 | - | ||
| 51 | - <?= $form->field($model, 'delivery_id') | ||
| 52 | - ->dropDownList($deliveries) ?> | ||
| 53 | - | ||
| 54 | - <?= $form->field($model, 'payment_id') | ||
| 55 | - ->dropDownList($payments) ?> | ||
| 56 | - | ||
| 57 | - <div class="ln_solid"></div> | ||
| 58 | - | ||
| 59 | - <div class="order-product-container"> | ||
| 60 | - <div class="row"> | ||
| 61 | - <div class="col-md-8"> | ||
| 62 | - <?php | ||
| 63 | - echo Select2::widget( | ||
| 64 | - [ | ||
| 65 | - 'name' => 'add-to-order', | ||
| 66 | - 'options' => [ | ||
| 67 | - 'placeholder' => \Yii::t('order', 'Select product'), | ||
| 68 | - ], | ||
| 69 | - 'pluginOptions' => [ | ||
| 70 | - 'allowClear' => true, | ||
| 71 | - 'minimumInputLength' => 3, | ||
| 72 | - 'language' => [ | ||
| 73 | - 'errorLoading' => new JsExpression( | ||
| 74 | - "function() {return '" . \Yii::t('order', 'Waiting for results') . "'; }" | ||
| 75 | - ), | ||
| 76 | - ], | ||
| 77 | - 'ajax' => [ | ||
| 78 | - 'url' => Url::to([ 'product-list' ]), | ||
| 79 | - 'dataType' => 'json', | ||
| 80 | - 'data' => new JsExpression('function(params) { return {q:params.term}; }'), | ||
| 81 | - ], | ||
| 82 | - 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), | ||
| 83 | - 'templateResult' => new JsExpression('function(city) { return city.text; }'), | ||
| 84 | - 'templateSelection' => new JsExpression('function (city) { return city.text; }'), | ||
| 85 | - ], | ||
| 86 | - 'id' => 'add-to-order', | ||
| 87 | - ] | ||
| 88 | - ); | ||
| 89 | - ?> | ||
| 90 | - </div> | ||
| 91 | - <div class="col-md-3"> | ||
| 92 | - <?php | ||
| 93 | - echo Html::textInput( | ||
| 94 | - 'count-to-order', | ||
| 95 | - null, | ||
| 96 | - [ | ||
| 97 | - 'class' => 'form-control', | ||
| 98 | - 'id' => 'count-to-order', | ||
| 99 | - ] | ||
| 100 | - ); | ||
| 101 | - ?> | ||
| 102 | - </div> | ||
| 103 | - <div class="col-md-1"> | ||
| 104 | - <?php | ||
| 105 | - echo Html::a( | ||
| 106 | - Html::icon( | ||
| 107 | - 'plus-circle', | ||
| 108 | - [ | ||
| 109 | - 'prefix' => 'fa fa-', | ||
| 110 | - ] | ||
| 111 | - ), | ||
| 112 | - '#', | ||
| 113 | - [ | ||
| 114 | - 'class' => 'variant-to-order', | ||
| 115 | - ] | ||
| 116 | - ); | ||
| 117 | - ?> | ||
| 118 | - </div> | ||
| 119 | - </div> | ||
| 120 | - <div class="ln_solid"></div> | ||
| 121 | - <div id="order-product-pjax" style="position: relative;"> | ||
| 122 | - <div class="row strong"> | ||
| 123 | - <div class="col-md-4"> | ||
| 124 | - <?php | ||
| 125 | - echo Html::tag('strong', \Yii::t('order', 'Product')); | ||
| 126 | - ?> | 32 | + <div class="wrapp-blocks-edit-page"> |
| 33 | + <?= $form->field($model, 'name') | ||
| 34 | + ->textInput([ 'maxlength' => true ]) ?> | ||
| 127 | </div> | 35 | </div> |
| 128 | - <div class="col-md-4"> | ||
| 129 | - <?php | ||
| 130 | - echo Html::tag('strong', \Yii::t('order', 'Price')); | ||
| 131 | - ?> | 36 | + <div class="wrapp-blocks-edit-page"> |
| 132 | </div> | 37 | </div> |
| 133 | - <div class="col-md-4"> | ||
| 134 | - <?php | ||
| 135 | - echo Html::tag('strong', \Yii::t('order', 'Count')); | ||
| 136 | - ?> | 38 | + <div class="wrapp-blocks-edit-page"> |
| 39 | + <?= $form->field($model, 'phone') | ||
| 40 | + ->textInput([ 'maxlength' => true ]) ?> | ||
| 137 | </div> | 41 | </div> |
| 138 | - </div> | ||
| 139 | - <div id="product-rows"> | 42 | + <div class="wrapp-blocks-edit-page"> |
| 43 | + <?= $form->field($model, 'email') | ||
| 44 | + ->textInput([ 'maxlength' => true ]) ?> | ||
| 45 | + </div> | ||
| 46 | + <div class="wrapp-blocks-edit-page"> | ||
| 47 | + <?= $form->field($model, 'city') | ||
| 48 | + ->textInput([ 'maxlength' => true ]) ?> | ||
| 49 | + </div> | ||
| 50 | + <div class="wrapp-blocks-edit-page"> | ||
| 51 | + <?= $form->field($model, 'address') | ||
| 52 | + ->textInput([ 'maxlength' => true ]) ?> | ||
| 53 | + </div> | ||
| 54 | + <div class="wrapp-blocks-edit-page"> | ||
| 55 | + <?= $form->field($model, 'comment') | ||
| 56 | + ->textarea() ?> | ||
| 57 | + </div> | ||
| 58 | + <div class="wrapp-blocks-edit-page"> | ||
| 59 | + <?= $form->field($model, 'label_id') | ||
| 60 | + ->dropDownList($labels) ?> | ||
| 61 | + </div> | ||
| 62 | + <div class="wrapp-blocks-edit-page"> | ||
| 63 | + <?= $form->field($model, 'delivery_id') | ||
| 64 | + ->dropDownList($deliveries) ?> | ||
| 65 | + </div> | ||
| 66 | + <div class="wrapp-blocks-edit-page"> | ||
| 67 | + <?= $form->field($model, 'payment_id') | ||
| 68 | + ->dropDownList($payments) ?> | ||
| 69 | + </div> | ||
| 70 | + </div> | ||
| 71 | + | ||
| 72 | + <div class="x_panel"> | ||
| 73 | + <div class="order-product-container wrapp-blocks-edit-page"> | ||
| 74 | + <div class="row"> | ||
| 75 | + <div class="col-xs-12"> | ||
| 76 | + <div class="row"> | ||
| 77 | + <div class="col-md-9"> | ||
| 78 | + <label>ะะพะฑะฐะฒะธัั ะตัะต ัะพะฒะฐั</label> | ||
| 79 | + <?php | ||
| 80 | + echo Select2::widget( | ||
| 81 | + [ | ||
| 82 | + 'name' => 'add-to-order', | ||
| 83 | + 'options' => [ | ||
| 84 | + 'placeholder' => \Yii::t('order', 'Select product'), | ||
| 85 | + ], | ||
| 86 | + 'pluginOptions' => [ | ||
| 87 | + 'allowClear' => true, | ||
| 88 | + 'minimumInputLength' => 3, | ||
| 89 | + 'language' => [ | ||
| 90 | + 'errorLoading' => new JsExpression( | ||
| 91 | + "function() {return '" . \Yii::t('order', 'Waiting for results') . "'; }" | ||
| 92 | + ), | ||
| 93 | + ], | ||
| 94 | + 'ajax' => [ | ||
| 95 | + 'url' => Url::to([ 'product-list' ]), | ||
| 96 | + 'dataType' => 'json', | ||
| 97 | + 'data' => new JsExpression('function(params) { return {q:params.term}; }'), | ||
| 98 | + ], | ||
| 99 | + 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), | ||
| 100 | + 'templateResult' => new JsExpression('function(city) { return city.text; }'), | ||
| 101 | + 'templateSelection' => new JsExpression('function (city) { return city.text; }'), | ||
| 102 | + ], | ||
| 103 | + 'id' => 'add-to-order', | ||
| 104 | + ] | ||
| 105 | + ); | ||
| 106 | + ?> | ||
| 107 | + </div> | ||
| 108 | + <div class="col-md-2"> | ||
| 109 | + <?php | ||
| 110 | + $idInput = 'count-to-order'; | ||
| 111 | + echo '<label for="'.$idInput.'">ะะะ-ะะ</label>'; | ||
| 112 | + echo Html::textInput( | ||
| 113 | + 'count-to-order', | ||
| 114 | + 1, | ||
| 115 | + [ | ||
| 116 | + 'class' => 'form-control', | ||
| 117 | + 'id' => $idInput, | ||
| 118 | + ] | ||
| 119 | + ); | ||
| 120 | + ?> | ||
| 121 | + </div> | ||
| 122 | + <a class="variant-to-order btn btn-success add-goods-order" href="#"> | ||
| 123 | + <i class="fa fa-plus"></i> | ||
| 124 | + </a> | ||
| 125 | + </div> | ||
| 126 | + </div> | ||
| 127 | + </div> | ||
| 128 | + | ||
| 129 | + <div id="order-product-pjax" class="row"> | ||
| 130 | + <div class="col-xs-12 order-goods-th"<?=$isCreate ? ' style="display: none;"' : ''?>> | ||
| 131 | + <div class="row"> | ||
| 132 | + <div class="col-md-7"> | ||
| 133 | + <?php | ||
| 134 | + echo Html::tag('label', \Yii::t('order', 'Product')); | ||
| 135 | + ?> | ||
| 136 | + </div> | ||
| 137 | + <div class="col-md-2"> | ||
| 138 | + <?php | ||
| 139 | + echo Html::tag('label', \Yii::t('order', 'Price')); | ||
| 140 | + ?> | ||
| 141 | + </div> | ||
| 142 | + <div class="col-md-2"> | ||
| 143 | + <?php | ||
| 144 | + echo Html::tag('label', \Yii::t('order', 'Count')); | ||
| 145 | + ?> | ||
| 146 | + </div> | ||
| 147 | + </div> | ||
| 148 | + </div> | ||
| 149 | + | ||
| 150 | + | ||
| 151 | + <div id="product-rows" class="col-xs-12"> | ||
| 140 | <?php | 152 | <?php |
| 153 | + $sum = 0; | ||
| 141 | if (!$model->isNewRecord) { | 154 | if (!$model->isNewRecord) { |
| 142 | - $sum = 0; | ||
| 143 | foreach ($model->orderProducts as $index => $orderProduct) { | 155 | foreach ($model->orderProducts as $index => $orderProduct) { |
| 144 | $sum += ( $orderProduct->count * $orderProduct->price ); | 156 | $sum += ( $orderProduct->count * $orderProduct->price ); |
| 145 | echo $this->render( | 157 | echo $this->render( |
| @@ -158,20 +170,21 @@ | @@ -158,20 +170,21 @@ | ||
| 158 | ?> | 170 | ?> |
| 159 | 171 | ||
| 160 | </div> | 172 | </div> |
| 161 | - <?php if (!$model->isNewRecord) { | ||
| 162 | - echo( " <div class='sum_all'>ะัะตะณะพ <p>" . $sum . "</p></div>" ); | ||
| 163 | - } ?> | 173 | + <?php |
| 174 | + echo( " <div class='sum_all col-xs-12'>ะัะพะณะพ: <strong id='total-sum'>" . $sum . "</strong></div>" ); | ||
| 175 | + ?> | ||
| 164 | </div> | 176 | </div> |
| 165 | </div> | 177 | </div> |
| 166 | - | ||
| 167 | - <div class="ln_solid"></div> | ||
| 168 | - | ||
| 169 | - <div class="form-group"> | ||
| 170 | - <?= Html::submitButton( | ||
| 171 | - $model->isNewRecord ? Yii::t('order', 'Create') : Yii::t('order', 'Update'), | ||
| 172 | - [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] | ||
| 173 | - ) ?> | ||
| 174 | - </div> | 178 | + </div> |
| 179 | + | ||
| 180 | + | ||
| 181 | + | ||
| 182 | + <div class="style buttons-page-wr"> | ||
| 183 | + <?= Html::submitButton( | ||
| 184 | + $model->isNewRecord ? Yii::t('order', 'Create') : Yii::t('order', 'Update'), | ||
| 185 | + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-success' ] | ||
| 186 | + ) ?> | ||
| 187 | + </div> | ||
| 175 | 188 | ||
| 176 | <?php ActiveForm::end(); ?> | 189 | <?php ActiveForm::end(); ?> |
| 177 | 190 |
views/order/_order_product.php
| @@ -18,38 +18,24 @@ | @@ -18,38 +18,24 @@ | ||
| 18 | ?> | 18 | ?> |
| 19 | 19 | ||
| 20 | <div class="row row-order-product" data-price="<?= $price ?>"> | 20 | <div class="row row-order-product" data-price="<?= $price ?>"> |
| 21 | - <div class="col-md-4"> | 21 | + <div class="row-order-product-title col-md-7"> |
| 22 | <?php | 22 | <?php |
| 23 | echo $form->field($orderProduct, "[$index]variant_id") | 23 | echo $form->field($orderProduct, "[$index]variant_id") |
| 24 | ->hiddenInput() | 24 | ->hiddenInput() |
| 25 | ->label(false); | 25 | ->label(false); |
| 26 | - echo $variant->product->lang->title . '(' . $variant->sku . ')'; | 26 | + echo $variant->product->lang->title . '<span class="sku"> (sku - ' . $variant->sku . ')</span>'; |
| 27 | ?> | 27 | ?> |
| 28 | </div> | 28 | </div> |
| 29 | - <div class="col-md-4"> | 29 | + <div class="row-order-product-price col-md-2"> |
| 30 | <?php echo $price; ?> | 30 | <?php echo $price; ?> |
| 31 | </div> | 31 | </div> |
| 32 | - <div class="col-md-3"> | 32 | + <div class="row-order-product-num col-md-2"> |
| 33 | <?php | 33 | <?php |
| 34 | echo $form->field($orderProduct, "[$index]count") | 34 | echo $form->field($orderProduct, "[$index]count") |
| 35 | ->textInput([ 'class' => 'count' ]) | 35 | ->textInput([ 'class' => 'count' ]) |
| 36 | ->label(false); | 36 | ->label(false); |
| 37 | ?> | 37 | ?> |
| 38 | </div> | 38 | </div> |
| 39 | - <div class="col-md-1"> | ||
| 40 | - <?php | ||
| 41 | - echo Html::a( | ||
| 42 | - Html::icon( | ||
| 43 | - 'trash-o', | ||
| 44 | - [ | ||
| 45 | - 'prefix' => 'fa fa-', | ||
| 46 | - ] | ||
| 47 | - ), | ||
| 48 | - '#', | ||
| 49 | - [ | ||
| 50 | - 'class' => 'remove-order-product', | ||
| 51 | - ] | ||
| 52 | - ) | ||
| 53 | - ?> | ||
| 54 | - </div> | 39 | + <a href="#" class="btn-danger btn btn-danger btn remove-order-product"></a> |
| 40 | + <div class="col-xs-12 row-order-product-line"><div></div></div> | ||
| 55 | </div> | 41 | </div> |
views/order/create.php
| @@ -26,8 +26,10 @@ | @@ -26,8 +26,10 @@ | ||
| 26 | ] | 26 | ] |
| 27 | ); | 27 | ); |
| 28 | ?> | 28 | ?> |
| 29 | - <h1><?= Html::encode($this->title) ?></h1> | ||
| 30 | - | 29 | + |
| 30 | + <?php | ||
| 31 | + $xPanel::end(); | ||
| 32 | + ?> | ||
| 31 | <?= $this->render( | 33 | <?= $this->render( |
| 32 | '_form', | 34 | '_form', |
| 33 | [ | 35 | [ |
| @@ -35,10 +37,9 @@ | @@ -35,10 +37,9 @@ | ||
| 35 | 'labels' => $labels, | 37 | 'labels' => $labels, |
| 36 | 'payments' => $payments, | 38 | 'payments' => $payments, |
| 37 | 'deliveries' => $deliveries, | 39 | 'deliveries' => $deliveries, |
| 40 | + 'isCreate' => true | ||
| 38 | ] | 41 | ] |
| 39 | ) ?> | 42 | ) ?> |
| 40 | 43 | ||
| 41 | - <?php | ||
| 42 | - $xPanel::end(); | ||
| 43 | - ?> | 44 | + |
| 44 | </div> | 45 | </div> |
views/order/update.php
| @@ -39,6 +39,9 @@ | @@ -39,6 +39,9 @@ | ||
| 39 | ] | 39 | ] |
| 40 | ); | 40 | ); |
| 41 | ?> | 41 | ?> |
| 42 | + <?php | ||
| 43 | + $xPanel::end(); | ||
| 44 | + ?> | ||
| 42 | 45 | ||
| 43 | <?= $this->render( | 46 | <?= $this->render( |
| 44 | '_form', | 47 | '_form', |
| @@ -47,10 +50,9 @@ | @@ -47,10 +50,9 @@ | ||
| 47 | 'labels' => $labels, | 50 | 'labels' => $labels, |
| 48 | 'payments' => $payments, | 51 | 'payments' => $payments, |
| 49 | 'deliveries' => $deliveries, | 52 | 'deliveries' => $deliveries, |
| 53 | + 'isCreate' => false, | ||
| 50 | ] | 54 | ] |
| 51 | ) ?> | 55 | ) ?> |
| 52 | 56 | ||
| 53 | - <?php | ||
| 54 | - $xPanel::end(); | ||
| 55 | - ?> | 57 | + |
| 56 | </div> | 58 | </div> |
views/order/view.php
| @@ -64,15 +64,15 @@ | @@ -64,15 +64,15 @@ | ||
| 64 | 'deleted_at:datetime', | 64 | 'deleted_at:datetime', |
| 65 | [ | 65 | [ |
| 66 | 'label' => \Yii::t('order', 'Label'), | 66 | 'label' => \Yii::t('order', 'Label'), |
| 67 | - 'attribute' => 'label.lang.title', | 67 | + 'attribute' => 'label.title', |
| 68 | ], | 68 | ], |
| 69 | [ | 69 | [ |
| 70 | 'label' => \Yii::t('order', 'Delivery'), | 70 | 'label' => \Yii::t('order', 'Delivery'), |
| 71 | - 'attribute' => 'delivery.lang.title', | 71 | + 'attribute' => 'delivery.title', |
| 72 | ], | 72 | ], |
| 73 | [ | 73 | [ |
| 74 | 'label' => \Yii::t('order', 'Payment'), | 74 | 'label' => \Yii::t('order', 'Payment'), |
| 75 | - 'attribute' => 'payment.lang.title', | 75 | + 'attribute' => 'payment.title', |
| 76 | ], | 76 | ], |
| 77 | [ | 77 | [ |
| 78 | 'label' => \Yii::t('order', 'Products'), | 78 | 'label' => \Yii::t('order', 'Products'), |
web/js/order.js
| @@ -3,7 +3,8 @@ $(function() { | @@ -3,7 +3,8 @@ $(function() { | ||
| 3 | .on('click', '.remove-order-product', function(e) { | 3 | .on('click', '.remove-order-product', function(e) { |
| 4 | e.preventDefault(); | 4 | e.preventDefault(); |
| 5 | var current_price = parseInt($(this).parents('.row-order-product').data('price')); | 5 | var current_price = parseInt($(this).parents('.row-order-product').data('price')); |
| 6 | - var number = parseInt($(this).parents('.row-order-product').children('.col-md-3').children('.form-group').children('input').val()); | 6 | + console.log(current_price); |
| 7 | + var number = parseInt($(this).parents('.row-order-product').children('.col-md-2').children('.form-group').children('input').val()); | ||
| 7 | var id = $(this) | 8 | var id = $(this) |
| 8 | .data('id'); | 9 | .data('id'); |
| 9 | var variant = $(this) | 10 | var variant = $(this) |
| @@ -11,16 +12,20 @@ $(function() { | @@ -11,16 +12,20 @@ $(function() { | ||
| 11 | $(this) | 12 | $(this) |
| 12 | .parents('.row-order-product') | 13 | .parents('.row-order-product') |
| 13 | .remove(); | 14 | .remove(); |
| 14 | - var total_price = parseInt($(".sum_all") | ||
| 15 | - .children('p') | ||
| 16 | - .text()); | 15 | + var total_price = parseInt($("#total-sum").text()); |
| 16 | + console.log(total_price); | ||
| 17 | total_price = total_price - (current_price * number); | 17 | total_price = total_price - (current_price * number); |
| 18 | console.log(number); | 18 | console.log(number); |
| 19 | - $(".sum_all") | ||
| 20 | - .children('p') | ||
| 21 | - .text(total_price); | 19 | + $("#total-sum").text(total_price); |
| 22 | }); | 20 | }); |
| 23 | - | 21 | + $('#count-to-order').keypress(function(e) { |
| 22 | + if (!(e.which==8 ||(e.which>47 && e.which<58))) return false; | ||
| 23 | + }); | ||
| 24 | + $('#count-to-order').change(function(e) { | ||
| 25 | + if ($(this).val() <= 0) { | ||
| 26 | + $(this).val('1') | ||
| 27 | + } | ||
| 28 | + }); | ||
| 24 | $(document) | 29 | $(document) |
| 25 | .on('click', '.variant-to-order', function(e) { | 30 | .on('click', '.variant-to-order', function(e) { |
| 26 | e.preventDefault(); | 31 | e.preventDefault(); |
| @@ -28,22 +33,28 @@ $(function() { | @@ -28,22 +33,28 @@ $(function() { | ||
| 28 | var count = $('#count-to-order'); | 33 | var count = $('#count-to-order'); |
| 29 | var order = $(this) | 34 | var order = $(this) |
| 30 | .data('id'); | 35 | .data('id'); |
| 31 | - if (id.val() && count.val()) { | 36 | + if (id.val() ) { |
| 37 | + if(count.val()<=0) { | ||
| 38 | + var newCountVal = count.val(); | ||
| 39 | + } else { | ||
| 40 | + var newCountVal = 1; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + $('.order-goods-th').css({display:'block'}); | ||
| 44 | + | ||
| 32 | $.post('/admin/order/add-to-order', { | 45 | $.post('/admin/order/add-to-order', { |
| 33 | id: id.val(), | 46 | id: id.val(), |
| 34 | - count: count.val(), | 47 | + count: newCountVal, |
| 35 | order: order | 48 | order: order |
| 36 | }, function(data) { | 49 | }, function(data) { |
| 37 | if (data.success) { | 50 | if (data.success) { |
| 38 | - var sum = $(".sum_all") | ||
| 39 | - .children('p') | ||
| 40 | - .text(); | ||
| 41 | - $(".sum_all") | ||
| 42 | - .children('p') | 51 | + var sum = $('#total-sum').text(); |
| 52 | + console.log(sum); | ||
| 53 | + $('#total-sum') | ||
| 43 | .html(parseInt(sum) + parseInt(data.price)); | 54 | .html(parseInt(sum) + parseInt(data.price)); |
| 44 | $('#product-rows') | 55 | $('#product-rows') |
| 45 | .append(data.row); | 56 | .append(data.row); |
| 46 | - | 57 | + $('#add-to-order').select2("val", ""); |
| 47 | } | 58 | } |
| 48 | 59 | ||
| 49 | }); | 60 | }); |
| @@ -54,10 +65,10 @@ $(function() { | @@ -54,10 +65,10 @@ $(function() { | ||
| 54 | console.log(count_old); | 65 | console.log(count_old); |
| 55 | var count_new = parseInt(this.value); | 66 | var count_new = parseInt(this.value); |
| 56 | var current_price = parseInt($(this).parents('.row-order-product').data('price')); | 67 | var current_price = parseInt($(this).parents('.row-order-product').data('price')); |
| 57 | - var total_price = parseInt($(".sum_all").children('p').text()); | 68 | + var total_price = parseInt($("#total-sum").text()); |
| 58 | total_price = total_price - (count_old * current_price) + (count_new * current_price); | 69 | total_price = total_price - (count_old * current_price) + (count_new * current_price); |
| 59 | this.defaultValue = this.value; | 70 | this.defaultValue = this.value; |
| 60 | - $(".sum_all").children('p').text(total_price); | 71 | + $("#total-sum").text(total_price); |
| 61 | }) | 72 | }) |
| 62 | }); | 73 | }); |
| 63 | function showLoader(container) { | 74 | function showLoader(container) { |