예제 #1
0
파일: RiskSearch.php 프로젝트: poykub/wph
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Risk::find()->orderBy(['code' => SORT_DESC]);
     //เลือกเฉพาะความเสี่ยงด้านคลีนิค ->where('riskGrp_code = "RG001"')
     //$query = Risk::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => 20]]);
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'riskEffDate' => $this->riskEffDate, 'reportDate' => $this->reportDate, 'riskConfirm' => $this->riskConfirm]);
     $query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'secRecord', $this->secRecord])->andFilterWhere(['like', 'riskEff', $this->riskEff])->andFilterWhere(['like', 'sect_name', $this->sect_name])->andFilterWhere(['like', 'mainRefer', $this->mainRefer])->andFilterWhere(['like', 'riskGrp_code', $this->riskGrp_code])->andFilterWhere(['like', 'riskGrp_name', $this->riskGrp_name])->andFilterWhere(['like', 'riskSubGrp_code', $this->riskSubGrp_code])->andFilterWhere(['like', 'riskSubGrp_name', $this->riskSubGrp_name])->andFilterWhere(['like', 'riskType_code', $this->riskType_code])->andFilterWhere(['like', 'riskType_name', $this->riskType_name])->andFilterWhere(['like', 'risk_code', $this->risk_code])->andFilterWhere(['like', 'risk_name', $this->risk_name])->andFilterWhere(['like', 'sectEff_code', $this->sectEff_code])->andFilterWhere(['like', 'sectEff_name', $this->sectEff_name])->andFilterWhere(['like', 'riskDetail', $this->riskDetail])->andFilterWhere(['like', 'riskDetail01', $this->riskDetail01])->andFilterWhere(['like', 'introduMan', $this->introduMan])->andFilterWhere(['like', 'advice', $this->advice])->andFilterWhere(['like', 'riskConfirmRemark', $this->riskConfirmRemark])->andFilterWhere(['like', 'editingDetail', $this->editingDetail])->andFilterWhere(['like', 'editingDetail_final', $this->editingDetail_final])->andFilterWhere(['like', 'riskEff_name', $this->riskEff_name])->andFilterWhere(['like', 'sectRecord', $this->sectRecord])->andFilterWhere(['like', 'diag', $this->diag]);
     return $dataProvider;
 }
예제 #2
0
파일: index.php 프로젝트: poykub/wph
        return $data->riskEffTitle->Name;
    } else {
        return 'ไม่ทราบข้อมูล';
        //
    }
}, 'filter' => \yii\helpers\ArrayHelper::map(app\models\RiskEff::find()->all(), 'Code', 'Name')], ['attribute' => 'sectRecName', 'width' => '40px', 'headerOptions' => ['style' => 'text-align:center'], 'hAlign' => 'center', 'value' => function ($data) {
    if (isset($data->sectTitle->Name)) {
        return $data->sectTitle->Name;
    } else {
        return 'ไม่ทราบข้อมูล';
        //
    }
}, 'filter' => \yii\helpers\ArrayHelper::map(app\models\Sect::find()->all(), 'Name', 'Name')], ['attribute' => 'RiskConfirm', 'format' => 'html', 'width' => '80px', 'headerOptions' => ['style' => 'text-align:center'], 'hAlign' => 'center', 'value' => function ($model, $key, $index, $column) {
    return $model->RiskConfirm == 1 ? "<span style=\"color:green;\">เป็นความเสี่ยง</span>" : "<span style=\"color:red;\">ไม่ใช่ความเสี่ยง</span>";
}, 'filter' => ArrayHelper::map($risk_choice, 'id', 'name')], ['attribute' => 'RiskEffDate', 'filterType' => GridView::FILTER_DATE, 'format' => 'raw', 'headerOptions' => ['style' => 'text-align:center'], 'hAlign' => 'center', 'width' => '70px', 'filterWidgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd']]], ['attribute' => 'ReportDate', 'filterType' => GridView::FILTER_DATE, 'format' => 'raw', 'headerOptions' => ['style' => 'text-align:center'], 'hAlign' => 'center', 'width' => '70px', 'filterWidgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd']]], ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{use_id}', 'buttons' => ['use_id' => function ($url, $model) {
    if (\app\models\Risk::find()->where(['Code' => $model->Code])->exists()) {
        return Html::a('<span class="glyphicon glyphicon-remove" style="display: none"></span>', '#', ['title' => 'หัวข้อนี้มีอยู่ในระบบแล้ว']);
    } else {
        return Html::a('<span class="glyphicon glyphicon-check"></span>', $url, ['title' => 'เลือกหัวข้อนี้']);
    }
}], 'urlCreator' => function ($action, $model, $key, $index) {
    if ($action === 'use_id') {
        return Url::to(['risk/create', 'code' => $model->Code]);
    }
    /*if (\app\models\Risk::find()->where([ 'Code' => $model->Code])->exists()) {
          return Url::to(['#']);
      }else{
          return Url::to(['risk/create', 'code' => $model->Code]);
      }*/
}], ['class' => 'kartik\\grid\\ActionColumn', 'dropdown' => false, 'order' => DynaGrid::ORDER_FIX_RIGHT]];
echo DynaGrid::widget(['columns' => $columns, 'storage' => DynaGrid::TYPE_COOKIE, 'theme' => 'panel-info', 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'hover' => true, 'panel' => ['heading' => '<h3 class="panel-title">รายการความเสี่ยงหลัก</h3>', 'before' => '{dynagrid}']], 'options' => ['id' => 'dynagrid-1']]);
예제 #3
0
파일: RiskBooking.php 프로젝트: poykub/wph
 public function getCode()
 {
     return $this->hasOne(Risk::className(), ['code' => 'Code']);
 }
예제 #4
0
 /**
  * Finds the Risk model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Risk the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Risk::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }