<div class="work-form"> <?php $form = ActiveForm::begin(); ?> <?php $items = ArrayHelper::map(TbKpi::find()->all(), 'id', 'topic'); ?> <?php echo $form->field($model, 'kpi')->dropDownList($items, ['prompt' => '-- ตัวชี้วัด --']); ?> <?php $items = ArrayHelper::map(Cchangwat::find()->all(), 'code', 'name'); ?> <?php echo $form->field($model, 'prov')->dropDownList($items, ['prompt' => '-- จังหวัด --']); ?> <?php echo $form->field($model, 'target')->textInput(); ?> <?php echo $form->field($model, 'result')->textInput(); ?> <div class="form-group"> <?php
<?php use yii\grid\GridView; use yii\helpers\Html; use app\models\Cchangwat; use app\models\TbKpi; ?> <div class="work-index"> <br> <p> <?php echo Html::a('เพิ่ม', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'kpi', 'value' => function ($model) { $code = $model->kpi; $data = TbKpi::find()->where(['id' => $code])->one(); return $code . "-" . $data->topic; }], ['attribute' => 'prov', 'value' => function ($model) { $code = $model->prov; $data = Cchangwat::find()->where(['code' => $code])->one(); return $code . "-" . $data->name; }], 'target', 'result', ['label' => 'ร้อยละ', 'value' => function ($model) { return number_format($model->result / $model->target * 100, 2); }], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>