-- phpMyAdmin SQL Dump
-- version 4.9.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Oct 10, 2020 at 11:10 AM
-- Server version: 10.4.8-MariaDB
-- PHP Version: 7.1.33

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `access_control`
--

-- --------------------------------------------------------

--
-- Table structure for table `area`
--

CREATE TABLE `area` (
  `id` int(11) NOT NULL,
  `code` int(11) NOT NULL,
  `pid` int(11) NOT NULL DEFAULT 0,
  `name` varchar(100) NOT NULL,
  `description` text DEFAULT NULL,
  `created_at` int(11) NOT NULL DEFAULT 0,
  `modified_at` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `area`
--

INSERT INTO `area` (`id`, `code`, `pid`, `name`, `description`, `created_at`, `modified_at`) VALUES
(1, 1, 0, 'AreaName', NULL, 0, 0),
(4, 2, 1, 'Khu vực 2', '123', 1602227006, 1602227006),
(5, 3, 2, 'Khu vực 1', '', 1602227907, 1602227907);

-- --------------------------------------------------------

--
-- Table structure for table `auth_assignment`
--

CREATE TABLE `auth_assignment` (
  `item_name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `user_id` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `created_at` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `auth_assignment`
--

INSERT INTO `auth_assignment` (`item_name`, `user_id`, `created_at`) VALUES
('administrator', '1', 1569900053);

-- --------------------------------------------------------

--
-- Table structure for table `auth_item`
--

CREATE TABLE `auth_item` (
  `name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `type` smallint(6) NOT NULL,
  `description` text COLLATE utf8_unicode_ci DEFAULT NULL,
  `rule_name` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
  `data` blob DEFAULT NULL,
  `created_at` int(11) DEFAULT NULL,
  `updated_at` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `auth_item`
--

INSERT INTO `auth_item` (`name`, `type`, `description`, `rule_name`, `data`, `created_at`, `updated_at`) VALUES
('administrator', 1, 'Administrator', NULL, NULL, 1535011160, 1535011160);

-- --------------------------------------------------------

--
-- Table structure for table `auth_item_child`
--

CREATE TABLE `auth_item_child` (
  `parent` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `child` varchar(64) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `auth_rule`
--

CREATE TABLE `auth_rule` (
  `name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `data` blob DEFAULT NULL,
  `created_at` int(11) DEFAULT NULL,
  `updated_at` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `department`
--

CREATE TABLE `department` (
  `id` int(11) NOT NULL,
  `code` int(11) NOT NULL,
  `pid` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `created_at` int(11) NOT NULL,
  `modified_at` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `department`
--

INSERT INTO `department` (`id`, `code`, `pid`, `name`, `created_at`, `modified_at`) VALUES
(1, 1, 0, 'CompanyName', 0, 0),
(2, 2, 1, 'Phòng CNTT', 1602151686, 1602151686),
(3, 3, 2, 'Phòng AI', 1602151780, 1602151780),
(4, 4, 2, 'Phòng OP', 1602151789, 1602151828);

-- --------------------------------------------------------

--
-- Table structure for table `device`
--

CREATE TABLE `device` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `serial` varchar(50) DEFAULT NULL,
  `ip_address` varchar(20) NOT NULL,
  `status` int(11) NOT NULL,
  `type` int(11) NOT NULL,
  `area_id` int(11) NOT NULL,
  `created_at` int(11) NOT NULL DEFAULT 0,
  `modified_at` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `staff`
--

CREATE TABLE `staff` (
  `id` int(11) NOT NULL,
  `code` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `card_number` int(11) NOT NULL DEFAULT 0,
  `department_id` int(11) NOT NULL DEFAULT 0,
  `gender` varchar(10) NOT NULL,
  `birthday` int(11) NOT NULL DEFAULT 0,
  `email` varchar(100) DEFAULT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `date_in` int(11) NOT NULL DEFAULT 0,
  `address` text DEFAULT NULL,
  `created_at` int(11) NOT NULL DEFAULT 0,
  `modified_at` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `staff`
--

INSERT INTO `staff` (`id`, `code`, `name`, `card_number`, `department_id`, `gender`, `birthday`, `email`, `phone`, `date_in`, `address`, `created_at`, `modified_at`) VALUES
(1, 1, 'Phạm Đức Đông', 1000001, 1, 'M', 691231867, '', '', 1602319867, '', 1602319867, 1602319867),
(2, 2, 'Ngô Văn Dũng', 10000002, 1, 'M', 608719882, '', '', 1602319882, '', 1602319882, 1602319882),
(3, 3, 'Hoàng Hồng Sơn', 10000003, 1, 'M', 622544932, NULL, NULL, 1602320932, NULL, 1602320932, 1602320932);

-- --------------------------------------------------------

--
-- Table structure for table `system_logs`
--

CREATE TABLE `system_logs` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `time` int(11) NOT NULL,
  `action` varchar(10) NOT NULL,
  `description` text NOT NULL,
  `type` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `system_logs`
--

INSERT INTO `system_logs` (`id`, `user_id`, `time`, `action`, `description`, `type`) VALUES
(1, 1, 1602151686, 'insert', 'Thêm mới phòng ban: Phòng CNTT', 'department'),
(2, 1, 1602151780, 'insert', 'Thêm mới phòng ban: Phòng AI', 'department'),
(3, 1, 1602151789, 'insert', 'Thêm mới phòng ban: Phòng OP', 'department'),
(4, 1, 1602151794, 'update', 'Chỉnh sửa phòng ban: Phòng OP', 'department'),
(5, 1, 1602151810, 'insert', 'Thêm mới phòng ban: gffdg', 'department'),
(6, 1, 1602151813, 'delete', 'Xóa phòng ban: gffdg', 'department'),
(7, 1, 1602151828, 'update', 'Chỉnh sửa phòng ban: Phòng OP', 'department'),
(8, 1, 1602225712, 'insert', 'Thêm mới khu vực: Khu vực 2', 'area'),
(9, 1, 1602226072, 'update', 'Chỉnh sửa khu vực: Khu vực 1', 'area'),
(10, 1, 1602226081, 'update', 'Chỉnh sửa khu vực: Khu vực 1', 'area'),
(11, 1, 1602226091, 'update', 'Chỉnh sửa khu vực: Khu vực 1', 'area'),
(12, 1, 1602226793, 'delete', 'Xóa khu vực: Khu vực 1', 'area'),
(13, 1, 1602226793, 'delete', 'Xóa khu vực: Khu vực 2', 'area'),
(14, 1, 1602227006, 'insert', 'Thêm mới khu vực: Khu vực 2', 'area'),
(15, 1, 1602227907, 'insert', 'Thêm mới khu vực: Khu vực 1', 'area'),
(16, 1, 1602316450, 'insert', 'Thêm mới nhân viên: Phạm Đức Đông', 'staff'),
(17, 1, 1602317528, 'update', 'Chỉnh sửa nhân viên: Phạm Đức Đông', 'staff'),
(18, 1, 1602318491, 'update', 'Chỉnh sửa nhân viên: Phạm Đức Đông', 'staff'),
(19, 1, 1602318858, 'insert', 'Thêm mới nhân viên: Ngô Văn Dũng', 'staff'),
(20, 1, 1602318893, 'delete', 'Xóa 2 nhân viên', 'staff'),
(21, 1, 1602319867, 'insert', 'Thêm mới nhân viên: Phạm Đức Đông', 'staff'),
(22, 1, 1602319882, 'insert', 'Thêm mới nhân viên: Ngô Văn Dũng', 'staff'),
(23, 1, 1602320932, 'import', 'Nhập dữ liệu: 1 nhân viên mới', 'staff');

-- --------------------------------------------------------

--
-- Table structure for table `user`
--

CREATE TABLE `user` (
  `id` int(11) NOT NULL,
  `first_name` varchar(250) NOT NULL,
  `last_name` varchar(250) DEFAULT NULL,
  `phone_number` varchar(30) DEFAULT NULL,
  `username` varchar(250) NOT NULL,
  `email` varchar(500) DEFAULT NULL,
  `password` varchar(250) NOT NULL,
  `authKey` varchar(250) DEFAULT NULL,
  `password_reset_token` varchar(250) DEFAULT NULL,
  `user_image` varchar(500) DEFAULT NULL,
  `quota` int(11) NOT NULL DEFAULT 2
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `user`
--

INSERT INTO `user` (`id`, `first_name`, `last_name`, `phone_number`, `username`, `email`, `password`, `authKey`, `password_reset_token`, `user_image`, `quota`) VALUES
(1, 'Administrator', '', '12313', 'admin', 'admin@bitraffic.vn', 'ceea23519f6f86ad67e9f798bf8002cb', NULL, NULL, '', 2);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `area`
--
ALTER TABLE `area`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `auth_assignment`
--
ALTER TABLE `auth_assignment`
  ADD PRIMARY KEY (`item_name`,`user_id`),
  ADD KEY `auth_assignment_user_id_idx` (`user_id`);

--
-- Indexes for table `auth_item`
--
ALTER TABLE `auth_item`
  ADD PRIMARY KEY (`name`),
  ADD KEY `rule_name` (`rule_name`),
  ADD KEY `idx-auth_item-type` (`type`);

--
-- Indexes for table `auth_item_child`
--
ALTER TABLE `auth_item_child`
  ADD PRIMARY KEY (`parent`,`child`),
  ADD KEY `child` (`child`);

--
-- Indexes for table `auth_rule`
--
ALTER TABLE `auth_rule`
  ADD PRIMARY KEY (`name`);

--
-- Indexes for table `department`
--
ALTER TABLE `department`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `device`
--
ALTER TABLE `device`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `staff`
--
ALTER TABLE `staff`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `system_logs`
--
ALTER TABLE `system_logs`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `user`
--
ALTER TABLE `user`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `area`
--
ALTER TABLE `area`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `department`
--
ALTER TABLE `department`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `device`
--
ALTER TABLE `device`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `staff`
--
ALTER TABLE `staff`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `system_logs`
--
ALTER TABLE `system_logs`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24;

--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=202;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `auth_item_child`
--
ALTER TABLE `auth_item_child`
  ADD CONSTRAINT `auth_item_child_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `auth_item` (`name`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `auth_item_child_ibfk_2` FOREIGN KEY (`child`) REFERENCES `auth_item` (`name`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
