/**
  * Lists all Meeting models.
  * @return mixed
  */
 public function actionIndex()
 {
     // add filter for upcoming or past
     $upcomingProvider = new ActiveDataProvider(['query' => Meeting::find()->joinWith('participants')->where(['owner_id' => Yii::$app->user->getId()])->orWhere(['participant_id' => Yii::$app->user->getId()])->andWhere(['Meeting.status' => [Meeting::STATUS_PLANNING, Meeting::STATUS_CONFIRMED]])]);
     $pastProvider = new ActiveDataProvider(['query' => Meeting::find()->joinWith('participants')->where(['owner_id' => Yii::$app->user->getId()])->orWhere(['participant_id' => Yii::$app->user->getId()])->andWhere(['Meeting.status' => Meeting::STATUS_COMPLETED])]);
     $canceledProvider = new ActiveDataProvider(['query' => Meeting::find()->joinWith('participants')->where(['owner_id' => Yii::$app->user->getId()])->orWhere(['participant_id' => Yii::$app->user->getId()])->andWhere(['Meeting.status' => Meeting::STATUS_CANCELED])]);
     return $this->render('index', ['upcomingProvider' => $upcomingProvider, 'pastProvider' => $pastProvider, 'canceledProvider' => $canceledProvider]);
 }
Beispiel #2
0
 /**
  * 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);
     }
 }
 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;
 }
Beispiel #5
0
 public function getMeetingTitle($meeting_id)
 {
     $meeting = Meeting::find()->where(['id' => $meeting_id])->one();
     $title = $this->getMeetingType($meeting->meeting_type);
     $title .= ' Meeting';
     return $title;
 }