/** * 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 data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Meeting::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'owner_id' => $this->owner_id, 'meeting_type' => $this->meeting_type, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'message', $this->message]); return $dataProvider; }
public function addForNewMeetingPlace($meeting_id, $suggested_by, $meeting_place_id) { // create new MeetingPlaceChoice for organizer and participant(s) // for this meeting_id and this meeting_place_id // first, let's add for organizer $mtg = Meeting::find()->where(['id' => $meeting_id])->one(); $this->add($meeting_place_id, $mtg->owner_id, $suggested_by); // then add for participants foreach ($mtg->participants as $p) { $this->add($meeting_place_id, $p->participant_id, $suggested_by); } }
/** * 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]); } }
/** * Finds the Meeting model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Meeting the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Meeting::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionChoose($id, $val) { // meeting_place_id needs to be set active // other meeting_place_id for this meeting need to be set inactive $meeting_id = intval($id); $mtg = Meeting::find()->where(['id' => $meeting_id])->one(); if (Yii::$app->user->getId() != $mtg->owner_id) { return false; } // to do - also check participant id if participants allowed to choose foreach ($mtg->meetingPlaces as $mp) { if ($mp->id == intval($val)) { $mp->status = MeetingPlace::STATUS_SELECTED; } else { $mp->status = MeetingPlace::STATUS_SUGGESTED; } $mp->save(); } return true; }
/** * @return \yii\db\ActiveQuery */ public function getMeeting() { return $this->hasOne(Meeting::className(), ['id' => 'meeting_id']); }
public function getMeetingTitle($meeting_id) { $meeting = Meeting::find()->where(['id' => $meeting_id])->one(); $title = $this->getMeetingType($meeting->meeting_type); $title .= ' Meeting'; return $title; }
<?php use yii\helpers\Html; use frontend\models\Meeting; use kartik\switchinput\SwitchInput; ?> <tr > <td style > <?php echo Meeting::friendlyDateFromTimestamp($model->start); ?> </td> <td style> <?php foreach ($model->meetingTimeChoices as $mtc) { if ($mtc->user_id == $model->meeting->owner_id) { if ($mtc->status == $mtc::STATUS_YES) { $value = 1; } else { $value = 0; } echo SwitchInput::widget(['type' => SwitchInput::CHECKBOX, 'name' => 'meeting-time-choice', 'id' => 'mtc-' . $mtc->id, 'value' => $value, 'pluginOptions' => ['size' => 'mini', 'onText' => '<i class="glyphicon glyphicon-ok"></i>', 'offText' => '<i class="glyphicon glyphicon-remove"></i>', 'onColor' => 'success', 'offColor' => 'danger']]); } } ?> </td> <td style> <?php foreach ($model->meetingTimeChoices as $mtc) { if (count($model->meeting->participants) == 0) {