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) {