Exemple #1
0
    <p>
        <?php 
//Html::a('Create Com Dep', ['create'], ['class' => 'btn btn-success']);
?>
    </p>
    <div class="box-body">
        <?php 
//        GridView::widget([
//            'dataProvider' => $dataProvider,
//            //'filterModel' => $searchModel,
//            'columns' => [
//                //['class' => 'yii\grid\SerialColumn'],
//                //'id',
//                'code',
//                'name',
//                'datein',
//                //'dateout',
//
//                ['class' => 'yii\grid\ActionColumn'],
//            ],
//        ]);
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'containerOptions' => ['style' => 'overflow: auto'], 'headerRowOptions' => ['class' => 'kartik-sheet-style'], 'filterRowOptions' => ['class' => 'kartik-sheet-style'], 'pjax' => true, 'columns' => [['class' => 'yii\\grid\\SerialColumn', 'contentOptions' => ['class' => 'kartik-sheet-style'], 'header' => '', 'headerOptions' => ['class' => 'kartik-sheet-style'], 'options' => ['style' => 'width:40px']], ['attribute' => 'com_id', 'width' => '350px', 'value' => function ($model) {
    return $model->getComCode($model->com_id);
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Computer::find()->orderBy('id')->asArray()->all(), 'id', 'code'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'หมายเลข'], 'format' => 'raw'], ['attribute' => 'dep_id', 'width' => '250px', 'value' => function ($model) {
    return $model->getDepName($model->dep_id);
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Department::find()->orderBy('id')->asArray()->all(), 'id', 'name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'แผนก'], 'format' => 'raw'], ['class' => 'kartik\\grid\\FormulaColumn', 'attribute' => 'datein', 'hAlign' => 'center', 'mergeHeader' => true, 'width' => '150px'], ['class' => '\\kartik\\grid\\ActionColumn', 'updateOptions' => ['label' => ''], 'deleteOptions' => ['label' => '']]], 'toolbar' => [['content' => Html::a('<i class="glyphicon glyphicon-plus"></i>', ['create'], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => 'เพิ่มรายการใหม่'])], '{toggleData}', '{export}'], 'export' => ['fontAwesome' => true], 'bordered' => true, 'responsive' => true, 'hover' => true, 'condensed' => true, 'exportConfig' => $exportConfig, 'persistResize' => false, 'panel' => ['type' => GridView::TYPE_PRIMARY, 'heading' => 'รายการคอมพิวเตอร์แยกฝ่าย']]);
?>
    </div>
</div>
Exemple #2
0
 public function getDepName($id)
 {
     $model = Department::find()->where(['id' => $id])->one();
     return $model->name;
 }