fix bug đồng bộ dữ liệu

This commit is contained in:
2020-10-19 17:44:52 +07:00
parent 0314fa4158
commit 5b24af3ad5
3 changed files with 16 additions and 8 deletions

View File

@@ -365,7 +365,6 @@ class DeviceController extends Controller {
$schedule = array_unique($schedule);
return [
"IP" => $this->findModel($device_id)->ip_address,
"staffs" => $staffs,
"schedule" => $schedule
];
}
@@ -408,9 +407,17 @@ class DeviceController extends Controller {
if (Yii::$app->request->post()) {
Yii::$app->response->format = "json";
$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 = [];
$UserAuthorizeInfos = [];
foreach ($staff_lists as $key => $value) {
$UserInfos[] = [
"CardNo" => $value["card_number"],