예제 #1
0
파일: ComSearch.php 프로젝트: bmanop20/com
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Computer::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, 'com_type_id' => $this->com_type_id, 'arch_type_id' => $this->arch_type_id]);
     $query->andFilterWhere(['like', 'cpu_type', $this->cpu_type])->andFilterWhere(['like', 'ram_type', $this->ram_type])->andFilterWhere(['like', 'cpuspeed', $this->cpuspeed])->andFilterWhere(['like', 'ramspeed', $this->ramspeed])->andFilterWhere(['like', 'os', $this->os])->andFilterWhere(['like', 'brand', $this->brand])->andFilterWhere(['like', 'code', $this->code]);
     return $dataProvider;
 }
예제 #2
0
파일: _form.php 프로젝트: bmanop20/com
use kartik\datecontrol\DateControl;
use kartik\select2\Select2;
/* @var $this yii\web\View */
/* @var $model frontend\models\ComDep */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="box box-info">
    <div class="box-header with-border">
        
            <?php 
$form = ActiveForm::begin();
?>

            <?php 
$dataCategory = ArrayHelper::map(Computer::find()->select(['id', 'concat("COMID: ",id, " หมายเลข: " ,code) as name'])->asArray()->all(), 'id', 'name');
echo $form->field($model, 'com_id')->widget(Select2::classname(), ['data' => $dataCategory, 'options' => ['placeholder' => '----- อุปกรณ์คอมพิวเตอร์ -------']]);
?>

            <?php 
$dataCategory = ArrayHelper::map(Department::find()->asArray()->all(), 'id', 'name');
echo $form->field($model, 'dep_id')->widget(Select2::classname(), ['data' => $dataCategory, 'options' => ['placeholder' => '----- เลือกฝ่าย -------']]);
?>


            <?php 
echo $form->field($model, 'datein')->widget(DateControl::classname(), ['type' => DateControl::FORMAT_DATE]);
?>

            <?php 
echo $form->field($model, 'dateout')->widget(DateControl::classname(), ['value' => '20-11-2015', 'type' => DateControl::FORMAT_DATE, 'displayFormat' => 'php: d-m-yy']);
예제 #3
0
파일: index.php 프로젝트: bmanop20/com
    <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>
예제 #4
0
파일: ComDep.php 프로젝트: bmanop20/com
 public function getComCode($id)
 {
     $model = Computer::find()->where(['id' => $id])->one();
     $code = empty($model->code) ? 'not set' : $model->code;
     return $code;
 }