From 72dfa46c946c2d24a19211e6ddc049b78343205e Mon Sep 17 00:00:00 2001 From: dongpd Date: Wed, 4 Nov 2020 17:03:35 +0700 Subject: [PATCH] =?UTF-8?q?update=20d=E1=BB=95i=20t=C3=AAn=20c=E1=BB=ADa?= =?UTF-8?q?=20realtime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/DeviceController.php | 12 +++++++++++- helpers/DeviceGrid.php | 3 ++- web/js/device.js | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/controllers/DeviceController.php b/controllers/DeviceController.php index fe5742a7..c5d7eb1f 100644 --- a/controllers/DeviceController.php +++ b/controllers/DeviceController.php @@ -640,7 +640,17 @@ class DeviceController extends Controller { $model->modified_at = time(); $model->save(); } - return $id; + $doors = Door::find()->andWhere(["device_id" => $model->device_id])->all(); + $ls = []; + foreach ($doors as $key => $value) { + $ls[] = $value->name; + } + Yii::$app->response->format = "json"; + return [ + "id" => $id, + "device_id" => $model->device_id, + "form" => implode("
", $ls) + ]; } } diff --git a/helpers/DeviceGrid.php b/helpers/DeviceGrid.php index 549d9ea1..dc0fd8a2 100644 --- a/helpers/DeviceGrid.php +++ b/helpers/DeviceGrid.php @@ -39,7 +39,8 @@ class DeviceGrid extends CommonGrid { return [ 'class' => 'text-center', 'onclick' => "common.form(this, '', true);", - 'data-href' => Url::to(['doors', 'id' => $model->id]) + 'data-href' => Url::to(['doors', 'id' => $model->id]), + 'id' => 'device-ls-' . $model->id ]; }; } diff --git a/web/js/device.js b/web/js/device.js index d8f593ae..23b00ed1 100644 --- a/web/js/device.js +++ b/web/js/device.js @@ -528,11 +528,12 @@ function editDoor(e) { }, success: function (data) { common.modalBlock(false); - var id = parseInt(data); + var id = parseInt(data.id); $("#name-text-" + id).html(name); $("#duration-text-" + id).html(duration); $(".real-" + id).removeClass("hidden"); $(".edit-" + id).addClass("hidden"); + $("#device-ls-" + data.device_id).html(data.form); notification.success("Đã lưu thông tin", 2000); }, error: function (jqXHR, textStatus, errorThrown) {