From 52c27888e0223563df9316662081a10c379fc8a6 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 6 Dec 2016 15:54:36 +0200 Subject: [PATCH] -Order module task #2.1 --- controllers/OrderController.php | 23 ++++++++++++----------- views/order/index.php | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/controllers/OrderController.php b/controllers/OrderController.php index 79257d4..07bd0ca 100755 --- a/controllers/OrderController.php +++ b/controllers/OrderController.php @@ -149,10 +149,10 @@ public function actionAdd() { - if (!empty( \Yii::$app->request->post() )) { + 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 { $count = 1; @@ -172,7 +172,7 @@ ) ->one(); - if (!empty( $model )) { + if (!empty($model)) { $model->count += $count; } else { $model = new OrderProduct(); @@ -217,7 +217,7 @@ if ($orderProduct->load($post)) { $orderProduct->save(); $output = ''; - if (isset( $posted[ 'count' ] )) { + if (isset($posted[ 'count' ])) { $output = Yii::$app->formatter->asDecimal($orderProduct->count, 0); } $out = Json::encode( @@ -269,7 +269,7 @@ 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', @@ -301,7 +301,7 @@ if ($orderProduct->load($post)) { $orderProduct->save(); $output = ''; - if (isset( $posted[ 'count' ] )) { + if (isset($posted[ 'count' ])) { $output = Yii::$app->formatter->asDecimal($orderProduct->count, 0); } $out = Json::encode( @@ -331,10 +331,11 @@ [ 'query' => $model->getProducts() ->joinWith('productVariant.product.brand'), + 'sort' => [ 'defaultOrder' => [ 'id' => SORT_ASC ] ], ] ); - if (empty( $model->manager_id )) { + if (empty($model->manager_id)) { $model->manager_id = \Yii::$app->user->id; } @@ -358,7 +359,7 @@ } } - public function actionFindProduct($q = null, $id = null) + public function actionFindProduct($q = NULL, $id = NULL) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $out = [ @@ -414,7 +415,7 @@ protected function findModel($id) { - if (( $model = Order::findOne($id) ) !== null) { + if (( $model = Order::findOne($id) ) !== NULL) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); @@ -440,7 +441,7 @@ public function actionBlockOrder() { - if (!empty( \Yii::$app->request->post() )) { + if (!empty(\Yii::$app->request->post())) { \Yii::$app->response->format = Response::FORMAT_JSON; $model = $this->findModel(\Yii::$app->request->post('id')); @@ -457,7 +458,7 @@ if ($model->save()) { return [ 'time' => $date, - 'user' => !empty( $user ) ? $user->username : '', + 'user' => !empty($user) ? $user->username : '', ]; } else { return [ diff --git a/views/order/index.php b/views/order/index.php index 112a78d..5c86d77 100755 --- a/views/order/index.php +++ b/views/order/index.php @@ -206,7 +206,7 @@ JS; ], [ 'attribute' => 'created_at', - 'format' => 'date', + 'format' => ['date', 'php:d/m/Y G:i'], 'filter' => $searchForm->field($searchModel, 'date_range') ->widget( DateRangePicker::className(), -- libgit2 0.21.4