/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = NurseEvent::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(['ref' => $this->ref, 'date' => $this->date, 'period' => $this->period, 'patient_flag' => $this->patient_flag, 'ward' => $this->ward, 'inp_id' => $this->inp_id, 'lastupdate' => $this->lastupdate]);
     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]);
     }
 }
 /**
  * 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.');
     }
 }
Beispiel #4
0
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'เพิ่มรายการกิจกรรม'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'rowOptions' => function ($model) {
    if ($model->patient_flag == 1) {
        return ['class' => 'info'];
    } else {
        return [];
    }
}, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'date', 'value' => 'date', 'options' => ['class' => 'col-md-3'], 'filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'date', 'language' => 'th', 'options' => ['placeholder' => 'เลือกวันที่'], 'pluginOptions' => ['format' => 'yyyy-mm-dd', 'todayHighlight' => true, 'autoclose' => true]]), 'format' => 'html'], ['attribute' => 'period', 'filter' => NurseEvent::itemAlias('shift'), 'value' => function ($model) {
    return $model->shiftName;
}], ['value' => function ($model) {
    return Html::a('เพิ่มข้อมูลผู้ป่วย', ['nurse-patient/create', 'event_ref' => $model->ref], ['class' => 'btn btn-default btn-block']);
}, 'format' => 'html'], ['value' => function ($model) {
    return Html::a('เพิ่มข้อมูล Staff Mix', ['nurse-staffevent/create', 'event_ref' => $model->ref], ['class' => 'btn btn-default btn-block']);
}, 'format' => 'html'], ['value' => function ($model) {
    return Html::a('พิมพ์ใบมอบหมายงาน', ['nurse-patient/assign-report', 'event_ref' => $model->ref], ['target' => '_blank', 'class' => 'btn btn-primary btn-block']);
}, 'format' => 'raw'], ['value' => function ($model) {
    return Html::a('พิมพ์ใบรายชื่อผู้ป่วย', ['nurse-patient/daily-report', 'event_ref' => $model->ref], ['target' => '_blank', 'class' => 'btn btn-default btn-block']);
}, 'format' => 'raw'], ['class' => 'yii\\grid\\ActionColumn', 'header' => 'ลบ', 'template' => '{delete}']]]);
?>

</div>
 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]);
 }