/**
  * Display all meetings
  * @return mixed
  */
 public function actionAllmeeting()
 {
     $connection = Yii::$app->db;
     if (Yii::$app->request->post()) {
         $value = \Yii::$app->request->post();
         $finaldata = array();
         if ($value['congress']) {
             $data = MeetingDetails::find()->where(['congress_id' => $value['congress'], 'is_active' => 1])->orderBy(['date' => SORT_ASC, 'start_time' => SORT_ASC])->all();
             if ($data) {
                 foreach ($data as $value) {
                     $sql = "SELECT DISTINCT ms.attendee_id,a.Name as Name, a.title as title, f.Name AS Funame, c.Group_name AS Cost_Center, a.phone as phone, a.speciality as speciality\n                                FROM  meeting_schedules ms\n                                INNER JOIN amgen_contact_list a ON ms.attendee_id = a.id\n                                LEFT JOIN functions f ON f.ID = a.function_id LEFT JOIN cost_center c ON c.id = a.group_id\n                                WHERE ms.meeting_id ={$value->id}";
                     $attendee = $connection->createCommand($sql)->queryAll();
                     $modelolattendee = $connection->createCommand("SELECT ola.user_type_id,ola.first_name,ola.last_name,ola.name,ola.ol_bio,ola.ol_phone_no,ola.ol_email FROM `meeting_schedules` msd INNER JOIN ol_attendees ola ON msd.ol_attendee_id = ola.id  WHERE msd.meeting_id = {$value->id}")->queryAll();
                     $data = array('meetingid' => $value->id, 'congress' => \backend\models\CongressDetails::findOne($value->congress_id)->name, 'title' => $value->title, 'date' => $value->date, 'time' => date("g:i a", strtotime($value->start_time)), 'start_time' => date("g:i a", strtotime($value->start_time)), 'end_time' => date("g:i a", strtotime($value->stop_time)), 'location' => $value->location, 'eventtype' => \backend\models\MeetingTypes::findOne($value->event_type)->type, 'attendee' => $attendee, 'olattendee' => $modelolattendee, 'rsr' => $value->rsr, 'ol_consultant' => $value->ol_consultant, 'meeting_approval' => $value->meeting_approval, 'ol_catering' => $value->ol_catering, 'notes' => $value->notes);
                     if (!empty($value->ol_profile_id)) {
                         $data['ol_profile'] = \backend\models\OlProfiles::findOne($value->ol_profile_id)->name;
                     }
                     $finaldata[] = $data;
                 }
                 return $finaldata;
             } else {
                 echo "No Result";
             }
         }
     }
 }
 /**
  * Displays all meetings
  * @return mixed
  */
 public function actionAllmeeting()
 {
     $connection = Yii::$app->db;
     if (Yii::$app->request->post()) {
         $value = \Yii::$app->request->post();
         $finaldata = array();
         if ($value['congress']) {
             $data = MeetingDetails::find()->where(['congress_id' => $value['congress']])->orderBy(['date' => SORT_ASC, 'start_time' => SORT_ASC])->all();
             if ($data) {
                 foreach ($data as $value) {
                     $sql = "SELECT DISTINCT ms.attendee_id,a.Name as Name, a.title as title, wc.function_value AS Funame, wc.costcenter_value AS Cost_Center, a.phone as phone, a.speciality as speciality\n                                    FROM  meeting_schedules ms\n                                    INNER JOIN amgen_contact_list a ON ms.attendee_id = a.id\n                                    LEFT JOIN workforce_contacts wc ON wc.id = a.workforce_id\n                                    WHERE ms.meeting_id ={$value->id}";
                     $attendee = $connection->createCommand($sql)->queryAll();
                     $modelolattendee = $connection->createCommand("SELECT ola.user_type_id,ola.first_name,ola.last_name,ola.name,ola.ol_bio,ola.ol_phone_no,ola.ol_email FROM `meeting_schedules` msd INNER JOIN ol_attendees ola ON msd.ol_attendee_id = ola.id  WHERE msd.meeting_id = {$value->id}")->queryAll();
                     $finaldata[$value->congress_id][$value->date][] = array('meetingid' => $value->id, 'congress' => \backend\models\CongressDetails::findOne($value->congress_id)->name, 'title' => $value->title, 'date' => $value->date, 'time' => date("g:i a", strtotime($value->start_time)), 'start_time' => date("g:i a", strtotime($value->start_time)), 'end_time' => date("g:i a", strtotime($value->stop_time)), 'location' => $value->location, 'eventtype' => \backend\models\MeetingTypes::findOne($value->event_type)->type, 'attendee' => $attendee, 'olattendee' => $modelolattendee);
                 }
                 return $finaldata;
             } else {
                 echo "No Result";
             }
         }
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMeeting()
 {
     return $this->hasOne(MeetingDetails::className(), ['id' => 'meeting_id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMeetingDetails()
 {
     return $this->hasMany(MeetingDetails::className(), ['event_type' => 'id']);
 }
 /**
  * Upload attachment for Meeting
  * @param int $id
  * @return mixed
  */
 public function actionUploadmeeting($id)
 {
     $id = (int) $id;
     $model1 = new MeetingAttachments();
     if ($model1->load(Yii::$app->request->post())) {
         //If request is post
         $model1->path = UploadedFile::getInstances($model1, 'path');
         foreach ($model1->path as $files) {
             $filesize = $files->size;
             if ($files->saveAs('uploads/' . $files->baseName . '.' . $files->extension)) {
                 $model1->congress_id = $id;
                 $path = "uploads/" . $files->name;
                 $filetype = $files->extension;
                 $cong = MeetingDetails::find()->where(['id' => $id])->one();
                 $congressid = $cong['congress_id'];
                 Yii::$app->db->createCommand("insert into meeting_attachments(meeting_id,path,congress_id,size,type)values('{$id}','{$path}','{$congressid}',' {$filesize}','{$filetype}')")->execute();
             }
         }
         return $this->redirect(array("meeting/update", 'id' => $id));
     }
 }
 /**
  * Finds the MeetingDetails model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MeetingDetails the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MeetingDetails::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }