/**
  * Displays a single BuildGuide model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     //$parts = $model->getAddedParts();
     $parts = new ActiveDataProvider(['query' => $model->getParts(), 'sort' => false, 'key' => 'role_fk']);
     if (Yii::$app->user->identity && Yii::$app->user->identity->isCreator($model->user_fk)) {
         // && !$model->in_order) {
         $haveAddress = Yii::$app->user->identity->haveAddress();
         $roles = Role::rolesArrayBuilder();
         if ($model->in_order) {
             Yii::$app->session->remove('build_id');
         } else {
             Yii::$app->session->set('build_id', $model->build_guide_id);
         }
         return $this->render('viewForAuthor', ['build' => $model, 'parts' => $parts, 'haveAddress' => $haveAddress, 'roles' => $roles]);
     } else {
         return $this->render('view', ['model' => $model, 'parts' => $parts]);
     }
 }