Example #1
0
use app\models\OsType;
/* @var $this yii\web\View */
/* @var $model frontend\models\Computer */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="box box-warning" style="width:75%">
    <div class="box-body">
    <?php 
$form = ActiveForm::begin(['options' => ['class' => '']]);
?>

    <?php 
//$form->field($model, 'com_type_id')->textInput();
//echo  Html::activeDropDownList($model, 'com_type_id',  yii\helpers\ArrayHelper::map(ComType::find()->all(), 'id', 'name'));
$dataCategory = ArrayHelper::map(ComType::find()->asArray()->all(), 'id', 'name');
echo $form->field($model, 'com_type_id')->dropDownList($dataCategory, ['prompt' => '--------']);
?>

    <?php 
echo $form->field($model, 'cpu_type')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'ram_type')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'cpuspeed')->textInput(['maxlength' => true]);
?>
Example #2
0
 public function getType($id)
 {
     $model = ComType::find()->where(['id' => $id])->one();
     return $model->name;
 }
Example #3
0
/* @var $this yii\web\View */
/* @var $searchModel frontend\controllers\ComSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$exportConfig = [GridView::EXCEL => ['label' => 'Save as Excel']];
$this->title = 'Computers';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="computer-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

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

    <?php 
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' => 'code', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(frontend\models\Computer::find()->groupBy('code')->asArray()->all(), 'code', 'code'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'หมายเลขครุภัณฑ์'], 'format' => 'raw'], ['attribute' => 'com_type_id', 'value' => function ($model) {
    return $model->getType($model->com_type_id);
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(ComType::find()->orderBy('id')->asArray()->all(), 'id', 'name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'ชนิด'], 'format' => 'raw'], ['attribute' => 'cpu_type', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(frontend\models\Computer::find()->groupBy('cpu_type')->asArray()->all(), 'cpu_type', 'cpu_type'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'CPU'], 'format' => 'raw'], ['attribute' => 'ram_type', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(frontend\models\Computer::find()->groupBy('ram_type')->asArray()->all(), 'ram_type', 'ram_type'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Ram'], 'format' => 'raw'], ['class' => 'kartik\\grid\\FormulaColumn', 'attribute' => 'cpuspeed', 'mergeHeader' => true], ['class' => '\\kartik\\grid\\ActionColumn', 'updateOptions' => ['label' => ''], 'deleteOptions' => ['label' => '']]], 'bordered' => true, 'responsive' => true, 'hover' => true, 'exportConfig' => $exportConfig, 'condensed' => true, 'panel' => ['type' => GridView::TYPE_PRIMARY, 'heading' => 'สรุปรายการ']]);
?>

</div>