public function actionView($id)
    {
        if (!empty($id)) {
            $model = Order::findOne($id);
            if (empty($model)) {
                $model = new Order();
            }
            if (Yii::$app->user->can('changeOrderStatus')) {
                if ($model->load(Yii::$app->request->post())) {
                    $this->trigger(self::EVENT_BEFORE_CHANGE_ORDER_STATUS);
                    if ($model->save()) {

                        $this->trigger(self::EVENT_AFTER_CHANGE_ORDER_STATUS, new OrderEvent([
                            'model' => $model
                        ]));

                        \Yii::$app->session->setFlash('success', \Yii::t('cart', 'The record was successfully saved.'));

                    } else {
                        \Yii::$app->session->setFlash('error', \Yii::t('cart', 'An error occurred when saving the record.'));
                    }
                    return $this->redirect(['view', 'id' => $id]);
                } else {
                    $orderProducts = $model->orderProducts;

                    return $this->render('view', [
                        'model' => $this->findModel($id),
                        'statuses' => OrderStatus::find()->all(),
                        'orderProducts' => $orderProducts,
                    ]);
                }
            } else throw new ForbiddenHttpException();

        } else throw new NotFoundHttpException();
    }