CREATE TABLE IF NOT EXISTS `printer` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(50) DEFAULT NULL,
  `path` varchar(50) DEFAULT NULL,
  `modelFk` varchar(50) DEFAULT NULL,
  `macWifi` varchar(20) DEFAULT NULL,
  `ipAddress` varchar(15) DEFAULT NULL,
  `reference` varchar(50) DEFAULT NULL,
  `isLabeler` tinyint(1) DEFAULT 0 COMMENT 'Indica si es impresora de etiquetas',
  `sectorFk` int(11) DEFAULT NULL,
  `paperSizeFk` varchar(100) DEFAULT NULL,
  `isRfid` tinyint(4) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `printer_UN` (`reference`),
  UNIQUE KEY `printer_UN1` (`macWifi`),
  UNIQUE KEY `printer_UN2` (`name`),
  KEY `printer_FK` (`modelFk`),
  KEY `printer_sectorFk_idx` (`id`,`sectorFk`),
  KEY `printer_sectorFk` (`sectorFk`),
  KEY `printer_FK_1` (`paperSizeFk`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

INSERT INTO `printer` (id, name, ipAddress) VALUES (1, 'printer1', '192.168.233.14');
INSERT INTO `printer` (id, name, ipAddress) VALUES (2, 'printer2', '192.168.233.14');
INSERT INTO `printer` (id, name, ipAddress) VALUES (3, 'printer4', '192.168.233.14');

CREATE TABLE IF NOT EXISTS `expedition_PrintOut` (
  `expeditionFk` int(11) NOT NULL,
  `ticketFk` int(11) NOT NULL,
  `addressFk` int(11) NOT NULL,
  `street` varchar(42) NOT NULL DEFAULT ' ',
  `postalCode` varchar(10) NOT NULL DEFAULT ' ',
  `city` varchar(100) NOT NULL DEFAULT ' ',
  `shopName` varchar(100) NOT NULL DEFAULT ' ',
  `isPrinted` int(11) NOT NULL DEFAULT 0,
  `created` timestamp NOT NULL DEFAULT current_timestamp(),
  `printerFk` int(10) unsigned NOT NULL DEFAULT 0,
  `routeFk` int(11) NOT NULL DEFAULT 0,
  `parkingCode` varchar(8) NOT NULL DEFAULT ' ',
  `truckName` varchar(25) NOT NULL DEFAULT ' ',
  `clientFk` int(11) NOT NULL,
  `phone` varchar(15) DEFAULT NULL,
  `province` varchar(20) NOT NULL,
  `agency` varchar(100) DEFAULT NULL,
  `m3` decimal(10,3) DEFAULT 0.000,
  `workerCode` varchar(25) DEFAULT NULL,
  `itemFk` int(11) DEFAULT NULL,
  `quantity` int(11) DEFAULT NULL,
  `longName` varchar(30) DEFAULT NULL,
  `shelvingFk` varchar(5) DEFAULT NULL,
  `comments` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`expeditionFk`),
  KEY `expedition_PrintOut_FK` (`printerFk`),
  CONSTRAINT `expedition_PrintOut_FK` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='listado de etiquetas a imprimir';

INSERT INTO `expedition_PrintOut` (
    `expeditionFk`, `ticketFk`, `addressFk`, `street`, `postalCode`, `city`,
    `shopName`, `isPrinted`, `created`, `printerFk`, `routeFk`, `parkingCode`,
    `truckName`, `clientFk`, `phone`, `province`, `agency`, `m3`,
    `workerCode`, `itemFk`, `quantity`, `longName`, `shelvingFk`, `comments`
)
VALUES
    (1, 1, 1, '1007 Mountain Drive', '46460', 'Gotham', 'Wayne Manor', 0, NOW(), 1, 1, 'A1', 'Truck 1', 1101, '1111111111', 'Gotham', 'Agency 1', 10.000, 'W1', 1001, 10, 'Item 1', 'S1', 'No comments'),
    (2, 2, 2, '20 Ingram Street', '46460', 'Gotham', 'Parker Residence', 0, NOW(), 2, 2, 'A2', 'Truck 2', 1102, '2222222222', 'Gotham', 'Agency 2', 20.000, 'W2', 1002, 20, 'Item 2', 'S2', 'No comments'),
    (3, 3, 3, '344 Clinton Street', '46460', 'Gotham', 'Kent Apartment', 0, NOW(), 1, 3, 'A3', 'Truck 3', 1103, '3333333333', 'Gotham', 'Agency 3', 30.000, 'W3', 1003, 30, 'Item 3', 'S3', 'No comments'),
    (4, 4, 4, '10880 Malibu Point', '46460', 'Gotham', 'Stark Tower', 0, NOW(), 2, 4, 'A4', 'Truck 4', 1104, '4444444444', 'Gotham', 'Agency 4', 40.000, 'W4', 1004, 40, 'Item 4', 'S4', 'No comments'),
    (5, 5, 5, 'Unknown Whereabouts', '46460', 'Gotham', 'Magneto Lair', 0, NOW(), 1, 5, 'A5', 'Truck 5', 1105, '5555555555', 'Gotham', 'Agency 5', 50.000, 'W5', 1005, 50, 'Item 5', 'S5', 'No comments'),
    (6, 6, 6, 'Evil Hideout', '46460', 'Gotham', 'Legion Base', 0, NOW(), 1, 6, 'A6', 'Truck 6', 1106, '6666666666', 'Gotham', 'Agency 6', 60.000, 'W6', 1006, 60, 'Item 6', 'S6', 'No comments'),
    (7, 7, 7, 'Anthill', '46460', 'Gotham', 'Pym Laboratory', 0, NOW(), 2, 7, 'A7', 'Truck 7', 1107, '7777777777', 'Gotham', 'Agency 7', 70.000, 'W7', 1007, 70, 'Item 7', 'S7', 'No comments'),
    (8, 8, 8, '3800 Victory Pkwy', '46460', 'Gotham', 'Xavier Institute', 0, NOW(), 1, 8, 'A8', 'Truck 8', 1108, '8888888888', 'Gotham', 'Agency 8', 80.000, 'W8', 1008, 80, 'Item 8', 'S8', 'No comments'),
    (9, 9, 9, 'Somewhere in New York', '46460', 'Gotham', 'Banner Lab', 0, NOW(), 1, 9, 'A9', 'Truck 9', 1109, '9999999999', 'Gotham', 'Agency 9', 90.000, 'W9', 1009, 90, 'Item 9', 'S9', 'No comments'),
    (10, 10, 10, 'Streets of New York', '46460', 'Gotham', 'Daily Bugle', 0, NOW(), 2, 10, 'A10', 'Truck 10', 1110, '0000000000', 'Gotham', 'Agency 10', 100.000, 'W10', 1010, 100, 'Item 10', 'S10', 'No comments'),
    (11, 1, 1, '1007 Mountain Drive', '46460', 'Gotham', 'Wayne Manor', 0, NOW(), 1, 1, 'A1', 'Truck 1', 1101, '1111111111', 'Gotham', 'Agency 1', 10.000, 'W1', 1001, 10, 'Item 1', 'S1', 'No comments'),
    (12, 2, 2, '20 Ingram Street', '46460', 'Gotham', 'Parker Residence', 0, NOW(), 2, 2, 'A2', 'Truck 2', 1102, '2222222222', 'Gotham', 'Agency 2', 20.000, 'W2', 1002, 20, 'Item 2', 'S2', 'No comments'),
    (13, 3, 3, '344 Clinton Street', '46460', 'Gotham', 'Kent Apartment', 0, NOW(), 1, 3, 'A3', 'Truck 3', 1103, '3333333333', 'Gotham', 'Agency 3', 30.000, 'W3', 1003, 30, 'Item 3', 'S3', 'No comments'),
    (14, 4, 4, '10880 Malibu Point', '46460', 'Gotham', 'Stark Tower', 0, NOW(), 2, 4, 'A4', 'Truck 4', 1104, '4444444444', 'Gotham', 'Agency 4', 40.000, 'W4', 1004, 40, 'Item 4', 'S4', 'No comments'),
    (15, 5, 5, 'Unknown Whereabouts', '46460', 'Gotham', 'Magneto Lair', 0, NOW(), 1, 5, 'A5', 'Truck 5', 1105, '5555555555', 'Gotham', 'Agency 5', 50.000, 'W5', 1005, 50, 'Item 5', 'S5', 'No comments'),
    (16, 6, 6, 'Evil Hideout', '46460', 'Gotham', 'Legion Base', 0, NOW(), 1, 6, 'A6', 'Truck 6', 1106, '6666666666', 'Gotham', 'Agency 6', 60.000, 'W6', 1006, 60, 'Item 6', 'S6', 'No comments'),
    (17, 7, 7, 'Anthill', '46460', 'Gotham', 'Pym Laboratory', 0, NOW(), 2, 7, 'A7', 'Truck 7', 1107, '7777777777', 'Gotham', 'Agency 7', 70.000, 'W7', 1007, 70, 'Item 7', 'S7', 'No comments'),
    (18, 8, 8, '3800 Victory Pkwy', '46460', 'Gotham', 'Xavier Institute', 0, NOW(), 1, 8, 'A8', 'Truck 8', 1108, '8888888888', 'Gotham', 'Agency 8', 80.000, 'W8', 1008, 80, 'Item 8', 'S8', 'No comments'),
    (19, 9, 9, 'Somewhere in New York', '46460', 'Gotham', 'Banner Lab', 0, NOW(), 1, 9, 'A9', 'Truck 9', 1109, '9999999999', 'Gotham', 'Agency 9', 90.000, 'W9', 1009, 90, 'Item 9', 'S9', 'No comments'),
    (20, 10, 10, 'Streets of New York', '46460', 'Gotham', 'Daily Bugle', 0, NOW(), 2, 10, 'A10', 'Truck 10', 1110, '0000000000', 'Gotham', 'Agency 10', 100.000, 'W10', 1010, 100, 'Item 10', 'S10', 'No comments'),
    (21, 1, 1, '1007 Mountain Drive', '46460', 'Gotham', 'Wayne Manor', 0, NOW(), 1, 1, 'A1', 'Truck 1', 1101, '1111111111', 'Gotham', 'Agency 1', 10.000, 'W1', 1001, 10, 'Item 1', 'S1', 'No comments'),
    (22, 2, 2, '20 Ingram Street', '46460', 'Gotham', 'Parker Residence', 0, NOW(), 2, 2, 'A2', 'Truck 2', 1102, '2222222222', 'Gotham', 'Agency 2', 20.000, 'W2', 1002, 20, 'Item 2', 'S2', 'No comments'),
    (23, 3, 3, '344 Clinton Street', '46460', 'Gotham', 'Kent Apartment', 0, NOW(), 1, 3, 'A3', 'Truck 3', 1103, '3333333333', 'Gotham', 'Agency 3', 30.000, 'W3', 1003, 30, 'Item 3', 'S3', 'No comments'),
    (24, 4, 4, '10880 Malibu Point', '46460', 'Gotham', 'Stark Tower', 0, NOW(), 2, 4, 'A4', 'Truck 4', 1104, '4444444444', 'Gotham', 'Agency 4', 40.000, 'W4', 1004, 40, 'Item 4', 'S4', 'No comments'),
    (25, 5, 5, 'Unknown Whereabouts', '46460', 'Gotham', 'Magneto Lair', 0, NOW(), 1, 5, 'A5', 'Truck 5', 1105, '5555555555', 'Gotham', 'Agency 5', 50.000, 'W5', 1005, 50, 'Item 5', 'S5', 'No comments'),
    (26, 6, 6, 'Evil Hideout', '46460', 'Gotham', 'Legion Base', 0, NOW(), 1, 6, 'A6', 'Truck 6', 1106, '6666666666', 'Gotham', 'Agency 6', 60.000, 'W6', 1006, 60, 'Item 6', 'S6', 'No comments'),
    (27, 7, 7, 'Anthill', '46460', 'Gotham', 'Pym Laboratory', 0, NOW(), 2, 7, 'A7', 'Truck 7', 1107, '7777777777', 'Gotham', 'Agency 7', 70.000, 'W7', 1007, 70, 'Item 7', 'S7', 'No comments'),
    (28, 8, 8, '3800 Victory Pkwy', '46460', 'Gotham', 'Xavier Institute', 0, NOW(), 1, 8, 'A8', 'Truck 8', 1108, '8888888888', 'Gotham', 'Agency 8', 80.000, 'W8', 1008, 80, 'Item 8', 'S8', 'No comments'),
    (29, 9, 9, 'Somewhere in New York', '46460', 'Gotham', 'Banner Lab', 0, NOW(), 1, 9, 'A9', 'Truck 9', 1109, '9999999999', 'Gotham', 'Agency 9', 90.000, 'W9', 1009, 90, 'Item 9', 'S9', 'No comments'),
    (30, 10, 10, 'Streets of New York', '46460', 'Gotham', 'Daily Bugle', 0, NOW(), 2, 10, 'A10', 'Truck 10', 1110, '0000000000', 'Gotham', 'Agency 10', 100.000, 'W10', 1010, 100, 'Item 10', 'S10', 'No comments'),
    (31, 1, 1, '1007 Mountain Drive', '46460', 'Gotham', 'Wayne Manor', 0, NOW(), 1, 1, 'A1', 'Truck 1', 1101, '1111111111', 'Gotham', 'Agency 1', 10.000, 'W1', 1001, 10, 'Item 1', 'S1', 'No comments'),
    (32, 2, 2, '20 Ingram Street', '46460', 'Gotham', 'Parker Residence', 0, NOW(), 2, 2, 'A2', 'Truck 2', 1102, '2222222222', 'Gotham', 'Agency 2', 20.000, 'W2', 1002, 20, 'Item 2', 'S2', 'No comments'),
    (33, 3, 3, '344 Clinton Street', '46460', 'Gotham', 'Kent Apartment', 0, NOW(), 1, 3, 'A3', 'Truck 3', 1103, '3333333333', 'Gotham', 'Agency 3', 30.000, 'W3', 1003, 30, 'Item 3', 'S3', 'No comments'),
    (34, 4, 4, '10880 Malibu Point', '46460', 'Gotham', 'Stark Tower', 0, NOW(), 2, 4, 'A4', 'Truck 4', 1104, '4444444444', 'Gotham', 'Agency 4', 40.000, 'W4', 1004, 40, 'Item 4', 'S4', 'No comments'),
    (35, 5, 5, 'Unknown Whereabouts', '46460', 'Gotham', 'Magneto Lair', 0, NOW(), 1, 5, 'A5', 'Truck 5', 1105, '5555555555', 'Gotham', 'Agency 5', 50.000, 'W5', 1005, 50, 'Item 5', 'S5', 'No comments'),
    (36, 6, 6, 'Evil Hideout', '46460', 'Gotham', 'Legion Base', 0, NOW(), 1, 6, 'A6', 'Truck 6', 1106, '6666666666', 'Gotham', 'Agency 6', 60.000, 'W6', 1006, 60, 'Item 6', 'S6', 'No comments'),
    (37, 7, 7, 'Anthill', '46460', 'Gotham', 'Pym Laboratory', 0, NOW(), 2, 7, 'A7', 'Truck 7', 1107, '7777777777', 'Gotham', 'Agency 7', 70.000, 'W7', 1007, 70, 'Item 7', 'S7', 'No comments'),
    (38, 8, 8, '3800 Victory Pkwy', '46460', 'Gotham', 'Xavier Institute', 0, NOW(), 1, 8, 'A8', 'Truck 8', 1108, '8888888888', 'Gotham', 'Agency 8', 80.000, 'W8', 1008, 80, 'Item 8', 'S8', 'No comments'),
    (39, 9, 9, 'Somewhere in New York', '46460', 'Gotham', 'Banner Lab', 0, NOW(), 1, 9, 'A9', 'Truck 9', 1109, '9999999999', 'Gotham', 'Agency 9', 90.000, 'W9', 1009, 90, 'Item 9', 'S9', 'No comments'),
    (40, 10, 10, 'Streets of New York', '46460', 'Gotham', 'Daily Bugle', 0, NOW(), 2, 10, 'A10', 'Truck 10', 1110, '0000000000', 'Gotham', 'Agency 10', 100.000, 'W10', 1010, 100, 'Item 10', 'S10', 'No comments'),
    (41, 1, 1, '1007 Mountain Drive', '46460', 'Gotham', 'Wayne Manor', 0, NOW(), 1, 1, 'A1', 'Truck 1', 1101, '1111111111', 'Gotham', 'Agency 1', 10.000, 'W1', 1001, 10, 'Item 1', 'S1', 'No comments'),
    (42, 2, 2, '20 Ingram Street', '46460', 'Gotham', 'Parker Residence', 0, NOW(), 2, 2, 'A2', 'Truck 2', 1102, '2222222222', 'Gotham', 'Agency 2', 20.000, 'W2', 1002, 20, 'Item 2', 'S2', 'No comments'),
    (43, 3, 3, '344 Clinton Street', '46460', 'Gotham', 'Kent Apartment', 0, NOW(), 1, 3, 'A3', 'Truck 3', 1103, '3333333333', 'Gotham', 'Agency 3', 30.000, 'W3', 1003, 30, 'Item 3', 'S3', 'No comments'),
    (44, 4, 4, '10880 Malibu Point', '46460', 'Gotham', 'Stark Tower', 0, NOW(), 2, 4, 'A4', 'Truck 4', 1104, '4444444444', 'Gotham', 'Agency 4', 40.000, 'W4', 1004, 40, 'Item 4', 'S4', 'No comments'),
    (45, 5, 5, 'Unknown Whereabouts', '46460', 'Gotham', 'Magneto Lair', 0, NOW(), 1, 5, 'A5', 'Truck 5', 1105, '5555555555', 'Gotham', 'Agency 5', 50.000, 'W5', 1005, 50, 'Item 5', 'S5', 'No comments'),
    (46, 6, 6, 'Evil Hideout', '46460', 'Gotham', 'Legion Base', 0, NOW(), 1, 6, 'A6', 'Truck 6', 1106, '6666666666', 'Gotham', 'Agency 6', 60.000, 'W6', 1006, 60, 'Item 6', 'S6', 'No comments'),
    (47, 7, 7, 'Anthill', '46460', 'Gotham', 'Pym Laboratory', 0, NOW(), 2, 7, 'A7', 'Truck 7', 1107, '7777777777', 'Gotham', 'Agency 7', 70.000, 'W7', 1007, 70, 'Item 7', 'S7', 'No comments'),
    (48, 8, 8, '3800 Victory Pkwy', '46460', 'Gotham', 'Xavier Institute', 0, NOW(), 1, 8, 'A8', 'Truck 8', 1108, '8888888888', 'Gotham', 'Agency 8', 80.000, 'W8', 1008, 80, 'Item 8', 'S8', 'No comments'),
    (49, 9, 9, 'Somewhere in New York', '46460', 'Gotham', 'Banner Lab', 0, NOW(), 1, 9, 'A9', 'Truck 9', 1109, '9999999999', 'Gotham', 'Agency 9', 90.000, 'W9', 1009, 90, 'Item 9', 'S9', 'No comments'),
    (50, 10, 10, 'Streets of New York', '46460', 'Gotham', 'Daily Bugle', 0, NOW(), 2, 10, 'A10', 'Truck 10', 1110, '0000000000', 'Gotham', 'Agency 10', 100.000, 'W10', 1010, 100, 'Item 10', 'S10', 'No comments'),
