public function search($params) { $query = Comkarupan::find(); //$query = Comkarupan::find()->groupByStatusName; $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => 'DESC']], 'pagination' => ['pagesize' => 20]]); if (isset($_GET['ComkarupanSearch']) && !($this->load($params) && $this->validate())) { return $dataProvider; } /*$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_hdd_size' => $this->com_hdd_size, 'com_ram_size' => $this->com_ram_size, 'network_type' => $this->network_type, 'warranty' => $this->warranty, 'depart' => $this->depart, 'date' => $this->date, 'price' => $this->price, 'dealer' => $this->dealer, 'status' => $this->status, 'addtosysdate' => $this->addtosysdate, 'editlasttime' => $this->editlasttime, 'ref' => $this->ref]); $query->andFilterWhere(['like', 'krp_code', $this->krp_code])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'serial', $this->serial])->andFilterWhere(['like', 'ctype', $this->ctype])->andFilterWhere(['like', 'com_ip', $this->com_ip])->andFilterWhere(['like', 'com_macaddr', $this->com_macaddr])->andFilterWhere(['like', 'com_hdd', $this->com_hdd])->andFilterWhere(['like', 'com_cpu', $this->com_cpu])->andFilterWhere(['like', 'com_cpu_detail', $this->com_cpu_detail])->andFilterWhere(['like', 'com_mb', $this->com_mb])->andFilterWhere(['like', 'com_mb_detail', $this->com_mb_detail])->andFilterWhere(['like', 'com_ram', $this->com_ram])->andFilterWhere(['like', 'com_vga', $this->com_vga])->andFilterWhere(['like', 'com_vga_detail', $this->com_vga_detail])->andFilterWhere(['like', 'com_dvd', $this->com_dvd])->andFilterWhere(['like', 'com_os', $this->com_os])->andFilterWhere(['like', 'com_program', $this->com_program])->andFilterWhere(['like', 'com_monitor', $this->com_monitor])->andFilterWhere(['like', 'com_mornitor_detail', $this->com_mornitor_detail])->andFilterWhere(['like', 'com_ups', $this->com_ups])->andFilterWhere(['like', 'com_ups_detail', $this->com_ups_detail])->andFilterWhere(['like', 'com_printer', $this->com_printer])->andFilterWhere(['like', 'com_printer_detail', $this->com_printer_detail])->andFilterWhere(['like', 'brand', $this->brand])->andFilterWhere(['like', 'network_detail', $this->network_detail])->andFilterWhere(['like', 'mornitor', $this->mornitor])->andFilterWhere(['like', 'mornitor_detail', $this->mornitor_detail])->andFilterWhere(['like', 'printer', $this->printer])->andFilterWhere(['like', 'printer_detail', $this->printer_detail])->andFilterWhere(['like', 'ups', $this->ups])->andFilterWhere(['like', 'ups_detail', $this->ups_detail])->andFilterWhere(['like', 'scanner', $this->ups])->andFilterWhere(['like', 'scanner_detail', $this->ups_detail])->andFilterWhere(['like', 'other', $this->other])->andFilterWhere(['like', 'other_detail', $this->other_detail])->andFilterWhere(['like', 'picture', $this->picture])->andFilterWhere(['like', 'docs', $this->docs])->andFilterWhere(['like', 'mod', $this->mod])->andFilterWhere(['like', 'user_rec', $this->user_rec])->andFilterWhere(['like', 'income', $this->income]); return $dataProvider; }
<div class="box box-warning"> <div class="box-header"> <h3 class="box-title">20 รายการที่บันทึกล่าสุด</h3> </div> <!-- /.box-header --> <div class="box-body table-responsive no-padding"> <table class="table table-hover"> <tr> <th>#ID</th> <th>วันที่</th> <th>สถานะ</th> <th>ชื่ออุปกรณ์</th> <th>ใช้งานที่</th> </tr> <?php $models = \app\models\Comkarupan::find()->limit(20)->orderBy('id desc')->all(); foreach ($models as $model) { if ($model->status == 1) { $statusLable = "<span class='label label-success'>กำลังใช้งาน</span>"; } elseif ($model->status == 2) { $statusLable = "<span class='label label-info'>พร้อมใช้งาน</span>"; } elseif ($model->status == 3) { $statusLable = "<span class='label label-warning'>อยู่ระหว่างซ่อม</span>"; } elseif ($model->status == 4) { $statusLable = "<span class='label label-primary'>ส่งซ่อม</span>"; } elseif ($model->status == 5) { $statusLable = "<span class='label label-danger'>ส่งซ่อม</span>"; } elseif ($model->status == 6) { $statusLable = "<span class='label label-default'>ส่งซ่อม</span>"; } else { $statusLable = "<span class='label'>ไม่อยู่ในเงื่อนไข</span>";
?> รายการ</span> <span class='label label-warning'>อุปกรณ์ที่อยู่ระหว่างซ่อม <?php echo Comkarupan::find()->where(['status' => 3])->count(); ?> รายการ</span> <span class='label label-primary'>อุปกรณ์ที่ส่งซ่อม <?php echo Comkarupan::find()->where(['status' => 4])->count(); ?> รายการ</span> <span class='label label-danger'>อุปกรณ์ที่ชำรุด/ซ่อมไม่ได้ <?php echo Comkarupan::find()->where(['status' => 5])->count(); ?> รายการ</span> <span class='label label-default'>อุปกรณ์ที่จำหน่ายออก <?php echo Comkarupan::find()->where(['status' => 6])->count(); ?> รายการ</span> </p> <?php $columns = [['attribute' => 'id', 'width' => '30px', 'headerOptions' => ['style' => 'text-align:center'], 'hAlign' => 'center'], ['attribute' => 'krp_code', 'width' => '160px', 'headerOptions' => ['style' => 'text-align:center'], 'hAlign' => 'center', 'pageSummary' => 'Page Total'], ['attribute' => 'name', 'headerOptions' => ['style' => 'text-align:center']], ['attribute' => 'ctype', 'filter' => \app\models\Comkarupan::itemsAlias('ctype'), 'value' => function ($model) { return $model->ctypeName; }, 'width' => '150px', 'headerOptions' => ['style' => 'text-align:center'], 'hAlign' => 'center'], ['attribute' => 'depart', 'value' => function ($data) { if (isset($data->depart_role->name)) { return $data->depart_role->name; } else { return 'ไม่ทราบข้อมูล'; // } }, 'hAlign' => 'center', 'width' => '200px', 'headerOptions' => ['style' => 'text-align:center'], 'filter' => \yii\helpers\ArrayHelper::map(app\models\Section::find()->all(), 'id', 'name')], ['attribute' => 'income', 'filter' => \app\models\Comkarupan::itemsAlias('income'), 'value' => function ($model) {