Commit 7f07c94f10ce26da02b407e40475afc4d9ef57e7
1 parent
308598c2
categories create
Showing
6 changed files
with
173 additions
and
156 deletions
Show diff stats
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,130 +13,142 @@ | @@ -13,130 +13,142 @@ | ||
| 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 |
| 141 | if (!$model->isNewRecord) { | 153 | if (!$model->isNewRecord) { |
| 142 | $sum = 0; | 154 | $sum = 0; |
| @@ -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>" . $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> |
web/js/order.js
| @@ -20,7 +20,14 @@ $(function() { | @@ -20,7 +20,14 @@ $(function() { | ||
| 20 | .children('p') | 20 | .children('p') |
| 21 | .text(total_price); | 21 | .text(total_price); |
| 22 | }); | 22 | }); |
| 23 | - | 23 | + $('#count-to-order').keypress(function(e) { |
| 24 | + if (!(e.which==8 ||(e.which>47 && e.which<58))) return false; | ||
| 25 | + }); | ||
| 26 | + $('#count-to-order').change(function(e) { | ||
| 27 | + if ($(this).val() <= 0) { | ||
| 28 | + $(this).val('1') | ||
| 29 | + } | ||
| 30 | + }); | ||
| 24 | $(document) | 31 | $(document) |
| 25 | .on('click', '.variant-to-order', function(e) { | 32 | .on('click', '.variant-to-order', function(e) { |
| 26 | e.preventDefault(); | 33 | e.preventDefault(); |
| @@ -28,10 +35,18 @@ $(function() { | @@ -28,10 +35,18 @@ $(function() { | ||
| 28 | var count = $('#count-to-order'); | 35 | var count = $('#count-to-order'); |
| 29 | var order = $(this) | 36 | var order = $(this) |
| 30 | .data('id'); | 37 | .data('id'); |
| 31 | - if (id.val() && count.val()) { | 38 | + if (id.val() ) { |
| 39 | + if(count.val()<=0) { | ||
| 40 | + var newCountVal = count.val(); | ||
| 41 | + } else { | ||
| 42 | + var newCountVal = 1; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + $('.order-goods-th').css({display:'block'}); | ||
| 46 | + | ||
| 32 | $.post('/admin/order/add-to-order', { | 47 | $.post('/admin/order/add-to-order', { |
| 33 | id: id.val(), | 48 | id: id.val(), |
| 34 | - count: count.val(), | 49 | + count: newCountVal, |
| 35 | order: order | 50 | order: order |
| 36 | }, function(data) { | 51 | }, function(data) { |
| 37 | if (data.success) { | 52 | if (data.success) { |
| @@ -43,7 +58,7 @@ $(function() { | @@ -43,7 +58,7 @@ $(function() { | ||
| 43 | .html(parseInt(sum) + parseInt(data.price)); | 58 | .html(parseInt(sum) + parseInt(data.price)); |
| 44 | $('#product-rows') | 59 | $('#product-rows') |
| 45 | .append(data.row); | 60 | .append(data.row); |
| 46 | - | 61 | + $('#add-to-order').select2("val", ""); |
| 47 | } | 62 | } |
| 48 | 63 | ||
| 49 | }); | 64 | }); |