fix bug đồng bộ dữ liệu
This commit is contained in:
parent
0314fa4158
commit
5b24af3ad5
|
@ -365,7 +365,6 @@ class DeviceController extends Controller {
|
||||||
$schedule = array_unique($schedule);
|
$schedule = array_unique($schedule);
|
||||||
return [
|
return [
|
||||||
"IP" => $this->findModel($device_id)->ip_address,
|
"IP" => $this->findModel($device_id)->ip_address,
|
||||||
"staffs" => $staffs,
|
|
||||||
"schedule" => $schedule
|
"schedule" => $schedule
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -408,9 +407,17 @@ class DeviceController extends Controller {
|
||||||
if (Yii::$app->request->post()) {
|
if (Yii::$app->request->post()) {
|
||||||
Yii::$app->response->format = "json";
|
Yii::$app->response->format = "json";
|
||||||
$post = Yii::$app->request->post();
|
$post = Yii::$app->request->post();
|
||||||
$staff_lists = $post["data"];
|
$device_id = Device::findOne(['ip_address' => $post['ip']])->id;
|
||||||
|
$doors = Door::find()->andWhere(["device_id" => $device_id])->all();
|
||||||
|
$filter = ["OR"];
|
||||||
|
foreach ($doors as $key => $value) {
|
||||||
|
$filter[] = ["LIKE", "door_access", '"' . $value->id . '"'];
|
||||||
|
}
|
||||||
|
$staff_lists = Staff::find()->andWhere($filter)->all();
|
||||||
|
|
||||||
$UserInfos = [];
|
$UserInfos = [];
|
||||||
$UserAuthorizeInfos = [];
|
$UserAuthorizeInfos = [];
|
||||||
|
|
||||||
foreach ($staff_lists as $key => $value) {
|
foreach ($staff_lists as $key => $value) {
|
||||||
$UserInfos[] = [
|
$UserInfos[] = [
|
||||||
"CardNo" => $value["card_number"],
|
"CardNo" => $value["card_number"],
|
||||||
|
|
|
@ -131,7 +131,9 @@ class Staff extends \yii\db\ActiveRecord {
|
||||||
if ($this->door_access) {
|
if ($this->door_access) {
|
||||||
$ls = json_decode($this->door_access, true);
|
$ls = json_decode($this->door_access, true);
|
||||||
foreach ($ls as $key => $value) {
|
foreach ($ls as $key => $value) {
|
||||||
$doors[] = Door::findOne($value)->name;
|
$dInfo = Door::findOne($value);
|
||||||
|
if ($dInfo)
|
||||||
|
$doors[] = $dInfo->name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return implode(", ", $doors);
|
return implode(", ", $doors);
|
||||||
|
|
|
@ -307,7 +307,7 @@ function getDataSync(data) {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
syncSchedule(data.schedule, data.staffs, data.IP);
|
syncSchedule(data.schedule, data.IP);
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
common.ajaxError();
|
common.ajaxError();
|
||||||
|
@ -315,7 +315,7 @@ function getDataSync(data) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function syncSchedule(schedule, staffs, ip) {
|
function syncSchedule(schedule, ip) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: $("input[name='sync_schedule_url']").val(),
|
url: $("input[name='sync_schedule_url']").val(),
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
|
@ -337,7 +337,7 @@ function syncSchedule(schedule, staffs, ip) {
|
||||||
progress = 0;
|
progress = 0;
|
||||||
$("#close-modal").attr("disabled", false);
|
$("#close-modal").attr("disabled", false);
|
||||||
}
|
}
|
||||||
syncStaffs(staffs, ip);
|
syncStaffs(ip);
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
common.ajaxError();
|
common.ajaxError();
|
||||||
|
@ -345,12 +345,11 @@ function syncSchedule(schedule, staffs, ip) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function syncStaffs(data, ip) {
|
function syncStaffs(ip) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: $("input[name='sync_staffs_url']").val(),
|
url: $("input[name='sync_staffs_url']").val(),
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: {
|
data: {
|
||||||
data: data,
|
|
||||||
ip: ip
|
ip: ip
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user