Commit 0893579c01904d70a56dcfdda3a27945293b3601
1 parent
f042e1ca
-Bug fixed
Showing
4 changed files
with
161 additions
and
70 deletions
Show diff stats
controllers/OrderController.php
| ... | ... | @@ -119,10 +119,9 @@ |
| 119 | 119 | if (!empty( \Yii::$app->request->post() )) { |
| 120 | 120 | $id = \Yii::$app->request->post('OrderProduct')[ 'id' ]; |
| 121 | 121 | $order_id = \Yii::$app->request->post('OrderProduct')[ 'order_id' ]; |
| 122 | - if(!empty(\Yii::$app->request->post('OrderProduct')[ 'count' ])) { | |
| 122 | + if (!empty( \Yii::$app->request->post('OrderProduct')[ 'count' ] )) { | |
| 123 | 123 | $count = \Yii::$app->request->post('OrderProduct')[ 'count' ]; |
| 124 | - } | |
| 125 | - else { | |
| 124 | + } else { | |
| 126 | 125 | $count = 1; |
| 127 | 126 | } |
| 128 | 127 | $productVariant = ProductVariant::findOne($id); |
| ... | ... | @@ -202,7 +201,8 @@ |
| 202 | 201 | |
| 203 | 202 | $dataProvider = new ActiveDataProvider( |
| 204 | 203 | [ |
| 205 | - 'query' => $model->getProducts()->joinWith('productVariant'), | |
| 204 | + 'query' => $model->getProducts() | |
| 205 | + ->joinWith('productVariant'), | |
| 206 | 206 | ] |
| 207 | 207 | ); |
| 208 | 208 | |
| ... | ... | @@ -218,23 +218,24 @@ |
| 218 | 218 | ); |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | - | |
| 222 | - | |
| 223 | - | |
| 224 | - | |
| 225 | - public function actionPrint(){ | |
| 221 | + | |
| 222 | + public function actionPrint() | |
| 223 | + { | |
| 226 | 224 | $orderId = Yii::$app->request->get("order_id"); |
| 227 | - if(!empty($orderId)){ | |
| 225 | + if (!empty( $orderId )) { | |
| 228 | 226 | $order = $this->findModel($orderId); |
| 229 | - return $this->renderPartial('@frontend/views/cabinet/order_print',[ | |
| 230 | - 'order' => $order | |
| 231 | - ]); | |
| 227 | + return $this->renderPartial( | |
| 228 | + '@frontend/views/cabinet/order_print', | |
| 229 | + [ | |
| 230 | + 'order' => $order, | |
| 231 | + ] | |
| 232 | + ); | |
| 232 | 233 | } else { |
| 233 | 234 | throw new NotFoundHttpException('The requested page does not exist.'); |
| 234 | 235 | } |
| 235 | - | |
| 236 | + | |
| 236 | 237 | } |
| 237 | - | |
| 238 | + | |
| 238 | 239 | public function actionUpdate($id) |
| 239 | 240 | { |
| 240 | 241 | if (\Yii::$app->request->post('hasEditable')) { |
| ... | ... | @@ -271,7 +272,8 @@ |
| 271 | 272 | |
| 272 | 273 | $dataProvider = new ActiveDataProvider( |
| 273 | 274 | [ |
| 274 | - 'query' => $model->getProducts()->joinWith('productVariant.product.brand'), | |
| 275 | + 'query' => $model->getProducts() | |
| 276 | + ->joinWith('productVariant.product.brand'), | |
| 275 | 277 | ] |
| 276 | 278 | ); |
| 277 | 279 | |
| ... | ... | @@ -293,13 +295,20 @@ |
| 293 | 295 | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; |
| 294 | 296 | $out = [ |
| 295 | 297 | 'results' => [ |
| 296 | - 'id' => '', | |
| 297 | - 'text' => '', | |
| 298 | + 'id' => '', | |
| 299 | + 'sku' => '', | |
| 298 | 300 | ], |
| 299 | 301 | ]; |
| 300 | 302 | if (!is_null($q)) { |
| 301 | 303 | $result = ProductVariant::find() |
| 302 | - ->select('id, sku') | |
| 304 | +// ->select( | |
| 305 | +// [ | |
| 306 | +// 'id', | |
| 307 | +// 'sku', | |
| 308 | +// 'product_lang.title AS name' | |
| 309 | +// ] | |
| 310 | +// ) | |
| 311 | + ->joinWith('product.lang') | |
| 303 | 312 | ->where( |
| 304 | 313 | [ |
| 305 | 314 | 'like', |
| ... | ... | @@ -313,7 +322,6 @@ |
| 313 | 322 | |
| 314 | 323 | $out[ 'results' ] = $result; |
| 315 | 324 | } |
| 316 | - | |
| 317 | 325 | return $out; |
| 318 | 326 | } |
| 319 | 327 | ... | ... |
models/OrderProduct.php
| ... | ... | @@ -11,6 +11,9 @@ |
| 11 | 11 | * @property int $id |
| 12 | 12 | * @property int $order_id |
| 13 | 13 | * @property int $product_variant_id |
| 14 | + * @property string $booking | |
| 15 | + * @property string $status | |
| 16 | + * @property boolean $return | |
| 14 | 17 | * @property string $product_name |
| 15 | 18 | * @property string $name |
| 16 | 19 | * @property string $sku |
| ... | ... | @@ -43,7 +46,17 @@ |
| 43 | 46 | [ 'order_id' ], |
| 44 | 47 | 'required', |
| 45 | 48 | ], |
| 46 | - //['email', 'email'], | |
| 49 | + [ | |
| 50 | + [ 'return' ], | |
| 51 | + 'boolean', | |
| 52 | + ], | |
| 53 | + [ | |
| 54 | + [ | |
| 55 | + 'booking', | |
| 56 | + 'status', | |
| 57 | + ], | |
| 58 | + 'string', | |
| 59 | + ], | |
| 47 | 60 | [ |
| 48 | 61 | [ |
| 49 | 62 | 'product_name', |
| ... | ... | @@ -68,6 +81,9 @@ |
| 68 | 81 | 'cost' => Yii::t('app', 'cost'), |
| 69 | 82 | 'count' => Yii::t('app', 'count'), |
| 70 | 83 | 'sum_cost' => Yii::t('app', 'sum_cost'), |
| 84 | + 'status' => Yii::t('app', 'Статус'), | |
| 85 | + 'booking' => Yii::t('app', 'Бронь'), | |
| 86 | + 'return' => Yii::t('app', 'Возврат'), | |
| 71 | 87 | ]; |
| 72 | 88 | } |
| 73 | 89 | ... | ... |
views/order/_form.php
| ... | ... | @@ -252,6 +252,70 @@ JS; |
| 252 | 252 | ], |
| 253 | 253 | 'sum_cost', |
| 254 | 254 | [ |
| 255 | + 'class' => 'kartik\grid\EditableColumn', | |
| 256 | + 'attribute' => 'booking', | |
| 257 | + 'editableOptions' => [ | |
| 258 | + 'header' => \Yii::t('app', 'Бронь'), | |
| 259 | + 'inputType' => kartik\editable\Editable::INPUT_TEXT, | |
| 260 | + 'options' => [ | |
| 261 | + 'pluginOptions' => [ | |
| 262 | + 'min' => 0, | |
| 263 | + 'max' => 20, | |
| 264 | + ], | |
| 265 | + ], | |
| 266 | + 'pluginEvents' => [ | |
| 267 | + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 268 | + ], | |
| 269 | + ], | |
| 270 | + 'format' => [ | |
| 271 | + 'text', | |
| 272 | + ], | |
| 273 | + 'pageSummary' => false, | |
| 274 | + ], | |
| 275 | + [ | |
| 276 | + 'class' => 'kartik\grid\EditableColumn', | |
| 277 | + 'attribute' => 'status', | |
| 278 | + 'editableOptions' => [ | |
| 279 | + 'header' => \Yii::t('app', 'Статус'), | |
| 280 | + 'inputType' => kartik\editable\Editable::INPUT_TEXT, | |
| 281 | + 'options' => [ | |
| 282 | + 'pluginOptions' => [ | |
| 283 | + 'min' => 0, | |
| 284 | + 'max' => 20, | |
| 285 | + ], | |
| 286 | + ], | |
| 287 | + 'pluginEvents' => [ | |
| 288 | + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 289 | + ], | |
| 290 | + ], | |
| 291 | + 'format' => [ | |
| 292 | + 'text', | |
| 293 | + ], | |
| 294 | + 'pageSummary' => false, | |
| 295 | + ], | |
| 296 | +// [ | |
| 297 | +// 'class' => 'kartik\grid\EditableColumn', | |
| 298 | +// 'attribute' => 'count', | |
| 299 | +// 'editableOptions' => [ | |
| 300 | +// 'header' => \Yii::t('app', 'Количество'), | |
| 301 | +// 'inputType' => kartik\editable\Editable::INPUT_SPIN, | |
| 302 | +// 'options' => [ | |
| 303 | +// 'pluginOptions' => [ | |
| 304 | +// 'min' => 0, | |
| 305 | +// 'max' => 5000, | |
| 306 | +// ], | |
| 307 | +// ], | |
| 308 | +// 'pluginEvents' => [ | |
| 309 | +// 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
| 310 | +// ], | |
| 311 | +// ], | |
| 312 | +// 'format' => [ | |
| 313 | +// 'decimal', | |
| 314 | +// 0, | |
| 315 | +// ], | |
| 316 | +// 'pageSummary' => false, | |
| 317 | +// ], | |
| 318 | + [ | |
| 255 | 319 | 'class' => 'yii\grid\ActionColumn', |
| 256 | 320 | 'template' => '{delete}', |
| 257 | 321 | ], | ... | ... |
views/order/index.php
| ... | ... | @@ -33,6 +33,7 @@ $('[name="OrderSearch[phone]"]').mask('+38(000)000-00-00', { |
| 33 | 33 | JS; |
| 34 | 34 | |
| 35 | 35 | $this->registerJs($js, View::POS_READY); |
| 36 | + | |
| 36 | 37 | ?> |
| 37 | 38 | <h1>Заказы</h1> |
| 38 | 39 | <p> |
| ... | ... | @@ -105,58 +106,60 @@ JS; |
| 105 | 106 | ); |
| 106 | 107 | ?> |
| 107 | 108 | |
| 108 | -<?php echo $searchForm->field($searchModel, 'sku') | |
| 109 | - ->widget( | |
| 110 | - Select2::className(), | |
| 111 | - [ | |
| 112 | - 'options' => [ 'placeholder' => 'Search for a product ...' ], | |
| 113 | - 'pluginOptions' => [ | |
| 114 | - 'allowClear' => true, | |
| 115 | - 'minimumInputLength' => 3, | |
| 116 | - 'language' => [ | |
| 117 | - 'errorLoading' => new JsExpression( | |
| 118 | - "function () { return 'Waiting for results...'; }" | |
| 119 | - ), | |
| 120 | - ], | |
| 121 | - 'ajax' => [ | |
| 122 | - 'url' => \yii\helpers\Url::to([ 'find-product' ]), | |
| 123 | - 'dataType' => 'json', | |
| 124 | - 'data' => new JsExpression( | |
| 125 | - 'function(params) { return {q:params.term}; }' | |
| 126 | - ), | |
| 127 | - ], | |
| 128 | - 'escapeMarkup' => new JsExpression( | |
| 129 | - 'function (markup) { return markup; }' | |
| 130 | - ), | |
| 131 | - 'templateResult' => new JsExpression( | |
| 132 | - 'function(data) { return data.sku; }' | |
| 133 | - ), | |
| 134 | - 'templateSelection' => new JsExpression( | |
| 135 | - 'function (data) { | |
| 136 | - if(data.sku == undefined) { | |
| 137 | - return "sku"; | |
| 138 | - } else { | |
| 139 | - return data.sku; | |
| 140 | - } | |
| 141 | - }' | |
| 142 | - ), | |
| 143 | - ], | |
| 144 | - ] | |
| 145 | - ); | |
| 109 | +<?php | |
| 110 | + $query = new JsExpression( | |
| 111 | + 'function(params) { return {q:params.term}; }' | |
| 112 | + ); | |
| 113 | + echo $searchForm->field($searchModel, 'sku') | |
| 114 | + ->widget( | |
| 115 | + Select2::className(), | |
| 116 | + [ | |
| 117 | + 'options' => [ 'placeholder' => 'Search for a product ...' ], | |
| 118 | + 'pluginOptions' => [ | |
| 119 | + 'allowClear' => true, | |
| 120 | + 'minimumInputLength' => 3, | |
| 121 | + 'language' => [ | |
| 122 | + 'errorLoading' => new JsExpression( | |
| 123 | + "function () { return 'Waiting for results...'; }" | |
| 124 | + ), | |
| 125 | + ], | |
| 126 | + 'ajax' => [ | |
| 127 | + 'url' => \yii\helpers\Url::to([ 'find-product' ]), | |
| 128 | + 'dataType' => 'json', | |
| 129 | + 'data' => $query, | |
| 130 | + ], | |
| 131 | + 'escapeMarkup' => new JsExpression( | |
| 132 | + 'function (markup) { return markup; }' | |
| 133 | + ), | |
| 134 | + 'templateResult' => new JsExpression( | |
| 135 | + 'function(data) { return data.sku; }' | |
| 136 | + ), | |
| 137 | + 'templateSelection' => new JsExpression( | |
| 138 | + 'function (data) { | |
| 139 | + if(data.sku == undefined) { | |
| 140 | + return "sku"; | |
| 141 | + } else { | |
| 142 | + return data.sku; | |
| 143 | + } | |
| 144 | + }' | |
| 145 | + ), | |
| 146 | + ], | |
| 147 | + ] | |
| 148 | + ); | |
| 146 | 149 | |
| 147 | 150 | ?> |
| 148 | 151 | |
| 149 | 152 | <?= $searchForm->field($searchModel, 'manager_id') |
| 150 | - ->dropDownList( | |
| 151 | - ArrayHelper::map( | |
| 152 | - User::find() | |
| 153 | - ->asArray() | |
| 154 | - ->all(), | |
| 155 | - 'id', | |
| 156 | - 'username' | |
| 157 | - ), | |
| 158 | - [ 'prompt' => \Yii::t('app', 'Выберите менеджера ...') ] | |
| 159 | - ) ?> | |
| 153 | + ->dropDownList( | |
| 154 | + ArrayHelper::map( | |
| 155 | + User::find() | |
| 156 | + ->asArray() | |
| 157 | + ->all(), | |
| 158 | + 'id', | |
| 159 | + 'username' | |
| 160 | + ), | |
| 161 | + [ 'prompt' => \Yii::t('app', 'Выберите менеджера ...') ] | |
| 162 | + ) ?> | |
| 160 | 163 | |
| 161 | 164 | <?= $searchForm->field($searchModel, 'email') |
| 162 | 165 | ->textInput() ?> |
| ... | ... | @@ -250,7 +253,7 @@ JS; |
| 250 | 253 | 'attribute' => 'body', |
| 251 | 254 | 'content' => function($model) { |
| 252 | 255 | if (!empty( $model->body )) { |
| 253 | - return StringHelper::truncate($model->body, 8, '...'); | |
| 256 | + return StringHelper::truncate($model->body, 12, '...'); | |
| 254 | 257 | } else { |
| 255 | 258 | return ''; |
| 256 | 259 | } | ... | ... |