/* 
 * Copyright (C) 2018 josh.north
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * Author:  josh.north
 * Created: Oct 15, 2018
 */

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
-- --------------------------------------------------------
DROP TABLE IF EXISTS `lsio_countries`;
CREATE TABLE `lsio_countries` (
  `id` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL COMMENT 'Unique ID',
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL COMMENT 'Country Name',
  `continent` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL COMMENT 'Continent of Country',
  `priority` int NOT NULL DEFAULT '9' COMMENT 'Priority Sort',
  `ban` int NOT NULL DEFAULT '0' COMMENT 'Sanctioned Country'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci COMMENT='Country List';
INSERT INTO `lsio_countries` (`id`, `name`, `continent`, `priority`, `ban`) VALUES
('AD', 'Andorra', 'Europe', 9, 0),
('AE', 'United Arab Emirates', 'Asia', 9, 0),
('AF', 'Afghanistan', 'Asia', 9, 0),
('AG', 'Antigua and Barbuda', 'North America', 9, 0),
('AI', 'Anguilla', 'North America', 9, 0),
('AL', 'Albania', 'Europe', 9, 0),
('AM', 'Armenia', 'Asia', 9, 0),
('AN', 'Netherlands Antilles', 'North America', 9, 0),
('AO', 'Angola', 'Africa', 9, 0),
('AQ', 'Antarctica', 'Antarctica', 9, 0),
('AR', 'Argentina', 'South America', 9, 0),
('AS', 'American Samoa', 'Oceania', 9, 0),
('AT', 'Austria', 'Europe', 9, 0),
('AU', 'Australia', 'Oceania', 9, 0),
('AW', 'Aruba', 'North America', 9, 0),
('AX', 'land Islands', 'Europe', 9, 0),
('AZ', 'Azerbaijan', 'Asia', 9, 0),
('BA', 'Bosnia and Herzegovina', 'Europe', 9, 0),
('BB', 'Barbados', 'North America', 9, 0),
('BD', 'Bangladesh', 'Asia', 9, 0),
('BE', 'Belgium', 'Europe', 1, 0),
('BF', 'Burkina Faso', 'Africa', 9, 0),
('BG', 'Bulgaria', 'Europe', 9, 0),
('BH', 'Bahrain', 'Asia', 9, 0),
('BI', 'Burundi', 'Africa', 9, 0),
('BJ', 'Benin', 'Africa', 9, 0),
('BM', 'Bermuda', 'North America', 9, 0),
('BN', 'Brunei Darussalam', 'Asia', 9, 0),
('BO', 'Bolivia', 'South America', 9, 0),
('BR', 'Brazil', 'South America', 9, 0),
('BS', 'Bahamas', 'North America', 9, 0),
('BT', 'Bhutan', 'Asia', 9, 0),
('BV', 'Bouvet Island', 'Antarctica', 9, 0),
('BW', 'Botswana', 'Africa', 9, 0),
('BY', 'Belarus', 'Europe', 9, 0),
('BZ', 'Belize', 'North America', 9, 0),
('CA', 'Canada', 'North America', 1, 0),
('CC', 'Cocos (Keeling] Islands', 'Asia', 9, 0),
('CD', 'The Democratic Republic of The Congo', 'Africa', 9, 0),
('CF', 'Central African Republic', 'Africa', 9, 0),
('CG', 'Congo', 'Africa', 9, 0),
('CH', 'Switzerland', 'Europe', 9, 0),
('CI', 'Cote D`ivoire', 'Africa', 9, 0),
('CK', 'Cook Islands', 'Oceania', 9, 0),
('CL', 'Chile', 'South America', 9, 0),
('CM', 'Cameroon', 'Africa', 9, 0),
('CN', 'China', 'Asia', 1, 0),
('CO', 'Colombia', 'South America', 9, 0),
('CR', 'Costa Rica', 'North America', 9, 0),
('CU', 'Cuba', 'North America', 9, 1),
('CV', 'Cape Verde', 'Africa', 9, 0),
('CX', 'Christmas Island', 'Asia', 9, 0),
('CY', 'Cyprus', 'Asia', 9, 0),
('CZ', 'Czech Republic', 'Europe', 9, 0),
('DE', 'Germany', 'Europe', 1, 0),
('DJ', 'Djibouti', 'Africa', 9, 0),
('DK', 'Denmark', 'Europe', 9, 0),
('DM', 'Dominica', 'North America', 9, 0),
('DO', 'Dominican Republic', 'North America', 9, 0),
('DZ', 'Algeria', 'Africa', 9, 0),
('EC', 'Ecuador', 'South America', 9, 0),
('EE', 'Estonia', 'Europe', 9, 0),
('EG', 'Egypt', 'Africa', 9, 0),
('EH', 'Western Sahara', 'Africa', 9, 0),
('ER', 'Eritrea', 'Africa', 9, 0),
('ES', 'Spain', 'Europe', 1, 0),
('ET', 'Ethiopia', 'Africa', 9, 0),
('FI', 'Finland', 'Europe', 9, 0),
('FJ', 'Fiji', 'Oceania', 9, 0),
('FK', 'Falkland Islands (Malvinas]', 'South America', 9, 0),
('FM', 'Micronesia', 'Oceania', 9, 0),
('FO', 'Faroe Islands', 'Europe', 9, 0),
('FR', 'France', 'Europe', 1, 0),
('GA', 'Gabon', 'Africa', 9, 0),
('GB', 'United Kingdom', 'Europe', 1, 0),
('GD', 'Grenada', 'North America', 9, 0),
('GE', 'Georgia', 'Asia', 9, 0),
('GF', 'French Guiana', 'South America', 9, 0),
('GG', 'Guernsey', 'Europe', 9, 0),
('GH', 'Ghana', 'Africa', 9, 0),
('GI', 'Gibraltar', 'Europe', 9, 0),
('GL', 'Greenland', 'North America', 9, 0),
('GM', 'Gambia', 'Africa', 9, 0),
('GN', 'Guinea', 'Africa', 9, 0),
('GP', 'Guadeloupe', 'North America', 9, 0),
('GQ', 'Equatorial Guinea', 'Africa', 9, 0),
('GR', 'Greece', 'Europe', 9, 0),
('GS', 'South Georgia and The South Sandwich Islands', 'Antarctica', 9, 0),
('GT', 'Guatemala', 'North America', 9, 0),
('GU', 'Guam', 'Oceania', 9, 0),
('GW', 'Guinea-bissau', 'Africa', 9, 0),
('GY', 'Guyana', 'South America', 9, 0),
('HK', 'Hong Kong', 'Asia', 9, 0),
('HM', 'Heard Island and Mcdonald Islands', 'Antarctica', 9, 0),
('HN', 'Honduras', 'North America', 9, 0),
('HR', 'Croatia', 'Europe', 9, 0),
('HT', 'Haiti', 'North America', 9, 0),
('HU', 'Hungary', 'Europe', 9, 0),
('ID', 'Indonesia', 'Asia', 9, 0),
('IE', 'Ireland', 'Europe', 1, 0),
('IL', 'Israel', 'Asia', 9, 0),
('IM', 'Isle of Man', 'Europe', 9, 0),
('IN', 'India', 'Asia', 9, 0),
('IO', 'British Indian Ocean Territory', 'Asia', 9, 0),
('IQ', 'Iraq', 'Asia', 9, 0),
('IR', 'Iran', 'Asia', 9, 1),
('IS', 'Iceland', 'Europe', 9, 0),
('IT', 'Italy', 'Europe', 1, 0),
('JE', 'Jersey', 'Europe', 9, 0),
('JM', 'Jamaica', 'North America', 9, 0),
('JO', 'Jordan', 'Asia', 9, 0),
('JP', 'Japan', 'Asia', 9, 0),
('KE', 'Kenya', 'Africa', 9, 0),
('KG', 'Kyrgyzstan', 'Asia', 9, 0),
('KH', 'Cambodia', 'Asia', 9, 0),
('KI', 'Kiribati', 'Oceania', 9, 0),
('KM', 'Comoros', 'Africa', 9, 0),
('KN', 'Saint Kitts and Nevis', 'North America', 9, 0),
('KP', 'Democratic People`s Republic of Korea', 'Asia', 9, 1),
('KR', 'Republic of Korea', 'Asia', 1, 0),
('KW', 'Kuwait', 'Asia', 9, 0),
('KY', 'Cayman Islands', 'North America', 9, 0),
('KZ', 'Kazakhstan', 'Asia', 9, 0),
('LA', 'Lao People`s Democratic Republic', 'Asia', 9, 0),
('LB', 'Lebanon', 'Asia', 9, 0),
('LC', 'Saint Lucia', 'North America', 9, 0),
('LI', 'Liechtenstein', 'Europe', 9, 0),
('LK', 'Sri Lanka', 'Asia', 9, 0),
('LR', 'Liberia', 'Africa', 9, 0),
('LS', 'Lesotho', 'Africa', 9, 0),
('LT', 'Lithuania', 'Europe', 9, 0),
('LU', 'Luxembourg', 'Europe', 9, 0),
('LV', 'Latvia', 'Europe', 9, 0),
('LY', 'Libya', 'Africa', 9, 0),
('MA', 'Morocco', 'Africa', 9, 0),
('MC', 'Monaco', 'Europe', 9, 0),
('MD', 'Moldova', 'Europe', 9, 0),
('ME', 'Montenegro', 'Europe', 9, 0),
('MG', 'Madagascar', 'Africa', 9, 0),
('MH', 'Marshall Islands', 'Oceania', 9, 0),
('MK', 'Macedonia', 'Europe', 9, 0),
('ML', 'Mali', 'Africa', 9, 0),
('MM', 'Myanmar', 'Asia', 9, 0),
('MN', 'Mongolia', 'Asia', 9, 0),
('MO', 'Macao', 'Asia', 9, 0),
('MP', 'Northern Mariana Islands', 'Oceania', 9, 0),
('MQ', 'Martinique', 'North America', 9, 0),
('MR', 'Mauritania', 'Africa', 9, 0),
('MS', 'Montserrat', 'North America', 9, 0),
('MT', 'Malta', 'Europe', 9, 0),
('MU', 'Mauritius', 'Africa', 9, 0),
('MV', 'Maldives', 'Asia', 9, 0),
('MW', 'Malawi', 'Africa', 9, 0),
('MX', 'Mexico', 'North America', 9, 0),
('MY', 'Malaysia', 'Asia', 1, 0),
('MZ', 'Mozambique', 'Africa', 9, 0),
('NA', 'Namibia', 'Africa', 9, 0),
('NC', 'New Caledonia', 'Oceania', 9, 0),
('NE', 'Niger', 'Africa', 9, 0),
('NF', 'Norfolk Island', 'Oceania', 9, 0),
('NG', 'Nigeria', 'Africa', 9, 0),
('NI', 'Nicaragua', 'North America', 9, 0),
('NL', 'Netherlands', 'Europe', 9, 0),
('NO', 'Norway', 'Europe', 9, 0),
('NP', 'Nepal', 'Asia', 9, 0),
('NR', 'Nauru', 'Oceania', 9, 0),
('NU', 'Niue', 'Oceania', 9, 0),
('NZ', 'New Zealand', 'Oceania', 9, 0),
('OM', 'Oman', 'Asia', 9, 0),
('PA', 'Panama', 'North America', 9, 0),
('PE', 'Peru', 'South America', 9, 0),
('PF', 'French Polynesia', 'Oceania', 9, 0),
('PG', 'Papua New Guinea', 'Oceania', 9, 0),
('PH', 'Philippines', 'Asia', 9, 0),
('PK', 'Pakistan', 'Asia', 9, 0),
('PL', 'Poland', 'Europe', 9, 0),
('PM', 'Saint Pierre and Miquelon', 'North America', 9, 0),
('PN', 'Pitcairn', 'Oceania', 9, 0),
('PR', 'Puerto Rico', 'North America', 9, 0),
('PS', 'Palestinia', 'Asia', 9, 0),
('PT', 'Portugal', 'Europe', 9, 0),
('PW', 'Palau', 'Oceania', 9, 0),
('PY', 'Paraguay', 'South America', 9, 0),
('QA', 'Qatar', 'Asia', 9, 0),
('RE', 'Reunion', 'Africa', 9, 0),
('RO', 'Romania', 'Europe', 9, 0),
('RS', 'Serbia', 'Europe', 9, 0),
('RU', 'Russian Federation', 'Europe', 1, 0),
('RW', 'Rwanda', 'Africa', 9, 0),
('SA', 'Saudi Arabia', 'Asia', 9, 0),
('SB', 'Solomon Islands', 'Oceania', 9, 0),
('SC', 'Seychelles', 'Africa', 9, 0),
('SD', 'Sudan', 'Africa', 9, 0),
('SE', 'Sweden', 'Europe', 9, 0),
('SG', 'Singapore', 'Asia', 9, 0),
('SH', 'Saint Helena', 'Africa', 9, 0),
('SI', 'Slovenia', 'Europe', 9, 0),
('SJ', 'Svalbard and Jan Mayen', 'Europe', 9, 0),
('SK', 'Slovakia', 'Europe', 9, 0),
('SL', 'Sierra Leone', 'Africa', 9, 0),
('SM', 'San Marino', 'Europe', 9, 0),
('SN', 'Senegal', 'Africa', 9, 0),
('SO', 'Somalia', 'Africa', 9, 0),
('SR', 'Suriname', 'South America', 9, 0),
('ST', 'Sao Tome and Principe', 'Africa', 9, 0),
('SV', 'El Salvador', 'North America', 9, 0),
('SY', 'Syrian Arab Republic', 'Asia', 9, 1),
('SZ', 'Swaziland', 'Africa', 9, 0),
('TC', 'Turks and Caicos Islands', 'North America', 9, 0),
('TD', 'Chad', 'Africa', 9, 0),
('TF', 'French Southern Territories', 'Antarctica', 9, 0),
('TG', 'Togo', 'Africa', 9, 0),
('TH', 'Thailand', 'Asia', 9, 0),
('TJ', 'Tajikistan', 'Asia', 9, 0),
('TK', 'Tokelau', 'Oceania', 9, 0),
('TL', 'Timor-leste', 'Asia', 9, 0),
('TM', 'Turkmenistan', 'Asia', 9, 0),
('TN', 'Tunisia', 'Africa', 9, 0),
('TO', 'Tonga', 'Oceania', 9, 0),
('TR', 'Turkey', 'Asia', 1, 0),
('TT', 'Trinidad and Tobago', 'North America', 9, 0),
('TV', 'Tuvalu', 'Oceania', 9, 0),
('TW', 'Taiwan, Province of China', 'Asia', 9, 0),
('TZ', 'Tanzania, United Republic of', 'Africa', 9, 0),
('UA', 'Ukraine', 'Europe', 9, 0),
('UG', 'Uganda', 'Africa', 9, 0),
('UM', 'United States Minor Outlying Islands', 'Oceania', 9, 0),
('US', 'United States', 'North America', 1, 0),
('UY', 'Uruguay', 'South America', 9, 0),
('UZ', 'Uzbekistan', 'Asia', 9, 0),
('VA', 'Holy See (Vatican City State]', 'Europe', 9, 0),
('VC', 'Saint Vincent and The Grenadines', 'North America', 9, 0),
('VE', 'Venezuela', 'South America', 9, 0),
('VG', 'Virgin Islands, British', 'North America', 9, 0),
('VI', 'Virgin Islands, U.S.', 'North America', 9, 0),
('VN', 'Viet Nam', 'Asia', 9, 0),
('VU', 'Vanuatu', 'Oceania', 9, 0),
('WF', 'Wallis and Futuna', 'Oceania', 9, 0),
('WS', 'Samoa', 'Oceania', 9, 0),
('YE', 'Yemen', 'Asia', 9, 0),
('YT', 'Mayotte', 'Africa', 9, 0),
('ZA', 'South Africa', 'Africa', 9, 0),
('ZM', 'Zambia', 'Africa', 9, 0),
('ZW', 'Zimbabwe', 'Africa', 9, 0);
-- --------------------------------------------------------
DROP TABLE IF EXISTS `lsio_idtypes`;
CREATE TABLE `lsio_idtypes` (
  `id` int UNSIGNED NOT NULL COMMENT 'Unique ID',
  `name` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL COMMENT 'Language File Code'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
INSERT INTO `lsio_idtypes` (`id`, `name`) VALUES
(3, 'PASSPORT'),
(2, 'STATEID'),
(1, 'UNAVAIL');
-- --------------------------------------------------------
DROP TABLE IF EXISTS `lsio_sites`;
CREATE TABLE `lsio_sites` (
  `id` int UNSIGNED NOT NULL COMMENT 'Unique ID',
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL COMMENT 'Location Code',
  `timezone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL COMMENT 'ISO Timezone',
  `region` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL COMMENT 'Region Group'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
INSERT INTO `lsio_sites` (`id`, `name`, `timezone`, `region`) VALUES
(1, 'NOSITE', 'UTC', 'NO'),
(2, 'Default Site', 'America/New_York', 'US');
-- --------------------------------------------------------
DROP TABLE IF EXISTS `lsio_users`;
CREATE TABLE `lsio_users` (
  `id` int UNSIGNED NOT NULL COMMENT 'Unique ID',
  `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL COMMENT 'Unique Username',
  `password` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL COMMENT 'Password',
  `email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT 'Unique Email',
  `created` datetime NOT NULL COMMENT 'Create Date',
  `firstname` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT 'Given Name',
  `lastname` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT 'Surname',
  `usertype` int UNSIGNED NOT NULL COMMENT 'Type permissions',
  `timezone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT 'ISO Timezone'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
INSERT INTO `lsio_users` (`id`, `username`, `password`, `email`, `created`, `firstname`, `lastname`, `usertype`, `timezone`) VALUES
(1, 'admin', '$2a$08$Y6l2CUoQgTQfQErQPEYZEuoZqDxkpAU34CoTTr7bc2oefzclUILJy', 'admin@domain.com', '2015-02-18 19:50:31', 'System', 'Administrator', 1, ''),
(2, 'KIOSK', '', '', '2018-10-19 00:00:00', '', '', 3, ''),
(3, 'Default User', '$2a$08$[REDACTED]', 'user1@domain.com', '2018-09-23 00:00:00', 'First', 'Last', 2, '');
-- --------------------------------------------------------
DROP TABLE IF EXISTS `lsio_users_sites`;
CREATE TABLE `lsio_users_sites` (
  `sites_id` int UNSIGNED NOT NULL COMMENT 'Site ID Link',
  `users_id` int UNSIGNED NOT NULL COMMENT 'User ID Link'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci COMMENT='PERMISSIONS LINK TABLE';
INSERT INTO `lsio_users_sites` (`sites_id`, `users_id`) VALUES
(1, 1),
(2, 1),
(1, 2),
(2, 2),
(1, 3),
(2, 3);
-- --------------------------------------------------------
DROP TABLE IF EXISTS `lsio_usertypes`;
CREATE TABLE `lsio_usertypes` (
  `id` int UNSIGNED NOT NULL COMMENT 'Unique ID',
  `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL COMMENT 'User type name'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
INSERT INTO `lsio_usertypes` (`id`, `name`) VALUES
(1, 'USER-TYPES-ADMIN'),
(3, 'USER-TYPES-KIOSK'),
(4, 'USER-TYPES-SADMIN'),
(2, 'USER-TYPES-USER');
-- --------------------------------------------------------
DROP TABLE IF EXISTS `lsio_vendorinfo`;
CREATE TABLE `lsio_vendorinfo` (
  `id` int UNSIGNED NOT NULL COMMENT 'Unique ID',
  `visitid` int UNSIGNED NOT NULL COMMENT 'Unique Visitor ID',
  `approverid` int DEFAULT NULL COMMENT 'Local Contact',
  `contact1` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT 'Cell Number',
  `contact2` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT 'Office Number',
  `workstart` datetime DEFAULT NULL COMMENT 'Work Start',
  `workend` datetime DEFAULT NULL COMMENT 'Work End',
  `checklistrequired` tinyint DEFAULT '0',
  `routinework` tinyint DEFAULT '0',
  `nonroutinework` tinyint DEFAULT '0',
  `coi` tinyint DEFAULT '0',
  `checklistcompleted` tinyint DEFAULT '0',
  `workcompleted` tinyint DEFAULT '0',
  `sitecleanup` tinyint DEFAULT '0',
  `doccompleted` tinyint DEFAULT '0',
  `worksummary` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT 'Work Summary',
  `equipmentsummary` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT 'Equipment Summary'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
-- --------------------------------------------------------
DROP TABLE IF EXISTS `lsio_visits`;
CREATE TABLE `lsio_visits` (
  `id` int UNSIGNED NOT NULL COMMENT 'Unique ID',
  `firstname` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL COMMENT 'Given Name',
  `lastname` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT 'Surname',
  `company` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL COMMENT 'Company',
  `escort` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT 'Escort Name',
  `intime` datetime NOT NULL COMMENT 'Time In',
  `outtime` datetime DEFAULT NULL COMMENT 'Time Out',
  `signature` mediumblob COMMENT 'Signature Image',
  `escort_signature` mediumblob COMMENT 'Escort Image',
  `citizen` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT 'Citizen ID',
  `id_type` int UNSIGNED DEFAULT NULL COMMENT 'Type ID',
  `id_reference` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT 'TIcket ID',
  `initials` int DEFAULT NULL COMMENT 'Username of Receptionist',
  `badge` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT 'Badge Number',
  `notes` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT 'Notes and Comments',
  `site_id` int UNSIGNED DEFAULT NULL COMMENT 'Site ID Link',
  `reason` int UNSIGNED DEFAULT NULL COMMENT 'Reason Code',
  `approved` tinyint DEFAULT '1' COMMENT '0 void, 1 unapproved, 2 approved',
  `carnum` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT 'Tag Number',
  `ssanum` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT 'Ticket Number',
  `isvendor` tinyint DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
-- --------------------------------------------------------
DROP TABLE IF EXISTS `lsio_visittypes`;
CREATE TABLE `lsio_visittypes` (
  `id` int UNSIGNED NOT NULL COMMENT 'Unique ID',
  `name` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL COMMENT 'Visit Type Name',
  `isvendor` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
INSERT INTO `lsio_visittypes` (`id`, `name`) VALUES
(1, 'NONEAVA', 0),
(2, 'ADDEQPT', 0),
(3, 'REMEQPT', 0),
(4, 'MEETING', 0),
(5, 'TOUR', 0),
(6, 'TESTING', 0),
(7, 'INSTHARD', 0),
(8, 'INSTSOFT', 0),
(9, 'MAINHARD', 0),
(10, 'MAINSOFT', 0),
(11, 'FACCLEAN', 1),
(12, 'PREVMAIN', 1),
(13, 'BRKFIX', 1),
(14, 'TELCO', 1);
-- --------------------------------------------------------
ALTER TABLE `lsio_countries`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id` (`id`),
  ADD UNIQUE KEY `name` (`name`);
ALTER TABLE `lsio_idtypes`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id` (`id`),
  ADD UNIQUE KEY `name` (`name`);
ALTER TABLE `lsio_sites`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id` (`id`),
  ADD UNIQUE KEY `name` (`name`);
ALTER TABLE `lsio_users`
  ADD PRIMARY KEY (`id`),
  ADD KEY `users_ibfk_1` (`usertype`);
ALTER TABLE `lsio_users_sites`
  ADD UNIQUE KEY `user_site_perm` (`sites_id`,`users_id`) USING BTREE,
  ADD KEY `users_id` (`users_id`);
ALTER TABLE `lsio_usertypes`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id` (`id`),
  ADD UNIQUE KEY `name` (`name`);
ALTER TABLE `lsio_visits`
  ADD PRIMARY KEY (`id`),
  ADD KEY `site_id` (`site_id`),
  ADD KEY `reason` (`reason`),
  ADD KEY `id_checked` (`id_reference`),
  ADD KEY `citizen` (`citizen`),
  ADD KEY `id_type` (`id_type`);
ALTER TABLE `lsio_visittypes`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id` (`id`),
  ADD UNIQUE KEY `name` (`name`);
-- --------------------------------------------------------
ALTER TABLE `lsio_idtypes`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Unique ID', AUTO_INCREMENT=100;
ALTER TABLE `lsio_sites`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Unique ID', AUTO_INCREMENT=107;
ALTER TABLE `lsio_users`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Unique ID', AUTO_INCREMENT=104;
ALTER TABLE `lsio_usertypes`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Unique ID', AUTO_INCREMENT=100;
ALTER TABLE `lsio_visits`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Unique ID', AUTO_INCREMENT=401;
ALTER TABLE `lsio_visittypes`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Unique ID', AUTO_INCREMENT=11;
ALTER TABLE `lsio_vendorinfo`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Unique ID', AUTO_INCREMENT=11;
-- --------------------------------------------------------
ALTER TABLE `lsio_users`
  ADD CONSTRAINT `lsio_users_ibfk_1` FOREIGN KEY (`usertype`) REFERENCES `lsio_usertypes` (`id`);
ALTER TABLE `lsio_users_sites`
  ADD CONSTRAINT `lsio_users_sites_ibfk_3` FOREIGN KEY (`sites_id`) REFERENCES `lsio_sites` (`id`),
  ADD CONSTRAINT `lsio_users_sites_ibfk_4` FOREIGN KEY (`users_id`) REFERENCES `lsio_users` (`id`);
ALTER TABLE `lsio_visits`
  ADD CONSTRAINT `lsio_visits_ibfk_1` FOREIGN KEY (`id_type`) REFERENCES `lsio_idtypes` (`id`),
  ADD CONSTRAINT `lsio_visits_ibfk_2` FOREIGN KEY (`reason`) REFERENCES `lsio_visittypes` (`id`),
  ADD CONSTRAINT `lsio_visits_ibfk_3` FOREIGN KEY (`site_id`) REFERENCES `lsio_sites` (`id`);
COMMIT;
