update data to device

This commit is contained in:
dongpd 2020-10-14 17:21:26 +07:00
parent fd27169e00
commit 37ab48f055
7 changed files with 321 additions and 55 deletions

View File

@ -3,7 +3,7 @@
-- https://www.phpmyadmin.net/ -- https://www.phpmyadmin.net/
-- --
-- Host: 127.0.0.1 -- Host: 127.0.0.1
-- Generation Time: Oct 14, 2020 at 08:59 AM -- Generation Time: Oct 14, 2020 at 11:53 AM
-- Server version: 10.4.8-MariaDB -- Server version: 10.4.8-MariaDB
-- PHP Version: 7.1.33 -- PHP Version: 7.1.33
@ -217,7 +217,8 @@ CREATE TABLE `device` (
-- --
INSERT INTO `device` (`id`, `name`, `serial`, `ip_address`, `subnet_mask`, `gateway`, `mac_address`, `status`, `type`, `version`, `area_id`, `created_at`, `modified_at`) VALUES INSERT INTO `device` (`id`, `name`, `serial`, `ip_address`, `subnet_mask`, `gateway`, `mac_address`, `status`, `type`, `version`, `area_id`, `created_at`, `modified_at`) VALUES
(4, 'Thiết bị 1', 'AJNV193560605', '192.168.1.200', '255.255.252.0', '192.168.0.1', '00:17:61:C9:6B:A4', 1, 'C3-200', 'AC Ver 4.3.4 Jan 5 2019', 1, 1602563228, 1602563228); (4, 'Thiết bị 1', 'AJNV193560605', '192.168.1.200', '255.255.252.0', '192.168.0.1', '00:17:61:C9:6B:A4', 1, 'C3-200', 'AC Ver 4.3.4 Jan 5 2019', 1, 1602563228, 1602563228),
(5, '192.168.1.202', 'AJNV200860076', '192.168.1.202', '255.255.252.0', '192.168.0.1', '00:17:61:CA:8D:F6', 1, 'C3-200', 'AC Ver 4.3.4 Jan 5 2019', 1, 1602659429, 1602659429);
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -240,7 +241,9 @@ CREATE TABLE `door` (
INSERT INTO `door` (`id`, `device_id`, `name`, `code`, `created_at`, `modified_at`) VALUES INSERT INTO `door` (`id`, `device_id`, `name`, `code`, `created_at`, `modified_at`) VALUES
(7, 4, 'Thiết bị 1-1', 1, 1602563228, 1602563228), (7, 4, 'Thiết bị 1-1', 1, 1602563228, 1602563228),
(8, 4, 'Thiết bị 1-2', 2, 1602563228, 1602563228); (8, 4, 'Thiết bị 1-2', 2, 1602563228, 1602563228),
(9, 5, '192.168.1.202-1', 1, 1602659432, 1602659432),
(10, 5, '192.168.1.202-2', 2, 1602659432, 1602659432);
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -282,7 +285,7 @@ CREATE TABLE `schedule` (
-- --
INSERT INTO `schedule` (`id`, `name`, `description`, `SunTime1`, `SunTime2`, `SunTime3`, `MonTime1`, `MonTime2`, `MonTime3`, `TueTime1`, `TueTime2`, `TueTime3`, `WedTime1`, `WedTime2`, `WedTime3`, `ThuTime1`, `ThuTime2`, `ThuTime3`, `FriTime1`, `FriTime2`, `FriTime3`, `SatTime1`, `SatTime2`, `SatTime3`, `created_at`, `modified_at`) VALUES INSERT INTO `schedule` (`id`, `name`, `description`, `SunTime1`, `SunTime2`, `SunTime3`, `MonTime1`, `MonTime2`, `MonTime3`, `TueTime1`, `TueTime2`, `TueTime3`, `WedTime1`, `WedTime2`, `WedTime3`, `ThuTime1`, `ThuTime2`, `ThuTime3`, `FriTime1`, `FriTime2`, `FriTime3`, `SatTime1`, `SatTime2`, `SatTime3`, `created_at`, `modified_at`) VALUES
(6, 'Nhân viên BI', '', '00:00-00:00', '00:00-00:00', '00:00-00:00', '09:00-12:00', '13:30-18:00', '00:00-00:00', '09:00-12:00', '13:30-18:00', '00:00-00:00', '09:00-12:00', '13:30-18:00', '00:00-00:00', '09:00-12:00', '13:30-18:00', '00:00-00:00', '09:00-12:00', '13:30-18:00', '00:00-00:00', '09:00-12:00', '13:30-18:00', '00:00-00:00', 1602644311, 1602644311); (6, 'Nhân viên BI', '', '00:00-00:00', '00:00-00:00', '00:00-00:00', '09:00-12:00', '13:30-18:00', '00:00-00:00', '09:00-12:00', '13:30-18:00', '00:00-00:00', '09:00-12:00', '13:30-18:00', '00:00-00:00', '09:00-12:00', '13:30-18:00', '00:00-00:00', '09:00-12:00', '13:30-18:00', '00:00-00:00', '09:00-12:00', '13:30-18:00', '00:00-00:00', 1602644311, 1602667425);
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -314,13 +317,13 @@ CREATE TABLE `staff` (
-- --
INSERT INTO `staff` (`id`, `code`, `name`, `card_number`, `department_id`, `gender`, `birthday`, `email`, `phone`, `date_in`, `address`, `created_at`, `modified_at`, `card_register_time`, `schedule_id`, `door_access`) VALUES INSERT INTO `staff` (`id`, `code`, `name`, `card_number`, `department_id`, `gender`, `birthday`, `email`, `phone`, `date_in`, `address`, `created_at`, `modified_at`, `card_register_time`, `schedule_id`, `door_access`) VALUES
(1, 201601065, 'Nguyen Thi Ha', 2147483647, 74, 'M', 1602645580, '', '', 1602645580, '', 1602645580, 1602645580, 1602645580, 0, NULL), (1, 201601065, 'Nguyen Thi Ha', 16673827, 74, 'M', 1602665891, '', '', 1602665891, '', 1602645580, 1602665891, 1602665891, 0, NULL),
(2, 201601076, 'Nguyen Van Dong', 2147483647, 74, 'M', 1602645580, '', '', 1602645580, '', 1602645580, 1602645580, 1602645580, 0, NULL), (2, 201601076, 'Nguyen Van Dong', 16672726, 74, 'M', 1602665902, '', '', 1602665902, '', 1602645580, 1602665902, 1602665902, 6, '[\"7\",\"8\"]'),
(3, 201601107, 'Trinh Thi Thanh', 2147483647, 74, 'M', 1602645580, '', '', 1602645580, '', 1602645580, 1602645580, 1602645580, 0, NULL), (3, 201601107, 'Trinh Thi Thanh', 2430805, 74, 'M', 1602665912, '', '', 1602665912, '', 1602645580, 1602665912, 1602665912, 6, '[\"7\",\"8\"]'),
(4, 201602001, 'Dao Thi Huong', 2147483647, 74, 'M', 1602645580, '', '', 1602645580, '', 1602645580, 1602645580, 1602645580, 0, NULL), (4, 201602001, 'Dao Thi Huong', 14380376, 74, 'M', 1602665921, '', '', 1602665921, '', 1602645580, 1602665921, 1602665921, 0, NULL),
(5, 201602050, 'Nguyen Duc Loc', 2147483647, 74, 'M', 1602645580, '', '', 1602645580, '', 1602645580, 1602645580, 1602645580, 0, NULL), (5, 201602050, 'Nguyen Duc Loc', 16441913, 74, 'M', 1602665931, '', '', 1602665931, '', 1602645580, 1602665931, 1602665931, 0, NULL),
(6, 201602057, 'Pham Van Tien', 746061653, 74, 'M', 1602645580, '', '', 1602645580, '', 1602645580, 1602645580, 1602645580, 0, NULL), (6, 201602057, 'Pham Van Tien', 16673826, 74, 'M', 1602665942, '', '', 1602665942, '', 1602645580, 1602665942, 1602665942, 0, NULL),
(7, 201602077, 'Le Thi Huyen Trang', 285454395, 74, 'M', 1602645580, '', '', 1602645580, '', 1602645580, 1602645580, 1602645580, 0, NULL), (7, 201602077, 'Le Thi Huyen Trang', 16672731, 74, 'M', 1602665951, '', '', 1602665951, '', 1602645580, 1602665951, 1602665951, 6, '[\"7\",\"8\"]'),
(8, 201602079, 'Truong Cong Chuc', 703758773, 74, 'M', 1602645580, '', '', 1602645580, '', 1602645580, 1602645580, 1602645580, 0, NULL), (8, 201602079, 'Truong Cong Chuc', 703758773, 74, 'M', 1602645580, '', '', 1602645580, '', 1602645580, 1602645580, 1602645580, 0, NULL),
(9, 201602080, 'Nguyen Van Phuong', 2147483647, 74, 'M', 1602645580, '', '', 1602645580, '', 1602645580, 1602645580, 1602645580, 0, NULL), (9, 201602080, 'Nguyen Van Phuong', 2147483647, 74, 'M', 1602645580, '', '', 1602645580, '', 1602645580, 1602645580, 1602645580, 0, NULL),
(10, 201604004, 'Le Van Minh', 1678782346, 74, 'M', 1602645580, '', '', 1602645580, '', 1602645580, 1602645580, 1602645580, 0, NULL), (10, 201604004, 'Le Van Minh', 1678782346, 74, 'M', 1602645580, '', '', 1602645580, '', 1602645580, 1602645580, 1602645580, 0, NULL),
@ -680,9 +683,9 @@ INSERT INTO `staff` (`id`, `code`, `name`, `card_number`, `department_id`, `gend
(364, 201904001, 'Bui Dinh Hung', 30974442, 58, 'M', 1602645581, '', '', 1602645581, '', 1602645581, 1602645581, 1602645581, 0, NULL), (364, 201904001, 'Bui Dinh Hung', 30974442, 58, 'M', 1602645581, '', '', 1602645581, '', 1602645581, 1602645581, 1602645581, 0, NULL),
(365, 201904003, 'Bui Huu Thuan', 31606442, 58, 'M', 1602645581, '', '', 1602645581, '', 1602645581, 1602645581, 1602645581, 0, NULL), (365, 201904003, 'Bui Huu Thuan', 31606442, 58, 'M', 1602645581, '', '', 1602645581, '', 1602645581, 1602645581, 1602645581, 0, NULL),
(366, 201904004, 'Pham Thanh Chung', 31108730, 58, 'M', 1602645581, '', '', 1602645581, '', 1602645581, 1602645581, 1602645581, 0, NULL), (366, 201904004, 'Pham Thanh Chung', 31108730, 58, 'M', 1602645581, '', '', 1602645581, '', 1602645581, 1602645581, 1602645581, 0, NULL),
(367, 201904034, 'Nguyen Van Nghi', 153865114, 58, 'M', 1602645581, '', '', 1602645581, '', 1602645581, 1602645581, 1602645581, 0, NULL), (367, 201904034, 'Nguyen Van Nghi', 153865114, 58, 'M', 1602645581, '', '', 1602645581, '', 1602645581, 1602645581, 1602645581, 0, NULL);
(368, 201905001, 'Nguyen Duy Huy', 167642218, 58, 'M', 1602645581, '', '', 1602645581, '', 1602645581, 1602645581, 1602645581, 0, NULL);
INSERT INTO `staff` (`id`, `code`, `name`, `card_number`, `department_id`, `gender`, `birthday`, `email`, `phone`, `date_in`, `address`, `created_at`, `modified_at`, `card_register_time`, `schedule_id`, `door_access`) VALUES INSERT INTO `staff` (`id`, `code`, `name`, `card_number`, `department_id`, `gender`, `birthday`, `email`, `phone`, `date_in`, `address`, `created_at`, `modified_at`, `card_register_time`, `schedule_id`, `door_access`) VALUES
(368, 201905001, 'Nguyen Duy Huy', 167642218, 58, 'M', 1602645581, '', '', 1602645581, '', 1602645581, 1602645581, 1602645581, 0, NULL),
(369, 201906010, 'Bui Thi Ngoc Anh', 151971258, 58, 'M', 1602645581, '', '', 1602645581, '', 1602645581, 1602645581, 1602645581, 0, NULL), (369, 201906010, 'Bui Thi Ngoc Anh', 151971258, 58, 'M', 1602645581, '', '', 1602645581, '', 1602645581, 1602645581, 1602645581, 0, NULL),
(370, 201911011, 'Pham Van Sang', 1682023786, 58, 'M', 1602645581, '', '', 1602645581, '', 1602645581, 1602645581, 1602645581, 0, NULL), (370, 201911011, 'Pham Van Sang', 1682023786, 58, 'M', 1602645581, '', '', 1602645581, '', 1602645581, 1602645581, 1602645581, 0, NULL),
(371, 201911013, 'Luu Van Thanh', 2147483647, 58, 'M', 1602645581, '', '', 1602645581, '', 1602645581, 1602645581, 1602645581, 0, NULL), (371, 201911013, 'Luu Van Thanh', 2147483647, 58, 'M', 1602645581, '', '', 1602645581, '', 1602645581, 1602645581, 1602645581, 0, NULL),
@ -1049,9 +1052,9 @@ INSERT INTO `staff` (`id`, `code`, `name`, `card_number`, `department_id`, `gend
(732, 201906026, 'Pham Thi Thanh Huong', 47363162, 62, 'M', 1602645583, '', '', 1602645583, '', 1602645583, 1602645583, 1602645583, 0, NULL), (732, 201906026, 'Pham Thi Thanh Huong', 47363162, 62, 'M', 1602645583, '', '', 1602645583, '', 1602645583, 1602645583, 1602645583, 0, NULL),
(733, 201907021, 'Doan Thi Huong', 46723098, 59, 'M', 1602645583, '', '', 1602645583, '', 1602645583, 1602645583, 1602645583, 0, NULL), (733, 201907021, 'Doan Thi Huong', 46723098, 59, 'M', 1602645583, '', '', 1602645583, '', 1602645583, 1602645583, 1602645583, 0, NULL),
(734, 201909022, 'Nguyen Hoang Yen', 1677169178, 62, 'M', 1602645583, '', '', 1602645583, '', 1602645583, 1602645583, 1602645583, 0, NULL), (734, 201909022, 'Nguyen Hoang Yen', 1677169178, 62, 'M', 1602645583, '', '', 1602645583, '', 1602645583, 1602645583, 1602645583, 0, NULL),
(735, 201909023, 'Vu Thi Dieu Hoa', 47228842, 59, 'M', 1602645583, '', '', 1602645583, '', 1602645583, 1602645583, 1602645583, 0, NULL), (735, 201909023, 'Vu Thi Dieu Hoa', 47228842, 59, 'M', 1602645583, '', '', 1602645583, '', 1602645583, 1602645583, 1602645583, 0, NULL);
(736, 201910003, 'Hoang Ngoc Tuan', 2147483647, 62, 'M', 1602645583, '', '', 1602645583, '', 1602645583, 1602645583, 1602645583, 0, NULL);
INSERT INTO `staff` (`id`, `code`, `name`, `card_number`, `department_id`, `gender`, `birthday`, `email`, `phone`, `date_in`, `address`, `created_at`, `modified_at`, `card_register_time`, `schedule_id`, `door_access`) VALUES INSERT INTO `staff` (`id`, `code`, `name`, `card_number`, `department_id`, `gender`, `birthday`, `email`, `phone`, `date_in`, `address`, `created_at`, `modified_at`, `card_register_time`, `schedule_id`, `door_access`) VALUES
(736, 201910003, 'Hoang Ngoc Tuan', 2147483647, 62, 'M', 1602645583, '', '', 1602645583, '', 1602645583, 1602645583, 1602645583, 0, NULL),
(737, 201910044, 'Ngo Van Bon', 2147483647, 62, 'M', 1602645583, '', '', 1602645583, '', 1602645583, 1602645583, 1602645583, 0, NULL), (737, 201910044, 'Ngo Van Bon', 2147483647, 62, 'M', 1602645583, '', '', 1602645583, '', 1602645583, 1602645583, 1602645583, 0, NULL),
(738, 201911004, 'Nguyen Thi Nguyet', 1674818090, 59, 'M', 1602645583, '', '', 1602645583, '', 1602645583, 1602645583, 1602645583, 0, NULL), (738, 201911004, 'Nguyen Thi Nguyet', 1674818090, 59, 'M', 1602645583, '', '', 1602645583, '', 1602645583, 1602645583, 1602645583, 0, NULL),
(739, 202002020, 'Cao Thuy Linh', 2147483647, 62, 'M', 1602645583, '', '', 1602645583, '', 1602645583, 1602645583, 1602645583, 0, NULL), (739, 202002020, 'Cao Thuy Linh', 2147483647, 62, 'M', 1602645583, '', '', 1602645583, '', 1602645583, 1602645583, 1602645583, 0, NULL),
@ -1416,9 +1419,9 @@ INSERT INTO `staff` (`id`, `code`, `name`, `card_number`, `department_id`, `gend
(1098, 201706009, 'Nguyen Van Tuan', 749819877, 31, 'M', 1602645584, '', '', 1602645584, '', 1602645584, 1602645584, 1602645584, 0, NULL), (1098, 201706009, 'Nguyen Van Tuan', 749819877, 31, 'M', 1602645584, '', '', 1602645584, '', 1602645584, 1602645584, 1602645584, 0, NULL),
(1099, 201706053, 'Vu Thi Kim Oanh', 747113989, 33, 'M', 1602645584, '', '', 1602645584, '', 1602645584, 1602645584, 1602645584, 0, NULL), (1099, 201706053, 'Vu Thi Kim Oanh', 747113989, 33, 'M', 1602645584, '', '', 1602645584, '', 1602645584, 1602645584, 1602645584, 0, NULL),
(1100, 201707031, 'Le Thi Men', 747521557, 31, 'M', 1602645584, '', '', 1602645584, '', 1602645584, 1602645584, 1602645584, 0, NULL), (1100, 201707031, 'Le Thi Men', 747521557, 31, 'M', 1602645584, '', '', 1602645584, '', 1602645584, 1602645584, 1602645584, 0, NULL),
(1101, 201707035, 'Dinh Viet Manh', 747114949, 31, 'M', 1602645584, '', '', 1602645584, '', 1602645584, 1602645584, 1602645584, 0, NULL), (1101, 201707035, 'Dinh Viet Manh', 747114949, 31, 'M', 1602645584, '', '', 1602645584, '', 1602645584, 1602645584, 1602645584, 0, NULL);
(1102, 201707049, 'Pham Van Manh', 748028741, 31, 'M', 1602645584, '', '', 1602645584, '', 1602645584, 1602645584, 1602645584, 0, NULL);
INSERT INTO `staff` (`id`, `code`, `name`, `card_number`, `department_id`, `gender`, `birthday`, `email`, `phone`, `date_in`, `address`, `created_at`, `modified_at`, `card_register_time`, `schedule_id`, `door_access`) VALUES INSERT INTO `staff` (`id`, `code`, `name`, `card_number`, `department_id`, `gender`, `birthday`, `email`, `phone`, `date_in`, `address`, `created_at`, `modified_at`, `card_register_time`, `schedule_id`, `door_access`) VALUES
(1102, 201707049, 'Pham Van Manh', 748028741, 31, 'M', 1602645584, '', '', 1602645584, '', 1602645584, 1602645584, 1602645584, 0, NULL),
(1103, 201707050, 'Nguyen Thi Tam', 747776629, 31, 'M', 1602645584, '', '', 1602645584, '', 1602645584, 1602645584, 1602645584, 0, NULL), (1103, 201707050, 'Nguyen Thi Tam', 747776629, 31, 'M', 1602645584, '', '', 1602645584, '', 1602645584, 1602645584, 1602645584, 0, NULL),
(1104, 201708020, 'Nguyen Hoang Tuan', 1678240529, 31, 'M', 1602645584, '', '', 1602645584, '', 1602645584, 1602645584, 1602645584, 0, NULL), (1104, 201708020, 'Nguyen Hoang Tuan', 1678240529, 31, 'M', 1602645584, '', '', 1602645584, '', 1602645584, 1602645584, 1602645584, 0, NULL),
(1105, 201710001, 'Dang Thi Hong', 746668805, 31, 'M', 1602645584, '', '', 1602645584, '', 1602645584, 1602645584, 1602645584, 0, NULL), (1105, 201710001, 'Dang Thi Hong', 746668805, 31, 'M', 1602645584, '', '', 1602645584, '', 1602645584, 1602645584, 1602645584, 0, NULL),
@ -1785,9 +1788,9 @@ INSERT INTO `staff` (`id`, `code`, `name`, `card_number`, `department_id`, `gend
(1466, 20160311, 'Temporary 311', 2147483647, 18, 'M', 1602645586, '', '', 1602645586, '', 1602645586, 1602645586, 1602645586, 0, NULL), (1466, 20160311, 'Temporary 311', 2147483647, 18, 'M', 1602645586, '', '', 1602645586, '', 1602645586, 1602645586, 1602645586, 0, NULL),
(1467, 20160312, 'Temporary 312', 2147483647, 18, 'M', 1602645586, '', '', 1602645586, '', 1602645586, 1602645586, 1602645586, 0, NULL), (1467, 20160312, 'Temporary 312', 2147483647, 18, 'M', 1602645586, '', '', 1602645586, '', 1602645586, 1602645586, 1602645586, 0, NULL),
(1468, 20160313, 'Temporary 313', 2147483647, 18, 'M', 1602645586, '', '', 1602645586, '', 1602645586, 1602645586, 1602645586, 0, NULL), (1468, 20160313, 'Temporary 313', 2147483647, 18, 'M', 1602645586, '', '', 1602645586, '', 1602645586, 1602645586, 1602645586, 0, NULL),
(1469, 20160314, 'Temporary 314', 2147483647, 18, 'M', 1602645586, '', '', 1602645586, '', 1602645586, 1602645586, 1602645586, 0, NULL), (1469, 20160314, 'Temporary 314', 2147483647, 18, 'M', 1602645586, '', '', 1602645586, '', 1602645586, 1602645586, 1602645586, 0, NULL);
(1470, 20160315, 'Temporary 315', 2147483647, 18, 'M', 1602645586, '', '', 1602645586, '', 1602645586, 1602645586, 1602645586, 0, NULL);
INSERT INTO `staff` (`id`, `code`, `name`, `card_number`, `department_id`, `gender`, `birthday`, `email`, `phone`, `date_in`, `address`, `created_at`, `modified_at`, `card_register_time`, `schedule_id`, `door_access`) VALUES INSERT INTO `staff` (`id`, `code`, `name`, `card_number`, `department_id`, `gender`, `birthday`, `email`, `phone`, `date_in`, `address`, `created_at`, `modified_at`, `card_register_time`, `schedule_id`, `door_access`) VALUES
(1470, 20160315, 'Temporary 315', 2147483647, 18, 'M', 1602645586, '', '', 1602645586, '', 1602645586, 1602645586, 1602645586, 0, NULL),
(1471, 20160316, 'Temporary 316', 2147483647, 18, 'M', 1602645586, '', '', 1602645586, '', 1602645586, 1602645586, 1602645586, 0, NULL), (1471, 20160316, 'Temporary 316', 2147483647, 18, 'M', 1602645586, '', '', 1602645586, '', 1602645586, 1602645586, 1602645586, 0, NULL),
(1472, 20160317, 'Temporary 317', 2147483647, 18, 'M', 1602645586, '', '', 1602645586, '', 1602645586, 1602645586, 1602645586, 0, NULL), (1472, 20160317, 'Temporary 317', 2147483647, 18, 'M', 1602645586, '', '', 1602645586, '', 1602645586, 1602645586, 1602645586, 0, NULL),
(1473, 20160318, 'Temporary 318', 2147483647, 18, 'M', 1602645586, '', '', 1602645586, '', 1602645586, 1602645586, 1602645586, 0, NULL), (1473, 20160318, 'Temporary 318', 2147483647, 18, 'M', 1602645586, '', '', 1602645586, '', 1602645586, 1602645586, 1602645586, 0, NULL),
@ -2114,36 +2117,36 @@ INSERT INTO `staff` (`id`, `code`, `name`, `card_number`, `department_id`, `gend
(1794, 2147483647, 'JNG017', 1494047197, 68, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL), (1794, 2147483647, 'JNG017', 1494047197, 68, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1795, 2147483647, 'JNG016', 1494622077, 68, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL), (1795, 2147483647, 'JNG016', 1494622077, 68, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1796, 2147483647, 'JNG012', 1494528413, 68, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL), (1796, 2147483647, 'JNG012', 1494528413, 68, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1797, 20160431, 'Temporary 431', 744290341, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1797, 20160431, 'Temporary 431', 744290341, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1798, 20160432, 'Temporary 432', 743868885, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1798, 20160432, 'Temporary 432', 743868885, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1799, 20160433, 'Temporary 433', 751432485, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1799, 20160433, 'Temporary 433', 751432485, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1800, 20160434, 'Temporary 434', 743882517, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1800, 20160434, 'Temporary 434', 743882517, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1801, 20160435, 'Temporary 435', 743898853, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1801, 20160435, 'Temporary 435', 743898853, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1802, 20160436, 'Temporary 436', 745669365, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1802, 20160436, 'Temporary 436', 745669365, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1803, 20160437, 'Temporary 437', 744294789, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1803, 20160437, 'Temporary 437', 744294789, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1804, 20160438, 'Temporary 438', 745675093, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1804, 20160438, 'Temporary 438', 745675093, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1805, 20160439, 'Temporary 439', 743766373, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1805, 20160439, 'Temporary 439', 743766373, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1806, 20160440, 'Temporary 440', 744733701, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1806, 20160440, 'Temporary 440', 744733701, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1807, 20160441, 'Temporary 441', 743861813, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1807, 20160441, 'Temporary 441', 743861813, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1808, 20160442, 'Temporary 442', 744282757, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1808, 20160442, 'Temporary 442', 744282757, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1809, 20160443, 'Temporary 443', 744287189, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1809, 20160443, 'Temporary 443', 744287189, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1810, 20160444, 'Temporary 444', 702879301, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1810, 20160444, 'Temporary 444', 702879301, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1811, 20160445, 'Temporary 445', 704423861, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1811, 20160445, 'Temporary 445', 704423861, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1812, 20160446, 'Temporary 446', 701300741, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1812, 20160446, 'Temporary 446', 701300741, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1813, 20160447, 'Temporary 447', 744286997, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1813, 20160447, 'Temporary 447', 744286997, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1814, 20160448, 'Temporary 448', 744286901, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1814, 20160448, 'Temporary 448', 744286901, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1815, 20160449, 'Temporary 449', 704569525, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1815, 20160449, 'Temporary 449', 704569525, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1816, 20160450, 'Temporary 450', 746697317, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1816, 20160450, 'Temporary 450', 746697317, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1817, 20160451, 'Temporary 451', 747122757, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1817, 20160451, 'Temporary 451', 747122757, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1818, 20160452, 'Temporary 452', 743361701, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1818, 20160452, 'Temporary 452', 743361701, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1819, 20160453, 'Temporary 453', 744753253, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 6, '[\"7\"]'), (1819, 20160453, 'Temporary 453', 744753253, 21, 'M', 1602645587, '', '', 1602645587, '', 1602645587, 1602645587, 1602645587, 0, NULL),
(1820, 20160454, 'Temporary 454', 746697381, 21, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 6, '[\"7\"]'), (1820, 20160454, 'Temporary 454', 746697381, 21, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 0, NULL),
(1821, 20160455, 'Temporary 455', 746630085, 21, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 6, '[\"7\"]'), (1821, 20160455, 'Temporary 455', 746630085, 21, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 0, NULL),
(1822, 20160456, 'Temporary 456', 747624821, 21, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 6, '[\"7\"]'), (1822, 20160456, 'Temporary 456', 747624821, 21, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 0, NULL),
(1823, 20160457, 'Temporary 457', 751300581, 21, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 6, '[\"7\"]'), (1823, 20160457, 'Temporary 457', 751300581, 21, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 0, NULL),
(1824, 20160458, 'Temporary 458', 746539397, 21, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 6, '[\"7\"]'), (1824, 20160458, 'Temporary 458', 746539397, 21, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 0, NULL),
(1825, 20160459, 'Temporary 459', 743962533, 21, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 6, '[\"7\"]'), (1825, 20160459, 'Temporary 459', 743962533, 21, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 0, NULL),
(1826, 20160460, 'Temporary 460', 745877013, 21, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 6, '[\"7\"]'), (1826, 20160460, 'Temporary 460', 745877013, 21, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 0, NULL),
(1827, 20160613, 'Temporary 613', 2147483647, 26, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 0, NULL), (1827, 20160613, 'Temporary 613', 2147483647, 26, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 0, NULL),
(1828, 20160615, 'Temporary 615', 2147483647, 26, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 0, NULL), (1828, 20160615, 'Temporary 615', 2147483647, 26, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 0, NULL),
(1829, 20160616, 'Temporary 616', 2147483647, 26, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 0, NULL), (1829, 20160616, 'Temporary 616', 2147483647, 26, 'M', 1602645588, '', '', 1602645588, '', 1602645588, 1602645588, 1602645588, 0, NULL),
@ -2341,7 +2344,15 @@ CREATE TABLE `system_logs` (
-- --
INSERT INTO `system_logs` (`id`, `user_id`, `time`, `action`, `description`, `type`) VALUES INSERT INTO `system_logs` (`id`, `user_id`, `time`, `action`, `description`, `type`) VALUES
(1, 1, 1602644847, 'update', 'Chỉnh sửa phòng ban: Haengsung', 'department'); (1, 1, 1602644847, 'update', 'Chỉnh sửa phòng ban: Haengsung', 'department'),
(2, 1, 1602659432, 'insert', 'Thêm mới thiết bị: 192.168.1.202', 'device'),
(3, 1, 1602665891, 'update', 'Chỉnh sửa nhân viên: Nguyen Thi Ha', 'staff'),
(4, 1, 1602665902, 'update', 'Chỉnh sửa nhân viên: Nguyen Van Dong', 'staff'),
(5, 1, 1602665912, 'update', 'Chỉnh sửa nhân viên: Trinh Thi Thanh', 'staff'),
(6, 1, 1602665921, 'update', 'Chỉnh sửa nhân viên: Dao Thi Huong', 'staff'),
(7, 1, 1602665931, 'update', 'Chỉnh sửa nhân viên: Nguyen Duc Loc', 'staff'),
(8, 1, 1602665942, 'update', 'Chỉnh sửa nhân viên: Pham Van Tien', 'staff'),
(9, 1, 1602665951, 'update', 'Chỉnh sửa nhân viên: Le Thi Huyen Trang', 'staff');
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -2471,13 +2482,13 @@ ALTER TABLE `department`
-- AUTO_INCREMENT for table `device` -- AUTO_INCREMENT for table `device`
-- --
ALTER TABLE `device` ALTER TABLE `device`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
-- --
-- AUTO_INCREMENT for table `door` -- AUTO_INCREMENT for table `door`
-- --
ALTER TABLE `door` ALTER TABLE `door`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9; MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
-- --
-- AUTO_INCREMENT for table `schedule` -- AUTO_INCREMENT for table `schedule`
@ -2495,7 +2506,7 @@ ALTER TABLE `staff`
-- AUTO_INCREMENT for table `system_logs` -- AUTO_INCREMENT for table `system_logs`
-- --
ALTER TABLE `system_logs` ALTER TABLE `system_logs`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
-- --
-- AUTO_INCREMENT for table `user` -- AUTO_INCREMENT for table `user`

View File

@ -8,6 +8,8 @@ use app\models\DeviceSearch;
use app\models\Area; use app\models\Area;
use app\models\common; use app\models\common;
use app\models\Door; use app\models\Door;
use app\models\Staff;
use app\models\Schedule;
use yii\web\Controller; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
@ -322,4 +324,114 @@ class DeviceController extends Controller {
} }
} }
public function actionSync() {
if (Yii::$app->request->post()) {
Yii::$app->response->format = "json";
return [
"title" => Html::tag("i", "", ["class" => "fa fa-exchange"]) . " Đồng bộ dữ liệu đến thiết bị",
"form" => $this->renderPartial("sync"),
"lists" => Yii::$app->request->post("lists")
];
}
}
public function actionGetDataSync() {
if (Yii::$app->request->post()) {
Yii::$app->response->format = "json";
$device_id = Yii::$app->request->post("data");
$doors = Door::find()->andWhere(["device_id" => $device_id])->all();
$filter = ["OR"];
foreach ($doors as $key => $value) {
$filter[] = ["LIKE", "door_access", '"' . $value->id . '"'];
}
$staffs = Staff::find()->andWhere($filter)->all();
$schedule = [];
foreach ($staffs as $key => $value) {
$schedule[] = $value->schedule_id;
}
$schedule = array_unique($schedule);
return [
"IP" => $this->findModel($device_id)->ip_address,
"staffs" => $staffs,
"schedule" => $schedule
];
}
}
public function actionSyncSchedule() {
if (Yii::$app->request->post()) {
Yii::$app->response->format = "json";
$post = Yii::$app->request->post();
$schedule_lists = $post["data"];
$TimeZoneInfos = [];
foreach ($schedule_lists as $key => $value) {
$schedule = Schedule::findOne($value);
$TimeZoneInfos[] = [
"TimezoneId" => $schedule->id,
"SunTime1" => Schedule::convertTimeAttr($schedule->SunTime1), "SunTime2" => Schedule::convertTimeAttr($schedule->SunTime2), "SunTime3" => Schedule::convertTimeAttr($schedule->SunTime3),
"MonTime1" => Schedule::convertTimeAttr($schedule->MonTime1), "MonTime2" => Schedule::convertTimeAttr($schedule->MonTime2), "MonTime3" => Schedule::convertTimeAttr($schedule->MonTime3),
"TueTime1" => Schedule::convertTimeAttr($schedule->TueTime1), "TueTime2" => Schedule::convertTimeAttr($schedule->TueTime2), "TueTime3" => Schedule::convertTimeAttr($schedule->TueTime3),
"WedTime1" => Schedule::convertTimeAttr($schedule->WedTime1), "WedTime2" => Schedule::convertTimeAttr($schedule->WedTime2), "WedTime3" => Schedule::convertTimeAttr($schedule->WedTime3),
"ThuTime1" => Schedule::convertTimeAttr($schedule->ThuTime1), "ThuTime2" => Schedule::convertTimeAttr($schedule->ThuTime2), "ThuTime3" => Schedule::convertTimeAttr($schedule->ThuTime3),
"FriTime1" => Schedule::convertTimeAttr($schedule->FriTime1), "FriTime2" => Schedule::convertTimeAttr($schedule->FriTime2), "FriTime3" => Schedule::convertTimeAttr($schedule->FriTime3),
"SatTime1" => Schedule::convertTimeAttr($schedule->SatTime1), "SatTime2" => Schedule::convertTimeAttr($schedule->SatTime2), "SatTime3" => Schedule::convertTimeAttr($schedule->SatTime3),
"Hol1Time1" => 0, "Hol1Time2" => 0, "Hol1Time3" => 0,
"Hol2Time1" => 0, "Hol2Time2" => 0, "Hol2Time3" => 0,
"Hol3Time1" => 0, "Hol3Time2" => 0, "Hol3Time3" => 0
];
}
$res = json_decode(common::requestToCardService("/SetDeviceData/TimeZone", [
"DeviceIP" => $post["ip"],
"TimeZoneInfos" => $TimeZoneInfos
]), true);
return [
"res" => $res,
"IP" => $post["ip"]
];
}
}
public function actionSyncStaffs() {
if (Yii::$app->request->post()) {
Yii::$app->response->format = "json";
$post = Yii::$app->request->post();
$staff_lists = $post["data"];
$UserInfos = [];
$UserAuthorizeInfos = [];
foreach ($staff_lists as $key => $value) {
$UserInfos[] = [
"CardNo" => $value["card_number"],
"Pin" => $value["id"],
"Password" => "",
"Group" => "",
"StartTime" => "",
"EndTime" => ""
];
$doors = json_decode($value["door_access"], true);
foreach ($doors as $k => $v) {
$doorInfo = Door::findOne($v);
$UserAuthorizeInfos[] = [
"Pin" => $value["id"],
"AuthorizeTimezoneId" => $value["schedule_id"],
"AuthorizeDoorId" => $doorInfo->code
];
}
}
$resUser = json_decode(common::requestToCardService("/SetDeviceData/User", [
"DeviceIP" => $post["ip"],
"UserInfos" => $UserInfos
]), true);
common::requestToCardService("/SetDeviceData/UserAuthorize", [
"DeviceIP" => $post["ip"],
"UserAuthorizeInfos" => $UserAuthorizeInfos
]);
return [
"resUser" => $resUser,
"IP" => $post["ip"]
];
}
}
} }

View File

@ -150,6 +150,17 @@ class Schedule extends \yii\db\ActiveRecord {
return hexdec("0" . $front . "0" . $back); return hexdec("0" . $front . "0" . $back);
} }
public static function convertTimeAttr($attr) {
$temp = explode("-", $attr);
$from = $temp[0];
$to = $temp[1];
$fTemp = explode(":", $from);
$front = dechex(intval($fTemp[0]) * 100 + intval($fTemp[1]));
$tTemp = explode(":", $to);
$back = dechex(intval($tTemp[0]) * 100 + intval($tTemp[1]));
return hexdec("0" . $front . "0" . $back);
}
public static function scheduleArray() { public static function scheduleArray() {
$lists = self::find()->all(); $lists = self::find()->all();
$results = []; $results = [];

View File

@ -6,6 +6,9 @@
{DeviceAsset::register($this)|void} {DeviceAsset::register($this)|void}
{block name='content'} {block name='content'}
<div class="device-index"> <div class="device-index">
<input type='hidden' name='get_data_sync_url' value="{Url::to(['get-data-sync'])}">
<input type='hidden' name='sync_schedule_url' value="{Url::to(['sync-schedule'])}">
<input type='hidden' name='sync_staffs_url' value="{Url::to(['sync-staffs'])}">
<div class="" style="font-size: 15px;"> <div class="" style="font-size: 15px;">
<label class="action-button" onclick="common.form(this, 'device');" data-href="{Url::to(['create'])}"> <label class="action-button" onclick="common.form(this, 'device');" data-href="{Url::to(['create'])}">
<i class="fa fa-plus-square fa-1-5x"></i> Thêm <i class="fa fa-plus-square fa-1-5x"></i> Thêm
@ -19,6 +22,9 @@
<label class="action-button" onclick="_form(this);" data-href="{Url::to(['change-ip'])}"> <label class="action-button" onclick="_form(this);" data-href="{Url::to(['change-ip'])}">
<i class="fa fa-pencil fa-1-5x"></i> Thay đổi địa chỉ IP <i class="fa fa-pencil fa-1-5x"></i> Thay đổi địa chỉ IP
</label> </label>
<label class="action-button" onclick="_sync(this);" data-href="{Url::to(['sync'])}">
<i class="fa fa-exchange fa-1-5x"></i> Đồng bộ dữ liệu đến thiết bị
</label>
<label class="action-button" onclick="_export(this);" data-href="{Url::to(['export'])}"> <label class="action-button" onclick="_export(this);" data-href="{Url::to(['export'])}">
<i class="fa fa-download fa-1-5x"></i> Xuất <i class="fa fa-download fa-1-5x"></i> Xuất
</label> </label>

13
views/device/sync.tpl Normal file
View File

@ -0,0 +1,13 @@
<div class="well" style="height: 300px;overflow-y: scroll;" id="logs-response">
</div>
<div class="progress">
<div class="progress-bar progress-bar-primary progress-bar-striped" id='progress' role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
0%
</div>
</div>
<div class="text-right">
<button class="btn btn-default" data-dismiss="modal" disabled="" id="close-modal">
<span class="fa fa-remove"></span> Đóng
</button>
</div>

View File

@ -244,3 +244,116 @@ function changeIP(e) {
}); });
} }
} }
var progress = 0;
var totals = 0;
function _sync(e) {
var lists = [];
$.each($("input[name='checkbox-device']:checked"), function () {
lists.push($(this).val());
});
if (lists.length == 0) {
alert("Vui lòng lựa chọn đối tượng!");
return;
}
common.modalBlock(true);
$.ajax({
url: $(e).attr('data-href'),
type: 'POST',
data: {
lists: lists
},
success: function (data) {
common.modalBlock(false);
common.modalOpen(data.form, false, data.title);
$("#close-modal").attr("disabled", true);
$("#modalHeader").find("button").remove();
totals = data.lists.length * 2;
for (var i = 0; i < data.lists.length; i++) {
getDataSync(data.lists[i]);
}
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
common.ajaxError();
}
});
}
function getDataSync(data) {
$.ajax({
url: $("input[name='get_data_sync_url']").val(),
type: 'POST',
data: {
data: data
},
success: function (data) {
var html = "";
html = "<span class='text-blue'><i class='fa fa-minus'></i> Bắt đầu đồng bộ dữ liệu tới thiết bị <b>" + data.IP + "</b>.</span><br>";
$("#logs-response").append(html);
syncSchedule(data.schedule, data.staffs, data.IP);
},
error: function (jqXHR, textStatus, errorThrown) {
common.ajaxError();
}
});
}
function syncSchedule(schedule, staffs, ip) {
$.ajax({
url: $("input[name='sync_schedule_url']").val(),
type: 'POST',
data: {
data: schedule,
ip: ip
},
success: function (data) {
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++;
var percent = parseInt(progress / totals * 100);
$("#progress").attr("aria-valuenow", percent);
$("#progress").attr("style", "width: " + percent + "%");
$("#progress").html(percent + "%");
if (percent >= 100) {
progress = 0;
$("#close-modal").attr("disabled", false);
}
syncStaffs(staffs, ip);
},
error: function (jqXHR, textStatus, errorThrown) {
common.ajaxError();
}
});
}
function syncStaffs(data, ip) {
$.ajax({
url: $("input[name='sync_staffs_url']").val(),
type: 'POST',
data: {
data: data,
ip: ip
},
success: function (data) {
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>";
$("#logs-response").append(html);
progress++;
var percent = parseInt(progress / totals * 100);
$("#progress").attr("aria-valuenow", percent);
$("#progress").attr("style", "width: " + percent + "%");
$("#progress").html(percent + "%");
if (percent >= 100) {
progress = 0;
$("#close-modal").attr("disabled", false);
}
},
error: function (jqXHR, textStatus, errorThrown) {
common.ajaxError();
}
});
}