diff --git a/controllers/OrderController.php b/controllers/OrderController.php index 5d723ff..5b0228b 100755 --- a/controllers/OrderController.php +++ b/controllers/OrderController.php @@ -119,10 +119,9 @@ if (!empty( \Yii::$app->request->post() )) { $id = \Yii::$app->request->post('OrderProduct')[ 'id' ]; $order_id = \Yii::$app->request->post('OrderProduct')[ 'order_id' ]; - if(!empty(\Yii::$app->request->post('OrderProduct')[ 'count' ])) { + if (!empty( \Yii::$app->request->post('OrderProduct')[ 'count' ] )) { $count = \Yii::$app->request->post('OrderProduct')[ 'count' ]; - } - else { + } else { $count = 1; } $productVariant = ProductVariant::findOne($id); @@ -202,7 +201,8 @@ $dataProvider = new ActiveDataProvider( [ - 'query' => $model->getProducts()->joinWith('productVariant'), + 'query' => $model->getProducts() + ->joinWith('productVariant'), ] ); @@ -218,23 +218,24 @@ ); } } - - - - - public function actionPrint(){ + + public function actionPrint() + { $orderId = Yii::$app->request->get("order_id"); - if(!empty($orderId)){ + if (!empty( $orderId )) { $order = $this->findModel($orderId); - return $this->renderPartial('@frontend/views/cabinet/order_print',[ - 'order' => $order - ]); + return $this->renderPartial( + '@frontend/views/cabinet/order_print', + [ + 'order' => $order, + ] + ); } else { throw new NotFoundHttpException('The requested page does not exist.'); } - + } - + public function actionUpdate($id) { if (\Yii::$app->request->post('hasEditable')) { @@ -271,7 +272,8 @@ $dataProvider = new ActiveDataProvider( [ - 'query' => $model->getProducts()->joinWith('productVariant.product.brand'), + 'query' => $model->getProducts() + ->joinWith('productVariant.product.brand'), ] ); @@ -293,13 +295,20 @@ \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $out = [ 'results' => [ - 'id' => '', - 'text' => '', + 'id' => '', + 'sku' => '', ], ]; if (!is_null($q)) { $result = ProductVariant::find() - ->select('id, sku') +// ->select( +// [ +// 'id', +// 'sku', +// 'product_lang.title AS name' +// ] +// ) + ->joinWith('product.lang') ->where( [ 'like', @@ -313,7 +322,6 @@ $out[ 'results' ] = $result; } - return $out; } diff --git a/models/OrderProduct.php b/models/OrderProduct.php index 1f308b3..14ee6bd 100755 --- a/models/OrderProduct.php +++ b/models/OrderProduct.php @@ -11,6 +11,9 @@ * @property int $id * @property int $order_id * @property int $product_variant_id + * @property string $booking + * @property string $status + * @property boolean $return * @property string $product_name * @property string $name * @property string $sku @@ -43,7 +46,17 @@ [ 'order_id' ], 'required', ], - //['email', 'email'], + [ + [ 'return' ], + 'boolean', + ], + [ + [ + 'booking', + 'status', + ], + 'string', + ], [ [ 'product_name', @@ -68,6 +81,9 @@ 'cost' => Yii::t('app', 'cost'), 'count' => Yii::t('app', 'count'), 'sum_cost' => Yii::t('app', 'sum_cost'), + 'status' => Yii::t('app', 'Статус'), + 'booking' => Yii::t('app', 'Бронь'), + 'return' => Yii::t('app', 'Возврат'), ]; } diff --git a/views/order/_form.php b/views/order/_form.php index 52dc876..2ee7d5e 100755 --- a/views/order/_form.php +++ b/views/order/_form.php @@ -252,6 +252,70 @@ JS; ], 'sum_cost', [ + 'class' => 'kartik\grid\EditableColumn', + 'attribute' => 'booking', + 'editableOptions' => [ + 'header' => \Yii::t('app', 'Бронь'), + 'inputType' => kartik\editable\Editable::INPUT_TEXT, + 'options' => [ + 'pluginOptions' => [ + 'min' => 0, + 'max' => 20, + ], + ], + 'pluginEvents' => [ + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', + ], + ], + 'format' => [ + 'text', + ], + 'pageSummary' => false, + ], + [ + 'class' => 'kartik\grid\EditableColumn', + 'attribute' => 'status', + 'editableOptions' => [ + 'header' => \Yii::t('app', 'Статус'), + 'inputType' => kartik\editable\Editable::INPUT_TEXT, + 'options' => [ + 'pluginOptions' => [ + 'min' => 0, + 'max' => 20, + ], + ], + 'pluginEvents' => [ + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', + ], + ], + 'format' => [ + 'text', + ], + 'pageSummary' => false, + ], +// [ +// 'class' => 'kartik\grid\EditableColumn', +// 'attribute' => 'count', +// 'editableOptions' => [ +// 'header' => \Yii::t('app', 'Количество'), +// 'inputType' => kartik\editable\Editable::INPUT_SPIN, +// 'options' => [ +// 'pluginOptions' => [ +// 'min' => 0, +// 'max' => 5000, +// ], +// ], +// 'pluginEvents' => [ +// 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', +// ], +// ], +// 'format' => [ +// 'decimal', +// 0, +// ], +// 'pageSummary' => false, +// ], + [ 'class' => 'yii\grid\ActionColumn', 'template' => '{delete}', ], diff --git a/views/order/index.php b/views/order/index.php index 9869ae2..308e870 100755 --- a/views/order/index.php +++ b/views/order/index.php @@ -33,6 +33,7 @@ $('[name="OrderSearch[phone]"]').mask('+38(000)000-00-00', { JS; $this->registerJs($js, View::POS_READY); + ?>
@@ -105,58 +106,60 @@ JS; ); ?> -field($searchModel, 'sku') - ->widget( - Select2::className(), - [ - 'options' => [ 'placeholder' => 'Search for a product ...' ], - 'pluginOptions' => [ - 'allowClear' => true, - 'minimumInputLength' => 3, - 'language' => [ - 'errorLoading' => new JsExpression( - "function () { return 'Waiting for results...'; }" - ), - ], - 'ajax' => [ - 'url' => \yii\helpers\Url::to([ 'find-product' ]), - 'dataType' => 'json', - 'data' => new JsExpression( - 'function(params) { return {q:params.term}; }' - ), - ], - 'escapeMarkup' => new JsExpression( - 'function (markup) { return markup; }' - ), - 'templateResult' => new JsExpression( - 'function(data) { return data.sku; }' - ), - 'templateSelection' => new JsExpression( - 'function (data) { - if(data.sku == undefined) { - return "sku"; - } else { - return data.sku; - } - }' - ), - ], - ] - ); +field($searchModel, 'sku') + ->widget( + Select2::className(), + [ + 'options' => [ 'placeholder' => 'Search for a product ...' ], + 'pluginOptions' => [ + 'allowClear' => true, + 'minimumInputLength' => 3, + 'language' => [ + 'errorLoading' => new JsExpression( + "function () { return 'Waiting for results...'; }" + ), + ], + 'ajax' => [ + 'url' => \yii\helpers\Url::to([ 'find-product' ]), + 'dataType' => 'json', + 'data' => $query, + ], + 'escapeMarkup' => new JsExpression( + 'function (markup) { return markup; }' + ), + 'templateResult' => new JsExpression( + 'function(data) { return data.sku; }' + ), + 'templateSelection' => new JsExpression( + 'function (data) { + if(data.sku == undefined) { + return "sku"; + } else { + return data.sku; + } + }' + ), + ], + ] + ); ?> = $searchForm->field($searchModel, 'manager_id') - ->dropDownList( - ArrayHelper::map( - User::find() - ->asArray() - ->all(), - 'id', - 'username' - ), - [ 'prompt' => \Yii::t('app', 'Выберите менеджера ...') ] - ) ?> + ->dropDownList( + ArrayHelper::map( + User::find() + ->asArray() + ->all(), + 'id', + 'username' + ), + [ 'prompt' => \Yii::t('app', 'Выберите менеджера ...') ] + ) ?> = $searchForm->field($searchModel, 'email') ->textInput() ?> @@ -250,7 +253,7 @@ JS; 'attribute' => 'body', 'content' => function($model) { if (!empty( $model->body )) { - return StringHelper::truncate($model->body, 8, '...'); + return StringHelper::truncate($model->body, 12, '...'); } else { return ''; } -- libgit2 0.21.4