From fe639c34fce86147b71acbc7eb3dba3155a5d9f8 Mon Sep 17 00:00:00 2001 From: dongpd Date: Wed, 4 Nov 2020 16:03:19 +0700 Subject: [PATCH] =?UTF-8?q?hi=E1=BB=83n=20th=E1=BB=8B=20danh=20s=C3=A1ch?= =?UTF-8?q?=20c=E1=BB=ADa=20=E1=BB=9F=20qu=E1=BA=A3n=20l=C3=BD=20thi?= =?UTF-8?q?=E1=BA=BFt=20b=E1=BB=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helpers/DeviceGrid.php | 33 ++++++++++++++++----------------- views/device/index.tpl | 2 +- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/helpers/DeviceGrid.php b/helpers/DeviceGrid.php index 21596305..549d9ea1 100644 --- a/helpers/DeviceGrid.php +++ b/helpers/DeviceGrid.php @@ -34,25 +34,24 @@ class DeviceGrid extends CommonGrid { }; } + public static function openDoorHeader() { + return function($model, $index, $widget, $grid) { + return [ + 'class' => 'text-center', + 'onclick' => "common.form(this, '', true);", + 'data-href' => Url::to(['doors', 'id' => $model->id]) + ]; + }; + } + public static function openDoor() { return function($model) { - $doors = Door::find()->andWhere(["device_id" => $model->id])->count(); - return Html::button(" Danh sách cửa " . Html::label($doors, "", ["class" => "label label-danger"]), [ - 'class' => 'btn btn-info', - 'data' => [ - 'href' => Url::to(['doors', 'id' => $model->id]) - ], - 'onclick' => "common.form(this, '', true);" - ]); -// foreach ($doors as $key => $value) { -// $html .= Html::button($value->code, [ -// 'class' => 'btn btn-info', -// 'data' => ['toggle' => 'tooltip', 'href' => Url::to(['open-door', 'id' => $model->id, 'door' => $value->code])], -// 'title' => \Yii::t('app', 'Mở cửa'), -// 'onclick' => "openDoor(this);" -// ]) . " "; -// } -// return $html; + $doors = Door::find()->andWhere(["device_id" => $model->id])->all(); + $ls = []; + foreach ($doors as $key => $value) { + $ls[] = $value->name; + } + return implode("
", $ls); }; } diff --git a/views/device/index.tpl b/views/device/index.tpl index c3a7f7d4..e8f76871 100644 --- a/views/device/index.tpl +++ b/views/device/index.tpl @@ -117,7 +117,7 @@ 'attribute' => 'door', 'format' => 'raw', 'headerOptions' => ['style' => 'width:10%'], - 'contentOptions' => ['class' => 'text-center'], + 'contentOptions' => \app\helpers\DeviceGrid::openDoorHeader(), 'value' => \app\helpers\DeviceGrid::openDoor() ] ],