diff --git a/config/params.php b/config/params.php index a4c7e42b..8f6533f6 100644 --- a/config/params.php +++ b/config/params.php @@ -2,5 +2,6 @@ return [ "hideInfomation" => false, - "TCTECH" => true + "TCTECH" => true, + "CardService" => "192.168.1.245:2001" ]; diff --git a/models/common.php b/models/common.php index 6322b56b..712a6ec4 100644 --- a/models/common.php +++ b/models/common.php @@ -184,7 +184,7 @@ class common extends \yii\db\ActiveRecord { } public static function requestToCardService($path, $data) { - return file_get_contents("http://192.168.2.119:2001" . $path, false, stream_context_create([ + return file_get_contents("http://" . Yii::$app->params["CardService"] . $path, false, stream_context_create([ 'http' => [ 'header' => "Content-Type: application/json", 'method' => "POST", diff --git a/web/js/device.js b/web/js/device.js index 18578410..de57235b 100644 --- a/web/js/device.js +++ b/web/js/device.js @@ -327,8 +327,14 @@ function syncSchedule(schedule, ip) { console.log("sync schedule: ", data.res); var html = ""; html = " Đồng bộ lịch trình tới thiết bị " + data.IP + ".
"; - $("#logs-response").append(html); progress++; + if (data.res.ErrorCode == "-1") { + html = " Đồng bộ tới thiết bị " + data.IP + " thất bại.
"; + progress++; + } else { + syncStaffs(ip); + } + $("#logs-response").append(html); var percent = parseInt(progress / totals * 100); $("#progress").attr("aria-valuenow", percent); $("#progress").attr("style", "width: " + percent + "%"); @@ -337,7 +343,6 @@ function syncSchedule(schedule, ip) { progress = 0; $("#close-modal").attr("disabled", false); } - syncStaffs(ip); }, error: function (jqXHR, textStatus, errorThrown) { common.ajaxError(); @@ -356,6 +361,9 @@ function syncStaffs(ip) { console.log("sync user: ", data.resUser); var html = ""; html = " Đồng bộ nhân viên tới thiết bị " + data.IP + ".
"; + if (data.res.ErrorCode == "-1") { + html = " Đồng bộ nhân viên tới thiết bị " + data.IP + " thất bại.
"; + } $("#logs-response").append(html); progress++; var percent = parseInt(progress / totals * 100);