diff --git a/views/delivery/_form.php b/views/delivery/_form.php index dd7773e..c4105f8 100755 --- a/views/delivery/_form.php +++ b/views/delivery/_form.php @@ -22,13 +22,13 @@ 'form' => $form, ] ) ?> - + field($model, 'sort') ->textInput() ?> - + field($model, 'value') ->textInput() ?> - + field($model, 'status') ->checkbox( [ diff --git a/views/order/_form.php b/views/order/_form.php index 8ac7643..01bd850 100755 --- a/views/order/_form.php +++ b/views/order/_form.php @@ -13,130 +13,142 @@ * @var array $deliveries * @var array $payments * @var ActiveForm $form + * @var bool $isCreate */ ?>
- +
+ + isNewRecord) { // echo $form->field($model, 'user_id') // ->textInput(); // } ?> - - field($model, 'name') - ->textInput([ 'maxlength' => true ]) ?> - - field($model, 'phone') - ->textInput([ 'maxlength' => true ]) ?> - - field($model, 'email') - ->textInput([ 'maxlength' => true ]) ?> - - field($model, 'city') - ->textInput([ 'maxlength' => true ]) ?> - - field($model, 'address') - ->textInput([ 'maxlength' => true ]) ?> - - field($model, 'comment') - ->textarea() ?> - - field($model, 'label_id') - ->dropDownList($labels) ?> - - field($model, 'delivery_id') - ->dropDownList($deliveries) ?> - - field($model, 'payment_id') - ->dropDownList($payments) ?> - -
- -
-
-
- 'add-to-order', - 'options' => [ - 'placeholder' => \Yii::t('order', 'Select product'), - ], - 'pluginOptions' => [ - 'allowClear' => true, - 'minimumInputLength' => 3, - 'language' => [ - 'errorLoading' => new JsExpression( - "function() {return '" . \Yii::t('order', 'Waiting for results') . "'; }" - ), - ], - 'ajax' => [ - 'url' => Url::to([ 'product-list' ]), - 'dataType' => 'json', - 'data' => new JsExpression('function(params) { return {q:params.term}; }'), - ], - 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), - 'templateResult' => new JsExpression('function(city) { return city.text; }'), - 'templateSelection' => new JsExpression('function (city) { return city.text; }'), - ], - 'id' => 'add-to-order', - ] - ); - ?> -
-
- 'form-control', - 'id' => 'count-to-order', - ] - ); - ?> -
-
- 'fa fa-', - ] - ), - '#', - [ - 'class' => 'variant-to-order', - ] - ); - ?> -
-
-
-
-
-
- +
+ field($model, 'name') + ->textInput([ 'maxlength' => true ]) ?>
-
- +
-
- +
+ field($model, 'phone') + ->textInput([ 'maxlength' => true ]) ?>
-
-
+
+ field($model, 'email') + ->textInput([ 'maxlength' => true ]) ?> +
+
+ field($model, 'city') + ->textInput([ 'maxlength' => true ]) ?> +
+
+ field($model, 'address') + ->textInput([ 'maxlength' => true ]) ?> +
+
+ field($model, 'comment') + ->textarea() ?> +
+
+ field($model, 'label_id') + ->dropDownList($labels) ?> +
+
+ field($model, 'delivery_id') + ->dropDownList($deliveries) ?> +
+
+ field($model, 'payment_id') + ->dropDownList($payments) ?> +
+
+ +
+
+
+
+
+
+ + 'add-to-order', + 'options' => [ + 'placeholder' => \Yii::t('order', 'Select product'), + ], + 'pluginOptions' => [ + 'allowClear' => true, + 'minimumInputLength' => 3, + 'language' => [ + 'errorLoading' => new JsExpression( + "function() {return '" . \Yii::t('order', 'Waiting for results') . "'; }" + ), + ], + 'ajax' => [ + 'url' => Url::to([ 'product-list' ]), + 'dataType' => 'json', + 'data' => new JsExpression('function(params) { return {q:params.term}; }'), + ], + 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), + 'templateResult' => new JsExpression('function(city) { return city.text; }'), + 'templateSelection' => new JsExpression('function (city) { return city.text; }'), + ], + 'id' => 'add-to-order', + ] + ); + ?> +
+
+ КОЛ-ВО'; + echo Html::textInput( + 'count-to-order', + 1, + [ + 'class' => 'form-control', + 'id' => $idInput, + ] + ); + ?> +
+ + + +
+
+
+ +
+ + + +
isNewRecord) { $sum = 0; @@ -158,20 +170,21 @@ ?>
- isNewRecord) { - echo( "
Всего

" . $sum . "

" ); - } ?> + Итого: " . $sum . "
" ); + ?>
- -
- -
- isNewRecord ? Yii::t('order', 'Create') : Yii::t('order', 'Update'), - [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] - ) ?> -
+
+ + + +
+ isNewRecord ? Yii::t('order', 'Create') : Yii::t('order', 'Update'), + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-success' ] + ) ?> +
diff --git a/views/order/_order_product.php b/views/order/_order_product.php index 16094ef..e4c103b 100644 --- a/views/order/_order_product.php +++ b/views/order/_order_product.php @@ -18,38 +18,24 @@ ?>
-
+
field($orderProduct, "[$index]variant_id") ->hiddenInput() ->label(false); - echo $variant->product->lang->title . '(' . $variant->sku . ')'; + echo $variant->product->lang->title . ' (sku - ' . $variant->sku . ')'; ?>
-
+
-
+
field($orderProduct, "[$index]count") ->textInput([ 'class' => 'count' ]) ->label(false); ?>
-
- 'fa fa-', - ] - ), - '#', - [ - 'class' => 'remove-order-product', - ] - ) - ?> -
+ +
diff --git a/views/order/create.php b/views/order/create.php index cea9462..e873b78 100755 --- a/views/order/create.php +++ b/views/order/create.php @@ -26,8 +26,10 @@ ] ); ?> -

title) ?>

- + + render( '_form', [ @@ -35,10 +37,9 @@ 'labels' => $labels, 'payments' => $payments, 'deliveries' => $deliveries, + 'isCreate' => true ] ) ?> - +
diff --git a/views/order/update.php b/views/order/update.php index eec182e..bc037f6 100755 --- a/views/order/update.php +++ b/views/order/update.php @@ -39,6 +39,9 @@ ] ); ?> + render( '_form', @@ -47,10 +50,9 @@ 'labels' => $labels, 'payments' => $payments, 'deliveries' => $deliveries, + 'isCreate' => false, ] ) ?> - +
diff --git a/web/js/order.js b/web/js/order.js index dbc5dd4..7e60da9 100755 --- a/web/js/order.js +++ b/web/js/order.js @@ -20,7 +20,14 @@ $(function() { .children('p') .text(total_price); }); - + $('#count-to-order').keypress(function(e) { + if (!(e.which==8 ||(e.which>47 && e.which<58))) return false; + }); + $('#count-to-order').change(function(e) { + if ($(this).val() <= 0) { + $(this).val('1') + } + }); $(document) .on('click', '.variant-to-order', function(e) { e.preventDefault(); @@ -28,10 +35,18 @@ $(function() { var count = $('#count-to-order'); var order = $(this) .data('id'); - if (id.val() && count.val()) { + if (id.val() ) { + if(count.val()<=0) { + var newCountVal = count.val(); + } else { + var newCountVal = 1; + } + + $('.order-goods-th').css({display:'block'}); + $.post('/admin/order/add-to-order', { id: id.val(), - count: count.val(), + count: newCountVal, order: order }, function(data) { if (data.success) { @@ -43,7 +58,7 @@ $(function() { .html(parseInt(sum) + parseInt(data.price)); $('#product-rows') .append(data.row); - + $('#add-to-order').select2("val", ""); } }); -- libgit2 0.21.4