public function actionRemovesda()
 {
     $connection = Yii::$app->db;
     if (Yii::$app->request->post()) {
         $value = \Yii::$app->request->post();
         $user = User::findOne(['id' => $value['userid']]);
         if ($user) {
             $congress = $value['congress'];
             $sdaid = $value['sdaid'];
             $model = SdaSchedules::deleteAll('congress_id = :congress_id AND sda_id = :sda_id AND attendee_id = :attendee_id', [':congress_id' => $congress, ':sda_id' => $sdaid, ':attendee_id' => $user->attendee_id]);
             if ($model) {
                 echo 'SDA deleted successfully';
             }
         } else {
             echo "User is not exist in Contect List";
         }
         die;
     }
 }
 /**
  * Updates an existing Sda model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $modelsSdaSchedules = $model->sdaSchedules;
     if ($model->load(Yii::$app->request->post())) {
         $oldIDs = ArrayHelper::map($modelsSdaSchedules, 'id', 'id');
         $modelsSdaSchedules = Model::createMultiple(SdaSchedules::classname(), $modelsSdaSchedules);
         Model::loadMultiple($modelsSdaSchedules, Yii::$app->request->post());
         $deletedIDs = array_diff($oldIDs, array_filter(ArrayHelper::map($modelsSdaSchedules, 'id', 'id')));
         // ajax validation
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ArrayHelper::merge(ActiveForm::validateMultiple($modelsSdaSchedules), ActiveForm::validate($model));
         }
         $model->date = \DateTime::createFromFormat('m-d-Y', $model->date)->format('Y-m-d');
         // validate all models
         $valid = $model->validate();
         if ($valid || !$valid) {
             //change condition for update without being validate
             $transaction = \Yii::$app->db->beginTransaction();
             try {
                 if ($flag = $model->save(false)) {
                     if (!empty($deletedIDs)) {
                         SdaSchedules::deleteAll(['id' => $deletedIDs]);
                     }
                     foreach ($modelsSdaSchedules as $modelSdaSchedule) {
                         if (!empty($modelSdaSchedule->attendee_id)) {
                             if (empty($modelSdaSchedule->congress_id)) {
                                 $modelSdaSchedule->sda_id = $model->id;
                                 $modelSdaSchedule->congress_id = $model->congress_id;
                                 $modelSdaSchedule->assigned = 0;
                                 $modelSdaSchedule->isNewRecord = true;
                             }
                             $flag = $modelSdaSchedule->save(false);
                             if (!$flag) {
                                 $transaction->rollBack();
                                 break;
                             }
                         }
                     }
                 }
                 if ($flag) {
                     $transaction->commit();
                     return $this->redirect(['view', 'id' => $model->id]);
                 }
             } catch (Exception $e) {
                 $transaction->rollBack();
             }
         }
     } else {
         $congressDetail = CongressDetails::findOne($model->congress_id);
         $congressStartDate = \DateTime::createFromFormat('Y-m-d', $congressDetail->start_date)->format('m-d-Y');
         $congressEndDate = \DateTime::createFromFormat('Y-m-d', $congressDetail->end_date)->format('m-d-Y');
         return $this->render('update', ['model' => $model, 'modelsSdaSchedules' => empty($modelsSdaSchedules) ? [new SdaSchedules()] : $modelsSdaSchedules, 'congressStartDate' => $congressStartDate, 'congressEndDate' => $congressEndDate]);
     }
 }