hiển thị danh sách cửa ở quản lý thiết bị
This commit is contained in:
parent
d3961cf040
commit
fe639c34fc
|
@ -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() {
|
public static function openDoor() {
|
||||||
return function($model) {
|
return function($model) {
|
||||||
$doors = Door::find()->andWhere(["device_id" => $model->id])->count();
|
$doors = Door::find()->andWhere(["device_id" => $model->id])->all();
|
||||||
return Html::button("<i class='fa fa-list'></i> Danh sách cửa " . Html::label($doors, "", ["class" => "label label-danger"]), [
|
$ls = [];
|
||||||
'class' => 'btn btn-info',
|
foreach ($doors as $key => $value) {
|
||||||
'data' => [
|
$ls[] = $value->name;
|
||||||
'href' => Url::to(['doors', 'id' => $model->id])
|
}
|
||||||
],
|
return implode("<br>", $ls);
|
||||||
'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;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@
|
||||||
'attribute' => 'door',
|
'attribute' => 'door',
|
||||||
'format' => 'raw',
|
'format' => 'raw',
|
||||||
'headerOptions' => ['style' => 'width:10%'],
|
'headerOptions' => ['style' => 'width:10%'],
|
||||||
'contentOptions' => ['class' => 'text-center'],
|
'contentOptions' => \app\helpers\DeviceGrid::openDoorHeader(),
|
||||||
'value' => \app\helpers\DeviceGrid::openDoor()
|
'value' => \app\helpers\DeviceGrid::openDoor()
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user