From fa10b73a3d83a6a47804dc2f47ad6d85ec581885 Mon Sep 17 00:00:00 2001 From: dongpd Date: Wed, 4 Nov 2020 17:24:56 +0700 Subject: [PATCH] =?UTF-8?q?update=20=C4=91=E1=BB=93ng=20b=E1=BB=99=20t?= =?UTF-8?q?=E1=BA=A5t=20c=E1=BA=A3=20thi=E1=BA=BFt=20b=E1=BB=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/web.php | 2 +- controllers/DeviceController.php | 27 +++++++++++++++++++++++++-- web/js/device.js | 14 ++++++++++++-- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/config/web.php b/config/web.php index 16d5c29b..ebc8ddde 100644 --- a/config/web.php +++ b/config/web.php @@ -48,7 +48,7 @@ $config = [ ], 'assetManager' => [ 'class' => 'app\\components\\AssetManager', - 'appendVersion' => '1.0.5', + 'appendVersion' => '1.0.6', 'bundles' => [ 'dmstr\web\AdminLteAsset' => [ 'skin' => 'skin-blue', diff --git a/controllers/DeviceController.php b/controllers/DeviceController.php index c5d7eb1f..89586958 100644 --- a/controllers/DeviceController.php +++ b/controllers/DeviceController.php @@ -87,6 +87,9 @@ class DeviceController extends Controller { if ($requestToCardService["Status"] === "ERROR") return ["status" => false, "type" => "connect"]; + if (intval($requestToCardService["LockCount"]) < 1) + return ["status" => false, "type" => "connect"]; + $device_id = $model->create([ 'name' => $data["Name"], 'serial' => isset($device['SN']) ? $device['SN'] : "", @@ -378,10 +381,20 @@ class DeviceController extends Controller { public function actionSync() { if (Yii::$app->request->post()) { Yii::$app->response->format = "json"; + $post = Yii::$app->request->post("lists"); + $lists = $post["lists"]; + if ($post["all"] && count($lists) >= 20) { + $temp = []; + $devices = Device::find()->all(); + foreach ($devices as $key => $value) { + $temp[] = $value->id; + } + $lists = $temp; + } return [ "title" => Html::tag("i", "", ["class" => "fa fa-refresh"]) . " Đồng bộ dữ liệu đến thiết bị", "form" => $this->renderPartial("sync"), - "lists" => Yii::$app->request->post("lists") + "lists" => $lists ]; } } @@ -533,10 +546,20 @@ class DeviceController extends Controller { public function actionGetLogs() { if (Yii::$app->request->post()) { Yii::$app->response->format = "json"; + $post = Yii::$app->request->post("lists"); + $lists = $post["lists"]; + if ($post["all"] && count($lists) >= 20) { + $temp = []; + $devices = Device::find()->all(); + foreach ($devices as $key => $value) { + $temp[] = $value->id; + } + $lists = $temp; + } return [ "title" => Html::tag("i", "", ["class" => "fa fa-exchange"]) . " Lấy các sự kiện", "form" => $this->renderPartial("logs"), - "lists" => Yii::$app->request->post("lists") + "lists" => $lists ]; } } diff --git a/web/js/device.js b/web/js/device.js index 23b00ed1..7b6b6f01 100644 --- a/web/js/device.js +++ b/web/js/device.js @@ -266,6 +266,10 @@ var currentPage = 1; var secondIncrement = 0; async function _sync(e) { + var checkAll = $("#checkall-device:checked").length; + var all = false; + if (checkAll > 0) + all = true; var lists = []; $.each($("input[name='checkbox-device']:checked"), function () { lists.push({ @@ -282,7 +286,8 @@ async function _sync(e) { url: $(e).attr('data-href'), type: 'POST', data: { - lists: lists + lists: lists, + all: all }, success: function (data) { common.modalBlock(false); @@ -401,6 +406,10 @@ function getDataSync(data) { var progressLogs = 0; var totalsLogs = 0; function _getLogs(e) { + var checkAll = $("#checkall-device:checked").length; + var all = false; + if (checkAll > 0) + all = true; var lists = []; $.each($("input[name='checkbox-device']:checked"), function () { lists.push($(this).val()); @@ -414,7 +423,8 @@ function _getLogs(e) { url: $(e).attr('data-href'), type: 'POST', data: { - lists: lists + lists: lists, + all: all }, success: function (data) { common.modalBlock(false);