/**
  * Creates a new Trmaschedule model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($id = 1)
 {
     $model = new Trmaschedule();
     $querytest = Trmaschedule::find()->where(['MedicaladvID' => $id])->orderBy('mascheduleID')->all();
     $matitle = Msmedicaladv::findOne($id);
     $medicaladvs = Msmedicaladv::find()->all();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->mascheduleID]);
     } else {
         return $this->render('create', ['model' => $model, 'querytest' => $querytest, 'matitle' => $matitle, 'medicaladvs' => $medicaladvs]);
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Trmaschedule::find()->where(['status' => 1]);
     $query->joinWith(['patient', 'medicaladv']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['patient'] = ['asc' => ['mspatient.FirstName' => SORT_ASC], 'desc' => ['mspatient.FirstName' => SORT_DESC]];
     $dataProvider->sort->attributes['medicaladv'] = ['asc' => ['msmedicaladv.FirstName' => SORT_ASC], 'desc' => ['msmedicaladv.FirstName' => SORT_DESC]];
     if (!($this->load($params) && $this->validate())) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         $query->orderBy(['Date' => SORT_DESC]);
         return $dataProvider;
     }
     $query->andFilterWhere(['mascheduleID' => $this->mascheduleID, 'Date' => $this->Date])->andFilterWhere(['like', 'msmedicaladv.FirstName', $this->medicaladv])->andFilterWhere(['like', 'mspatient.FirstName', $this->patient]);
     return $dataProvider;
 }