public function actionDelete($id, $act) { $connection = Yii::$app->getDb(); $meeting = \backend\models\MeetingSchedules::find()->where(['id' => $id])->all(); if ($meeting) { foreach ($meeting as $row) { $olattend = $row['ol_attendee_id']; $attend = $row['attendee_id']; $meeting = $row['meeting_id']; } } if ($act == "ol") { $sql = "update meeting_schedules set ol_attendee_id=NULL where id='{$id}'"; $command = $connection->createCommand($sql); $result = $command->execute(); } else { $sql = "update meeting_schedules set attendee_id=NULL where id='{$id}'"; $command = $connection->createCommand($sql); $result = $command->execute(); } if ($olattend == NULL && $attend == NULL) { $this->findModel($id)->delete(); } return $this->redirect(['index', 'meeting_id' => $meeting]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function searchAttendees($params) { $query = MeetingSchedules::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, 'meeting_id' => $this->meeting_id, 'attendee_id' => $this->attendee_id, 'ol_attendee_id' => $this->ol_attendee_id, 'state_rule' => $this->state_rule, 'consultant' => $this->consultant]); $query->andWhere('attendee_id is not null'); return $dataProvider; }