fix bug ErrorCode -1

This commit is contained in:
dongpd 2020-10-20 11:32:50 +07:00
parent b5619f7a5f
commit 9719e836f8
3 changed files with 13 additions and 4 deletions

View File

@ -2,5 +2,6 @@
return [
"hideInfomation" => false,
"TCTECH" => true
"TCTECH" => true,
"CardService" => "192.168.1.245:2001"
];

View File

@ -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",

View File

@ -327,8 +327,14 @@ function syncSchedule(schedule, ip) {
console.log("sync schedule: ", data.res);
var html = "";
html = "<span class='text-green'><i class='fa fa-check'></i> Đồng bộ lịch trình tới thiết bị <b>" + data.IP + "</b>.</span><br>";
$("#logs-response").append(html);
progress++;
if (data.res.ErrorCode == "-1") {
html = "<span class='text-red'><i class='fa fa-remove'></i> Đồng bộ tới thiết bị <b>" + data.IP + "</b> thất bại.</span><br>";
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 = "<span class='text-green'><i class='fa fa-check'></i> Đồng bộ nhân viên tới thiết bị <b>" + data.IP + "</b>.</span><br>";
if (data.res.ErrorCode == "-1") {
html = "<span class='text-red'><i class='fa fa-remove'></i> Đồng bộ nhân viên tới thiết bị <b>" + data.IP + "</b> thất bại.</span><br>";
}
$("#logs-response").append(html);
progress++;
var percent = parseInt(progress / totals * 100);