/**
  * Creates a new MeetingPlace model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($meeting_id)
 {
     $mtg = new Meeting();
     $title = $mtg->getMeetingTitle($meeting_id);
     $model = new MeetingPlace();
     $model->meeting_id = $meeting_id;
     $model->suggested_by = Yii::$app->user->getId();
     $model->status = MeetingPlace::STATUS_SUGGESTED;
     $posted_form = Yii::$app->request->post();
     if ($model->load($posted_form)) {
         // check if both are chosen and return an error
         if ($model->place_id != '' and $posted_form['MeetingPlace']['google_place_id'] != '') {
             $model->addErrors(['place_id' => Yii::t('frontend', 'Please choose one or the other')]);
             return $this->render('create', ['model' => $model, 'title' => $title]);
         }
         if ($posted_form['MeetingPlace']['google_place_id'] != '') {
             // a google place is selected
             // is google place already in the Place database?
             // or, can we create a new place for this Google Place
             $model->place_id = Place::googlePlaceSuggested($posted_form['MeetingPlace']);
         }
         // validate the form against model rules
         if ($model->validate()) {
             // all inputs are valid
             $model->save();
             return $this->redirect(['/meeting/view', 'id' => $meeting_id]);
         } else {
             // validation failed
             return $this->render('create', ['model' => $model, 'title' => $title]);
         }
     } else {
         return $this->render('create', ['model' => $model, 'title' => $title]);
     }
 }
 /**
  * Creates a new Participant model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($meeting_id)
 {
     $mtg = new Meeting();
     $title = $mtg->getMeetingTitle($meeting_id);
     $model = new Participant();
     $model->meeting_id = $meeting_id;
     $model->invited_by = Yii::$app->user->getId();
     // load friends for auto complete field
     $friends = Friend::getFriendList(Yii::$app->user->getId());
     if ($model->load(Yii::$app->request->post())) {
         if (!User::find()->where(['email' => $model->email])->exists()) {
             // if email not already registered
             //  create new user with temporary username & password
             $temp_email_arr[] = $model->email;
             $model->username = Inflector::slug(implode('-', $temp_email_arr));
             $model->password = Yii::$app->security->generateRandomString(12);
             $model->participant_id = $model->addUser();
         } else {
             // add participant from user record
             $usr = User::find()->where(['email' => $model->email])->one();
             $model->participant_id = $usr->id;
         }
         // validate the form against model rules
         if ($model->validate()) {
             // all inputs are valid
             $model->save();
             return $this->redirect(['/meeting/view', 'id' => $meeting_id]);
         } else {
             // validation failed
             return $this->render('create', ['model' => $model, 'title' => $title, 'friends' => $friends]);
         }
     } else {
         return $this->render('create', ['model' => $model, 'title' => $title, 'friends' => $friends]);
     }
 }
 /**
  * Creates a new MeetingNote model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($meeting_id)
 {
     $model = new MeetingNote();
     $mtg = new Meeting();
     $title = $mtg->getMeetingTitle($meeting_id);
     $model->meeting_id = $meeting_id;
     $model->posted_by = Yii::$app->user->getId();
     $model->status = self::STATUS_POSTED;
     if ($model->load(Yii::$app->request->post())) {
         // validate the form against model rules
         if ($model->validate()) {
             // all inputs are valid
             $model->save();
             return $this->redirect(['/meeting/view', 'id' => $meeting_id]);
         } else {
             // validation failed
             return $this->render('create', ['model' => $model, 'title' => $title]);
         }
     } else {
         return $this->render('create', ['model' => $model, 'title' => $title]);
     }
 }