/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = HospitalAssignment::find(); $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(['id' => $this->id, 'user_id' => $this->user_id, 'hospital_id' => $this->hospital_id, 'created_at' => $this->created_at, 'created_by' => $this->created_by]); return $dataProvider; }
<h1><?php echo Html::encode($this->title); ?> </h1> <div class="jumbotron well "> <h3>คุณยังไม่ได้รับสิทธ์ในการประเมิน!</h3> <p>โปรดติดต่อผู้ดูแลระบบ...</p> </div> <?php } ?> <?php if ($dataProvider->getCount() > 0) { ?> <h1 class="text-center"><?php echo Html::encode($this->title); ?> </h1> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['hospital.code', 'hospital.name', ['attribute' => 'province_id', 'filter' => ArrayHelper::map(HospitalAssignment::find()->byHospitalProvince()->byUser()->all(), 'hospital.province.PROVINCE_ID', 'hospital.province.PROVINCE_NAME'), 'value' => function ($model) { return $model->hospital->province->PROVINCE_NAME; }], ['label' => 'Actoin', 'format' => 'raw', 'value' => function ($model) { return Html::a('<i class="glyphicon glyphicon-share-alt"></i> ประเมิน', ['evauate-score/create', 'hospital_id' => $model->hospital_id], ['class' => 'btn btn-default btn-block']); }]]]); ?> <?php } ?> </div>
/** * Finds the HospitalAssignment model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return HospitalAssignment the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = HospitalAssignment::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }