/** * 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]); } }
/** * Finds the NurseEvent model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return NurseEvent the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = NurseEvent::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionDailyReport($event_ref) { $ward = Yii::$app->user->identity->ward; $event = NurseEvent::findOne($event_ref); $ward_name = Ward::find()->where('code=:code', [':code' => $ward])->one(); $patient = NursePatient::find()->where('event_ref=:event_ref and disc_type=0', [':event_ref' => $event_ref])->orderBy('bed_type desc,bed_no asc')->all(); return $this->renderPartial('daily_report', ['patient' => $patient, 'event' => $event, 'ward_name' => $ward_name]); }