/**
  * Updates an existing Campaigns model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $projects = Projects::all_users_projects_one(Yii::$app->user->identity->id, $model->id_project);
     // проекты пользователя
     $spheres = Spheres::all_spheres();
     // список сфер деятельности
     $time = Yii::$app->request->get();
     if (!empty($time['analytics'])) {
         $time_end = $time['analytics'] / 1000;
         $time_end = $time_end + 10 * 24 * 3600;
         $time_end = date('Y-m-d', $time_end);
     } else {
         $time_begin = $model->date_begin;
         $time_begin = date('Y-m-d', $time_begin);
         $time_end = $model->date_end;
         $time_end = date('Y-m-d', $time_end);
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('flashupdate', constant('FLASH_UPDATE'));
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'projects' => $projects, 'spheres' => $spheres, 'time_begin' => $time_begin, 'time_end' => $time_end]);
     }
 }