Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = NurseStaff::find()->byWard();
     $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
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['staff_ref' => $this->staff_ref, 'code' => $this->code, 'ward' => $this->ward, 'position' => $this->position, 'priority' => $this->priority, 'hn' => $this->hn, 'part_time' => $this->part_time, 'assist' => $this->assist, 'sup' => $this->sup, 'wardclerk' => $this->wardclerk, 'lastupdate' => $this->lastupdate]);
     $query->andFilterWhere(['like', 'no', $this->no])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'surname', $this->surname]);
     return $dataProvider;
 }
 /**
  * Creates a new NurseStaffevent model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($event_ref)
 {
     $model = new NurseStaffevent();
     $event = NurseEvent::findOne($event_ref);
     $staff = NurseStaff::find()->where(['ward' => Yii::$app->user->identity->ward])->all();
     $staff_event = NurseStaffevent::find()->where('event_ref = :event_ref', [':event_ref' => $event_ref]);
     $dataProvider = new ActiveDataProvider(['query' => $staff_event]);
     if (isset($_POST['NurseStaffevent'])) {
         foreach ($staff as $v) {
             if (isset($_POST['NurseStaffevent'][$v->staff_ref]) && $_POST['NurseStaffevent'][$v->staff_ref]['staff_ref'] != 0) {
                 $model_s2 = new NurseStaffevent();
                 $model_s2->attributes = $_POST['NurseStaffevent'][$v->staff_ref];
                 if ($model_s2->validate()) {
                     $model_s2->save();
                 }
             }
         }
         return $this->refresh();
         //         return $this->redirect(['nurse-staffevent/create']);
     } else {
         return $this->render('create', ['model' => $model, 'staff' => $staff, 'event' => $event, 'staff_event' => $staff_event, 'dataProvider' => $dataProvider]);
     }
 }
Ejemplo n.º 3
0
 public function getStaff()
 {
     return @$this->hasOne(NurseStaff::className(), ['staff_ref' => 'staff_ref']);
 }
Ejemplo n.º 4
0
 /**
  * Finds the NurseStaff model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return NurseStaff the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = NurseStaff::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }