/**
  * Get details of workforce contacts
  */
 public function actionGetcontactdata()
 {
     $model1 = new AmgenContactList();
     $model2 = new CongressSchedules();
     $model1->workforce_id = $_POST['AmgenContactList']['workforce_id'];
     $wf_id = $model1->workforce_id;
     $exists = $model1::find()->where(['Name' => $wf_id])->exists();
     if ($exists) {
         $userid = \backend\models\AmgenContactList::find()->where(['Name' => $wf_id])->one();
         $userid = $userid['id'];
         $model2->attendee_id = $userid;
         $model2->congress_id = $_POST['CongressSchedules']['congress_id'];
         $congid = $_POST['CongressSchedules']['congress_id'];
         $sql = "select congress_id,attendee_id from congress_schedules where congress_id='{$congid}' and attendee_id='{$userid}'";
         $res = Yii::$app->db->createCommand($sql)->execute();
         if ($res == 0) {
             $model2->save(FALSE);
             echo "TRUE";
         } else {
             echo "FALSE";
         }
     } else {
         echo "Exists";
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CongressSchedules::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'congress_id' => $this->congress_id, 'attendee_id' => $this->attendee_id, 'notify' => $this->notify, 'assigned' => $this->assigned]);
     return $dataProvider;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCongressSchedules()
 {
     return $this->hasMany(CongressSchedules::className(), ['attendee_id' => 'id']);
 }
 /**
  * Finds the CongressSchedules model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CongressSchedules the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CongressSchedules::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }