diff --git a/db/changes/10310-mothersDay/00-ACL.sql b/db/changes/10310-mothersDay/00-ACL.sql deleted file mode 100644 index 1067c02f7..000000000 --- a/db/changes/10310-mothersDay/00-ACL.sql +++ /dev/null @@ -1,4 +0,0 @@ -INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) -VALUES - ('SupplierAddress', '*', '*', 'ALLOW', 'ROLE', 'employee'), - ('SalesMonitor', '*', '*', 'ALLOW', 'ROLE', 'employee'); diff --git a/db/changes/10310-mothersDay/00-module.sql b/db/changes/10310-mothersDay/00-module.sql deleted file mode 100644 index 18067529b..000000000 --- a/db/changes/10310-mothersDay/00-module.sql +++ /dev/null @@ -1 +0,0 @@ -INSERT INTO salix.module (code) VALUES ('Monitors'); diff --git a/db/changes/10310-mothersDay/00-receiptAcl.sql b/db/changes/10310-mothersDay/00-receiptAcl.sql deleted file mode 100644 index d3450cc9d..000000000 --- a/db/changes/10310-mothersDay/00-receiptAcl.sql +++ /dev/null @@ -1,3 +0,0 @@ -UPDATE salix.ACL - SET principalId = "salesAssistant" - WHERE model = 'Client' AND property = 'createReceipt'; \ No newline at end of file diff --git a/db/changes/10310-mothersDay/00-supplierAddress.sql b/db/changes/10310-mothersDay/00-supplierAddress.sql deleted file mode 100644 index e15a25a81..000000000 --- a/db/changes/10310-mothersDay/00-supplierAddress.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE `vn`.`supplierAddress` -( - id INT NULL AUTO_INCREMENT, - supplierFk INT NULL, - nickname VARCHAR(40) NULL, - street VARCHAR(255) NULL, - provinceFk SMALLINT(6) UNSIGNED NULL, - postalCode VARCHAR(10) NULL, - city VARCHAR(50) NULL, - phone VARCHAR(15) NULL, - mobile VARCHAR(15) NULL, - CONSTRAINT supplierAddress_pk - PRIMARY KEY (id), - CONSTRAINT supplierAddress_province_fk - FOREIGN KEY (provinceFk) REFERENCES province (id) - ON UPDATE CASCADE -); - diff --git a/db/changes/10320-monitors/00-sale_getProblems.sql b/db/changes/10320-monitors/00-sale_getProblems.sql deleted file mode 100644 index 290dcddb2..000000000 --- a/db/changes/10320-monitors/00-sale_getProblems.sql +++ /dev/null @@ -1,193 +0,0 @@ -DROP PROCEDURE IF EXISTS `vn`.`sale_getProblems`; - -DELIMITER $$ -$$ -CREATE - DEFINER = root@`%` PROCEDURE `vn`.`sale_getProblems`(IN vIsTodayRelative TINYINT(1)) -BEGIN -/** - * Calcula los problemas de cada venta - * para un conjunto de tickets. - * - * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular - * @return tmp.sale_problems - */ - DECLARE vWarehouse INT; - DECLARE vDate DATE; - DECLARE vAvailableCache INT; - DECLARE vDone INT DEFAULT 0; - DECLARE vComponentCount INT; - - DECLARE vCursor CURSOR FOR - SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, CURDATE(), date(tt.shipped)) - FROM tmp.sale_getProblems tt - WHERE DATE(tt.shipped) BETWEEN CURDATE() - AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), CURDATE()); - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; - - DROP TEMPORARY TABLE IF EXISTS tmp.sale_problems; - CREATE TEMPORARY TABLE tmp.sale_problems ( - ticketFk INT(11), - saleFk INT(11), - isFreezed INTEGER(1) DEFAULT 0, - risk DECIMAL(10,2) DEFAULT 0, - hasTicketRequest INTEGER(1) DEFAULT 0, - isAvailable INTEGER(1) DEFAULT 1, - itemShortage VARCHAR(250), - isTaxDataChecked INTEGER(1) DEFAULT 1, - itemDelay VARCHAR(250), - hasComponentLack INTEGER(1), - PRIMARY KEY (ticketFk, saleFk) - ) ENGINE = MEMORY; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; - CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (ticketFk)) - ENGINE = MEMORY - SELECT tp.ticketFk, c.id clientFk - FROM tmp.sale_getProblems tp - JOIN vn.client c ON c.id = tp.clientFk; - - SELECT COUNT(*) INTO vComponentCount - FROM vn.component c - WHERE c.isRequired; - - INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk) - SELECT tl.ticketFk, (COUNT(DISTINCT s.id) * vComponentCount > COUNT(c.id)), s.id - FROM tmp.ticket_list tl - JOIN vn.sale s ON s.ticketFk = tl.ticketFk - LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id - LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired - GROUP BY tl.ticketFk, s.id; - - INSERT INTO tmp.sale_problems(ticketFk, isFreezed) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN vn.client c ON c.id = tl.clientFk - WHERE c.isFreezed - ON DUPLICATE KEY UPDATE - isFreezed = c.isFreezed; - - DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; - CREATE TEMPORARY TABLE tmp.clientGetDebt - (PRIMARY KEY (clientFk)) - ENGINE = MEMORY - SELECT DISTINCT clientFk - FROM tmp.ticket_list; - - CALL clientGetDebt(CURDATE()); - - INSERT INTO tmp.sale_problems(ticketFk, risk) - SELECT DISTINCT tl.ticketFk, r.risk - FROM tmp.ticket_list tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.agencyMode a ON t.agencyModeFk = a.id - JOIN tmp.risk r ON r.clientFk = t.clientFk - JOIN vn.client c ON c.id = t.clientFk - JOIN vn.clientConfig cc - WHERE r.risk - cc.riskTolerance > c.credit + 10 - AND a.isRiskFree = FALSE - ON DUPLICATE KEY UPDATE - risk = r.risk; - - INSERT INTO tmp.sale_problems(ticketFk, hasTicketRequest) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN vn.ticketRequest tr ON tr.ticketFk = tl.ticketFk - WHERE tr.isOK IS NULL - ON DUPLICATE KEY UPDATE - hasTicketRequest = TRUE; - - OPEN vCursor; - - WHILE NOT vDone - DO - FETCH vCursor INTO vWarehouse, vDate; - - CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouse, vDate); - - INSERT INTO tmp.sale_problems(ticketFk, isAvailable, saleFk) - SELECT tl.ticketFk, FALSE, s.id - FROM tmp.ticket_list tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it on it.id = i.typeFk - LEFT JOIN cache.available av ON av.item_id = i.id - AND av.calc_id = vAvailableCache - WHERE date(t.shipped) = vDate - AND it.categoryFk != 6 - AND IFNULL(av.available, 0) < 0 - AND s.isPicked = FALSE - AND NOT i.generic - AND vWarehouse = t.warehouseFk - GROUP BY tl.ticketFk - ON DUPLICATE KEY UPDATE - isAvailable = FALSE, saleFk = VALUE(saleFk); - - INSERT INTO tmp.sale_problems(ticketFk, itemShortage, saleFk) - SELECT ticketFk, problem, saleFk - FROM ( - SELECT tl.ticketFk, CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')) problem, s.id AS saleFk - FROM tmp.ticket_list tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it on it.id = i.typeFk - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache - WHERE IFNULL(av.available, 0) < 0 - AND s.quantity > IFNULL(issw.visible, 0) - AND s.quantity > 0 - AND s.isPicked = FALSE - AND s.reserved = FALSE - AND it.categoryFk != 6 - AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) - AND NOT i.generic - AND CURDATE() = vDate - AND t.warehouseFk = vWarehouse - GROUP BY tl.ticketFk LIMIT 1) sub - ON DUPLICATE KEY UPDATE - itemShortage = sub.problem, saleFk = sub.saleFk; - - INSERT INTO tmp.sale_problems(ticketFk, itemDelay, saleFk) - SELECT ticketFk, problem, saleFk - FROM ( - SELECT tl.ticketFk, GROUP_CONCAT('I: ',i.id, ' ', i.longName, ' ') problem, s.id AS saleFk - FROM tmp.ticket_list tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it on it.id = i.typeFk - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - WHERE s.quantity > IFNULL(issw.visible, 0) - AND s.quantity > 0 - AND s.isPicked = FALSE - AND s.reserved = FALSE - AND it.categoryFk != 6 - AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) - AND NOT i.generic - AND CURDATE() = vDate - AND t.warehouseFk = vWarehouse - GROUP BY tl.ticketFk LIMIT 1) sub - ON DUPLICATE KEY UPDATE - itemDelay = sub.problem, saleFk = sub.saleFk; - END WHILE; - - CLOSE vCursor; - - INSERT INTO tmp.sale_problems(ticketFk, isTaxDataChecked) - SELECT DISTINCT tl.ticketFk, FALSE - FROM tmp.ticket_list tl - JOIN vn.client c ON c.id = tl.clientFk - WHERE c.isTaxDataChecked = FALSE - ON DUPLICATE KEY UPDATE - isTaxDataChecked = FALSE; - - DROP TEMPORARY TABLE - tmp.clientGetDebt, - tmp.ticket_list; -END;;$$ -DELIMITER ; - diff --git a/db/changes/10320-monitors/00-sale_getProblemsByTicket.sql b/db/changes/10320-monitors/00-sale_getProblemsByTicket.sql deleted file mode 100644 index 1f30014d4..000000000 --- a/db/changes/10320-monitors/00-sale_getProblemsByTicket.sql +++ /dev/null @@ -1,30 +0,0 @@ -DROP PROCEDURE IF EXISTS `vn`.`sale_getProblemsByTicket`; - -DELIMITER $$ -$$ -CREATE - DEFINER = root@`%` PROCEDURE `vn`.`sale_getProblemsByTicket`(IN vTicketFk INT, IN vIsTodayRelative TINYINT(1)) -BEGIN -/** - * Calcula los problemas de cada venta - * para un conjunto de tickets. - * - * @return Problems result - */ - DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems; - CREATE TEMPORARY TABLE tmp.sale_getProblems - (INDEX (ticketFk)) - ENGINE = MEMORY - SELECT t.id ticketFk, t.clientFk, t.warehouseFk, t.shipped - FROM ticket t - WHERE t.id = vTicketFk; - - CALL sale_getProblems(vIsTodayRelative); - - SELECT * FROM tmp.sale_problems; - - DROP TEMPORARY TABLE - tmp.sale_getProblems, - tmp.sale_problems; -END;;$$ -DELIMITER ; diff --git a/db/changes/10320-monitors/00-ticketGetProblems.sql b/db/changes/10320-monitors/00-ticketGetProblems.sql deleted file mode 100644 index 06d0275b3..000000000 --- a/db/changes/10320-monitors/00-ticketGetProblems.sql +++ /dev/null @@ -1,187 +0,0 @@ -DROP PROCEDURE IF EXISTS `vn`.`ticketGetProblems`; - -DELIMITER $$ -$$ -CREATE - DEFINER = root@`%` PROCEDURE `vn`.`ticketGetProblems`(IN vIsTodayRelative TINYINT(1)) -BEGIN -/** - * @deprecated Use ticket_getProblems() instead - * - */ - DECLARE vWarehouse INT; - DECLARE vDate DATE; - DECLARE vAvailableCache INT; - DECLARE vDone INT DEFAULT 0; - DECLARE vComponentCount INT; - - DECLARE vCursor CURSOR FOR - SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, CURDATE(), date(tt.shipped)) - FROM tmp.ticketGetProblems tt - WHERE DATE(tt.shipped) BETWEEN CURDATE() - AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), CURDATE()); - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketProblems; - CREATE TEMPORARY TABLE tmp.ticketProblems ( - ticketFk INT(11) PRIMARY KEY, - isFreezed INTEGER(1) DEFAULT 0, - risk DECIMAL(10,2) DEFAULT 0, - hasTicketRequest INTEGER(1) DEFAULT 0, - isAvailable INTEGER(1) DEFAULT 1, - itemShortage VARCHAR(250), - isTaxDataChecked INTEGER(1) DEFAULT 1, - itemDelay VARCHAR(250), - componentLack INTEGER(1) - ) ENGINE = MEMORY; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketList; - CREATE TEMPORARY TABLE tmp.ticketList - (PRIMARY KEY (ticketFk)) - ENGINE = MEMORY - SELECT tp.ticketFk, c.id clientFk - FROM tmp.ticketGetProblems tp - JOIN vn.client c ON c.id = tp.clientFk; - - SELECT COUNT(*) INTO vComponentCount - FROM vn.component c - WHERE c.isRequired; - - INSERT INTO tmp.ticketProblems(ticketFk, componentLack) - SELECT tl.ticketFk, (COUNT(DISTINCT s.id) * vComponentCount > COUNT(c.id)) - FROM tmp.ticketList tl - JOIN vn.sale s ON s.ticketFk = tl.ticketFk - LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id - LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired - GROUP BY tl.ticketFk; - - INSERT INTO tmp.ticketProblems(ticketFk, isFreezed) - SELECT DISTINCT tl.ticketFk, 1 - FROM tmp.ticketList tl - JOIN vn.client c ON c.id = tl.clientFk - WHERE c.isFreezed - ON DUPLICATE KEY UPDATE - isFreezed = c.isFreezed; - - DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; - CREATE TEMPORARY TABLE tmp.clientGetDebt - (PRIMARY KEY (clientFk)) - ENGINE = MEMORY - SELECT DISTINCT clientFk - FROM tmp.ticketList; - - CALL clientGetDebt(CURDATE()); - - INSERT INTO tmp.ticketProblems(ticketFk, risk) - SELECT DISTINCT tl.ticketFk, r.risk - FROM tmp.ticketList tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.agencyMode a ON t.agencyModeFk = a.id - JOIN tmp.risk r ON r.clientFk = t.clientFk - JOIN vn.client c ON c.id = t.clientFk - JOIN vn.clientConfig cc - WHERE r.risk - cc.riskTolerance > c.credit + 10 - AND a.isRiskFree = FALSE - ON DUPLICATE KEY UPDATE - risk = r.risk; - - INSERT INTO tmp.ticketProblems(ticketFk, hasTicketRequest) - SELECT DISTINCT tl.ticketFk, 1 - FROM tmp.ticketList tl - JOIN vn.ticketRequest tr ON tr.ticketFk = tl.ticketFk - WHERE tr.isOK IS NULL AND tr.saleFk IS NOT NULL - ON DUPLICATE KEY UPDATE - hasTicketRequest = 1; - - OPEN vCursor; - - WHILE NOT vDone - DO - FETCH vCursor INTO vWarehouse, vDate; - - CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouse, vDate); - - INSERT INTO tmp.ticketProblems(ticketFk, isAvailable) - SELECT tl.ticketFk, 0 - FROM tmp.ticketList tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it on it.id = i.typeFk - LEFT JOIN cache.available av ON av.item_id = i.id - AND av.calc_id = vAvailableCache - WHERE date(t.shipped) = vDate - AND it.categoryFk != 6 - AND IFNULL(av.available, 0) < 0 - AND s.isPicked = FALSE - AND NOT i.generic - AND vWarehouse = t.warehouseFk - GROUP BY tl.ticketFk - ON DUPLICATE KEY UPDATE - isAvailable = 0; - - INSERT INTO tmp.ticketProblems(ticketFk, itemShortage) - SELECT ticketFk, problem - FROM ( - SELECT tl.ticketFk, CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')) problem - FROM tmp.ticketList tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it on it.id = i.typeFk - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache - WHERE IFNULL(av.available, 0) < 0 - AND s.quantity > IFNULL(issw.visible, 0) - AND s.quantity > 0 - AND s.isPicked = FALSE - AND s.reserved = FALSE - AND it.categoryFk != 6 - AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) - AND NOT i.generic - AND CURDATE() = vDate - AND t.warehouseFk = vWarehouse - GROUP BY tl.ticketFk) sub - ON DUPLICATE KEY UPDATE - itemShortage = sub.problem; - - INSERT INTO tmp.ticketProblems(ticketFk, itemDelay) - SELECT ticketFk, problem - FROM ( - SELECT tl.ticketFk, GROUP_CONCAT('I: ',i.id, ' ', i.longName, ' ') problem - FROM tmp.ticketList tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it on it.id = i.typeFk - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - WHERE s.quantity > IFNULL(issw.visible, 0) - AND s.quantity > 0 - AND s.isPicked = FALSE - AND s.reserved = FALSE - AND it.categoryFk != 6 - AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) - AND NOT i.generic - AND CURDATE() = vDate - AND t.warehouseFk = vWarehouse - GROUP BY tl.ticketFk) sub - ON DUPLICATE KEY UPDATE - itemDelay = sub.problem; - END WHILE; - - CLOSE vCursor; - - INSERT INTO tmp.ticketProblems(ticketFk, isTaxDataChecked) - SELECT DISTINCT tl.ticketFk, FALSE - FROM tmp.ticketList tl - JOIN vn.client c ON c.id = tl.clientFk - WHERE c.isTaxDataChecked= FALSE - ON DUPLICATE KEY UPDATE - isTaxDataChecked = FALSE; - - DROP TEMPORARY TABLE - tmp.clientGetDebt, - tmp.ticketList; -END;;$$ -DELIMITER ; diff --git a/db/changes/10320-monitors/00-ticket_componentMakeUpdate.sql b/db/changes/10320-monitors/00-ticket_componentMakeUpdate.sql deleted file mode 100644 index 242b09d34..000000000 --- a/db/changes/10320-monitors/00-ticket_componentMakeUpdate.sql +++ /dev/null @@ -1,92 +0,0 @@ -DROP PROCEDURE `vn`.`ticket_componentMakeUpdate`; - -DELIMITER $$ -$$ -CREATE - DEFINER = root@`%` PROCEDURE `vn`.`ticket_componentMakeUpdate`(IN vTicketFk INT, IN vClientFk INT, IN vAgencyModeFk INT, - IN vAddressFk INT, IN vZoneFk INT, IN vWarehouseFk TINYINT, - IN vCompanyFk SMALLINT, IN vShipped DATETIME, - IN vLanded DATE, IN vIsDeleted TINYINT(1), - IN vHasToBeUnrouted TINYINT(1), IN vOption INT) -BEGIN -/** - * Modifica en el ticket los campos que se le pasan por parámetro - * y cambia sus componentes. - * Este procedimiento es transacionado en Salix - * - * @param vTicketFk Id del ticket a modificar - * @param vClientFk nuevo cliente - * @param vAgencyModeFk nueva agencia - * @param vAddressFk nuevo consignatario - * @param vZoneFk nueva zona - * @param vWarehouseFk nuevo almacen - * @param vCompanyFk nueva empresa - * @param vShipped nueva fecha del envio de mercancia - * @param vLanded nueva fecha de recepcion de mercancia - * @param vIsDeleted si se borra el ticket - * @param vHasToBeUnrouted si se le elimina la ruta al ticket - * @param vOption opcion para el case del proc ticketComponentUpdateSale - */ - DECLARE vPrice DECIMAL(10,2); - DECLARE vBonus DECIMAL(10,2); - - CALL ticket_componentPreview (vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk); - - IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN - - UPDATE ticket t - JOIN address a ON a.id = vAddressFk - SET t.nickname = a.nickname - WHERE t.id = vTicketFk; - - END IF; - - CALL zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk); - - SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus - FROM tmp.zoneGetShipped - WHERE shipped BETWEEN DATE(vShipped) AND util.dayEnd(vShipped) AND warehouseFk = vWarehouseFk LIMIT 1; - - UPDATE ticket t - SET - t.clientFk = vClientFk, - t.agencyModeFk = vAgencyModeFk, - t.addressFk = vAddressFk, - t.zoneFk = vZoneFk, - t.zonePrice = vPrice, - t.zoneBonus = vBonus, - t.warehouseFk = vWarehouseFk, - t.companyFk = vCompanyFk, - t.landed = vLanded, - t.shipped = vShipped, - t.isDeleted = vIsDeleted - WHERE - t.id = vTicketFk; - - IF vHasToBeUnrouted THEN - UPDATE ticket t SET t.routeFk = NULL - WHERE t.id = vTicketFk; - END IF; - - IF vOption <> 8 THEN - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - CREATE TEMPORARY TABLE tmp.sale - (PRIMARY KEY (saleFk)) - ENGINE = MEMORY - SELECT id AS saleFk, vWarehouseFk warehouseFk - FROM sale s WHERE s.ticketFk = vTicketFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; - CREATE TEMPORARY TABLE tmp.ticketComponent - SELECT * FROM tmp.ticketComponentPreview; - - CALL ticketComponentUpdateSale (vOption); - - DROP TEMPORARY TABLE tmp.sale; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; - END IF; - - DROP TEMPORARY TABLE tmp.zoneGetShipped, tmp.ticketComponentPreview; -END;;$$ -DELIMITER ; - diff --git a/db/changes/10320-monitors/00-ticket_getProblems.sql b/db/changes/10320-monitors/00-ticket_getProblems.sql deleted file mode 100644 index 290a083df..000000000 --- a/db/changes/10320-monitors/00-ticket_getProblems.sql +++ /dev/null @@ -1,36 +0,0 @@ -DROP PROCEDURE IF EXISTS `vn`.`ticket_getProblems`; - -DELIMITER $$ -$$ -CREATE - DEFINER = root@`%` PROCEDURE `vn`.`ticket_getProblems`(IN vIsTodayRelative TINYINT(1)) -BEGIN -/** - * Calcula los problemas para un conjunto de tickets. - * Agrupados por ticket - * - * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular - * @return tmp.ticket_problems - */ - CALL sale_getProblems(vIsTodayRelative); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket_problems; - CREATE TEMPORARY TABLE tmp.ticket_problems - (INDEX (ticketFk)) - ENGINE = MEMORY - SELECT - ticketFk, - MAX(p.isFreezed) AS isFreezed, - MAX(p.risk) AS risk, - MAX(p.hasTicketRequest) AS hasTicketRequest, - MIN(p.isAvailable) AS isAvailable, - MAX(p.itemShortage) AS itemShortage, - MIN(p.isTaxDataChecked) AS isTaxDataChecked, - MAX(p.hasComponentLack) AS hasComponentLack - FROM tmp.sale_problems p - GROUP BY ticketFk; - - DROP TEMPORARY TABLE - tmp.sale_problems; -END;;$$ -DELIMITER ; diff --git a/db/changes/10320-monitors/01-warehouse.sql b/db/changes/10320-monitors/01-warehouse.sql deleted file mode 100644 index 45e1c0c56..000000000 --- a/db/changes/10320-monitors/01-warehouse.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE `vn`.`warehouse` - ADD `code` VARCHAR(3) NULL AFTER name; - -UPDATE `vn`.`warehouse` SET `code` = 'ALG' WHERE `id` = 60; \ No newline at end of file diff --git a/db/changes/10320-monitors/02-starredModule.sql b/db/changes/10320-monitors/02-starredModule.sql deleted file mode 100644 index ee00a80bd..000000000 --- a/db/changes/10320-monitors/02-starredModule.sql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE `vn`.`starredModule` - ADD `position` INT NOT NULL AFTER `moduleFk`; - -SET @count:=0; -UPDATE `vn`.`starredModule` sm - JOIN ( - SELECT sm.id, IF(@workerFk = sm.workerFk, @count:=@count+1, @count:=1) AS position, @workerFk:=sm.workerFk - FROM `vn`.`starredModule` sm ORDER BY workerFk, moduleFk ASC) AS smt ON smt.id = sm.id - SET sm.position = smt.position; \ No newline at end of file diff --git a/db/changes/10330-jun2021/00-invoiceInLog.sql b/db/changes/10330-jun2021/00-invoiceInLog.sql deleted file mode 100644 index 899c6c63f..000000000 --- a/db/changes/10330-jun2021/00-invoiceInLog.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE `vn`.`invoiceInLog` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `originFk` MEDIUMINT UNSIGNED NOT NULL, - `userFk` int(10) unsigned DEFAULT NULL, - `action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL, - `creationDate` timestamp NULL DEFAULT current_timestamp(), - `description` text CHARACTER SET utf8 DEFAULT NULL, - `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8_unicode_ci DEFAULT NULL, - `newInstance` text COLLATE utf8_unicode_ci DEFAULT NULL, - `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `originFk` (`originFk`), - KEY `userFk` (`userFk`), - CONSTRAINT `invoiceInLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn`.`invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `invoiceInLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; \ No newline at end of file diff --git a/db/changes/10330-jun2021/00-sale_getProblems.sql b/db/changes/10330-jun2021/00-sale_getProblems.sql deleted file mode 100644 index 6685378b3..000000000 --- a/db/changes/10330-jun2021/00-sale_getProblems.sql +++ /dev/null @@ -1,192 +0,0 @@ -DROP PROCEDURE IF EXISTS `vn`.`sale_getProblems`; - -DELIMITER $$ -$$ -CREATE - DEFINER = root@`%` PROCEDURE `vn`.`sale_getProblems`(IN vIsTodayRelative TINYINT(1)) -BEGIN -/** - * Calcula los problemas de cada venta - * para un conjunto de tickets. - * - * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular - * @return tmp.sale_problems - */ - DECLARE vWarehouse INT; - DECLARE vDate DATE; - DECLARE vAvailableCache INT; - DECLARE vDone INT DEFAULT 0; - DECLARE vComponentCount INT; - - DECLARE vCursor CURSOR FOR - SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, CURDATE(), date(tt.shipped)) - FROM tmp.sale_getProblems tt - WHERE DATE(tt.shipped) BETWEEN CURDATE() - AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), CURDATE()); - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; - - DROP TEMPORARY TABLE IF EXISTS tmp.sale_problems; - CREATE TEMPORARY TABLE tmp.sale_problems ( - ticketFk INT(11), - saleFk INT(11), - isFreezed INTEGER(1) DEFAULT 0, - risk DECIMAL(10,2) DEFAULT 0, - hasTicketRequest INTEGER(1) DEFAULT 0, - isAvailable INTEGER(1) DEFAULT 1, - itemShortage VARCHAR(250), - isTaxDataChecked INTEGER(1) DEFAULT 1, - itemDelay VARCHAR(250), - hasComponentLack INTEGER(1), - PRIMARY KEY (ticketFk, saleFk) - ) ENGINE = MEMORY; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; - CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (ticketFk)) - ENGINE = MEMORY - SELECT tp.ticketFk, c.id clientFk - FROM tmp.sale_getProblems tp - JOIN vn.client c ON c.id = tp.clientFk; - - SELECT COUNT(*) INTO vComponentCount - FROM vn.component c - WHERE c.isRequired; - - INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk) - SELECT tl.ticketFk, (COUNT(DISTINCT s.id) * vComponentCount > COUNT(c.id)), s.id - FROM tmp.ticket_list tl - JOIN vn.sale s ON s.ticketFk = tl.ticketFk - LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id - LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired - GROUP BY tl.ticketFk, s.id; - - INSERT INTO tmp.sale_problems(ticketFk, isFreezed) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN vn.client c ON c.id = tl.clientFk - WHERE c.isFreezed - ON DUPLICATE KEY UPDATE - isFreezed = c.isFreezed; - - DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; - CREATE TEMPORARY TABLE tmp.clientGetDebt - (PRIMARY KEY (clientFk)) - ENGINE = MEMORY - SELECT DISTINCT clientFk - FROM tmp.ticket_list; - - CALL clientGetDebt(CURDATE()); - - INSERT INTO tmp.sale_problems(ticketFk, risk) - SELECT DISTINCT tl.ticketFk, r.risk - FROM tmp.ticket_list tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.agencyMode a ON t.agencyModeFk = a.id - JOIN tmp.risk r ON r.clientFk = t.clientFk - JOIN vn.client c ON c.id = t.clientFk - JOIN vn.clientConfig cc - WHERE r.risk > c.credit + 10 - AND a.isRiskFree = FALSE - ON DUPLICATE KEY UPDATE - risk = r.risk; - - INSERT INTO tmp.sale_problems(ticketFk, hasTicketRequest) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN vn.ticketRequest tr ON tr.ticketFk = tl.ticketFk - WHERE tr.isOK IS NULL - ON DUPLICATE KEY UPDATE - hasTicketRequest = TRUE; - - OPEN vCursor; - - WHILE NOT vDone - DO - FETCH vCursor INTO vWarehouse, vDate; - - CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouse, vDate); - - INSERT INTO tmp.sale_problems(ticketFk, isAvailable, saleFk) - SELECT tl.ticketFk, FALSE, s.id - FROM tmp.ticket_list tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it on it.id = i.typeFk - LEFT JOIN cache.available av ON av.item_id = i.id - AND av.calc_id = vAvailableCache - WHERE date(t.shipped) = vDate - AND it.categoryFk != 6 - AND IFNULL(av.available, 0) < 0 - AND s.isPicked = FALSE - AND NOT i.generic - AND vWarehouse = t.warehouseFk - GROUP BY tl.ticketFk - ON DUPLICATE KEY UPDATE - isAvailable = FALSE, saleFk = VALUE(saleFk); - - INSERT INTO tmp.sale_problems(ticketFk, itemShortage, saleFk) - SELECT ticketFk, problem, saleFk - FROM ( - SELECT tl.ticketFk, CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')) problem, s.id AS saleFk - FROM tmp.ticket_list tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it on it.id = i.typeFk - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache - WHERE IFNULL(av.available, 0) < 0 - AND s.quantity > IFNULL(issw.visible, 0) - AND s.quantity > 0 - AND s.isPicked = FALSE - AND s.reserved = FALSE - AND it.categoryFk != 6 - AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) - AND NOT i.generic - AND CURDATE() = vDate - AND t.warehouseFk = vWarehouse - GROUP BY tl.ticketFk LIMIT 1) sub - ON DUPLICATE KEY UPDATE - itemShortage = sub.problem, saleFk = sub.saleFk; - - INSERT INTO tmp.sale_problems(ticketFk, itemDelay, saleFk) - SELECT ticketFk, problem, saleFk - FROM ( - SELECT tl.ticketFk, GROUP_CONCAT('I: ',i.id, ' ', i.longName, ' ') problem, s.id AS saleFk - FROM tmp.ticket_list tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it on it.id = i.typeFk - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - WHERE s.quantity > IFNULL(issw.visible, 0) - AND s.quantity > 0 - AND s.isPicked = FALSE - AND s.reserved = FALSE - AND it.categoryFk != 6 - AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) - AND NOT i.generic - AND CURDATE() = vDate - AND t.warehouseFk = vWarehouse - GROUP BY tl.ticketFk LIMIT 1) sub - ON DUPLICATE KEY UPDATE - itemDelay = sub.problem, saleFk = sub.saleFk; - END WHILE; - - CLOSE vCursor; - - INSERT INTO tmp.sale_problems(ticketFk, isTaxDataChecked) - SELECT DISTINCT tl.ticketFk, FALSE - FROM tmp.ticket_list tl - JOIN vn.client c ON c.id = tl.clientFk - WHERE c.isTaxDataChecked = FALSE - ON DUPLICATE KEY UPDATE - isTaxDataChecked = FALSE; - - DROP TEMPORARY TABLE - tmp.clientGetDebt, - tmp.ticket_list; -END;;$$ -DELIMITER ; diff --git a/db/changes/10330-jun2021/01-ticket_componentMakeUpdate.sql b/db/changes/10330-jun2021/01-ticket_componentMakeUpdate.sql deleted file mode 100644 index 058d6eb99..000000000 --- a/db/changes/10330-jun2021/01-ticket_componentMakeUpdate.sql +++ /dev/null @@ -1,95 +0,0 @@ -DROP PROCEDURE IF EXISTS `vn`.`ticket_componentMakeUpdate`; - -DELIMITER $$ -$$ - -CREATE - DEFINER = root@`%` PROCEDURE `vn`.`ticket_componentMakeUpdate`(IN vTicketFk INT, IN vClientFk INT, - IN vNickname VARCHAR(50), IN vAgencyModeFk INT, - IN vAddressFk INT, IN vZoneFk INT, IN vWarehouseFk TINYINT, - IN vCompanyFk SMALLINT, IN vShipped DATETIME, - IN vLanded DATE, IN vIsDeleted TINYINT(1), - IN vHasToBeUnrouted TINYINT(1), IN vOption INT) -BEGIN -/** - * Modifica en el ticket los campos que se le pasan por parámetro - * y cambia sus componentes - * - * @param vTicketFk Id del ticket a modificar - * @param vClientFk nuevo cliente - * @param vNickname nuevo alias - * @param vAgencyModeFk nueva agencia - * @param vAddressFk nuevo consignatario - * @param vZoneFk nueva zona - * @param vWarehouseFk nuevo almacen - * @param vCompanyFk nueva empresa - * @param vShipped nueva fecha del envio de mercancia - * @param vLanded nueva fecha de recepcion de mercancia - * @param vIsDeleted si se borra el ticket - * @param vHasToBeUnrouted si se le elimina la ruta al ticket - * @param vOption opcion para el case del proc ticketComponentUpdateSale - */ - DECLARE vPrice DECIMAL(10,2); - DECLARE vBonus DECIMAL(10,2); - - CALL ticket_componentPreview (vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk); - - IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN - - UPDATE ticket t - JOIN address a ON a.id = vAddressFk - SET t.nickname = a.nickname - WHERE t.id = vTicketFk; - - END IF; - - CALL zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk); - - SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus - FROM tmp.zoneGetShipped - WHERE shipped BETWEEN DATE(vShipped) AND util.dayEnd(vShipped) AND warehouseFk = vWarehouseFk LIMIT 1; - - UPDATE ticket t - SET - t.clientFk = vClientFk, - t.nickname = vNickname, - t.agencyModeFk = vAgencyModeFk, - t.addressFk = vAddressFk, - t.zoneFk = vZoneFk, - t.zonePrice = vPrice, - t.zoneBonus = vBonus, - t.warehouseFk = vWarehouseFk, - t.companyFk = vCompanyFk, - t.landed = vLanded, - t.shipped = vShipped, - t.isDeleted = vIsDeleted - WHERE - t.id = vTicketFk; - - IF vHasToBeUnrouted THEN - UPDATE ticket t SET t.routeFk = NULL - WHERE t.id = vTicketFk; - END IF; - - IF vOption <> 8 THEN - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - CREATE TEMPORARY TABLE tmp.sale - (PRIMARY KEY (saleFk)) - ENGINE = MEMORY - SELECT id AS saleFk, vWarehouseFk warehouseFk - FROM sale s WHERE s.ticketFk = vTicketFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; - CREATE TEMPORARY TABLE tmp.ticketComponent - SELECT * FROM tmp.ticketComponentPreview; - - CALL ticketComponentUpdateSale (vOption); - - DROP TEMPORARY TABLE tmp.sale; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; - END IF; - - DROP TEMPORARY TABLE tmp.zoneGetShipped, tmp.ticketComponentPreview; -END$$ -DELIMITER ; - diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index b8f17d6ed..871c8e933 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -1,6 +1,6 @@ USE `util`; --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.10-MariaDB, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: util -- ------------------------------------------------------ @@ -22,7 +22,7 @@ USE `util`; LOCK TABLES `config` WRITE; /*!40000 ALTER TABLE `config` DISABLE KEYS */; -INSERT INTO `config` VALUES (1,'10300',0,'production',NULL); +INSERT INTO `config` VALUES (1,'10320',0,'production',NULL); /*!40000 ALTER TABLE `config` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -34,9 +34,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-05-25 11:53:07 +-- Dump completed on 2021-06-22 14:40:02 USE `account`; --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.10-MariaDB, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: account -- ------------------------------------------------------ @@ -58,7 +58,7 @@ USE `account`; LOCK TABLES `role` WRITE; /*!40000 ALTER TABLE `role` DISABLE KEYS */; -INSERT INTO `role` VALUES (1,'employee','Empleado básico',1,'2017-05-19 07:04:58','2017-11-29 10:06:31'),(2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(9,'developer','Desarrolladores del sistema',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(11,'account','Privilegios relacionados con el login',0,'2017-05-19 07:04:58','2017-09-20 17:06:35'),(13,'teamBoss','Jefe de departamento',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Departamento de gerencia',1,'2017-06-01 14:57:02','2017-06-01 14:57:51'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyBoss','Jefe/a del departamento de agencias',1,'2018-01-29 16:44:39','2018-02-23 07:58:53'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42'),(36,'replenisher','Trabajadores de camara',1,'2018-02-16 14:07:10','2019-04-12 05:38:08'),(37,'hr','Gestor/a de recursos humanos',1,'2018-02-22 17:34:53','2018-02-22 17:34:53'),(38,'hrBoss','Jefe/a de recursos humanos',1,'2018-02-22 17:35:09','2018-02-22 17:35:09'),(39,'adminAssistant','Jefe auxiliar administrativo',1,'2018-02-23 10:37:36','2018-02-23 10:38:41'),(40,'handmade','Departamento de confección',1,'2018-02-23 11:14:53','2018-02-23 11:39:12'),(41,'handmadeBoss','Jefe de departamento de confección',1,'2018-02-23 11:15:09','2018-02-23 11:39:26'),(42,'artificial','Departamento de artificial',1,'2018-02-23 11:39:59','2018-02-23 11:39:59'),(43,'artificialBoss','Jefe del departamento de artificial',1,'2018-02-23 11:40:16','2018-02-23 11:40:16'),(44,'accessory','Departamento de complementos',1,'2018-02-23 11:41:12','2018-02-23 11:41:12'),(45,'accessoryBoss','Jefe del departamento de complementos',1,'2018-02-23 11:41:23','2018-02-23 11:41:23'),(47,'cooler','Empleados de cámara',1,'2018-02-23 13:08:18','2018-02-23 13:08:18'),(48,'coolerBoss','Jefe del departamento de cámara',1,'2018-02-23 13:12:01','2018-02-23 13:12:01'),(49,'production','Empleado de producción',1,'2018-02-26 15:28:23','2021-02-12 09:42:35'),(50,'productionBoss','Jefe de producción',1,'2018-02-26 15:34:12','2018-02-26 15:34:12'),(51,'marketing','Departamento de marketing',1,'2018-03-01 07:28:39','2018-03-01 07:28:39'),(52,'marketingBoss','Jefe del departamento de marketing',1,'2018-03-01 07:28:57','2018-03-01 07:28:57'),(53,'insurance','Gestor de seguros de cambio',0,'2018-03-05 07:44:35','2019-02-01 13:47:57'),(54,'itemPicker','Sacador en cámara',1,'2018-03-05 12:08:17','2018-03-05 12:08:17'),(55,'itemPickerBoss','Jefe de sacadores',1,'2018-03-05 12:08:31','2018-03-05 12:08:31'),(56,'delivery','Personal de reparto',1,'2018-05-30 06:07:02','2018-05-30 06:07:02'),(57,'deliveryBoss','Jefe de personal de reparto',1,'2018-05-30 06:07:19','2018-05-30 06:07:19'),(58,'packager','Departamento encajadores',1,'2019-01-21 12:43:45','2019-01-21 12:43:45'),(59,'packagerBoss','Jefe departamento encajadores',1,'2019-01-21 12:44:10','2019-01-21 12:44:10'),(60,'productionAssi','Tareas relacionadas con producción y administración',1,'2019-01-29 13:29:01','2019-01-29 13:29:01'),(61,'replenisherBos','Jefe de Complementos/Camara',1,'2019-07-01 06:44:07','2019-07-01 06:44:07'),(62,'noLogin','Role without login access to MySQL',0,'2019-07-01 06:50:19','2019-07-02 13:42:05'),(64,'balanceSheet','Consulta de Balance',0,'2019-07-16 12:12:08','2019-07-16 12:12:08'),(65,'officeBoss','Jefe de filial',1,'2019-08-02 06:54:26','2019-08-02 06:54:26'),(66,'sysadmin','Administrador de sistema',1,'2019-08-08 06:58:56','2019-08-08 06:58:56'),(67,'adminOfficer','categoria profesional oficial de administración',1,'2020-01-03 08:09:23','2020-01-03 08:09:23'),(69,'coolerAssist','Empleado cámara con permiso compras',1,'2020-02-05 12:36:09','2020-02-05 12:36:09'),(70,'trainee','Alumno de prácticas',1,'2020-03-04 11:00:25','2020-03-04 11:00:25'),(71,'checker','Rol de revisor con privilegios de itemPicker',1,'2020-10-02 10:50:07','2020-10-02 10:50:07'),(72,'claimManager','Personal de reclamaciones',1,'2020-10-13 10:01:32','2020-10-26 07:29:46'),(73,'financial','Departamento de finanzas',1,'2020-11-16 09:30:27','2020-11-16 09:30:27'),(74,'userPhotos','Privilegios para subir fotos de usuario',1,'2021-02-03 10:24:27','2021-02-03 10:24:27'),(75,'catalogPhotos','Privilegios para subir fotos del catálogo',1,'2021-02-03 10:24:27','2021-02-03 10:24:27'),(76,'chat','Rol para utilizar el rocket chat',1,'2020-11-27 13:06:50','2020-12-17 07:49:41'),(100,'root','Rol con todos los privilegios',0,'2018-04-23 14:33:36','2020-11-12 06:50:07'); +INSERT INTO `role` VALUES (1,'employee','Empleado básico',1,'2017-05-19 07:04:58','2017-11-29 10:06:31'),(2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(9,'developer','Desarrolladores del sistema',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(11,'account','Privilegios relacionados con el login',0,'2017-05-19 07:04:58','2017-09-20 17:06:35'),(13,'teamBoss','Jefe de departamento',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Departamento de gerencia',1,'2017-06-01 14:57:02','2017-06-01 14:57:51'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyBoss','Jefe/a del departamento de agencias',1,'2018-01-29 16:44:39','2018-02-23 07:58:53'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42'),(36,'replenisher','Trabajadores de camara',1,'2018-02-16 14:07:10','2019-04-12 05:38:08'),(37,'hr','Gestor/a de recursos humanos',1,'2018-02-22 17:34:53','2018-02-22 17:34:53'),(38,'hrBoss','Jefe/a de recursos humanos',1,'2018-02-22 17:35:09','2018-02-22 17:35:09'),(39,'adminAssistant','Jefe auxiliar administrativo',1,'2018-02-23 10:37:36','2018-02-23 10:38:41'),(40,'handmade','Departamento de confección',1,'2018-02-23 11:14:53','2018-02-23 11:39:12'),(41,'handmadeBoss','Jefe de departamento de confección',1,'2018-02-23 11:15:09','2018-02-23 11:39:26'),(42,'artificial','Departamento de artificial',1,'2018-02-23 11:39:59','2018-02-23 11:39:59'),(43,'artificialBoss','Jefe del departamento de artificial',1,'2018-02-23 11:40:16','2018-02-23 11:40:16'),(44,'accessory','Departamento de complementos',1,'2018-02-23 11:41:12','2018-02-23 11:41:12'),(45,'accessoryBoss','Jefe del departamento de complementos',1,'2018-02-23 11:41:23','2018-02-23 11:41:23'),(47,'cooler','Empleados de cámara',1,'2018-02-23 13:08:18','2018-02-23 13:08:18'),(48,'coolerBoss','Jefe del departamento de cámara',1,'2018-02-23 13:12:01','2018-02-23 13:12:01'),(49,'production','Empleado de producción',1,'2018-02-26 15:28:23','2021-02-12 09:42:35'),(50,'productionBoss','Jefe de producción',1,'2018-02-26 15:34:12','2018-02-26 15:34:12'),(51,'marketing','Departamento de marketing',1,'2018-03-01 07:28:39','2018-03-01 07:28:39'),(52,'marketingBoss','Jefe del departamento de marketing',1,'2018-03-01 07:28:57','2018-03-01 07:28:57'),(53,'insurance','Gestor de seguros de cambio',0,'2018-03-05 07:44:35','2019-02-01 13:47:57'),(54,'itemPicker','Sacador en cámara',1,'2018-03-05 12:08:17','2018-03-05 12:08:17'),(55,'itemPickerBoss','Jefe de sacadores',1,'2018-03-05 12:08:31','2018-03-05 12:08:31'),(56,'delivery','Personal de reparto',1,'2018-05-30 06:07:02','2018-05-30 06:07:02'),(57,'deliveryBoss','Jefe de personal de reparto',1,'2018-05-30 06:07:19','2018-05-30 06:07:19'),(58,'packager','Departamento encajadores',1,'2019-01-21 12:43:45','2019-01-21 12:43:45'),(59,'packagerBoss','Jefe departamento encajadores',1,'2019-01-21 12:44:10','2019-01-21 12:44:10'),(60,'productionAssi','Tareas relacionadas con producción y administración',1,'2019-01-29 13:29:01','2019-01-29 13:29:01'),(61,'replenisherBos','Jefe de Complementos/Camara',1,'2019-07-01 06:44:07','2019-07-01 06:44:07'),(62,'noLogin','Role without login access to MySQL',0,'2019-07-01 06:50:19','2019-07-02 13:42:05'),(64,'balanceSheet','Consulta de Balance',0,'2019-07-16 12:12:08','2019-07-16 12:12:08'),(65,'officeBoss','Jefe de filial',1,'2019-08-02 06:54:26','2019-08-02 06:54:26'),(66,'sysadmin','Administrador de sistema',1,'2019-08-08 06:58:56','2019-08-08 06:58:56'),(67,'adminOfficer','categoria profesional oficial de administración',1,'2020-01-03 08:09:23','2020-01-03 08:09:23'),(69,'coolerAssist','Empleado cámara con permiso compras',1,'2020-02-05 12:36:09','2020-02-05 12:36:09'),(70,'trainee','Alumno de prácticas',1,'2020-03-04 11:00:25','2020-03-04 11:00:25'),(71,'checker','Rol de revisor con privilegios de itemPicker',1,'2020-10-02 10:50:07','2020-10-02 10:50:07'),(72,'claimManager','Personal de reclamaciones',1,'2020-10-13 10:01:32','2020-10-26 07:29:46'),(73,'financial','Departamento de finanzas',1,'2020-11-16 09:30:27','2020-11-16 09:30:27'),(74,'userPhotos','Privilegios para subir fotos de usuario',1,'2021-02-03 10:24:27','2021-02-03 10:24:27'),(75,'catalogPhotos','Privilegios para subir fotos del catálogo',1,'2021-02-03 10:24:27','2021-02-03 10:24:27'),(76,'chat','Rol para utilizar el rocket chat',1,'2020-11-27 13:06:50','2020-12-17 07:49:41'),(100,'root','Rol con todos los privilegios',0,'2018-04-23 14:33:36','2020-11-12 06:50:07'),(101,'buyerBoss','Jefe del departamento de compras',1,'2021-06-16 09:53:17','2021-06-16 09:53:17'); /*!40000 ALTER TABLE `role` ENABLE KEYS */; UNLOCK TABLES; @@ -68,7 +68,7 @@ UNLOCK TABLES; LOCK TABLES `roleInherit` WRITE; /*!40000 ALTER TABLE `roleInherit` DISABLE KEYS */; -INSERT INTO `roleInherit` VALUES (1,1,2),(2,1,3),(3,1,70),(4,2,11),(5,3,11),(6,5,1),(7,5,21),(8,5,33),(124,5,76),(123,9,76),(9,9,100),(10,11,6),(11,13,1),(12,15,35),(143,15,49),(13,15,57),(114,15,76),(14,16,13),(15,16,15),(127,16,76),(16,17,20),(17,17,37),(18,17,39),(19,17,64),(145,17,67),(136,17,76),(20,18,1),(132,18,76),(21,19,21),(22,20,13),(23,20,16),(24,20,65),(134,20,76),(25,21,13),(26,21,18),(27,21,53),(131,21,76),(28,22,13),(29,22,21),(30,30,5),(31,30,20),(32,30,22),(33,30,53),(34,30,64),(118,30,76),(35,31,1),(36,32,1),(37,34,1),(38,34,13),(39,34,33),(40,35,1),(142,35,75),(129,35,76),(41,36,44),(42,36,47),(43,37,1),(139,37,74),(125,37,76),(44,38,37),(45,38,64),(126,38,76),(46,39,5),(47,39,21),(48,39,57),(115,39,76),(49,40,1),(50,40,49),(51,41,13),(52,41,35),(53,41,40),(135,41,76),(54,42,35),(55,42,49),(128,42,76),(56,43,13),(57,43,42),(58,44,1),(59,45,13),(60,45,44),(61,47,1),(62,48,13),(63,48,47),(64,49,36),(65,49,58),(66,50,13),(67,50,21),(68,50,35),(69,50,49),(70,50,57),(71,50,59),(133,50,76),(72,51,1),(140,51,74),(141,51,75),(73,52,13),(74,52,19),(75,52,35),(76,52,51),(137,52,76),(77,53,1),(78,54,1),(79,55,13),(80,55,54),(81,56,1),(82,57,13),(83,57,56),(138,57,76),(84,58,1),(85,59,13),(109,59,50),(87,60,5),(88,60,37),(89,60,50),(90,60,57),(130,60,76),(91,61,13),(92,61,36),(93,65,19),(94,65,35),(95,65,50),(117,65,76),(122,66,76),(96,66,100),(97,67,5),(98,67,37),(99,69,35),(100,69,47),(101,70,11),(144,70,76),(102,71,1),(103,71,58),(104,72,13),(105,72,18),(106,73,5),(108,73,19),(107,73,64); +INSERT INTO `roleInherit` VALUES (1,1,2),(2,1,3),(3,1,70),(4,2,11),(5,3,11),(6,5,1),(7,5,21),(8,5,33),(124,5,76),(123,9,76),(9,9,100),(10,11,6),(11,13,1),(12,15,35),(143,15,49),(13,15,57),(114,15,76),(14,16,13),(15,16,15),(127,16,76),(16,17,20),(17,17,37),(18,17,39),(19,17,64),(145,17,67),(136,17,76),(20,18,1),(132,18,76),(21,19,21),(22,20,13),(23,20,16),(24,20,65),(134,20,76),(25,21,13),(26,21,18),(27,21,53),(131,21,76),(28,22,13),(29,22,21),(30,30,5),(31,30,20),(32,30,22),(33,30,53),(34,30,64),(118,30,76),(35,31,1),(36,32,1),(37,34,1),(38,34,13),(39,34,33),(40,35,1),(142,35,75),(129,35,76),(41,36,44),(42,36,47),(43,37,1),(139,37,74),(125,37,76),(146,38,13),(44,38,37),(45,38,64),(126,38,76),(46,39,5),(47,39,21),(48,39,57),(115,39,76),(49,40,1),(50,40,49),(51,41,13),(52,41,35),(53,41,40),(135,41,76),(54,42,35),(55,42,49),(128,42,76),(56,43,13),(57,43,42),(58,44,1),(59,45,13),(60,45,44),(61,47,1),(62,48,13),(63,48,47),(64,49,36),(65,49,58),(66,50,13),(67,50,21),(68,50,35),(69,50,49),(70,50,57),(71,50,59),(133,50,76),(72,51,1),(140,51,74),(141,51,75),(73,52,13),(74,52,19),(75,52,35),(76,52,51),(137,52,76),(77,53,1),(78,54,1),(79,55,13),(80,55,54),(81,56,1),(82,57,13),(83,57,56),(138,57,76),(84,58,1),(85,59,13),(109,59,50),(87,60,5),(88,60,37),(89,60,50),(90,60,57),(130,60,76),(91,61,13),(92,61,36),(93,65,19),(94,65,35),(95,65,50),(117,65,76),(122,66,76),(96,66,100),(97,67,5),(98,67,37),(99,69,35),(100,69,47),(101,70,11),(144,70,76),(102,71,1),(103,71,58),(104,72,13),(105,72,18),(106,73,5),(108,73,19),(107,73,64),(148,101,13),(147,101,35); /*!40000 ALTER TABLE `roleInherit` ENABLE KEYS */; UNLOCK TABLES; @@ -78,7 +78,7 @@ UNLOCK TABLES; LOCK TABLES `roleRole` WRITE; /*!40000 ALTER TABLE `roleRole` DISABLE KEYS */; -INSERT INTO `roleRole` VALUES (37416,1,1),(37417,1,2),(37418,1,3),(37422,1,6),(37421,1,11),(37419,1,70),(37420,1,76),(37334,2,2),(37336,2,6),(37335,2,11),(37229,3,3),(37231,3,6),(37230,3,11),(37201,5,1),(37208,5,2),(37207,5,3),(37200,5,5),(37212,5,6),(37211,5,11),(37205,5,13),(37209,5,18),(37202,5,21),(37203,5,33),(37210,5,53),(37206,5,70),(37204,5,76),(37487,6,6),(37380,9,1),(37377,9,2),(37365,9,3),(37363,9,5),(37385,9,6),(37355,9,9),(37360,9,11),(37412,9,13),(37394,9,15),(37395,9,16),(37362,9,17),(37410,9,18),(37409,9,19),(37396,9,20),(37408,9,21),(37413,9,22),(37383,9,30),(37384,9,31),(37381,9,32),(37391,9,33),(37366,9,34),(37370,9,35),(37406,9,36),(37388,9,37),(37389,9,38),(37361,9,39),(37386,9,40),(37387,9,41),(37367,9,42),(37368,9,43),(37358,9,44),(37359,9,45),(37374,9,47),(37376,9,48),(37403,9,49),(37405,9,50),(37397,9,51),(37398,9,52),(37390,9,53),(37392,9,54),(37393,9,55),(37378,9,56),(37379,9,57),(37401,9,58),(37402,9,59),(37404,9,60),(37407,9,61),(37399,9,62),(37369,9,64),(37400,9,65),(37411,9,66),(37364,9,67),(37375,9,69),(37414,9,70),(37372,9,71),(37373,9,72),(37382,9,73),(37415,9,74),(37371,9,75),(37356,9,76),(37357,9,100),(37148,11,6),(37147,11,11),(37948,13,1),(37949,13,2),(37950,13,3),(37954,13,6),(37953,13,11),(37947,13,13),(37951,13,70),(37952,13,76),(37573,15,1),(37580,15,2),(37579,15,3),(37582,15,6),(37581,15,11),(37574,15,13),(37565,15,15),(37566,15,35),(37571,15,36),(37577,15,44),(37576,15,47),(37567,15,49),(37575,15,56),(37568,15,57),(37570,15,58),(37578,15,70),(37572,15,75),(37569,15,76),(37589,16,1),(37594,16,2),(37593,16,3),(37601,16,6),(37600,16,11),(37584,16,13),(37585,16,15),(37583,16,16),(37588,16,35),(37595,16,36),(37599,16,44),(37598,16,47),(37587,16,49),(37597,16,56),(37590,16,57),(37596,16,58),(37592,16,70),(37591,16,75),(37586,16,76),(37174,17,1),(37183,17,2),(37182,17,3),(37172,17,5),(37195,17,6),(37191,17,11),(37177,17,13),(37187,17,15),(37176,17,16),(37165,17,17),(37188,17,18),(37186,17,19),(37166,17,20),(37178,17,21),(37180,17,33),(37185,17,35),(37197,17,36),(37167,17,37),(37168,17,39),(37199,17,44),(37198,17,47),(37194,17,49),(37184,17,50),(37189,17,53),(37190,17,56),(37179,17,57),(37196,17,58),(37192,17,59),(37169,17,64),(37175,17,65),(37170,17,67),(37181,17,70),(37173,17,74),(37193,17,75),(37171,17,76),(37879,18,1),(37882,18,2),(37881,18,3),(37885,18,6),(37884,18,11),(37878,18,18),(37883,18,70),(37880,18,76),(37872,19,1),(37875,19,2),(37874,19,3),(37877,19,6),(37876,19,11),(37868,19,13),(37869,19,18),(37866,19,19),(37867,19,21),(37870,19,53),(37873,19,70),(37871,19,76),(37610,20,1),(37616,20,2),(37615,20,3),(37628,20,6),(37625,20,11),(37603,20,13),(37609,20,15),(37604,20,16),(37621,20,18),(37608,20,19),(37602,20,20),(37617,20,21),(37607,20,35),(37624,20,36),(37627,20,44),(37626,20,47),(37613,20,49),(37611,20,50),(37620,20,53),(37622,20,56),(37612,20,57),(37623,20,58),(37619,20,59),(37605,20,65),(37614,20,70),(37618,20,75),(37606,20,76),(37860,21,1),(37863,21,2),(37862,21,3),(37865,21,6),(37864,21,11),(37856,21,13),(37857,21,18),(37855,21,21),(37858,21,53),(37861,21,70),(37859,21,76),(37959,22,1),(37964,22,2),(37963,22,3),(37966,22,6),(37965,22,11),(37956,22,13),(37958,22,18),(37957,22,21),(37955,22,22),(37960,22,53),(37962,22,70),(37961,22,76),(37459,30,1),(37465,30,2),(37464,30,3),(37448,30,5),(37476,30,6),(37472,30,11),(37456,30,13),(37461,30,15),(37455,30,16),(37462,30,18),(37460,30,19),(37449,30,20),(37458,30,21),(37450,30,22),(37447,30,30),(37457,30,33),(37466,30,35),(37475,30,36),(37478,30,44),(37477,30,47),(37471,30,49),(37467,30,50),(37451,30,53),(37473,30,56),(37470,30,57),(37474,30,58),(37468,30,59),(37452,30,64),(37454,30,65),(37463,30,70),(37469,30,75),(37453,30,76),(37480,31,1),(37481,31,2),(37482,31,3),(37486,31,6),(37485,31,11),(37479,31,31),(37483,31,70),(37484,31,76),(37424,32,1),(37425,32,2),(37426,32,3),(37430,32,6),(37429,32,11),(37423,32,32),(37427,32,70),(37428,32,76),(37546,33,33),(37233,34,1),(37238,34,2),(37237,34,3),(37241,34,6),(37240,34,11),(37234,34,13),(37235,34,33),(37232,34,34),(37236,34,70),(37239,34,76),(37276,35,1),(37281,35,2),(37280,35,3),(37283,35,6),(37282,35,11),(37275,35,35),(37279,35,70),(37277,35,75),(37278,35,76),(37775,36,1),(37777,36,2),(37776,36,3),(37781,36,6),(37780,36,11),(37772,36,36),(37773,36,44),(37774,36,47),(37778,36,70),(37779,36,76),(37519,37,1),(37524,37,2),(37523,37,3),(37526,37,6),(37525,37,11),(37518,37,37),(37522,37,70),(37520,37,74),(37521,37,76),(37532,38,1),(37535,38,2),(37534,38,3),(37537,38,6),(37536,38,11),(37528,38,37),(37527,38,38),(37529,38,64),(37533,38,70),(37531,38,74),(37530,38,76),(37157,39,1),(37162,39,2),(37161,39,3),(37150,39,5),(37164,39,6),(37163,39,11),(37155,39,13),(37154,39,18),(37151,39,21),(37156,39,33),(37149,39,39),(37158,39,53),(37159,39,56),(37152,39,57),(37160,39,70),(37153,39,76),(37489,40,1),(37492,40,2),(37491,40,3),(37500,40,6),(37499,40,11),(37494,40,36),(37488,40,40),(37497,40,44),(37496,40,47),(37490,40,49),(37495,40,58),(37493,40,70),(37498,40,76),(37508,41,1),(37512,41,2),(37511,41,3),(37517,41,6),(37516,41,11),(37502,41,13),(37503,41,35),(37509,41,36),(37504,41,40),(37501,41,41),(37515,41,44),(37514,41,47),(37506,41,49),(37513,41,58),(37510,41,70),(37507,41,75),(37505,41,76),(37248,42,1),(37253,42,2),(37252,42,3),(37256,42,6),(37255,42,11),(37243,42,35),(37246,42,36),(37242,42,42),(37250,42,44),(37254,42,47),(37244,42,49),(37249,42,58),(37251,42,70),(37247,42,75),(37245,42,76),(37261,43,1),(37267,43,2),(37266,43,3),(37273,43,6),(37272,43,11),(37258,43,13),(37260,43,35),(37268,43,36),(37259,43,42),(37257,43,43),(37271,43,44),(37270,43,47),(37262,43,49),(37269,43,58),(37265,43,70),(37264,43,75),(37263,43,76),(37130,44,1),(37131,44,2),(37132,44,3),(37136,44,6),(37135,44,11),(37129,44,44),(37133,44,70),(37134,44,76),(37140,45,1),(37142,45,2),(37141,45,3),(37146,45,6),(37145,45,11),(37138,45,13),(37139,45,44),(37137,45,45),(37143,45,70),(37144,45,76),(37306,47,1),(37307,47,2),(37308,47,3),(37312,47,6),(37311,47,11),(37305,47,47),(37309,47,70),(37310,47,76),(37327,48,1),(37329,48,2),(37328,48,3),(37333,48,6),(37332,48,11),(37325,48,13),(37326,48,47),(37324,48,48),(37330,48,70),(37331,48,76),(37716,49,1),(37719,49,2),(37718,49,3),(37722,49,6),(37721,49,11),(37712,49,36),(37715,49,44),(37714,49,47),(37711,49,49),(37713,49,58),(37717,49,70),(37720,49,76),(37764,50,1),(37769,50,2),(37768,50,3),(37771,50,6),(37770,50,11),(37751,50,13),(37763,50,18),(37752,50,21),(37753,50,35),(37760,50,36),(37766,50,44),(37765,50,47),(37754,50,49),(37750,50,50),(37762,50,53),(37758,50,56),(37755,50,57),(37759,50,58),(37756,50,59),(37767,50,70),(37761,50,75),(37757,50,76),(37630,51,1),(37635,51,2),(37634,51,3),(37638,51,6),(37637,51,11),(37629,51,51),(37633,51,70),(37631,51,74),(37632,51,75),(37636,51,76),(37648,52,1),(37653,52,2),(37652,52,3),(37655,52,6),(37654,52,11),(37640,52,13),(37650,52,18),(37641,52,19),(37647,52,21),(37642,52,35),(37643,52,51),(37639,52,52),(37649,52,53),(37651,52,70),(37645,52,74),(37646,52,75),(37644,52,76),(37539,53,1),(37540,53,2),(37541,53,3),(37545,53,6),(37544,53,11),(37538,53,53),(37542,53,70),(37543,53,76),(37548,54,1),(37549,54,2),(37550,54,3),(37554,54,6),(37553,54,11),(37547,54,54),(37551,54,70),(37552,54,76),(37558,55,1),(37560,55,2),(37559,55,3),(37564,55,6),(37563,55,11),(37556,55,13),(37557,55,54),(37555,55,55),(37561,55,70),(37562,55,76),(37338,56,1),(37339,56,2),(37340,56,3),(37344,56,6),(37343,56,11),(37337,56,56),(37341,56,70),(37342,56,76),(37349,57,1),(37352,57,2),(37351,57,3),(37354,57,6),(37353,57,11),(37346,57,13),(37347,57,56),(37345,57,57),(37350,57,70),(37348,57,76),(37682,58,1),(37683,58,2),(37684,58,3),(37688,58,6),(37687,58,11),(37681,58,58),(37685,58,70),(37686,58,76),(37693,59,1),(37703,59,2),(37702,59,3),(37710,59,6),(37709,59,11),(37690,59,13),(37700,59,18),(37692,59,21),(37694,59,35),(37704,59,36),(37708,59,44),(37707,59,47),(37695,59,49),(37691,59,50),(37699,59,53),(37706,59,56),(37696,59,57),(37705,59,58),(37689,59,59),(37701,59,70),(37698,59,75),(37697,59,76),(37733,60,1),(37745,60,2),(37744,60,3),(37724,60,5),(37749,60,6),(37748,60,11),(37729,60,13),(37742,60,18),(37732,60,21),(37731,60,33),(37734,60,35),(37739,60,36),(37725,60,37),(37747,60,44),(37746,60,47),(37735,60,49),(37726,60,50),(37741,60,53),(37737,60,56),(37727,60,57),(37738,60,58),(37736,60,59),(37723,60,60),(37743,60,70),(37730,60,74),(37740,60,75),(37728,60,76),(37786,61,1),(37790,61,2),(37789,61,3),(37793,61,6),(37792,61,11),(37783,61,13),(37784,61,36),(37785,61,44),(37787,61,47),(37782,61,61),(37788,61,70),(37791,61,76),(37656,62,62),(37274,64,64),(37664,65,1),(37673,65,2),(37672,65,3),(37680,65,6),(37679,65,11),(37662,65,13),(37675,65,18),(37658,65,19),(37665,65,21),(37659,65,35),(37670,65,36),(37678,65,44),(37677,65,47),(37666,65,49),(37660,65,50),(37674,65,53),(37676,65,56),(37667,65,57),(37669,65,58),(37668,65,59),(37657,65,65),(37671,65,70),(37663,65,75),(37661,65,76),(37912,66,1),(37908,66,2),(37896,66,3),(37894,66,5),(37917,66,6),(37911,66,9),(37891,66,11),(37943,66,13),(37926,66,15),(37927,66,16),(37893,66,17),(37942,66,18),(37941,66,19),(37928,66,20),(37940,66,21),(37944,66,22),(37915,66,30),(37916,66,31),(37913,66,32),(37923,66,33),(37897,66,34),(37901,66,35),(37938,66,36),(37920,66,37),(37921,66,38),(37892,66,39),(37918,66,40),(37919,66,41),(37898,66,42),(37899,66,43),(37889,66,44),(37890,66,45),(37905,66,47),(37907,66,48),(37935,66,49),(37937,66,50),(37929,66,51),(37930,66,52),(37922,66,53),(37924,66,54),(37925,66,55),(37909,66,56),(37910,66,57),(37933,66,58),(37934,66,59),(37936,66,60),(37939,66,61),(37931,66,62),(37900,66,64),(37932,66,65),(37886,66,66),(37895,66,67),(37906,66,69),(37945,66,70),(37903,66,71),(37904,66,72),(37914,66,73),(37946,66,74),(37902,66,75),(37887,66,76),(37888,66,100),(37217,67,1),(37225,67,2),(37224,67,3),(37214,67,5),(37228,67,6),(37227,67,11),(37222,67,13),(37221,67,18),(37216,67,21),(37218,67,33),(37215,67,37),(37226,67,53),(37213,67,67),(37223,67,70),(37220,67,74),(37219,67,76),(37317,69,1),(37321,69,2),(37320,69,3),(37323,69,6),(37322,69,11),(37314,69,35),(37315,69,47),(37313,69,69),(37319,69,70),(37316,69,75),(37318,69,76),(37970,70,6),(37968,70,11),(37967,70,70),(37969,70,76),(37287,71,1),(37290,71,2),(37289,71,3),(37294,71,6),(37293,71,11),(37288,71,58),(37291,71,70),(37286,71,71),(37292,71,76),(37299,72,1),(37301,72,2),(37300,72,3),(37304,72,6),(37303,72,11),(37296,72,13),(37297,72,18),(37302,72,70),(37295,72,72),(37298,72,76),(37437,73,1),(37442,73,2),(37441,73,3),(37432,73,5),(37446,73,6),(37445,73,11),(37439,73,13),(37443,73,18),(37433,73,19),(37436,73,21),(37435,73,33),(37444,73,53),(37434,73,64),(37440,73,70),(37431,73,73),(37438,73,76),(37971,74,74),(37284,75,75),(37285,76,76),(37819,100,1),(37815,100,2),(37802,100,3),(37800,100,5),(37824,100,6),(37818,100,9),(37797,100,11),(37851,100,13),(37833,100,15),(37834,100,16),(37799,100,17),(37849,100,18),(37848,100,19),(37835,100,20),(37847,100,21),(37852,100,22),(37822,100,30),(37823,100,31),(37820,100,32),(37830,100,33),(37803,100,34),(37807,100,35),(37845,100,36),(37827,100,37),(37828,100,38),(37798,100,39),(37825,100,40),(37826,100,41),(37804,100,42),(37805,100,43),(37795,100,44),(37796,100,45),(37812,100,47),(37814,100,48),(37842,100,49),(37844,100,50),(37836,100,51),(37837,100,52),(37829,100,53),(37831,100,54),(37832,100,55),(37816,100,56),(37817,100,57),(37840,100,58),(37841,100,59),(37843,100,60),(37846,100,61),(37838,100,62),(37806,100,64),(37839,100,65),(37850,100,66),(37801,100,67),(37813,100,69),(37853,100,70),(37810,100,71),(37811,100,72),(37821,100,73),(37854,100,74),(37808,100,75),(37809,100,76),(37794,100,100); +INSERT INTO `roleRole` VALUES (39114,1,1),(39115,1,2),(39116,1,3),(39120,1,6),(39119,1,11),(39117,1,70),(39118,1,76),(39031,2,2),(39033,2,6),(39032,2,11),(38916,3,3),(38918,3,6),(38917,3,11),(38888,5,1),(38895,5,2),(38894,5,3),(38887,5,5),(38899,5,6),(38898,5,11),(38892,5,13),(38896,5,18),(38889,5,21),(38890,5,33),(38897,5,53),(38893,5,70),(38891,5,76),(39185,6,6),(39078,9,1),(39075,9,2),(39062,9,3),(39060,9,5),(39083,9,6),(39052,9,9),(39057,9,11),(39110,9,13),(39092,9,15),(39093,9,16),(39059,9,17),(39108,9,18),(39107,9,19),(39094,9,20),(39106,9,21),(39111,9,22),(39081,9,30),(39082,9,31),(39079,9,32),(39089,9,33),(39063,9,34),(39067,9,35),(39104,9,36),(39086,9,37),(39087,9,38),(39058,9,39),(39084,9,40),(39085,9,41),(39064,9,42),(39065,9,43),(39055,9,44),(39056,9,45),(39072,9,47),(39074,9,48),(39101,9,49),(39103,9,50),(39095,9,51),(39096,9,52),(39088,9,53),(39090,9,54),(39091,9,55),(39076,9,56),(39077,9,57),(39099,9,58),(39100,9,59),(39102,9,60),(39105,9,61),(39097,9,62),(39066,9,64),(39098,9,65),(39109,9,66),(39061,9,67),(39073,9,69),(39112,9,70),(39070,9,71),(39071,9,72),(39080,9,73),(39113,9,74),(39069,9,75),(39053,9,76),(39054,9,100),(39068,9,101),(38835,11,6),(38834,11,11),(39649,13,1),(39650,13,2),(39651,13,3),(39655,13,6),(39654,13,11),(39648,13,13),(39652,13,70),(39653,13,76),(39272,15,1),(39279,15,2),(39278,15,3),(39281,15,6),(39280,15,11),(39273,15,13),(39264,15,15),(39265,15,35),(39270,15,36),(39276,15,44),(39275,15,47),(39266,15,49),(39274,15,56),(39267,15,57),(39269,15,58),(39277,15,70),(39271,15,75),(39268,15,76),(39288,16,1),(39293,16,2),(39292,16,3),(39300,16,6),(39299,16,11),(39283,16,13),(39284,16,15),(39282,16,16),(39287,16,35),(39294,16,36),(39298,16,44),(39297,16,47),(39286,16,49),(39296,16,56),(39289,16,57),(39295,16,58),(39291,16,70),(39290,16,75),(39285,16,76),(38861,17,1),(38870,17,2),(38869,17,3),(38859,17,5),(38882,17,6),(38878,17,11),(38864,17,13),(38874,17,15),(38863,17,16),(38852,17,17),(38875,17,18),(38873,17,19),(38853,17,20),(38865,17,21),(38867,17,33),(38872,17,35),(38884,17,36),(38854,17,37),(38855,17,39),(38886,17,44),(38885,17,47),(38881,17,49),(38871,17,50),(38876,17,53),(38877,17,56),(38866,17,57),(38883,17,58),(38879,17,59),(38856,17,64),(38862,17,65),(38857,17,67),(38868,17,70),(38860,17,74),(38880,17,75),(38858,17,76),(39579,18,1),(39582,18,2),(39581,18,3),(39585,18,6),(39584,18,11),(39578,18,18),(39583,18,70),(39580,18,76),(39572,19,1),(39575,19,2),(39574,19,3),(39577,19,6),(39576,19,11),(39568,19,13),(39569,19,18),(39566,19,19),(39567,19,21),(39570,19,53),(39573,19,70),(39571,19,76),(39309,20,1),(39315,20,2),(39314,20,3),(39327,20,6),(39324,20,11),(39302,20,13),(39308,20,15),(39303,20,16),(39320,20,18),(39307,20,19),(39301,20,20),(39316,20,21),(39306,20,35),(39323,20,36),(39326,20,44),(39325,20,47),(39312,20,49),(39310,20,50),(39319,20,53),(39321,20,56),(39311,20,57),(39322,20,58),(39318,20,59),(39304,20,65),(39313,20,70),(39317,20,75),(39305,20,76),(39560,21,1),(39563,21,2),(39562,21,3),(39565,21,6),(39564,21,11),(39556,21,13),(39557,21,18),(39555,21,21),(39558,21,53),(39561,21,70),(39559,21,76),(39660,22,1),(39665,22,2),(39664,22,3),(39667,22,6),(39666,22,11),(39657,22,13),(39659,22,18),(39658,22,21),(39656,22,22),(39661,22,53),(39663,22,70),(39662,22,76),(39157,30,1),(39163,30,2),(39162,30,3),(39146,30,5),(39174,30,6),(39170,30,11),(39154,30,13),(39159,30,15),(39153,30,16),(39160,30,18),(39158,30,19),(39147,30,20),(39156,30,21),(39148,30,22),(39145,30,30),(39155,30,33),(39164,30,35),(39173,30,36),(39176,30,44),(39175,30,47),(39169,30,49),(39165,30,50),(39149,30,53),(39171,30,56),(39168,30,57),(39172,30,58),(39166,30,59),(39150,30,64),(39152,30,65),(39161,30,70),(39167,30,75),(39151,30,76),(39178,31,1),(39179,31,2),(39180,31,3),(39184,31,6),(39183,31,11),(39177,31,31),(39181,31,70),(39182,31,76),(39122,32,1),(39123,32,2),(39124,32,3),(39128,32,6),(39127,32,11),(39121,32,32),(39125,32,70),(39126,32,76),(39245,33,33),(38920,34,1),(38925,34,2),(38924,34,3),(38928,34,6),(38927,34,11),(38921,34,13),(38922,34,33),(38919,34,34),(38923,34,70),(38926,34,76),(38963,35,1),(38968,35,2),(38967,35,3),(38970,35,6),(38969,35,11),(38962,35,35),(38966,35,70),(38964,35,75),(38965,35,76),(39474,36,1),(39476,36,2),(39475,36,3),(39480,36,6),(39479,36,11),(39471,36,36),(39472,36,44),(39473,36,47),(39477,36,70),(39478,36,76),(39217,37,1),(39222,37,2),(39221,37,3),(39224,37,6),(39223,37,11),(39216,37,37),(39220,37,70),(39218,37,74),(39219,37,76),(39231,38,1),(39234,38,2),(39233,38,3),(39236,38,6),(39235,38,11),(39226,38,13),(39227,38,37),(39225,38,38),(39228,38,64),(39232,38,70),(39230,38,74),(39229,38,76),(38844,39,1),(38849,39,2),(38848,39,3),(38837,39,5),(38851,39,6),(38850,39,11),(38842,39,13),(38841,39,18),(38838,39,21),(38843,39,33),(38836,39,39),(38845,39,53),(38846,39,56),(38839,39,57),(38847,39,70),(38840,39,76),(39187,40,1),(39190,40,2),(39189,40,3),(39198,40,6),(39197,40,11),(39192,40,36),(39186,40,40),(39195,40,44),(39194,40,47),(39188,40,49),(39193,40,58),(39191,40,70),(39196,40,76),(39206,41,1),(39210,41,2),(39209,41,3),(39215,41,6),(39214,41,11),(39200,41,13),(39201,41,35),(39207,41,36),(39202,41,40),(39199,41,41),(39213,41,44),(39212,41,47),(39204,41,49),(39211,41,58),(39208,41,70),(39205,41,75),(39203,41,76),(38935,42,1),(38940,42,2),(38939,42,3),(38943,42,6),(38942,42,11),(38930,42,35),(38933,42,36),(38929,42,42),(38937,42,44),(38941,42,47),(38931,42,49),(38936,42,58),(38938,42,70),(38934,42,75),(38932,42,76),(38948,43,1),(38954,43,2),(38953,43,3),(38960,43,6),(38959,43,11),(38945,43,13),(38947,43,35),(38955,43,36),(38946,43,42),(38944,43,43),(38958,43,44),(38957,43,47),(38949,43,49),(38956,43,58),(38952,43,70),(38951,43,75),(38950,43,76),(38817,44,1),(38818,44,2),(38819,44,3),(38823,44,6),(38822,44,11),(38816,44,44),(38820,44,70),(38821,44,76),(38827,45,1),(38829,45,2),(38828,45,3),(38833,45,6),(38832,45,11),(38825,45,13),(38826,45,44),(38824,45,45),(38830,45,70),(38831,45,76),(39003,47,1),(39004,47,2),(39005,47,3),(39009,47,6),(39008,47,11),(39002,47,47),(39006,47,70),(39007,47,76),(39024,48,1),(39026,48,2),(39025,48,3),(39030,48,6),(39029,48,11),(39022,48,13),(39023,48,47),(39021,48,48),(39027,48,70),(39028,48,76),(39415,49,1),(39418,49,2),(39417,49,3),(39421,49,6),(39420,49,11),(39411,49,36),(39414,49,44),(39413,49,47),(39410,49,49),(39412,49,58),(39416,49,70),(39419,49,76),(39463,50,1),(39468,50,2),(39467,50,3),(39470,50,6),(39469,50,11),(39450,50,13),(39462,50,18),(39451,50,21),(39452,50,35),(39459,50,36),(39465,50,44),(39464,50,47),(39453,50,49),(39449,50,50),(39461,50,53),(39457,50,56),(39454,50,57),(39458,50,58),(39455,50,59),(39466,50,70),(39460,50,75),(39456,50,76),(39329,51,1),(39334,51,2),(39333,51,3),(39337,51,6),(39336,51,11),(39328,51,51),(39332,51,70),(39330,51,74),(39331,51,75),(39335,51,76),(39347,52,1),(39352,52,2),(39351,52,3),(39354,52,6),(39353,52,11),(39339,52,13),(39349,52,18),(39340,52,19),(39346,52,21),(39341,52,35),(39342,52,51),(39338,52,52),(39348,52,53),(39350,52,70),(39344,52,74),(39345,52,75),(39343,52,76),(39238,53,1),(39239,53,2),(39240,53,3),(39244,53,6),(39243,53,11),(39237,53,53),(39241,53,70),(39242,53,76),(39247,54,1),(39248,54,2),(39249,54,3),(39253,54,6),(39252,54,11),(39246,54,54),(39250,54,70),(39251,54,76),(39257,55,1),(39259,55,2),(39258,55,3),(39263,55,6),(39262,55,11),(39255,55,13),(39256,55,54),(39254,55,55),(39260,55,70),(39261,55,76),(39035,56,1),(39036,56,2),(39037,56,3),(39041,56,6),(39040,56,11),(39034,56,56),(39038,56,70),(39039,56,76),(39046,57,1),(39049,57,2),(39048,57,3),(39051,57,6),(39050,57,11),(39043,57,13),(39044,57,56),(39042,57,57),(39047,57,70),(39045,57,76),(39381,58,1),(39382,58,2),(39383,58,3),(39387,58,6),(39386,58,11),(39380,58,58),(39384,58,70),(39385,58,76),(39392,59,1),(39402,59,2),(39401,59,3),(39409,59,6),(39408,59,11),(39389,59,13),(39399,59,18),(39391,59,21),(39393,59,35),(39403,59,36),(39407,59,44),(39406,59,47),(39394,59,49),(39390,59,50),(39398,59,53),(39405,59,56),(39395,59,57),(39404,59,58),(39388,59,59),(39400,59,70),(39397,59,75),(39396,59,76),(39432,60,1),(39444,60,2),(39443,60,3),(39423,60,5),(39448,60,6),(39447,60,11),(39428,60,13),(39441,60,18),(39431,60,21),(39430,60,33),(39433,60,35),(39438,60,36),(39424,60,37),(39446,60,44),(39445,60,47),(39434,60,49),(39425,60,50),(39440,60,53),(39436,60,56),(39426,60,57),(39437,60,58),(39435,60,59),(39422,60,60),(39442,60,70),(39429,60,74),(39439,60,75),(39427,60,76),(39485,61,1),(39489,61,2),(39488,61,3),(39492,61,6),(39491,61,11),(39482,61,13),(39483,61,36),(39484,61,44),(39486,61,47),(39481,61,61),(39487,61,70),(39490,61,76),(39355,62,62),(38961,64,64),(39363,65,1),(39372,65,2),(39371,65,3),(39379,65,6),(39378,65,11),(39361,65,13),(39374,65,18),(39357,65,19),(39364,65,21),(39358,65,35),(39369,65,36),(39377,65,44),(39376,65,47),(39365,65,49),(39359,65,50),(39373,65,53),(39375,65,56),(39366,65,57),(39368,65,58),(39367,65,59),(39356,65,65),(39370,65,70),(39362,65,75),(39360,65,76),(39613,66,1),(39609,66,2),(39596,66,3),(39594,66,5),(39618,66,6),(39612,66,9),(39591,66,11),(39644,66,13),(39627,66,15),(39628,66,16),(39593,66,17),(39643,66,18),(39642,66,19),(39629,66,20),(39641,66,21),(39645,66,22),(39616,66,30),(39617,66,31),(39614,66,32),(39624,66,33),(39597,66,34),(39601,66,35),(39639,66,36),(39621,66,37),(39622,66,38),(39592,66,39),(39619,66,40),(39620,66,41),(39598,66,42),(39599,66,43),(39589,66,44),(39590,66,45),(39606,66,47),(39608,66,48),(39636,66,49),(39638,66,50),(39630,66,51),(39631,66,52),(39623,66,53),(39625,66,54),(39626,66,55),(39610,66,56),(39611,66,57),(39634,66,58),(39635,66,59),(39637,66,60),(39640,66,61),(39632,66,62),(39600,66,64),(39633,66,65),(39586,66,66),(39595,66,67),(39607,66,69),(39646,66,70),(39604,66,71),(39605,66,72),(39615,66,73),(39647,66,74),(39603,66,75),(39587,66,76),(39588,66,100),(39602,66,101),(38904,67,1),(38912,67,2),(38911,67,3),(38901,67,5),(38915,67,6),(38914,67,11),(38909,67,13),(38908,67,18),(38903,67,21),(38905,67,33),(38902,67,37),(38913,67,53),(38900,67,67),(38910,67,70),(38907,67,74),(38906,67,76),(39014,69,1),(39018,69,2),(39017,69,3),(39020,69,6),(39019,69,11),(39011,69,35),(39012,69,47),(39010,69,69),(39016,69,70),(39013,69,75),(39015,69,76),(39671,70,6),(39669,70,11),(39668,70,70),(39670,70,76),(38984,71,1),(38987,71,2),(38986,71,3),(38991,71,6),(38990,71,11),(38985,71,58),(38988,71,70),(38983,71,71),(38989,71,76),(38996,72,1),(38998,72,2),(38997,72,3),(39001,72,6),(39000,72,11),(38993,72,13),(38994,72,18),(38999,72,70),(38992,72,72),(38995,72,76),(39135,73,1),(39140,73,2),(39139,73,3),(39130,73,5),(39144,73,6),(39143,73,11),(39137,73,13),(39141,73,18),(39131,73,19),(39134,73,21),(39133,73,33),(39142,73,53),(39132,73,64),(39138,73,70),(39129,73,73),(39136,73,76),(39672,74,74),(38981,75,75),(38982,76,76),(39519,100,1),(39515,100,2),(39501,100,3),(39499,100,5),(39524,100,6),(39518,100,9),(39496,100,11),(39551,100,13),(39533,100,15),(39534,100,16),(39498,100,17),(39549,100,18),(39548,100,19),(39535,100,20),(39547,100,21),(39552,100,22),(39522,100,30),(39523,100,31),(39520,100,32),(39530,100,33),(39502,100,34),(39506,100,35),(39545,100,36),(39527,100,37),(39528,100,38),(39497,100,39),(39525,100,40),(39526,100,41),(39503,100,42),(39504,100,43),(39494,100,44),(39495,100,45),(39512,100,47),(39514,100,48),(39542,100,49),(39544,100,50),(39536,100,51),(39537,100,52),(39529,100,53),(39531,100,54),(39532,100,55),(39516,100,56),(39517,100,57),(39540,100,58),(39541,100,59),(39543,100,60),(39546,100,61),(39538,100,62),(39505,100,64),(39539,100,65),(39550,100,66),(39500,100,67),(39513,100,69),(39553,100,70),(39510,100,71),(39511,100,72),(39521,100,73),(39554,100,74),(39508,100,75),(39509,100,76),(39493,100,100),(39507,100,101),(38973,101,1),(38978,101,2),(38977,101,3),(38980,101,6),(38979,101,11),(38972,101,35),(38976,101,70),(38974,101,75),(38975,101,76),(38971,101,101); /*!40000 ALTER TABLE `roleRole` ENABLE KEYS */; UNLOCK TABLES; @@ -120,9 +120,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-05-25 11:53:07 +-- Dump completed on 2021-06-22 14:40:03 USE `salix`; --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.10-MariaDB, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: salix -- ------------------------------------------------------ @@ -144,7 +144,7 @@ USE `salix`; LOCK TABLES `ACL` WRITE; /*!40000 ALTER TABLE `ACL` DISABLE KEYS */; -INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','trainee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','trainee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','trainee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','trainee'),(30,'GreugeType','*','READ','ALLOW','ROLE','trainee'),(31,'Mandate','*','READ','ALLOW','ROLE','trainee'),(32,'MandateType','*','READ','ALLOW','ROLE','trainee'),(33,'Company','*','READ','ALLOW','ROLE','trainee'),(34,'Greuge','*','READ','ALLOW','ROLE','trainee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','trainee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','deleteSales','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','claimManager'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','claimManager'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','claimManager'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(107,'ItemNiche','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','trainee'),(111,'ClientLog','*','READ','ALLOW','ROLE','trainee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','trainee'),(114,'Receipt','*','READ','ALLOW','ROLE','trainee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','trainee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','trainee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'Calendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'Calendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(164,'InvoiceOut','regenerate','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','READ','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','trainee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(188,'TicketDms','removeFile','WRITE','ALLOW','ROLE','employee'),(189,'TicketDms','*','READ','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','deliveryBoss'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','trainee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','claimManager'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','WRITE','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'),(218,'Intrastat','*','*','ALLOW','ROLE','buyer'),(219,'Account','acl','READ','ALLOW','ROLE','account'),(220,'Account','getCurrentUserData','READ','ALLOW','ROLE','account'),(221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','account'),(222,'Client','*','READ','ALLOW','ROLE','trainee'),(226,'ClientObservation','*','READ','ALLOW','ROLE','trainee'),(227,'Address','*','READ','ALLOW','ROLE','trainee'),(228,'AddressObservation','*','READ','ALLOW','ROLE','trainee'),(230,'ClientCredit','*','READ','ALLOW','ROLE','trainee'),(231,'ClientContact','*','READ','ALLOW','ROLE','trainee'),(232,'ClientSample','*','READ','ALLOW','ROLE','trainee'),(233,'EntryLog','*','READ','ALLOW','ROLE','buyer'),(234,'WorkerLog','*','READ','ALLOW','ROLE','salesAssistant'),(235,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(236,'Buy','*','*','ALLOW','ROLE','buyer'),(237,'WorkerDms','filter','*','ALLOW','ROLE','employee'),(238,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(239,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(240,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(241,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(242,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(243,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(244,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(245,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(246,'Account','changePassword','*','ALLOW','ROLE','account'),(247,'UserAccount','exists','*','ALLOW','ROLE','account'),(248,'RoleMapping','*','READ','ALLOW','ROLE','account'),(249,'UserPassword','*','READ','ALLOW','ROLE','account'),(250,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(251,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(252,'Supplier','*','READ','ALLOW','ROLE','employee'),(253,'Supplier','*','WRITE','ALLOW','ROLE','administrative'),(254,'SupplierLog','*','READ','ALLOW','ROLE','employee'),(255,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(256,'Image','*','WRITE','ALLOW','ROLE','employee'),(257,'FixedPrice','*','*','ALLOW','ROLE','buyer'),(258,'PayDem','*','READ','ALLOW','ROLE','employee'),(259,'Client','createReceipt','*','ALLOW','ROLE','administrative'),(260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','employee'),(261,'SupplierAccount','*','*','ALLOW','ROLE','administrative'),(262,'Entry','*','*','ALLOW','ROLE','administrative'),(263,'InvoiceIn','*','*','ALLOW','ROLE','administrative'),(264,'StarredModule','*','*','ALLOW','ROLE','employee'),(265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss'),(266,'ZoneLog','*','READ','ALLOW','ROLE','employee'),(267,'Genus','*','WRITE','ALLOW','ROLE','logisticBoss'),(268,'Specie','*','WRITE','ALLOW','ROLE','logisticBoss'),(269,'InvoiceOut','createPdf','WRITE','ALLOW','ROLE','invoicing'); +INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','trainee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','trainee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','trainee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','trainee'),(30,'GreugeType','*','READ','ALLOW','ROLE','trainee'),(31,'Mandate','*','READ','ALLOW','ROLE','trainee'),(32,'MandateType','*','READ','ALLOW','ROLE','trainee'),(33,'Company','*','READ','ALLOW','ROLE','trainee'),(34,'Greuge','*','READ','ALLOW','ROLE','trainee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','trainee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','deleteSales','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','claimManager'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','claimManager'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','claimManager'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(107,'ItemNiche','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','trainee'),(111,'ClientLog','*','READ','ALLOW','ROLE','trainee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','trainee'),(114,'Receipt','*','READ','ALLOW','ROLE','trainee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','trainee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','trainee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'Calendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'Calendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(164,'InvoiceOut','regenerate','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','READ','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','trainee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(188,'TicketDms','removeFile','WRITE','ALLOW','ROLE','employee'),(189,'TicketDms','*','READ','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','deliveryBoss'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','trainee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','claimManager'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','WRITE','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'),(218,'Intrastat','*','*','ALLOW','ROLE','buyer'),(219,'Account','acl','READ','ALLOW','ROLE','account'),(220,'Account','getCurrentUserData','READ','ALLOW','ROLE','account'),(221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','account'),(222,'Client','*','READ','ALLOW','ROLE','trainee'),(226,'ClientObservation','*','READ','ALLOW','ROLE','trainee'),(227,'Address','*','READ','ALLOW','ROLE','trainee'),(228,'AddressObservation','*','READ','ALLOW','ROLE','trainee'),(230,'ClientCredit','*','READ','ALLOW','ROLE','trainee'),(231,'ClientContact','*','READ','ALLOW','ROLE','trainee'),(232,'ClientSample','*','READ','ALLOW','ROLE','trainee'),(233,'EntryLog','*','READ','ALLOW','ROLE','buyer'),(234,'WorkerLog','*','READ','ALLOW','ROLE','salesAssistant'),(235,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(236,'Buy','*','*','ALLOW','ROLE','buyer'),(237,'WorkerDms','filter','*','ALLOW','ROLE','employee'),(238,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(239,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(240,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(241,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(242,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(243,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(244,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(245,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(246,'Account','changePassword','*','ALLOW','ROLE','account'),(247,'UserAccount','exists','*','ALLOW','ROLE','account'),(248,'RoleMapping','*','READ','ALLOW','ROLE','account'),(249,'UserPassword','*','READ','ALLOW','ROLE','account'),(250,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(251,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(252,'Supplier','*','READ','ALLOW','ROLE','employee'),(253,'Supplier','*','WRITE','ALLOW','ROLE','administrative'),(254,'SupplierLog','*','READ','ALLOW','ROLE','employee'),(255,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(256,'Image','*','WRITE','ALLOW','ROLE','employee'),(257,'FixedPrice','*','*','ALLOW','ROLE','buyer'),(258,'PayDem','*','READ','ALLOW','ROLE','employee'),(259,'Client','createReceipt','*','ALLOW','ROLE','salesAssistant'),(260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','employee'),(261,'SupplierAccount','*','*','ALLOW','ROLE','administrative'),(262,'Entry','*','*','ALLOW','ROLE','administrative'),(263,'InvoiceIn','*','*','ALLOW','ROLE','administrative'),(264,'StarredModule','*','*','ALLOW','ROLE','employee'),(265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss'),(266,'ZoneLog','*','READ','ALLOW','ROLE','employee'),(267,'Genus','*','WRITE','ALLOW','ROLE','logisticBoss'),(268,'Specie','*','WRITE','ALLOW','ROLE','logisticBoss'),(269,'InvoiceOut','createPdf','WRITE','ALLOW','ROLE','invoicing'),(270,'SupplierAddress','*','*','ALLOW','ROLE','employee'),(271,'SalesMonitor','*','*','ALLOW','ROLE','employee'); /*!40000 ALTER TABLE `ACL` ENABLE KEYS */; UNLOCK TABLES; @@ -164,7 +164,7 @@ UNLOCK TABLES; LOCK TABLES `module` WRITE; /*!40000 ALTER TABLE `module` DISABLE KEYS */; -INSERT INTO `module` VALUES ('Claims'),('Clients'),('Entries'),('Invoices in'),('Invoices out'),('Items'),('Orders'),('Routes'),('Suppliers'),('Tickets'),('Travels'),('Users'),('Workers'),('Zones'); +INSERT INTO `module` VALUES ('Claims'),('Clients'),('Entries'),('Invoices in'),('Invoices out'),('Items'),('Monitors'),('Orders'),('Routes'),('Suppliers'),('Tickets'),('Travels'),('Users'),('Workers'),('Zones'); /*!40000 ALTER TABLE `module` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -176,9 +176,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-05-25 11:53:08 +-- Dump completed on 2021-06-22 14:40:03 USE `vn`; --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.10-MariaDB, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: vn -- ------------------------------------------------------ @@ -200,7 +200,7 @@ USE `vn`; LOCK TABLES `alertLevel` WRITE; /*!40000 ALTER TABLE `alertLevel` DISABLE KEYS */; -INSERT INTO `alertLevel` VALUES ('DELIVERED',3),('FREE',0),('ON_PREPARATION',1),('PACKED',2); +INSERT INTO `alertLevel` VALUES ('FREE',0,0),('ON_PREPARATION',1,1),('PACKED',2,2),('DELIVERED',3,3); /*!40000 ALTER TABLE `alertLevel` ENABLE KEYS */; UNLOCK TABLES; @@ -214,6 +214,16 @@ INSERT INTO `bookingPlanner` VALUES (5,'2017-06-30 22:00:00','4770000002','WORLD /*!40000 ALTER TABLE `bookingPlanner` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Dumping data for table `businessType` +-- + +LOCK TABLES `businessType` WRITE; +/*!40000 ALTER TABLE `businessType` DISABLE KEYS */; +INSERT INTO `businessType` VALUES ('decoration','Decoración'),('events','Eventos'),('florist','Floristería'),('mortuary','Funeraria'),('others','Otros'),('restoration','Restauración'),('wholesaler','Mayorista'); +/*!40000 ALTER TABLE `businessType` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Dumping data for table `cplusInvoiceType472` -- @@ -370,7 +380,7 @@ UNLOCK TABLES; LOCK TABLES `department` WRITE; /*!40000 ALTER TABLE `department` DISABLE KEYS */; -INSERT INTO `department` VALUES (1,NULL,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL),(22,NULL,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL,1,NULL),(23,NULL,'CAMARA',14,19,NULL,72,604,2,6,1,0,1,2,37,'/37/',NULL,0,NULL),(31,'IT','INFORMATICA',5,6,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica-cau',1,NULL),(34,NULL,'CONTABILIDAD',7,8,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL),(35,NULL,'FINANZAS',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL),(36,NULL,'LABORAL',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL),(37,NULL,'PRODUCCION',13,52,NULL,72,230,3,11,1,0,0,17,NULL,'/',NULL,0,NULL),(38,NULL,'SACADO',20,21,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL,0,NULL),(39,NULL,'ENCAJADO',22,23,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL,0,NULL),(41,NULL,'ADMINISTRACION',53,54,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL,1,NULL),(43,NULL,'VENTAS',55,76,NULL,0,NULL,NULL,NULL,0,0,0,10,NULL,'/',NULL,1,'direccioncomercial@verdnatura.es'),(44,NULL,'GERENCIA',77,78,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL,0,NULL),(45,NULL,'LOGISTICA',79,80,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL,1,NULL),(46,NULL,'REPARTO',81,84,NULL,72,659,3,10,0,0,0,1,NULL,'/',NULL,1,NULL),(48,NULL,'ALMACENAJE',85,86,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL,0,NULL),(49,NULL,'PROPIEDAD',87,88,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL,0,NULL),(52,NULL,'CARGA AEREA',89,90,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL,0,NULL),(53,NULL,'MARKETING Y COMUNICACIÓN',91,92,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL,1,NULL),(54,NULL,'ORNAMENTALES',93,94,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL,0,NULL),(55,NULL,'TALLER NATURAL',95,96,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL,0,NULL),(56,NULL,'TALLER ARTIFICIAL',97,98,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL,0,NULL),(58,NULL,'CAMPOS',99,100,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL,0,NULL),(59,NULL,'MANTENIMIENTO',101,102,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL,0,NULL),(60,NULL,'RECLAMACIONES',103,104,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL,1,NULL),(61,NULL,'VNH',105,106,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL,0,NULL),(63,NULL,'VENTAS FRANCIA',56,57,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL,0,NULL),(66,NULL,'VERDNAMADRID',107,108,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL,0,NULL),(68,NULL,'COMPLEMENTOS',24,25,NULL,72,617,3,26,1,0,1,0,37,'/37/',NULL,0,NULL),(69,NULL,'VERDNABARNA',109,110,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL,0,NULL),(77,NULL,'PALETIZADO',82,83,NULL,72,230,4,15,1,0,1,0,46,'/46/',NULL,0,NULL),(80,NULL,'EQUIPO J VALLES',58,59,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo',1,NULL),(86,NULL,'LIMPIEZA',111,112,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL,0,NULL),(89,NULL,'COORDINACION',113,114,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL,0,NULL),(90,NULL,'TRAILER',115,116,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL),(91,NULL,'ARTIFICIAL',26,27,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(92,NULL,'EQUIPO SILVERIO',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo',1,NULL),(93,NULL,'CONFECCION',117,118,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL),(94,NULL,'EQUIPO J BROCAL',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo',1,NULL),(95,NULL,'EQUIPO C ZAMBRANO',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo',1,NULL),(96,NULL,'EQUIPO C LOPEZ',66,67,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo',1,NULL),(98,NULL,'EQUIPO RODRIGO',68,69,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo',1,NULL),(101,NULL,'EQUIPO J IBAÑEZ',70,71,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo',1,NULL),(102,NULL,'EQ ROJO FV RUBEN C',28,29,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(103,NULL,'EQ AZUL FV A FOLQUES',30,31,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(104,NULL,'EQ AMARILLO FV NORMAN G',32,33,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(105,NULL,'EQ MORADO FV MATOU',34,35,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(106,NULL,'EQ VERDE PCA KEVIN GIMENEZ',36,37,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(107,NULL,'EQ NARANJA PCA RUBEN ZANON',38,39,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(110,NULL,'EQ ROSA PCA J BONDIA',40,41,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(111,NULL,'EQ REPONEDOR CAJAS',42,43,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(112,NULL,'CAMARA EQ EDGAR LLEO',15,16,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL,0,NULL),(113,NULL,'CAMARA EQ MARC ROCA',17,18,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL,0,NULL),(114,NULL,'EQ MARRON PCA JL NUEVO',44,45,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(115,NULL,'EQUIPO CLAUDI',72,73,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','csr_equipo',1,NULL),(120,NULL,'PCA PRODUCCION',46,47,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(121,NULL,'FV PRODUCCION',48,49,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(122,NULL,'PCA ALMACEN',50,51,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(123,NULL,'EQUIPO ELENA BASCUÑANA',74,75,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','ebt_equipo',1,NULL),(124,NULL,'CONTROL INTERNO',119,120,NULL,72,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL); +INSERT INTO `department` VALUES (1,NULL,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL,0),(22,NULL,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL,1,NULL,1),(23,NULL,'CAMARA',14,19,NULL,72,604,2,6,1,0,1,2,37,'/37/',NULL,0,NULL,0),(31,'IT','INFORMATICA',5,6,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica-cau',1,NULL,1),(34,NULL,'CONTABILIDAD',7,8,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL,1),(35,NULL,'FINANZAS',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL,1),(36,NULL,'LABORAL',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL,1),(37,NULL,'PRODUCCION',13,52,NULL,72,230,3,11,1,0,0,17,NULL,'/',NULL,0,NULL,0),(38,NULL,'SACADO',20,21,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL,0,NULL,0),(39,NULL,'ENCAJADO',22,23,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL,0,NULL,0),(41,NULL,'ADMINISTRACION',53,54,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL,1,NULL,1),(43,NULL,'VENTAS',55,78,NULL,0,NULL,NULL,NULL,0,0,0,11,NULL,'/',NULL,1,'direccioncomercial@verdnatura.es',1),(44,NULL,'GERENCIA',79,80,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL,0,NULL,0),(45,NULL,'LOGISTICA',81,82,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL,1,NULL,1),(46,NULL,'REPARTO',83,86,NULL,72,659,3,10,0,0,0,1,NULL,'/',NULL,1,NULL,1),(48,NULL,'ALMACENAJE',87,88,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL,0,NULL,0),(49,NULL,'PROPIEDAD',89,90,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL,0,NULL,0),(52,NULL,'CARGA AEREA',91,92,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL,0,NULL,0),(53,NULL,'MARKETING Y COMUNICACIÓN',93,94,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL,1,NULL,1),(54,NULL,'ORNAMENTALES',95,96,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL,0,NULL,0),(55,NULL,'TALLER NATURAL',97,98,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL,0,NULL,0),(56,NULL,'TALLER ARTIFICIAL',99,100,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL,0,NULL,0),(58,NULL,'CAMPOS',101,102,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL,0,NULL,1),(59,NULL,'MANTENIMIENTO',103,104,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL,0,NULL,0),(60,NULL,'RECLAMACIONES',105,106,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL,1,NULL,1),(61,NULL,'VNH',107,108,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL,0,NULL,0),(63,NULL,'VENTAS FRANCIA',56,57,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL,0,NULL,0),(66,NULL,'VERDNAMADRID',109,110,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL,0,NULL,0),(68,NULL,'COMPLEMENTOS',24,25,NULL,72,617,3,26,1,0,1,0,37,'/37/',NULL,0,NULL,0),(69,NULL,'VERDNABARNA',111,112,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL,0,NULL,0),(77,NULL,'PALETIZADO',84,85,NULL,72,230,4,15,1,0,1,0,46,'/46/',NULL,0,NULL,0),(80,NULL,'EQUIPO J VALLES',58,59,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo',1,NULL,1),(86,NULL,'LIMPIEZA',113,114,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL,0,NULL,0),(89,NULL,'COORDINACION',115,116,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL,0,NULL,0),(90,NULL,'TRAILER',117,118,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL,0),(91,NULL,'ARTIFICIAL',26,27,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(92,NULL,'EQUIPO SILVERIO',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo',1,NULL,1),(93,NULL,'CONFECCION',119,120,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL,0),(94,NULL,'EQUIPO J BROCAL',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo',1,NULL,1),(95,NULL,'EQUIPO C ZAMBRANO',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo',1,NULL,1),(96,NULL,'EQUIPO C LOPEZ',66,67,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo',1,NULL,1),(98,NULL,'EQUIPO RODRIGO',68,69,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo',1,NULL,1),(101,NULL,'EQUIPO J IBAÑEZ',70,71,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo',1,NULL,1),(102,NULL,'EQ ROJO FV RUBEN C',28,29,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(103,NULL,'EQ AZUL FV A FOLQUES',30,31,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(104,NULL,'EQ AMARILLO FV NORMAN G',32,33,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(105,NULL,'EQ MORADO FV MATOU',34,35,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(106,NULL,'EQ VERDE PCA KEVIN GIMENEZ',36,37,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(107,NULL,'EQ NARANJA PCA RUBEN ZANON',38,39,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(110,NULL,'EQ ROSA PCA J BONDIA',40,41,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(111,NULL,'EQ REPONEDOR CAJAS',42,43,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(112,NULL,'CAMARA EQ EDGAR LLEO',15,16,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL,0,NULL,0),(113,NULL,'CAMARA EQ MARC ROCA',17,18,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL,0,NULL,0),(114,NULL,'EQ MARRON PCA JL NUEVO',44,45,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(115,NULL,'EQUIPO CLAUDI',72,73,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','csr_equipo',1,NULL,1),(120,NULL,'PCA PRODUCCION',46,47,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(121,NULL,'FV PRODUCCION',48,49,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(122,NULL,'PCA ALMACEN',50,51,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(123,NULL,'EQUIPO ELENA BASCUÑANA',74,75,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','ebt_equipo',1,NULL,1),(124,NULL,'CONTROL INTERNO',121,122,NULL,72,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL,1),(125,NULL,'EQUIPO MIRIAM MAR',76,77,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','mir_equipo',0,NULL,0); /*!40000 ALTER TABLE `department` ENABLE KEYS */; UNLOCK TABLES; @@ -410,7 +420,7 @@ UNLOCK TABLES; LOCK TABLES `volumeConfig` WRITE; /*!40000 ALTER TABLE `volumeConfig` DISABLE KEYS */; -INSERT INTO `volumeConfig` VALUES (2.67,1.60,0.8,150,0.30,120,57); +INSERT INTO `volumeConfig` VALUES (2.67,1.60,0.8,150,0.30,120,57,2.0); /*!40000 ALTER TABLE `volumeConfig` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -422,9 +432,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-05-25 11:53:09 +-- Dump completed on 2021-06-22 14:40:05 USE `cache`; --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.10-MariaDB, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: cache -- ------------------------------------------------------ @@ -446,7 +456,7 @@ USE `cache`; LOCK TABLES `cache` WRITE; /*!40000 ALTER TABLE `cache` DISABLE KEYS */; -INSERT INTO `cache` VALUES (1,'equalizator','00:19:00'),(2,'available','00:06:00'),(3,'stock','00:30:00'),(4,'last_buy','00:30:00'),(5,'weekly_sales','12:00:00'),(6,'bionic','00:06:00'),(7,'sales','00:04:00'),(8,'visible','00:04:00'),(9,'item_range','00:03:00'),(10,'barcodes','01:00:00'),(11,'prod_graphic','00:17:00'),(12,'ticketShipping','00:01:00'),(13,'availableNoRaids','00:06:00'); +INSERT INTO `cache` VALUES (1,'equalizator','00:19:00'),(2,'available','00:06:00'),(3,'stock','00:30:00'),(4,'last_buy','00:30:00'),(5,'weekly_sales','12:00:00'),(6,'bionic','00:06:00'),(7,'sales','00:04:00'),(8,'visible','00:04:00'),(9,'item_range','00:03:00'),(10,'barcodes','01:00:00'),(11,'prod_graphic','00:17:00'),(12,'ticketShipping','00:01:00'),(13,'availableNoRaids','00:06:00'),(14,'lastBuy','00:30:00'); /*!40000 ALTER TABLE `cache` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -458,9 +468,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-05-25 11:53:10 +-- Dump completed on 2021-06-22 14:40:05 USE `hedera`; --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.10-MariaDB, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: hedera -- ------------------------------------------------------ @@ -524,9 +534,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-05-25 11:53:10 +-- Dump completed on 2021-06-22 14:40:06 USE `postgresql`; --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.10-MariaDB, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: postgresql -- ------------------------------------------------------ @@ -598,7 +608,7 @@ UNLOCK TABLES; LOCK TABLES `workcenter` WRITE; /*!40000 ALTER TABLE `workcenter` DISABLE KEYS */; -INSERT INTO `workcenter` VALUES (1,'Silla',20,1177,1,'Av espioca 100',552703),(2,'Mercaflor',19,NULL,NULL,NULL,NULL),(3,'Marjales',26,20008,NULL,NULL,NULL),(4,'VNH',NULL,NULL,3,NULL,NULL),(5,'Madrid',28,2861,5,'Av constitución 3',554145),(6,'Vilassar',88,88035,2,'Cami del Crist, 33',556412),(7,'Tenerife',NULL,NULL,10,NULL,NULL),(8,NULL,NULL,NULL,NULL,NULL,NULL),(9,'Algemesi',20,NULL,60,'Fenollars, 20',523549),(10,NULL,NULL,NULL,NULL,NULL,NULL); +INSERT INTO `workcenter` VALUES (1,'Silla',20,1208,1,'Av espioca 100',552703),(2,'Mercaflor',19,NULL,NULL,NULL,NULL),(3,'Marjales',26,20008,NULL,NULL,NULL),(4,'VNH',NULL,NULL,3,NULL,NULL),(5,'Madrid',28,2865,5,'Av constitución 3',554145),(6,'Vilassar',88,88036,2,'Cami del Crist, 33',556412),(7,'Tenerife',NULL,NULL,10,NULL,NULL),(8,NULL,NULL,NULL,NULL,NULL,NULL),(9,'Algemesi',20,NULL,60,'Fenollars, 20',523549),(10,NULL,NULL,NULL,NULL,NULL,NULL); /*!40000 ALTER TABLE `workcenter` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -610,9 +620,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-05-25 11:53:10 +-- Dump completed on 2021-06-22 14:40:06 USE `sage`; --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.10-MariaDB, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: sage -- ------------------------------------------------------ @@ -666,4 +676,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-05-25 11:53:11 +-- Dump completed on 2021-06-22 14:40:07 diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 8df46890d..c07919155 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -1,4 +1,4 @@ --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.10-MariaDB, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: account -- ------------------------------------------------------ @@ -2544,7 +2544,7 @@ CREATE TABLE `clientDied` ( `Boss` varchar(3) COLLATE utf8_unicode_ci NOT NULL, `Aviso` varchar(13) CHARACTER SET utf8 DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Clientes que no han comprado en los ultimos 3 meses, se actualiza con proceso nocturno el 3 de cada mes'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2607,7 +2607,7 @@ DROP TABLE IF EXISTS `compradores`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `compradores` ( - `Id_Trabajador` int(11) NOT NULL, + `Id_Trabajador` int(10) unsigned NOT NULL, `año` int(4) NOT NULL, `semana` int(2) NOT NULL, `importe` decimal(10,2) DEFAULT NULL, @@ -2625,7 +2625,7 @@ DROP TABLE IF EXISTS `compradores_evolution`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `compradores_evolution` ( - `Id_Trabajador` int(11) NOT NULL, + `Id_Trabajador` int(10) unsigned NOT NULL, `fecha` date NOT NULL, `importe` decimal(10,0) DEFAULT NULL, PRIMARY KEY (`Id_Trabajador`,`fecha`), @@ -3205,7 +3205,7 @@ DROP TABLE IF EXISTS `salesByclientSalesPerson`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `salesByclientSalesPerson` ( `dated` date NOT NULL DEFAULT '0000-00-00', - `salesPersonFk` int(11) DEFAULT NULL, + `salesPersonFk` int(10) unsigned DEFAULT NULL, `clientFk` int(11) NOT NULL, `amount` decimal(10,3) NOT NULL DEFAULT '0.000', `equalizationTax` decimal(10,3) NOT NULL DEFAULT '0.000', @@ -3282,7 +3282,7 @@ DROP TABLE IF EXISTS `salesPersonEvolution`; CREATE TABLE `salesPersonEvolution` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dated` date NOT NULL DEFAULT '0000-00-00', - `salesPersonFk` int(11) DEFAULT NULL, + `salesPersonFk` int(10) unsigned DEFAULT NULL, `amount` decimal(10,3) NOT NULL DEFAULT '0.000', `equalizationTax` decimal(10,3) NOT NULL DEFAULT '0.000', `amountNewBorn` decimal(10,3) NOT NULL DEFAULT '0.000', @@ -3318,7 +3318,7 @@ DROP TABLE IF EXISTS `vendedores`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `vendedores` ( - `Id_Trabajador` int(11) NOT NULL, + `Id_Trabajador` int(10) unsigned NOT NULL, `año` int(4) NOT NULL, `mes` int(2) NOT NULL, `importe` decimal(10,2) DEFAULT NULL, @@ -3343,7 +3343,7 @@ DROP TABLE IF EXISTS `vendedores_evolution`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `vendedores_evolution` ( - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `year` int(11) NOT NULL, `sales` decimal(10,2) DEFAULT NULL, `month` int(11) NOT NULL, @@ -3412,11 +3412,12 @@ CREATE TABLE `waste` ( `year` int(4) NOT NULL, `week` int(2) NOT NULL, `family` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `itemFk` int(11) DEFAULT NULL, + `itemFk` int(11) NOT NULL DEFAULT '0', `itemTypeFk` smallint(5) unsigned DEFAULT NULL, `saleTotal` decimal(16,0) DEFAULT NULL, `saleWaste` decimal(16,0) DEFAULT NULL, `rate` decimal(5,1) DEFAULT NULL, + PRIMARY KEY (`buyer`,`year`,`week`,`family`,`itemFk`), KEY `waste_itemType_id` (`itemTypeFk`), KEY `waste_item_id` (`itemFk`), CONSTRAINT `waste_itemType_id` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn`.`itemType` (`id`) ON UPDATE CASCADE, @@ -3449,7 +3450,7 @@ CREATE TABLE `workerProductivity` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dated` date NOT NULL, `warehouseFk` smallint(6) unsigned NOT NULL, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `volume` decimal(10,6) NOT NULL, `seconds` int(11) NOT NULL, `roleFk` int(10) unsigned NOT NULL, @@ -4022,9 +4023,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -4059,6 +4060,9 @@ BEGIN WHERE (maxIssued IS NULL OR maxIssued < @primerAviso) AND c.created < @tercerAviso; + DELETE cd.* FROM bs.clientDied cd + JOIN vn.ticket t ON t.clientFk = cd.id + WHERE t.refFk IS NULL AND t.shipped >=TIMESTAMPADD(MONTH,-1,CURDATE()); END IF; END ;; @@ -5904,38 +5908,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `userSundayRole__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `userSundayRole__`() -BEGIN - -- 4996 Fran Natek Echevarria - DECLARE vDay INT; - SET vDay := (SELECT DAYOFWEEK(CURDATE())); - IF vDay = 1 THEN - UPDATE account.user u - JOIN account.role r - SET u.role = r.id - WHERE u.id = 4996 AND r.name = "salesAssistant"; - ELSE - UPDATE account.user u - JOIN account.role r - SET u.role = r.id - WHERE u.id = 4996 AND r.name = "salesPerson"; - END IF; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `vendedores_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6056,165 +6028,6 @@ BEGIN CALL bs.vendedores_evolution_add; CALL bs.salesPersonClient_add(YEAR(CURDATE()), QUARTER(CURDATE())); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `vendedores_add__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `vendedores_add__`(intYEAR INT, vQuarter INT) -BEGIN - - DECLARE vCommissionRate DOUBLE DEFAULT 0.029; - - -- vaciar tabla - DELETE v.* FROM vendedores v - JOIN vn.`time` t ON t.`year` = v.año AND t.`month` = v.mes - WHERE t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter; - - REPLACE vendedores(Id_Trabajador, año, mes, importe, comision) - SELECT c.Id_Trabajador - , intYEAR - , MONTH(v.fecha) intMONTH - , sum(v.importe) - , sum(v.importe) * vCommissionRate - FROM ventas v - JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente - JOIN vn.`time` t on t.dated = v.fecha - WHERE c.Id_Trabajador is not null - AND t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter - GROUP BY c.Id_Trabajador, t.`month`; - - -- Ventas nuevas - UPDATE vendedores v - JOIN - ( - SELECT c.Id_Trabajador - , sum(importe) * vCommissionRate as comisionNueva - , t.`month` - , t.`year` - FROM ventas v - JOIN bs.clientNewBorn cnb on v.Id_Cliente = cnb.clientFk - JOIN vn2008.Clientes c ON c.Id_Cliente = v.Id_Cliente - JOIN vn2008.`time` t on t.`date` = v.fecha - WHERE c.Id_Trabajador is not null - AND t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter - AND cnb.firstShipped > DATE_ADD(v.fecha, INTERVAL -1 YEAR) - GROUP BY c.Id_Trabajador, t.`month` - ) sub ON sub.Id_Trabajador = v.Id_Trabajador AND sub.`month` = v.mes AND sub.`year` = v.año - SET v.comisionNuevos = sub.comisionNueva, v.comision = v.comision - sub.comisionNueva; - - -- Ventas cedidas - UPDATE vendedores v - JOIN ( - SELECT cc.Id_Trabajador_old as Id_Trabajador - , sum(importe) * vCommissionRate * comision_old as cedido - , sum(importe) * vCommissionRate * comision_new as arrendada - , t.`month` - , t.`year` - FROM ventas v - JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente - JOIN vn2008.Clientes_cedidos cc on cc.Id_Cliente = c.Id_Cliente AND v.fecha between datSTART and datEND - JOIN vn2008.`time` t on t.`date` = v.fecha - WHERE c.Id_Trabajador is not null - AND t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter - GROUP BY cc.Id_Trabajador_old, t.`month` - ) sub ON sub.Id_Trabajador = v.Id_Trabajador AND sub.`month` = v.mes AND sub.`year` = v.año - SET v.comisionCedida = sub.cedido, v.comision = v.comision - sub.cedido - sub.arrendada; - - -- Ventas arrendadas - UPDATE vendedores v - JOIN ( - SELECT cc.Id_Trabajador_new as Id_Trabajador - , sum(importe) * vCommissionRate * comision_new as arrendada - , t.`month` - , t.`year` - FROM ventas v - JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente - JOIN vn2008.Clientes_cedidos cc on cc.Id_Cliente = c.Id_Cliente AND v.fecha between datSTART and datEND - JOIN vn2008.`time` t on t.`date` = v.fecha - WHERE c.Id_Trabajador is not null - AND t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter - GROUP BY cc.Id_Trabajador_new, t.`month` - ) sub ON sub.Id_Trabajador = v.Id_Trabajador AND sub.`month` = v.mes AND sub.`year` = v.año - SET v.comisionArrendada = sub.arrendada; - - -- Sustitucion cedidas - lended - INSERT INTO vendedores (Id_Trabajador, mes, año, comision) - SELECT c.salesPersonFk - , t.`month` - , t.`year` - , sum(importe) * vCommissionRate as lended - FROM ventas v - JOIN vn.client c ON c.id = v.Id_Cliente - JOIN vn.sharingCartDaily scd on scd.ownerFk = c.salesPersonFk AND scd.dated = v.fecha - JOIN vn.`time` t ON t.dated = v.fecha - WHERE t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter - GROUP BY c.salesPersonFk, t.`month` - ON DUPLICATE KEY UPDATE comision = comision - VALUES(comision); - - -- Sustitucion arrendadas - borrowed - INSERT INTO vendedores (Id_Trabajador, mes, año, sustitucionArrendada) - SELECT scd.substituteFk - , t.`month` - , t.`year` - , sum(importe) * vCommissionRate as borrowed - FROM ventas v - JOIN vn.client c ON c.id = v.Id_Cliente - JOIN vn.sharingCartDaily scd on scd.ownerFk = c.salesPersonFk AND scd.dated = v.fecha - JOIN vn.`time` t ON t.dated = v.fecha - WHERE t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter - GROUP BY scd.substituteFk, t.`month` - ON DUPLICATE KEY UPDATE sustitucionArrendada = VALUES(sustitucionArrendada); - - DROP TEMPORARY TABLE IF EXISTS tmp.workerItemType; - CREATE TEMPORARY TABLE tmp.workerItemType - (INDEX(ownerWorkerFk, itemTypeFk)) - SELECT wd.workerFk ownerWorkerFk, itemTypeFk, dit.workerFk substituteFk - FROM vn.departmentItemType dit - JOIN vn.workerDepartment wd ON wd.departmentFk = dit.departmentFk; - - -- itemType Lended, prestado - UPDATE vendedores v - JOIN ( - SELECT c.Id_Trabajador - , sum(importe) * vCommissionRate as amount - , t.`month` - , t.`year` - FROM ventas v - JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente - JOIN tmp.workerItemType wit ON wit.ownerWorkerFk = c.Id_Trabajador AND wit.itemTypeFk = v.tipo_id - JOIN vn2008.`time` t on t.`date` = v.fecha - WHERE t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter - GROUP BY c.Id_Trabajador, t.`month` - ) sub ON sub.Id_Trabajador = v.Id_Trabajador AND sub.`month` = v.mes AND sub.`year` = v.año - SET v.comision = v.comision - sub.amount; - - -- itemType borrowed, tomado prestado - INSERT INTO vendedores (Id_Trabajador, año, mes, itemTypeBorrowed) - SELECT wit.substituteFk - , t.`year` - , t.`month` - , importe * vCommissionRate - FROM ventas v - JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente - JOIN tmp.workerItemType wit ON wit.ownerWorkerFk = c.Id_Trabajador AND wit.itemTypeFk = v.tipo_id - JOIN vn2008.`time` t on t.`date` = v.fecha - WHERE t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter - ON DUPLICATE KEY UPDATE itemTypeBorrowed = itemTypeBorrowed + values(itemTypeBorrowed); - - DROP TEMPORARY TABLE tmp.workerItemType; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6278,80 +6091,6 @@ Inserta en la tabla compradores_evolution las ventas acumuladas en el ultimo mes END IF; END WHILE; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `vendedores_evolution_add__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `vendedores_evolution_add__`() -BEGIN -/* - -Inserta en la tabla compradores_evolution las ventas acumuladas en el ultimo mes - -*/ - -DECLARE vYear, vMonth INTEGER; -DECLARE vCurYear, vCurMonth INTEGER; -DECLARE vFirstYear INTEGER DEFAULT 2017; -DECLARE vFirstMonth INTEGER DEFAULT 1; - -DECLARE vDateFrom DATE; -DECLARE vDateTo DATE; - -SET vCurYear = year(CURDATE()); -SET vCurMonth = month(CURDATE()); - -SELECT IFNULL(max(year),vFirstYear), IFNULL(max(month),vFirstMonth) - INTO vYear, vMonth - FROM bs.vendedores_evolution; - - WHILE (vYear < vCurYear) OR (vYear = vCurYear AND vMonth < vCurMonth) DO - - SELECT max(dated), TIMESTAMPADD(DAY,-364,max(dated)) INTO vDateTo, vDateFrom - FROM vn.time - WHERE year = vYear - AND month = vMonth; - - SELECT vDateTo, vDateFrom, vYear, vMonth; - - REPLACE bs.vendedores_evolution( workerFk - , year - , month - , sales) - SELECT c.salesPersonFk - , vYear as year - , vMonth as month - , sum(v.importe) as sales - FROM bs.ventas v - JOIN vn.client c on c.id = v.Id_Cliente - WHERE v.fecha BETWEEN vDateFrom AND vDateTo - AND c.salesPersonFk is not null - GROUP BY c.salesPersonFk; - - SET vMonth = vMonth + 1; - - IF vMonth = 13 THEN - - SET vMonth = 1; - SET vYear = vYear + 1; - - END IF; - - END WHILE; - - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6493,73 +6232,6 @@ BEGIN call bs.ventas_add(timestampadd(week,-1,curdate()),curdate()); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ventas_add__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ventas_add__`(IN datSTART DATETIME, IN datEND DATETIME) -BEGIN - - DECLARE vStartingDate DATETIME; - DECLARE vEndingDate DATETIME; - DECLARE TIPO_PATRIMONIAL INT DEFAULT 188; - - SET datEND = util.dayEnd(datEND); - SET vStartingDate = GREATEST('2015-10-01',datSTART); - SET vEndingDate = vn2008.dayend(vStartingDate); - - DELETE - FROM ventas - WHERE fecha between vStartingDate and datEND; - - WHILE vEndingDate <= datEND DO - - REPLACE ventas(Id_Movimiento, importe, recargo, fecha, tipo_id, Id_Cliente, empresa_id) - SELECT Id_Movimiento, - SUM(IF(base, Cantidad * Valor, 0)) as importe, - SUM(IF(base, 0, Cantidad * Valor)) as recargo, - vStartingDate, - a.tipo_id, - cs.Id_Cliente, - t.empresa_id - FROM vn2008.Movimientos_componentes mc - JOIN bi.tarifa_componentes tc using(Id_Componente) - JOIN bi.tarifa_componentes_series tcs using(tarifa_componentes_series_id) - JOIN vn2008.Movimientos m using(Id_Movimiento) - JOIN vn2008.Articles a using(Id_Article) - JOIN vn2008.Tipos tp using(tipo_id) - JOIN vn2008.reinos r on r.id = tp.reino_id - JOIN vn2008.Tickets t using(Id_Ticket) - JOIN vn2008.Consignatarios cs using(Id_Consigna) - JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente - WHERE t.Fecha between vStartingDate and vEndingDate - AND datEND >= '2015-10-01' - AND c.typeFk IN ('Normal','handMaking','internalUse') - AND m.Cantidad <> 0 - AND a.tipo_id != TIPO_PATRIMONIAL - AND c.Id_Trabajador IS NOT NULL - AND m.Descuento <> 100 - AND (m.Id_Article = 98 or m.Id_Article = 95 or r.mercancia != 0) - GROUP BY mc.Id_Movimiento - HAVING IFNULL(importe,0) <> 0 OR IFNULL(recargo,0) <> 0; - - SET vStartingDate = TIMESTAMPADD(DAY,1, vStartingDate); - SET vEndingDate = util.dayEnd(vStartingDate); - - END WHILE; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6875,121 +6547,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `weekWaste_byWorker__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `weekWaste_byWorker__`(IN vWorkerFk INT) -BEGIN - - DECLARE vWeek INT; - DECLARE vYear INT; - - SELECT week, year - INTO vWeek, vYear - FROM vn.time - WHERE dated = TIMESTAMPADD(WEEK, -1, CURDATE()); - - SELECT *, 100 * mermas / total AS porcentaje - FROM ( - SELECT ws.family, - SUM(ws.saleTotal) AS total, - SUM(ws.saleWaste) AS mermas - FROM bs.waste ws - JOIN vn.worker w ON w.user = ws.buyer - WHERE year = vYear - AND week = vWeek - AND w.id = vWorkerFk - GROUP BY family - ) sub - ORDER BY porcentaje DESC; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `weekWaste_getDetail__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `weekWaste_getDetail__`() -BEGIN - DECLARE vLastWeek DATE; - DECLARE vWeek INT; - DECLARE vYear INT; - - SET vLastWeek = TIMESTAMPADD(WEEK, -1, CURDATE()); - SET vYear = YEAR(vLastWeek); - SET vWeek = WEEK(vLastWeek, 1); - - SELECT *, 100 * dwindle / total AS percentage - FROM ( - SELECT buyer, - ws.family, - SUM(ws.saleTotal) AS total, - SUM(ws.saleWaste) AS dwindle - FROM bs.waste ws - WHERE year = vYear - AND week = vWeek - GROUP BY buyer, family - ) sub - ORDER BY percentage DESC; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `weekWaste__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `weekWaste__`() -BEGIN - DECLARE vWeek INT; - DECLARE vYear INT; - - SELECT week, year - INTO vWeek, vYear - FROM vn.time - WHERE dated = DATE_ADD(CURDATE(), INTERVAL -1 WEEK); - - SELECT *, 100 * dwindle / total AS percentage - FROM ( - SELECT buyer, - SUM(saleTotal) AS total, - SUM(saleWaste) AS dwindle - FROM bs.waste - WHERE year = vYear - AND week = vWeek - GROUP BY buyer - ) sub - ORDER BY percentage DESC; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerProductivity_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7076,172 +6633,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `workerSpeed_detail__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `workerSpeed_detail__`(vWorkerCode VARCHAR(3), vAction VARCHAR(25)) -BEGIN - - SELECT * FROM - ( - SELECT time_format(st.created,'%H:%i') as hora, - t.warehouseFk as Almacen, - t.id as ticketFk, - floor(sum(s.quantity * r.cm3) / 1000) as Litros - - FROM vn.saleTracking st - JOIN vn.sale s ON s.id = st.saleFk - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN bi.rotacion r ON r.warehouse_id = t.warehouseFk AND r.Id_Article = s.itemFk - JOIN vn.worker w ON w.id = st.workerFk - JOIN vn.state e ON e.id = st.stateFk - JOIN vncontrol.accion a ON a.accion_id = st.actionFk - WHERE st.created > CURDATE() - AND a.accion LIKE vAction - AND w.code LIKE vWorkerCode - GROUP BY t.id) sub - ORDER BY hora; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `workerSpeed__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `workerSpeed__`() -BEGIN - - /* #UPDATED PAK 2019/09/02 - * #PENDING REVIEW - * - * - * - * - */ - - DECLARE vLastUpdated DATETIME; - DECLARE vSecondsDelay INT DEFAULT 300; - - SELECT IFNULL(MAX(lastUpdated),CURDATE()) INTO vLastUpdated - FROM bs.workerSpeed; - - IF TIMESTAMPDIFF(SECOND, vLastUpdated, NOW()) > vSecondsDelay THEN - - DELETE FROM bs.workerSpeed ; - -- WHERE lastUpdated < CURDATE(); - - -- Sacadores - REPLACE bs.workerSpeed - SELECT workerCode, - accion, - warehouseFk, - CAST(60 * sumaLitros / time_to_sec(timediff(finished, started)) AS DECIMAL(10,1)) as LitrosMinuto, - CAST(sumaLitrosLastHour / 60 AS DECIMAL(10,1)) as LitrosMinutoLastHour, - now() as lastUpdated - FROM - ( - SELECT warehouseFk, - accion, - workerCode, - sum(litros) as sumaLitros, - min(created) as started, - max(created) as finished, - sum(IF(created >= TIMESTAMPADD(HOUR, -1, NOW()),litros, 0)) as sumaLitrosLastHour - FROM - ( - SELECT t.warehouseFk, - st.saleFk, - st.isChecked, - st.originalQuantity, - a.accion, - st.created, - e.code, - w.firstname, - w.lastName, - w.code as workerCode, - r.cm3 * s.quantity / 1000 as litros, - s.concept - FROM vn.saleTracking st - LEFT JOIN - (SELECT saleFk - FROM vn.saleTracking st - JOIN vn.state e ON e.id = st.stateFk - WHERE st.created > CURDATE() - AND e.code LIKE 'PREVIOUS_PREPARATION') prevPrepSales ON prevPrepSales.saleFk = st.saleFk - JOIN vn.sale s ON s.id = st.saleFk - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN bi.rotacion r ON r.warehouse_id = t.warehouseFk AND r.Id_Article = s.itemFk - JOIN vn.worker w ON w.id = st.workerFk - JOIN vn.state e ON e.id = st.stateFk - JOIN vncontrol.accion a ON a.accion_id = st.actionFk - WHERE st.created > TIMESTAMPADD(HOUR,-1,NOW()) - AND prevPrepSales.saleFk IS NULL - ) sub - GROUP BY warehouseFk, accion, workerCode - ) sub2; - - -- Encajadores - REPLACE bs.workerSpeed - SELECT code as workerCode, - 'ENCAJAR' as accion, - warehouseFk, - CAST(60 * sum(Litros) / time_to_sec(timediff(MAX(finished), MIN(started))) AS DECIMAL(10,1)) as LitrosMinuto, - CAST(sum(litrosUltimaHora) / 60 AS DECIMAL(10,1)) as LitrosMinutoLastHour, - now() as lastUpdated - FROM ( - SELECT sv.ticketFk, - sum(sv.litros) as litros, - sum(IF(started > TIMESTAMPADD(HOUR,-1,NOW()),sv.litros,0)) as litrosUltimaHora, - code, - started, - finished, - cajas, - warehouseFk - FROM vn.saleVolume sv - JOIN - ( - SELECT ticketFk, - min(e.created) as started, - max(e.created) as finished, - max(counter) as cajas, - w.code, - t.warehouseFk - FROM vn.expedition e - JOIN vn.worker w ON w.id = e.workerFk - JOIN vn.ticket t ON t.id = e.ticketFk - WHERE e.created > CURDATE() - GROUP BY ticketFk - ) sub ON sub.ticketFk = sv.ticketFk - GROUP BY sv.ticketFk) sub2 - GROUP BY code; - - END IF; - - SELECT * FROM bs.workerSpeed; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_ETD_byTime` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -8103,7 +7494,6 @@ proc: BEGIN IF v_calc IS NULL THEN - -- call util.debugAdd(concat('if start ', v_lock_id) ,v_refresh); INSERT INTO cache_calc SET cache_id = v_cache_id, cacheName = v_cache_name, @@ -8111,17 +7501,15 @@ proc: BEGIN last_refresh = NULL, expires = NULL, connection_id = CONNECTION_ID(); - -- call util.debugAdd(concat('if end ', v_lock_id),v_refresh); + SET v_calc = LAST_INSERT_ID(); ELSE - -- call util.debugAdd(concat('else start ', v_lock_id) ,v_refresh); UPDATE cache_calc SET last_refresh = NULL, expires = NULL, connection_id = CONNECTION_ID() WHERE id = v_calc; - -- call util.debugAdd(concat('else end ', v_lock_id) ,v_refresh); END IF; -- Si se debe recalcular mantiene el bloqueo y devuelve su identificador. @@ -8885,6 +8273,9 @@ CREATE TABLE `VMPSettings` ( `closedTo` int(11) DEFAULT NULL, `totalRefreshHours` int(11) DEFAULT NULL COMMENT 'Numero > 4 para no saturar, no repetir para que no solapen las actualizaciones', `UseSupplierEmbalageCode` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'vmp you want to see their embalage code', + `firstSupplyResponseId` int(11) DEFAULT NULL, + `ApiId` int(11) DEFAULT NULL, + `ApiKey` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`VMPID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -8929,6 +8320,20 @@ CREATE TABLE `bucket_type` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='/tmp/floricode/VBN020101/FB090916.txt'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `clientFHAdminNumber` +-- + +DROP TABLE IF EXISTS `clientFHAdminNumber`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientFHAdminNumber` ( + `fhAdminNumber` int(11) NOT NULL, + `clientFk` int(11) NOT NULL, + PRIMARY KEY (`clientFk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `deliveryInformation` -- @@ -9170,6 +8575,18 @@ CREATE TABLE `fileConfig` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `floraHollandConfig` +-- + +DROP TABLE IF EXISTS `floraHollandConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `floraHollandConfig` ( + `defaultAdminNumber` int(11) NOT NULL DEFAULT '66011' +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `ftpConfig` -- @@ -9530,6 +8947,7 @@ CREATE TABLE `putOrder` ( `error` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `barcode` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `FHAdminNumber` int(11) DEFAULT '66011', PRIMARY KEY (`id`), UNIQUE KEY `orderTradelineItemID_UNIQUE` (`orderTradelineItemID`), KEY `deliveryInformationID_idx` (`deliveryInformationID`), @@ -9825,44 +9243,25 @@ CREATE TABLE `supplyResponse` ( /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER supplyResponse_BU -BEFORE UPDATE -ON supplyResponse FOR EACH ROW -BEGIN - - - INSERT INTO edi.supplyResponseLog (supplyResponseFk, NumberOfUnitsOld, NumberOfUnitsNew, lastVMPUpdate) - SELECT OLD.ID, OLD.NumberOfUnits, NEW.NumberOfUnits, v.dateTimeLastSync - FROM edi.VMPSettings v - WHERE v.VMPID = OLD.vmpID; - -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER supplyResponse_AFTER_UPDATE AFTER UPDATE ON supplyResponse FOR EACH ROW BEGIN -/* - IF NEW.NumberOfUnits = 0 AND OLD.NumberOfUnits <> 0 AND NEW.MarketPlaceID = 8713783439043 THEN - INSERT INTO vn.mail(sender, `subject`, body) - VALUES( 'jgallego@verdnatura.es', - 'Cantidad a cero', - CONCAT('SupplyResponse: ', NEW.ID, ', Articulo: ' , NEW.VBNOmschrijving)); - END IF;*/ + + UPDATE vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel tr ON tr.id = e.travelFk + JOIN vn.agencyMode am ON am.id = tr.agencyFk + JOIN vn.item i ON i.id = b.itemFk + JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID + SET b.quantity = NEW.NumberOfItemsPerCask * NEW.NumberOfUnits, + b.stickers = NEW.NumberOfUnits + WHERE i.supplyResponseFk = NEW.ID + AND am.name = 'LOGIFLORA' + AND e.isRaid + AND tr.landed >= CURDATE(); + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -10864,8 +10263,7 @@ proc: BEGIN numberOfItemsPerCask, embalageCode, quality, - isFloramondo, - inkFk) + isFloramondo) SELECT iti.itemFk, iti.product_name, iti.product_name, @@ -10878,11 +10276,9 @@ proc: BEGIN iti.NumberOfItemsPerCask, iti.EmbalageCode, iti.Quality, - TRUE, - ii.inkFk - FROM itemToInsert iti - LEFT JOIN vn.itemInk ii ON ii.longName = iti.product_name; - + TRUE + FROM itemToInsert iti; + INSERT IGNORE INTO vn.itemImageQueue(itemFk, url) SELECT i.id, PictureReference FROM itemToInsert ii @@ -10963,14 +10359,17 @@ proc: BEGIN JOIN vn.item i ON i.supplyResponseFk = ii.`srId` WHERE s6Value != ''; - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id, ink.name, 11 + INSERT IGNORE INTO vn.itemTag(itemFk, tagFk, value, priority) + SELECT i.id, t.id, IFNULL(ink.name, ik.color), 11 FROM itemToInsert ii JOIN vn.item i ON i.supplyResponseFk = ii.`srId` JOIN vn.tag t ON t.`name` = 'Color' - JOIN edi.feature f ON f.item_id = ii.Item_ArticleCode - JOIN edi.`type` tp ON tp.type_id = f.feature_type_id AND tp.`description` = 'Hoofdkleur 1' - JOIN vn.ink ON ink.dutchCode = f.feature_value; + LEFT JOIN edi.feature f ON f.item_id = ii.Item_ArticleCode + LEFT JOIN edi.`type` tp ON tp.type_id = f.feature_type_id AND tp.`description` = 'Hoofdkleur 1' + LEFT JOIN vn.ink ON ink.dutchCode = f.feature_value + LEFT JOIN vn.itemInk ik ON ik.longName = i.longName + WHERE ink.name IS NOT NULL + OR ik.color IS NOT NULL; UPDATE vn.item i JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId` @@ -11167,6 +10566,66 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `orderLog` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `orderLog`(vItemFk INT) +BEGIN + + DECLARE vSupplyResponseFk INT; + DECLARE vDescription VARCHAR(100); + + SELECT supplyResponseFk, CONCAT(id, ' ',longName) INTO vSupplyResponseFk, vDescription + FROM vn.item + WHERE id = vItemFk; + + SELECT * FROM + ( + SELECT 'Cliente confirma' accion, or2.created hora, amount Cantidad + FROM hedera.order_row or2 + JOIN vn.item i ON i.id = or2.item_id + WHERE i.supplyResponseFk = vSupplyResponseFk + + UNION ALL + + SELECT vDescription, NULL, NULL + + UNION ALL + + SELECT 'Cliente se conecta' , o.date_make , NULL + FROM hedera.`order` o + JOIN hedera.order_row or2 ON or2.order_id = o.id + JOIN vn.item i ON i.id = or2.item_id + WHERE i.supplyResponseFk = vSupplyResponseFk + + UNION ALL + + SELECT DISTINCT 'Subasta cambia cantidad', srl.created, srl.NumberOfUnitsNew * sr.NumberOfItemsPerCask + FROM edi.supplyResponseLog srl + JOIN edi.supplyResponse sr ON sr.ID = srl.supplyResponseFk + WHERE srl.supplyResponseFk = vSupplyResponseFk + + UNION ALL + + SELECT 'Linea de venta definitiva', s.created, s.quantity + FROM vn.sale s + JOIN vn.item i ON i.id = s.itemFk + WHERE i.supplyResponseFk = vSupplyResponseFk) sub + ORDER BY hora; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Current Database: `hedera` @@ -12058,7 +11517,7 @@ DROP TABLE IF EXISTS `orderConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `orderConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `employeeFk` int(11) NOT NULL, + `employeeFk` int(10) unsigned NOT NULL, `defaultAgencyFk` int(11) DEFAULT NULL, `guestMethod` varchar(45) CHARACTER SET utf8 NOT NULL, `guestAgencyFk` int(11) NOT NULL, @@ -12425,7 +11884,7 @@ CREATE TABLE `tpvConfig` ( `terminal` tinyint(3) unsigned NOT NULL, `transactionType` tinyint(3) unsigned NOT NULL, `maxAmount` int(10) unsigned DEFAULT NULL, - `employeeFk` int(10) NOT NULL, + `employeeFk` int(10) unsigned NOT NULL, `url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The bank web service URL for production environment', `testMode` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT 'Whether test mode is enabled', `testUrl` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT 'The bank web service URL for test environment', @@ -14750,29 +14209,24 @@ BEGIN SET available = GREATEST(0,available - vAmount) WHERE item_id = vItem AND calc_id = vCalc; - /* - CALL util.debugAdd('vShipment vWarehouse vOrder vClient vAmount vItem availableNoRaids', - CONCAT( vShipment,' ', - vWarehouse,' ', - vOrder,' ', - vClientId,' ', - vAmount,' ', - vItem, ' ', - @available)); - */ + INSERT INTO edi.putOrder (deliveryInformationID, supplyResponseId, quantity , EndUserPartyId, - EndUserPartyGLN) + EndUserPartyGLN, + FHAdminNumber) SELECT di.ID, i.supplyResponseFk, CEIL((vAmount - @available)/ sr.NumberOfItemsPerCask ), FALSE, - vClientId + vClientId, + IFNULL(ca.fhAdminNumber, fhc.defaultAdminNumber) FROM edi.deliveryInformation di JOIN vn.item i ON i.supplyResponseFk = di.supplyResponseID JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk + LEFT JOIN edi.clientFHAdminNumber ca ON ca.clientFk = vClientId + JOIN edi.floraHollandConfig fhc WHERE i.id = vItem AND di.LatestOrderDateTime > NOW() AND vAmount > @available @@ -17743,7 +17197,7 @@ CREATE TABLE `person` ( `firstname` varchar(20) DEFAULT NULL, `p2` longtext, `nis` int(11) DEFAULT NULL, - `id_trabajador` int(11) DEFAULT NULL, + `id_trabajador` int(10) unsigned DEFAULT NULL, `isDisable` smallint(6) NOT NULL DEFAULT '0', `isFreelance` smallint(6) NOT NULL DEFAULT '0' COMMENT 'M Male\nF Female', `isSsDiscounted` smallint(6) NOT NULL DEFAULT '0', @@ -20356,6 +19810,7 @@ BEGIN WHERE BASEEURO <> 0 AND ASIEN = (SELECT ASIEN FROM vn.XDiario WHERE id = vXDiarioId) )sub SET xmi.CodigoRetencion = t.CodigoRetencion, + xmi.ClaveOperacionFactura = IF( t.Retencion = 'ARRENDAMIENTO Y SUBARRENDAMIENTO', 'R', xmi.ClaveOperacionFactura), xmi.BaseRetencion = IF (t.CodigoRetencion = 2, sub.taxableBase + sub.taxBase, sub.taxableBase), xmi.PorRetencion = t.PorcentajeRetencion, xmi.ImporteRetencion = iit.taxableBase * - 1 @@ -20744,7 +20199,7 @@ BEGIN FROM vn2008.XDiario x LEFT JOIN vn.invoiceIn ii ON x.CLAVE = ii.id LEFT JOIN vn.invoiceInTax it ON it.invoiceInFk = ii.id - WHERE it.taxTypeSageFk IS NOT NULL AND + WHERE(it.taxTypeSageFk IS NOT NULL OR x.SERIE='D') AND x.enlazadoSage = FALSE AND x.FECHA >= vDated ) sub ON sub.ASIEN =x.ASIEN -- Elimina las Facturas con IVA 0 (-) no se trasladan a sage @@ -24565,13 +24020,13 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `throw`(vMessage CHAR(35)) +CREATE DEFINER=`root`@`%` PROCEDURE `throw`(vMessage CHAR(55)) BEGIN /** * Throws a user-defined exception. @@ -25189,8 +24644,8 @@ CREATE TABLE `agencyTerm` ( `packagePrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'precio extra por bulto', `routePrice` decimal(10,2) DEFAULT NULL COMMENT 'precio fijo por ruta', `minimumKm` int(11) NOT NULL DEFAULT '0', - `minimumM3` decimal(10,0) DEFAULT NULL, - `m3Price` decimal(10,0) DEFAULT NULL, + `minimumM3` decimal(10,0) NOT NULL DEFAULT '0', + `m3Price` decimal(10,0) NOT NULL DEFAULT '0', PRIMARY KEY (`agencyFk`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -25205,8 +24660,8 @@ DROP TABLE IF EXISTS `alertLevel`; CREATE TABLE `alertLevel` ( `code` varchar(45) CHARACTER SET utf8 NOT NULL, `alertLevel` int(11) NOT NULL, - PRIMARY KEY (`code`), - CONSTRAINT `fk_code_1` FOREIGN KEY (`code`) REFERENCES `state` (`code`) ON DELETE CASCADE ON UPDATE CASCADE + `id` int(11) NOT NULL, + PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -25324,7 +24779,7 @@ CREATE TABLE `awb` ( `package` float unsigned NOT NULL, `weight` float unsigned DEFAULT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `transitoryFk` int(11) NOT NULL DEFAULT '582', + `transitoryFk` int(11) DEFAULT NULL, `taxFk` int(10) unsigned DEFAULT '62', `duakk` varchar(18) COLLATE utf8_unicode_ci DEFAULT NULL, `docFk` int(11) DEFAULT NULL, @@ -25496,6 +24951,7 @@ CREATE TABLE `beach` ( `x` int(11) NOT NULL, `y` int(11) NOT NULL, `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `isShowed` tinyint(1) DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Ubicaciones respecto a la playa del almacén'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -25618,6 +25074,20 @@ CREATE TABLE `businessReasonEnd` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `businessType` +-- + +DROP TABLE IF EXISTS `businessType`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `businessType` ( + `code` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', + `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `buy` -- @@ -26069,7 +25539,10 @@ CREATE TABLE `chain` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, `rappel` decimal(5,2) NOT NULL DEFAULT '0.00', - PRIMARY KEY (`id`) + `componentFk` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `chain_FK` (`componentFk`), + CONSTRAINT `chain_FK` FOREIGN KEY (`componentFk`) REFERENCES `component` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Grupos de clientes'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26201,7 +25674,7 @@ CREATE TABLE `claimDevelopment` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `claimFk` int(10) unsigned NOT NULL, `claimResponsibleFk` int(10) unsigned NOT NULL DEFAULT '1', - `workerFk` int(11) DEFAULT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, `claimReasonFk` int(10) unsigned NOT NULL DEFAULT '1', `claimResultFk` int(10) unsigned NOT NULL DEFAULT '1', `claimRedeliveryFk` tinyint(3) unsigned NOT NULL DEFAULT '1', @@ -26252,7 +25725,7 @@ CREATE TABLE `claimEnd` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `saleFk` int(11) DEFAULT NULL, `claimFk` int(10) unsigned NOT NULL, - `workerFk` int(11) NOT NULL DEFAULT '20', + `workerFk` int(10) unsigned NOT NULL DEFAULT '20', `claimDestinationFk` tinyint(4) DEFAULT NULL, `isGreuge` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), @@ -26445,7 +25918,7 @@ CREATE TABLE `client` ( `invoiceCopy__` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', `hold` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', `isFreezed` tinyint(1) NOT NULL DEFAULT '0', - `salesPersonFk` int(11) DEFAULT NULL, + `salesPersonFk` int(10) unsigned DEFAULT NULL, `credit` decimal(10,2) NOT NULL DEFAULT '0.00', `cyc` double DEFAULT NULL COMMENT 'obsoleta (comprobar)', `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', @@ -26483,6 +25956,7 @@ CREATE TABLE `client` ( `transactionTypeSageFk` tinyint(4) DEFAULT NULL COMMENT 'Tipo de transacción por defecto asociado al cliente en SAGE', `transferorFk` int(11) DEFAULT NULL COMMENT 'Cliente que le ha transmitido la titularidad de la empresa', `lastSalesPersonFk` int(11) DEFAULT NULL COMMENT 'ultimo comercial que tuvo, para el calculo del peso en los rankings de equipo', + `businessTypeFk` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `IF` (`fi`), KEY `Id_Trabajador` (`salesPersonFk`), @@ -26500,7 +25974,9 @@ CREATE TABLE `client` ( KEY `typeFk` (`typeFk`), KEY `client_taxTypeSageFk_idx` (`taxTypeSageFk`), KEY `client_transactionTypeSageFk_idx` (`transactionTypeSageFk`), + KEY `client_FK` (`businessTypeFk`), CONSTRAINT `canal_nuevo_cliente` FOREIGN KEY (`contactChannelFk`) REFERENCES `contactChannel` (`id`) ON UPDATE CASCADE, + CONSTRAINT `client_FK` FOREIGN KEY (`businessTypeFk`) REFERENCES `businessType` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `client_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, CONSTRAINT `client_ibfk_2` FOREIGN KEY (`payMethodFk`) REFERENCES `payMethod` (`id`) ON UPDATE CASCADE, CONSTRAINT `client_ibfk_3` FOREIGN KEY (`salesPersonFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, @@ -26710,12 +26186,12 @@ CREATE TABLE `clientCredit` ( `clientFk` int(11) NOT NULL, `amount` double unsigned NOT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `workerFk` int(11) DEFAULT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `workers_fk_idx` (`workerFk`), KEY `credit_ClienteFk` (`clientFk`), CONSTRAINT `credit_ClienteFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `workers_fk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE + CONSTRAINT `workers_fk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26823,7 +26299,7 @@ DROP TABLE IF EXISTS `clientObservation`; CREATE TABLE `clientObservation` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `clientFk` int(11) NOT NULL, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, `text` text COLLATE utf8_unicode_ci NOT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), @@ -26885,7 +26361,7 @@ DROP TABLE IF EXISTS `clientProtected`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `clientProtected` ( `clientFk` int(11) NOT NULL, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `isValidated__` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`clientFk`), KEY `clientProtected_fk2_idx` (`workerFk`), @@ -27130,7 +26606,7 @@ DROP TABLE IF EXISTS `collection`; CREATE TABLE `collection` ( `id` int(11) NOT NULL AUTO_INCREMENT, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `workerFk` int(11) DEFAULT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, `stateFk` tinyint(3) unsigned DEFAULT NULL, `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, `saleTotalCount` int(11) NOT NULL DEFAULT '0', @@ -27316,7 +26792,7 @@ CREATE TABLE `company` ( `id` smallint(5) unsigned NOT NULL, `code` char(3) COLLATE utf8_unicode_ci DEFAULT NULL, `register` varchar(120) COLLATE utf8_unicode_ci NOT NULL, - `workerManagerFk` int(11) NOT NULL, + `workerManagerFk` int(10) unsigned NOT NULL, `registered` date NOT NULL, `expired` date DEFAULT NULL, `logo` longblob, @@ -27335,6 +26811,7 @@ CREATE TABLE `company` ( `companyCodeTest` int(2) DEFAULT NULL, `footnotes` longtext COLLATE utf8_unicode_ci COMMENT 'pie de paginas en las facturas', `phytosanitary` longtext COLLATE utf8_unicode_ci, + `fhAdminNumber` int(11) DEFAULT NULL COMMENT 'número de cliente en FloraHolland', PRIMARY KEY (`id`), KEY `gerente_id` (`workerManagerFk`), KEY `empresa_cliente_idx` (`clientFk`), @@ -27580,7 +27057,7 @@ DROP TABLE IF EXISTS `contratos_subvencion_270619`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `contratos_subvencion_270619` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `cod_centroFk` int(11) NOT NULL, `CodContratoFk` int(11) NOT NULL, `journey` decimal(5,2) NOT NULL DEFAULT '8.00', @@ -27612,7 +27089,8 @@ CREATE TABLE `conveyor` ( `height` int(11) DEFAULT NULL, `x` int(11) DEFAULT NULL, `y` int(11) DEFAULT NULL, - `color` int(11) DEFAULT '14548991', + `freeSpace` int(11) NOT NULL DEFAULT '0', + `isBusy` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `conveyor_fk1_idx` (`typeFk`), CONSTRAINT `conveyor_fk1` FOREIGN KEY (`typeFk`) REFERENCES `conveyorType` (`id`) ON UPDATE CASCADE @@ -27663,14 +27141,16 @@ CREATE TABLE `conveyorExpedition` ( `expeditionFk` int(11) NOT NULL, `conveyorFk` int(11) DEFAULT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `conveyorBuildingClassFk` int(11) NOT NULL, + `conveyorBuildingClassFk` int(11) NOT NULL DEFAULT '1', `length` int(11) NOT NULL DEFAULT '1', `width` int(11) NOT NULL DEFAULT '1', `height` int(11) NOT NULL DEFAULT '1', - `x` int(11) NOT NULL DEFAULT '1', + `x` int(11) NOT NULL DEFAULT '18100', `y` int(11) NOT NULL DEFAULT '1', `routeFk` int(11) NOT NULL, - `isBuilt` tinyint(4) NOT NULL DEFAULT '0', + `isIn` tinyint(4) NOT NULL DEFAULT '0', + `productionMinute` int(11) DEFAULT NULL, + `isOut` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`expeditionFk`), KEY `conveyorExpedition_fk1_idx` (`conveyorFk`), KEY `conveyorExpedition_fk2_idx` (`conveyorBuildingClassFk`), @@ -27723,6 +27203,7 @@ DROP TABLE IF EXISTS `conveyorType`; CREATE TABLE `conveyorType` ( `id` int(11) NOT NULL AUTO_INCREMENT, `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `color` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -28203,7 +27684,7 @@ CREATE TABLE `department` ( `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, `lft` int(11) DEFAULT NULL, `rgt` int(11) DEFAULT NULL, - `workerFk` int(11) DEFAULT NULL COMMENT 'Id_Trabajador es el jefe del departamento', + `workerFk` int(10) unsigned DEFAULT NULL COMMENT 'Id_Trabajador es el jefe del departamento', `companyFk` int(11) NOT NULL, `bossFk__` int(11) DEFAULT NULL, `x__` int(11) DEFAULT NULL, @@ -28217,6 +27698,7 @@ CREATE TABLE `department` ( `chatName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `isTeleworking` tinyint(1) DEFAULT '0', `notificationEmail` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, + `hasToRefill` tinyint(1) DEFAULT '0' COMMENT 'Rellenar días sin fichadas presenciales', PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`), KEY `fk_department_Trabajadores1_idx` (`workerFk`), @@ -28296,7 +27778,7 @@ CREATE TABLE `departmentItemType` ( `id` int(11) NOT NULL AUTO_INCREMENT, `departmentFk` int(11) NOT NULL, `itemTypeFk` smallint(5) unsigned NOT NULL, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `departmentItemTypeIdx1_idx` (`departmentFk`,`itemTypeFk`), KEY `departmentItemTypeIdx2_idx` (`itemTypeFk`), @@ -28439,7 +27921,7 @@ CREATE TABLE `dms` ( `contentType` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, `file` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, `hasFile` tinyint(4) NOT NULL DEFAULT '0', - `workerFk` int(11) DEFAULT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT '60', PRIMARY KEY (`id`), @@ -29144,26 +28626,6 @@ CREATE TABLE `entryObservation` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `entryShelving__` --- - -DROP TABLE IF EXISTS `entryShelving__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `entryShelving__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `entryFk` int(11) NOT NULL DEFAULT '204539', - `shelvingFk` varchar(10) CHARACTER SET utf8 NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `shelvingFk_UNIQUE` (`shelvingFk`), - KEY `entryShelving_fk1_idx` (`entryFk`), - KEY `entryShelving_fk2_idx` (`shelvingFk`), - CONSTRAINT `entryShelving_fk1` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `entryShelving_fk2` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='relaciona matriculas con entradas'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `entrySplit` -- @@ -29647,7 +29109,7 @@ CREATE TABLE `expeditionScan` ( `expeditionFk` int(11) NOT NULL, `scanned` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `palletFk` int(11) NOT NULL, - `workerFk` int(11) DEFAULT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `expeditionFk_UNIQUE` (`expeditionFk`), KEY `expeditionScan_fk1_idx` (`expeditionFk`), @@ -30239,8 +29701,8 @@ CREATE TABLE `inventoryFailure` ( `quantity` int(11) NOT NULL, `value` decimal(10,2) NOT NULL, `warehouseFk` smallint(6) unsigned NOT NULL, - `throwerFk` int(11) DEFAULT NULL, - `guiltyFk` int(11) DEFAULT NULL, + `throwerFk` int(10) unsigned DEFAULT NULL, + `guiltyFk` int(10) unsigned DEFAULT NULL, `causeFk` int(11) DEFAULT NULL, `explanation` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -30344,7 +29806,7 @@ CREATE TABLE `invoiceIn` ( `serialNumber` mediumint(11) unsigned DEFAULT NULL COMMENT 'insertado por Trigger', `serial` char(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'R', `supplierFk` int(11) NOT NULL, - `issued` date NOT NULL COMMENT 'Fecha de emision de la factura', + `issued` date DEFAULT NULL COMMENT 'Fecha de emision de la factura', `supplierRef` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `isBooked` tinyint(1) NOT NULL DEFAULT '0', `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT '1', @@ -30503,13 +29965,23 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `invoiceIn_au` AFTER UPDATE ON `invoiceIn` FOR EACH ROW BEGIN - IF NEW.issued != OLD.issued - OR - NEW.currencyFk != OLD.currencyFk - THEN - - -- CALL vn2008.recibidaIvaDivisaUpdate(NEW.id); - + IF NEW.issued != OLD.issued + OR NEW.currencyFk != OLD.currencyFk THEN + + UPDATE invoiceInTax iit + JOIN invoiceIn ii ON ii.id = iit.invoiceInFk + LEFT JOIN referenceRate rr ON rr.dated = ii.issued + AND rr.currencyFk = ii.currencyFk + SET iit.taxableBase = IF(iit.foreignValue IS NULL, iit.taxableBase, iit.foreignValue / rr.value) + WHERE ii.id = NEW.id; + + UPDATE invoiceInDueDay iidd + JOIN invoiceIn ii ON ii.id = iidd.invoiceInFk + LEFT JOIN referenceRate rr ON rr.dated = ii.issued + AND rr.currencyFk = ii.currencyFk + SET iidd.amount = IF(iidd.foreignValue IS NULL, iidd.amount, iidd.foreignValue / rr.value) + WHERE ii.id = NEW.id; + END IF; END */;; @@ -31085,7 +30557,7 @@ CREATE TABLE `item` ( `minPrice` double DEFAULT '0', `isToPrint` tinyint(1) NOT NULL DEFAULT '0', `isDeliveryNote__` tinyint(1) NOT NULL DEFAULT '0', - `taxClassFk` tinyint(4) unsigned NOT NULL DEFAULT '1', + `taxClassFk__` tinyint(4) unsigned NOT NULL DEFAULT '1', `family` varchar(3) CHARACTER SET utf8 NOT NULL DEFAULT 'VT', `box` tinyint(1) NOT NULL DEFAULT '0', `category` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -31142,7 +30614,7 @@ CREATE TABLE `item` ( KEY `Color` (`inkFk`), KEY `id_origen` (`originFk`), KEY `Codintrastat` (`intrastatFk`), - KEY `iva_group_id` (`taxClassFk`), + KEY `iva_group_id` (`taxClassFk__`), KEY `tipo_id` (`typeFk`), KEY `producer_id` (`producerFk`), KEY `ArticlesIsActive_idx` (`isActive`), @@ -31157,7 +30629,7 @@ CREATE TABLE `item` ( CONSTRAINT `item_family` FOREIGN KEY (`family`) REFERENCES `itemFamily` (`code`) ON UPDATE CASCADE, CONSTRAINT `item_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `origin` (`id`) ON UPDATE CASCADE, CONSTRAINT `item_ibfk_2` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE, - CONSTRAINT `item_ibfk_4` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE, + CONSTRAINT `item_ibfk_4` FOREIGN KEY (`taxClassFk__`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE, CONSTRAINT `item_ibfk_5` FOREIGN KEY (`typeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, CONSTRAINT `item_ibfk_6` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `itemsupplyResponseFk` FOREIGN KEY (`supplyResponseFk`) REFERENCES `edi`.`supplyResponse` (`ID`) ON DELETE SET NULL ON UPDATE CASCADE, @@ -31223,21 +30695,21 @@ DELIMITER ;; BEGIN CALL hedera.image_ref('catalog', NEW.image); - INSERT INTO vn.itemTaxCountry(itemFk, countryFk, taxClassFk) - SELECT NEW.id, 1, NEW.taxClassFk; + INSERT INTO vn.itemTaxCountry(itemFk, countryFk) + SELECT NEW.id, 1; - INSERT INTO vn.itemTaxCountry(itemFk, countryFk, taxClassFk) - SELECT NEW.id, 5, NEW.taxClassFk; + INSERT INTO vn.itemTaxCountry(itemFk, countryFk) + SELECT NEW.id, 5; - INSERT INTO vn.itemTaxCountry(itemFk, countryFk, taxClassFk) - SELECT NEW.id, 30, NEW.taxClassFk; -/* + INSERT INTO vn.itemTaxCountry(itemFk, countryFk) + SELECT NEW.id, 30; + /* IF NEW.typeFk IS NOT NULL THEN INSERT INTO vn.itemTag (itemFk, tagFk, priority) SELECT NEW.id, tagFk, priority FROM vn.itemTypeTag WHERE itemTypeFk = NEW.typeFk; - END IF; -*/ + END IF;*/ + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -31331,57 +30803,10 @@ CREATE TABLE `itemBotanical` ( KEY `genusFgn_idx` (`genusFk`), KEY `specieFgn_idx` (`specieFk`), CONSTRAINT `itemBotanicalItemFkFk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `itemBotanical_FK` FOREIGN KEY (`specieFk`) REFERENCES `specie` (`id`) ON DELETE SET NULL ON UPDATE CASCADE + CONSTRAINT `itemBotanical_FK` FOREIGN KEY (`specieFk`) REFERENCES `specie` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `itemBotanical_FK_1` FOREIGN KEY (`genusFk`) REFERENCES `genus` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Sustituye a antiguo NomBotanic de Articles'; /*!40101 SET character_set_client = @saved_cs_client */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`itemBotanical_beforeInsert` BEFORE INSERT ON `itemBotanical` FOR EACH ROW -BEGIN -/** - * Hay una versión en salix que machacará toda esta función/procedimiento avisa - * a jgallego de los cambios que quieres hacer. - */ - /*IF (NEW.botanical >= '') THEN - CALL util.throw('no se puede modificar el nombre botanico, use los campos genero y especie'); - END IF;*/ -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`itemBotanical_beforeUpdate` BEFORE UPDATE ON `itemBotanical` FOR EACH ROW -BEGIN -/** - * Hay una versión en salix que machacará toda esta función/procedimiento avisa - * a jgallego de los cambios que quieres hacer. - - IF (NEW.botanical >= '') THEN - CALL util.throw('no se puede modificar el nombre botanico, use los campos genero y especie'); - END IF; */ -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Temporary table structure for view `itemBotanicalWithGenus` @@ -31629,7 +31054,8 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `itemInk` ( `longName` tinyint NOT NULL, - `inkFk` tinyint NOT NULL + `inkFk` tinyint NOT NULL, + `color` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; @@ -32590,7 +32016,7 @@ CREATE TABLE `itemType` ( `order` int(11) DEFAULT '0', `temperature` tinyint(1) unsigned NOT NULL DEFAULT '0', `categoryFk` int(10) unsigned NOT NULL, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `isInventory` tinyint(4) NOT NULL DEFAULT '1' COMMENT 'Se utiliza tanto en el cálculo del inventario, como en el del informe del inventario valorado', `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `f11` tinyint(4) NOT NULL DEFAULT '0', @@ -32874,7 +32300,7 @@ CREATE TABLE `machine` ( `use` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `productionYear` int(11) DEFAULT NULL, `photo` blob, - `workerFk` int(11) DEFAULT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', `ppeFk` int(11) DEFAULT NULL, `supplierFk` int(11) DEFAULT NULL, @@ -32882,8 +32308,8 @@ CREATE TABLE `machine` ( UNIQUE KEY `plate` (`plate`), UNIQUE KEY `serialNumber` (`serialNumber`), KEY `machine_FK` (`ppeFk`), - KEY `machine_FK_1` (`workerFk`), KEY `machine_FK_2` (`supplierFk`), + KEY `machine_FK_1` (`workerFk`), CONSTRAINT `machine_FK` FOREIGN KEY (`ppeFk`) REFERENCES `ppe` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `machine_FK_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `machine_FK_2` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON DELETE SET NULL ON UPDATE CASCADE @@ -32925,12 +32351,12 @@ CREATE TABLE `machineDetail` ( `dated` date NOT NULL, `action` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `value` decimal(10,2) DEFAULT NULL, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `dmsFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `machineDetail_FK` (`machineFk`), - KEY `machineDetail_FK_1` (`workerFk`), KEY `machineDetail_FK_2` (`dmsFk`), + KEY `machineDetail_FK_1` (`workerFk`), CONSTRAINT `machineDetail_FK` FOREIGN KEY (`machineFk`) REFERENCES `machine` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `machineDetail_FK_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `machineDetail_FK_2` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE SET NULL ON UPDATE CASCADE @@ -33100,7 +32526,7 @@ DROP TABLE IF EXISTS `medicalReview`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `medicalReview` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `centerFk` int(11) NOT NULL, `date` date DEFAULT NULL, `time` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -33223,7 +32649,7 @@ DROP TABLE IF EXISTS `mobileAppVersionControl`; CREATE TABLE `mobileAppVersionControl` ( `id` int(11) NOT NULL AUTO_INCREMENT, `appName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `version` int(11) NOT NULL DEFAULT '0', + `version` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla para llevar el control de las Versions de las aplicaciones móvil '; /*!40101 SET character_set_client = @saved_cs_client */; @@ -33823,7 +33249,7 @@ CREATE TABLE `person` ( `fi` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, `birth` date DEFAULT NULL, `readerId` int(11) DEFAULT NULL, - `workerFk` int(11) DEFAULT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, `isDisable` tinyint(1) NOT NULL DEFAULT '0', `isFreelance` tinyint(1) NOT NULL DEFAULT '0', `isSsDiscounted` tinyint(1) NOT NULL DEFAULT '0', @@ -34071,7 +33497,7 @@ CREATE TABLE `ppe` ( `cause` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `photo` blob, `isInvestmentAsset` tinyint(4) NOT NULL DEFAULT '0', - `workerFk` int(11) DEFAULT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -34160,48 +33586,6 @@ CREATE TABLE `ppePlan` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Plan de amortizacion para la tabla ppe'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `priceBuilderWarehouse__` --- - -DROP TABLE IF EXISTS `priceBuilderWarehouse__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `priceBuilderWarehouse__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `warehouseFk` smallint(6) unsigned NOT NULL, - `priceBuilderFk` int(11) NOT NULL, - PRIMARY KEY (`id`), - KEY `priceBuilderWarehouse_fk1_idx` (`warehouseFk`), - KEY `priceBuilderWarehouse_fk2_idx` (`priceBuilderFk`), - CONSTRAINT `priceBuilderWarehouse_fk1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `priceBuilderWarehouse_fk2` FOREIGN KEY (`priceBuilderFk`) REFERENCES `priceBuilder__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `priceBuilder__` --- - -DROP TABLE IF EXISTS `priceBuilder__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `priceBuilder__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `itemTypeFk` smallint(5) unsigned NOT NULL COMMENT 'Sirve para definir precios en tarifa2 para grupos de items', - `started` date DEFAULT NULL, - `finished` date DEFAULT NULL, - `price` decimal(10,3) NOT NULL, - `userFk` int(10) unsigned DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `priceBuilder_fk1_idx` (`itemTypeFk`), - KEY `priceBuilder_fk2_idx` (`userFk`), - CONSTRAINT `priceBuilder_fk1` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `priceBuilder_fk2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `priceFixed` -- @@ -34293,7 +33677,7 @@ CREATE TABLE `printServerQueue` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `printerFk` tinyint(3) unsigned DEFAULT NULL, `priorityFk` tinyint(3) unsigned DEFAULT NULL, - `labelReportFk` tinyint(3) unsigned DEFAULT '0', + `labelReportFk` tinyint(3) unsigned DEFAULT NULL, `statusFk` tinyint(3) unsigned DEFAULT '1', `started` datetime DEFAULT NULL, `finished` datetime DEFAULT NULL, @@ -34303,13 +33687,15 @@ CREATE TABLE `printServerQueue` ( `param3` text COLLATE utf8_unicode_ci, `error` text COLLATE utf8_unicode_ci, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `reportFk` tinyint(3) DEFAULT NULL, + `reportFk__` tinyint(3) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `Id_Impresora_2` (`printerFk`,`priorityFk`,`labelReportFk`,`statusFk`,`param1`,`workerFk`,`param2`), KEY `Id_estado` (`statusFk`), KEY `Id_Impresora` (`printerFk`), KEY `Id_Prioridad` (`priorityFk`), KEY `Id_Trabajador` (`workerFk`), + KEY `printServerQueue_FK` (`labelReportFk`), + CONSTRAINT `printServerQueue_FK` FOREIGN KEY (`labelReportFk`) REFERENCES `labelReport` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `printServerQueue_ibfk_3` FOREIGN KEY (`priorityFk`) REFERENCES `queuePriority` (`id`) ON UPDATE CASCADE, CONSTRAINT `printServerQueue_ibfk_4` FOREIGN KEY (`printerFk`) REFERENCES `vn2008`.`Impresoras` (`Id_Impresora`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -34345,6 +33731,40 @@ CREATE TABLE `printServerQueue2` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `printServerQueue3` +-- + +DROP TABLE IF EXISTS `printServerQueue3`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `printServerQueue3` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `printerFk` tinyint(3) unsigned DEFAULT NULL, + `priorityFk` tinyint(3) unsigned DEFAULT NULL, + `labelReportFk` tinyint(3) unsigned DEFAULT NULL, + `statusFk` tinyint(3) unsigned DEFAULT '1', + `started` datetime DEFAULT NULL, + `finished` datetime DEFAULT NULL, + `param1` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `workerFk` int(11) DEFAULT NULL, + `param2` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `param3` text COLLATE utf8_unicode_ci, + `error` text COLLATE utf8_unicode_ci, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `reportFk__` tinyint(3) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `Id_Impresora_2` (`printerFk`,`priorityFk`,`labelReportFk`,`statusFk`,`param1`,`workerFk`,`param2`), + KEY `Id_estado` (`statusFk`), + KEY `Id_Impresora` (`printerFk`), + KEY `Id_Prioridad` (`priorityFk`), + KEY `Id_Trabajador` (`workerFk`), + KEY `printServerQueue_FK` (`labelReportFk`), + CONSTRAINT `printServerQueue3_ibfk_3` FOREIGN KEY (`priorityFk`) REFERENCES `queuePriority` (`id`) ON UPDATE CASCADE, + CONSTRAINT `printServerQueue3_ibfk_4` FOREIGN KEY (`printerFk`) REFERENCES `vn2008`.`Impresoras` (`Id_Impresora`) ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `printingQueueCheck` -- @@ -34699,7 +34119,7 @@ CREATE TABLE `receipt` ( `amountPaid` decimal(10,2) NOT NULL DEFAULT '0.00', `amountUnpaid` decimal(10,2) NOT NULL DEFAULT '0.00', `payed` datetime DEFAULT NULL, - `workerFk` int(11) DEFAULT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, `bankFk` int(11) DEFAULT '0', `clientFk` int(11) DEFAULT '0', `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, @@ -34956,7 +34376,7 @@ DROP TABLE IF EXISTS `route`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `route` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `workerFk` int(11) DEFAULT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, `created` date NOT NULL, `vehicleFk` int(10) unsigned DEFAULT NULL, `agencyModeFk` int(11) DEFAULT NULL, @@ -35093,7 +34513,7 @@ DROP TABLE IF EXISTS `routeComplement`; CREATE TABLE `routeComplement` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dated` date NOT NULL, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `price` decimal(10,2) NOT NULL, `routeActionFk` int(11) NOT NULL, PRIMARY KEY (`id`), @@ -35132,7 +34552,10 @@ CREATE TABLE `routeConfig` ( `distributionM3Category2` decimal(5,2) DEFAULT NULL, `plusCategory1Concept` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `plusCategory2Concept` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`id`) + `defaultCompanyFk` smallint(5) unsigned DEFAULT '442', + PRIMARY KEY (`id`), + KEY `routeConfig_FK` (`defaultCompanyFk`), + CONSTRAINT `routeConfig_FK` FOREIGN KEY (`defaultCompanyFk`) REFERENCES `company` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -35205,7 +34628,7 @@ DROP TABLE IF EXISTS `routeLoadWorker`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `routeLoadWorker` ( `routeFk` int(10) unsigned NOT NULL, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, PRIMARY KEY (`routeFk`,`workerFk`), KEY `frmWorker_idx` (`workerFk`), CONSTRAINT `frmRutas` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, @@ -35249,7 +34672,7 @@ DROP TABLE IF EXISTS `routeUserPercentage`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `routeUserPercentage` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `percentage` decimal(10,2) NOT NULL, `dated` date NOT NULL, PRIMARY KEY (`id`), @@ -35321,7 +34744,7 @@ CREATE TABLE `sale` ( /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER sale_afterInsert AFTER INSERT @@ -35360,18 +34783,18 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER sale_beforeUpdate BEFORE UPDATE ON sale FOR EACH ROW BEGIN - +/* IF (SELECT COUNT(*) from item i WHERE id = NEW.itemFk AND family = 'SER') THEN CALL util.throw('Cannot insert a service item into a ticket'); END IF; - +*/ IF NEW.discount > 100 THEN SET NEW.discount = 0; END IF; @@ -35394,7 +34817,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `sale_afterUpdate` AFTER UPDATE ON `sale` @@ -35403,6 +34826,7 @@ BEGIN DECLARE vIsToSendMail BOOL; DECLARE vPickedLines INT; DECLARE vCollectionFk INT; + DECLARE vUserRole VARCHAR(255); IF !(NEW.id <=> OLD.id) OR !(NEW.ticketFk <=> OLD.ticketFk) @@ -35427,11 +34851,16 @@ BEGIN WHERE saleFk = NEW.id; END IF; + SELECT account.myUser_getName() INTO vUserRole; + SELECT account.user_getMysqlRole(vUserRole) INTO vUserRole; + IF !(OLD.quantity <=> NEW.quantity) THEN SELECT COUNT(*) INTO vIsToSendMail FROM vncontrol.inter i JOIN vn.state s ON s.id = i.state_id - WHERE s.code='PACKED' AND i.Id_Ticket = OLD.ticketFk + WHERE s.code='PACKED' + AND i.Id_Ticket = OLD.ticketFk + AND vUserRole IN ('salesPerson', 'salesBoss') LIMIT 1; IF vIsToSendMail THEN @@ -35478,9 +34907,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -35489,14 +34918,20 @@ DELIMITER ;; FOR EACH ROW BEGIN DECLARE vIsToSendMail BOOL; + DECLARE vUserRole VARCHAR(255); CALL stock.log_add('sale', NULL, OLD.id); CALL ticket_requestRecalc(OLD.ticketFk); + SELECT account.myUser_getName() INTO vUserRole; + SELECT account.user_getMysqlRole(vUserRole) INTO vUserRole; + SELECT COUNT(*) INTO vIsToSendMail FROM vncontrol.inter i JOIN vn.state s ON s.id = i.state_id - WHERE s.code='PACKED' AND i.Id_Ticket = OLD.ticketFk + WHERE s.code='PACKED' + AND i.Id_Ticket = OLD.ticketFk + AND vUserRole IN ('salesPerson', 'salesBoss') LIMIT 1; IF vIsToSendMail THEN @@ -35686,13 +35121,13 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `saleItemShelving` +-- Table structure for table `saleItemShelving__` -- -DROP TABLE IF EXISTS `saleItemShelving`; +DROP TABLE IF EXISTS `saleItemShelving__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `saleItemShelving` ( +CREATE TABLE `saleItemShelving__` ( `id` int(11) NOT NULL AUTO_INCREMENT, `saleFk` int(11) NOT NULL, `itemShelvingFk` int(10) unsigned NOT NULL, @@ -35714,7 +35149,7 @@ DROP TABLE IF EXISTS `saleMistake`; CREATE TABLE `saleMistake` ( `id` int(11) NOT NULL AUTO_INCREMENT, `saleFk` int(11) NOT NULL, - `userFk` int(11) NOT NULL, + `userFk` int(10) unsigned NOT NULL, `typeFk` int(11) NOT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), @@ -36056,7 +35491,7 @@ CREATE TABLE `sector` ( `isMain` tinyint(1) NOT NULL DEFAULT '0', `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, `workerFk` int(11) DEFAULT NULL, - `labelReport` tinyint(3) DEFAULT NULL, + `labelReport__` tinyint(3) DEFAULT NULL, `printerFk` tinyint(3) unsigned DEFAULT NULL, PRIMARY KEY (`id`,`warehouseFk`), UNIQUE KEY `code_UNIQUE` (`code`), @@ -36076,10 +35511,10 @@ DROP TABLE IF EXISTS `sharingCart`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sharingCart` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `started` date NOT NULL, `ended` date NOT NULL, - `workerSubstitute` int(11) NOT NULL, + `workerSubstitute` int(10) unsigned NOT NULL, `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `workerFk_UNIQUE` (`workerFk`,`started`,`ended`,`workerSubstitute`), @@ -36175,8 +35610,8 @@ DROP TABLE IF EXISTS `sharingCartDaily`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sharingCartDaily` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `ownerFk` int(11) NOT NULL, - `substituteFk` int(11) NOT NULL, + `ownerFk` int(10) unsigned NOT NULL, + `substituteFk` int(10) unsigned NOT NULL, `dated` date NOT NULL, `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), @@ -36196,7 +35631,7 @@ DROP TABLE IF EXISTS `sharingClient`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sharingClient` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `started` date NOT NULL, `ended` date NOT NULL, `clientFk` int(11) NOT NULL, @@ -36259,7 +35694,7 @@ CREATE TABLE `shelving` ( `isPrinted` tinyint(4) NOT NULL DEFAULT '0', `priority` int(11) DEFAULT NULL, `parked` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `userFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`code`), KEY `shelving_fk1_idx` (`parkingFk`), KEY `shelving_fk2_idx` (`userFk`), @@ -36312,7 +35747,7 @@ CREATE TABLE `sinister` ( `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `insureRate` decimal(3,2) NOT NULL DEFAULT '0.75', `isBooked` tinyint(4) NOT NULL DEFAULT '0', - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `companyFk` smallint(5) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `sinister_fk1_idx` (`supplierFk`), @@ -36340,7 +35775,7 @@ CREATE TABLE `sinisterDetail` ( `amountIn` decimal(10,2) DEFAULT NULL, `amountOut` decimal(10,2) DEFAULT NULL, `isConciliated` tinyint(1) NOT NULL DEFAULT '0', - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `bankFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `sinisterDetail_fk1_idx` (`sinisterFk`), @@ -36613,8 +36048,9 @@ DROP TABLE IF EXISTS `starredModule`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `starredModule` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `workerFk` int(10) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `moduleFk` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `position` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `starred_workerFk` (`workerFk`), KEY `starred_moduleFk` (`moduleFk`), @@ -36648,7 +36084,9 @@ CREATE TABLE `state` ( `isNotValidated` tinyint(1) DEFAULT '0' COMMENT 'Los tienen que ser validados por un comercial para prepararse', PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`), - KEY `state_id3` (`semaphore`) + KEY `state_id3` (`semaphore`), + KEY `alertLevel` (`alertLevel`), + CONSTRAINT `state_ibfk_1` FOREIGN KEY (`alertLevel`) REFERENCES `alertLevel` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36725,7 +36163,7 @@ CREATE TABLE `supplier` ( `withholdingSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipos de retención SAGE', `transactionTypeSageFk` tinyint(4) DEFAULT NULL COMMENT 'Ti po de transacción SAGE', `isTrucker` tinyint(1) NOT NULL DEFAULT '0', - `workerFk` int(11) DEFAULT NULL COMMENT 'Responsible for approving invoices', + `workerFk` int(10) unsigned DEFAULT NULL COMMENT 'Responsible for approving invoices', `supplierActivityFk` varchar(45) NOT NULL DEFAULT 'flowersPlants', `healthRegister` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`), @@ -36820,6 +36258,29 @@ CREATE TABLE `supplierActivity` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `supplierAddress` +-- + +DROP TABLE IF EXISTS `supplierAddress`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `supplierAddress` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `supplierFk` int(11) DEFAULT NULL, + `nickname` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, + `street` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `provinceFk` smallint(6) unsigned DEFAULT NULL, + `postalCode` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `city` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `phone` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `mobile` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `supplierAddress_province_fk` (`provinceFk`), + CONSTRAINT `supplierAddress_province_fk` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `supplierContact` -- @@ -36898,7 +36359,7 @@ CREATE TABLE `supplierLog` ( KEY `supplierLog_ibfk_2` (`userFk`), CONSTRAINT `supplierLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `supplier` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `supplierLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -37172,7 +36633,7 @@ CREATE TABLE `ticket` ( `shipped` datetime NOT NULL, `nickname` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `notes` longtext COLLATE utf8_unicode_ci, - `refFk` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `refFk` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `invoiceOutFk` int(10) unsigned DEFAULT NULL COMMENT 'eliminar', `isBooked` tinyint(1) NOT NULL DEFAULT '0', `addressFk` int(11) NOT NULL DEFAULT '0', @@ -37196,7 +36657,7 @@ CREATE TABLE `ticket` ( `isBoxed` tinyint(2) NOT NULL DEFAULT '0', `isDeleted` tinyint(2) NOT NULL DEFAULT '0', `zoneFk` int(11) DEFAULT NULL, - `collectionFk` int(11) DEFAULT NULL, + `collectionFk__` int(11) DEFAULT NULL, `zonePrice` decimal(10,2) DEFAULT NULL, `zoneBonus` decimal(10,2) DEFAULT NULL, `totalWithVat` decimal(10,2) DEFAULT NULL COMMENT 'cache calculada del total con iva', @@ -37213,15 +36674,15 @@ CREATE TABLE `ticket` ( KEY `warehouse_date` (`warehouseFk`,`shipped`), KEY `Fecha` (`shipped`,`clientFk`), KEY `tickets_zone_fk_idx` (`zoneFk`), - KEY `tickets_fk11_idx` (`collectionFk`), + KEY `tickets_fk11_idx` (`collectionFk__`), + CONSTRAINT `ticket_FK` FOREIGN KEY (`refFk`) REFERENCES `invoiceOut` (`ref`) ON UPDATE CASCADE, CONSTRAINT `ticket_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticket_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticket_ibfk_5` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticket_ibfk_6` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticket_ibfk_8` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`), CONSTRAINT `ticket_ibfk_9` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `tickets_fk10` FOREIGN KEY (`refFk`) REFERENCES `invoiceOut` (`ref`) ON UPDATE CASCADE, - CONSTRAINT `tickets_fk11` FOREIGN KEY (`collectionFk`) REFERENCES `collection` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `tickets_fk11` FOREIGN KEY (`collectionFk__`) REFERENCES `collection` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `tickets_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -37649,6 +37110,21 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `ticketLocation` +-- + +DROP TABLE IF EXISTS `ticketLocation`; +/*!50001 DROP VIEW IF EXISTS `ticketLocation`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `ticketLocation` ( + `ticketFk` tinyint NOT NULL, + `longitude` tinyint NOT NULL, + `latitude` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `ticketLog` -- @@ -37771,7 +37247,7 @@ CREATE TABLE `ticketPackaging` ( `quantity` int(10) DEFAULT '0', `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `pvp` double DEFAULT NULL, - `workerFk` int(11) DEFAULT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `ticketPackaging_fk1_idx` (`ticketFk`), KEY `ticketPackaging_fk2_idx` (`packagingFk`), @@ -37841,7 +37317,8 @@ SET character_set_client = utf8; `province` tinyint NOT NULL, `itemFk` tinyint NOT NULL, `concept` tinyint NOT NULL, - `quantity` tinyint NOT NULL + `quantity` tinyint NOT NULL, + `litros` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; @@ -37948,8 +37425,8 @@ CREATE TABLE `ticketRequest` ( `saleFk` int(11) DEFAULT NULL, `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `isOk` tinyint(1) DEFAULT NULL, - `requesterFk` int(11) DEFAULT NULL, - `attenderFk` int(11) DEFAULT NULL, + `requesterFk` int(10) unsigned DEFAULT NULL, + `attenderFk` int(10) unsigned DEFAULT NULL, `ticketFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `Id_Movimiento_UNIQUE` (`saleFk`), @@ -38048,6 +37525,69 @@ CREATE TABLE `ticketService` ( CONSTRAINT `ticketService_ticketServiceType` FOREIGN KEY (`ticketServiceTypeFk`) REFERENCES `ticketServiceType` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Servicios asociadas a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`ticketService_ai` AFTER INSERT ON `ticketService` FOR EACH ROW +BEGIN + + CALL ticket_requestRecalc(NEW.ticketFk); + +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`ticketService_au` AFTER UPDATE ON `ticketService` FOR EACH ROW +BEGIN + IF !(NEW.price <=> OLD.price) + OR !(NEW.ticketFk <=> OLD.ticketFk) + OR !(NEW.quantity <=> OLD.quantity) THEN + CALL ticket_requestRecalc(NEW.ticketFk); + CALL ticket_requestRecalc(OLD.ticketFk); + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`ticketService_ad` AFTER DELETE ON `ticketService` FOR EACH ROW +BEGIN + + CALL ticket_requestRecalc(OLD.ticketFk); + +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Table structure for table `ticketServiceType` @@ -38192,7 +37732,7 @@ CREATE TABLE `till` ( `in` decimal(10,2) DEFAULT NULL, `out` decimal(10,2) DEFAULT NULL, `bankFk` int(11) DEFAULT '1', - `workerFk` int(11) DEFAULT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, `companyFk` smallint(5) unsigned DEFAULT '442' COMMENT 'kakear', `isLinked` tinyint(4) DEFAULT '0', `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, @@ -38512,7 +38052,7 @@ DROP TABLE IF EXISTS `trainingCourse`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `trainingCourse` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `trainingCourseTypeFk` int(11) NOT NULL, `centerFk` int(11) DEFAULT NULL, `started` datetime NOT NULL, @@ -38757,7 +38297,7 @@ DROP TABLE IF EXISTS `trolley`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `trolley` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `workerFk` int(11) DEFAULT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, `coupled` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `trolley_FK` (`workerFk`), @@ -38904,7 +38444,8 @@ CREATE TABLE `volumeConfig` ( `standardFlowerBox` int(11) NOT NULL COMMENT 'en litros', `minCompressionRate` decimal(10,2) DEFAULT '0.30' COMMENT 'minimo permitido por la empresa', `ccLength` int(11) NOT NULL DEFAULT '130' COMMENT 'longitud útil para la carga de un CC, en cm', - `ccWidth` int(11) NOT NULL DEFAULT '60' COMMENT 'ancho útil para la carga en un CC, en cm' + `ccWidth` int(11) NOT NULL DEFAULT '60' COMMENT 'ancho útil para la carga en un CC, en cm', + `sorterPallet_m3` decimal(5,1) NOT NULL DEFAULT '2.0' COMMENT 'volumen minimo para extraer pallet del sorter' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='almacena el valor standard para volumenes convencionales de Verdnatura, en metros cúbicos'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -38953,6 +38494,7 @@ DROP TABLE IF EXISTS `warehouse`; CREATE TABLE `warehouse` ( `id` smallint(6) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(20) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `isFeedStock` tinyint(1) unsigned NOT NULL DEFAULT '0', `addressName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `delay` double NOT NULL DEFAULT '0.004', @@ -39091,7 +38633,7 @@ DROP TABLE IF EXISTS `worker`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `worker` ( - `id` int(11) NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(3) COLLATE utf8_unicode_ci NOT NULL, `firstName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `lastName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -39106,7 +38648,7 @@ CREATE TABLE `worker` ( `ended__` datetime DEFAULT NULL, `notes__` varchar(254) COLLATE utf8_unicode_ci DEFAULT NULL, `photo` blob, - `fi` varchar(9) COLLATE utf8_unicode_ci DEFAULT NULL, + `fi__` varchar(9) COLLATE utf8_unicode_ci DEFAULT NULL, `address__` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `birthed__` date NOT NULL, `maritalStatus__` enum('soltero/a','casado/a') COLLATE utf8_unicode_ci NOT NULL, @@ -39127,7 +38669,7 @@ CREATE TABLE `worker` ( KEY `sub` (`sub`), KEY `boss_idx` (`bossFk`), CONSTRAINT `Clientes` FOREIGN KEY (`clientFk__`) REFERENCES `client` (`id`) ON UPDATE CASCADE, - CONSTRAINT `worker_ibfk_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE + CONSTRAINT `worker_ibfk_1` FOREIGN KEY (`id`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -39140,8 +38682,8 @@ DROP TABLE IF EXISTS `workerBosses`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerBosses` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `workerFk` int(11) NOT NULL, - `bossFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, + `bossFk` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `workerFk_UNIQUE` (`workerFk`,`bossFk`), KEY `fg_worker_worker_idx` (`workerFk`), @@ -39211,7 +38753,7 @@ DROP TABLE IF EXISTS `workerConfig__`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerConfig__` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `defaultWorkerFk` int(11) NOT NULL, + `defaultWorkerFk` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `defaultWorkerFk` (`defaultWorkerFk`), CONSTRAINT `workerConfig___ibfk_1` FOREIGN KEY (`defaultWorkerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -39240,7 +38782,7 @@ DROP TABLE IF EXISTS `workerDisableExcluded`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerDisableExcluded` ( - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `dated` date DEFAULT NULL, PRIMARY KEY (`workerFk`), CONSTRAINT `workerDisableExcludedFk1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -39256,7 +38798,7 @@ DROP TABLE IF EXISTS `workerDistributionCategory`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerDistributionCategory` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `category` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `workerDistributionCategory_workerFk_idx` (`workerFk`), @@ -39324,7 +38866,7 @@ DROP TABLE IF EXISTS `workerIrpf`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerIrpf` ( - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `spouseNif` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `geographicMobilityDate` date DEFAULT NULL, `disabilityGradeFk` int(11) DEFAULT NULL, @@ -39403,7 +38945,7 @@ DROP TABLE IF EXISTS `workerLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `originFk` int(11) NOT NULL, + `originFk` int(10) unsigned NOT NULL, `userFk` int(10) unsigned NOT NULL, `action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL, `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, @@ -39429,7 +38971,7 @@ DROP TABLE IF EXISTS `workerMana`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerMana` ( - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `size` int(11) NOT NULL DEFAULT '300', `amount` int(11) NOT NULL DEFAULT '0', `pricesModifierRate` double NOT NULL DEFAULT '0', @@ -39450,7 +38992,7 @@ DROP TABLE IF EXISTS `workerManaExcluded`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerManaExcluded` ( - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, PRIMARY KEY (`workerFk`), CONSTRAINT `mana_spellers_excluded_fk1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Usuarios que tienen que estar excluidos del cálculo del maná'; @@ -39498,7 +39040,7 @@ DROP TABLE IF EXISTS `workerRelatives`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerRelatives` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `isDescendant` tinyint(1) DEFAULT '1' COMMENT 'Descendientes - Ascendientes', `disabilityGradeFk` int(11) DEFAULT NULL, `birthed` int(4) NOT NULL, @@ -39523,7 +39065,7 @@ DROP TABLE IF EXISTS `workerShelving`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerShelving` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `shelvingFk` varchar(10) CHARACTER SET utf8 NOT NULL, `collectionFk` int(11) DEFAULT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, @@ -39675,7 +39217,7 @@ DROP TABLE IF EXISTS `workerTimeControlMail`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerTimeControlMail` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `workerFk` int(10) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `year` int(4) NOT NULL, `week` int(2) NOT NULL, `state` enum('SENDED','CONFIRMED','REVISE') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'SENDED', @@ -39723,7 +39265,7 @@ DROP TABLE IF EXISTS `workerTimeControlPin`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerTimeControlPin` ( - `workerFk` int(11) NOT NULL, + `workerFk` int(10) unsigned NOT NULL, `pin` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`workerFk`), CONSTRAINT `workerFk_.1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -40153,12 +39695,78 @@ CREATE TABLE `zoneExclusion` ( `id` int(11) NOT NULL AUTO_INCREMENT, `zoneFk` int(11) NOT NULL, `dated` date NOT NULL, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `userFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `zoneFk_2` (`zoneFk`,`dated`), KEY `zoneFk` (`zoneFk`), CONSTRAINT `zoneExclusion_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER zoneExclusion_BI +BEFORE INSERT +ON zoneExclusion FOR EACH ROW +BEGIN + + SET NEW.userFk = account.myUser_getId(); + +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER zoneExclusion_BU +BEFORE UPDATE +ON zoneExclusion FOR EACH ROW +BEGIN + + SET NEW.userFk = account.myUser_getId(); + +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; + +-- +-- Table structure for table `zoneFilter` +-- + +DROP TABLE IF EXISTS `zoneFilter`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `zoneFilter` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `zoneFk` int(11) NOT NULL, + `sizeMax` int(11) DEFAULT NULL COMMENT 'altura máxima en cm', + `itemTypeFk` smallint(5) unsigned NOT NULL, + PRIMARY KEY (`id`), + KEY `zoneFilter_FK` (`zoneFk`), + KEY `zoneFilter_FK_1` (`itemTypeFk`), + CONSTRAINT `zoneFilter_FK` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `zoneFilter_FK_1` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='recoge los parámetros para filtrar determinados productos según la zona'; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `zoneGeo` @@ -40609,24 +40217,6 @@ END */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; /*!50003 SET character_set_results = @saved_cs_results */ ;; /*!50003 SET collation_connection = @saved_col_connection */ ;; -/*!50106 DROP EVENT IF EXISTS `zoneClosure_doRecalc` */;; -DELIMITER ;; -/*!50003 SET @saved_cs_client = @@character_set_client */ ;; -/*!50003 SET @saved_cs_results = @@character_set_results */ ;; -/*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8 */ ;; -/*!50003 SET character_set_results = utf8 */ ;; -/*!50003 SET collation_connection = utf8_general_ci */ ;; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ;; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; -/*!50003 SET @saved_time_zone = @@time_zone */ ;; -/*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`salix`@`10.0.%.%`*/ /*!50106 EVENT `zoneClosure_doRecalc` ON SCHEDULE AT '2021-05-25 10:32:44' ON COMPLETION NOT PRESERVE DISABLE DO CALL zoneClosure_recalc */ ;; -/*!50003 SET time_zone = @saved_time_zone */ ;; -/*!50003 SET sql_mode = @saved_sql_mode */ ;; -/*!50003 SET character_set_client = @saved_cs_client */ ;; -/*!50003 SET character_set_results = @saved_cs_results */ ;; -/*!50003 SET collation_connection = @saved_col_connection */ ;; /*!50106 DROP EVENT IF EXISTS `zoneGeo_doCalc` */;; DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; @@ -41146,13 +40736,13 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` FUNCTION `clientGetDebt`(vClient INT, vDate DATE) RETURNS decimal(10,2) +CREATE DEFINER=`root`@`%` FUNCTION `clientGetDebt`(`vClient` INT, `vDate` DATE) RETURNS decimal(10,2) READS SQL DATA BEGIN /** @@ -41179,23 +40769,14 @@ BEGIN SET vDateIni = TIMESTAMPADD(MONTH, -2, CURDATE()); SET vDateEnd = TIMESTAMP(vDate, '23:59:59'); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - CREATE TEMPORARY TABLE tmp.ticket - (INDEX (ticketFk)) - ENGINE = MEMORY - SELECT id ticketFk - FROM ticket - WHERE clientFk = vClient - AND refFk IS NULL - AND shipped BETWEEN vDateIni AND vDateEnd; - - CALL vn.ticketGetTotal; SELECT IFNULL(SUM(t.amount), 0) INTO vDebt FROM ( - SELECT SUM(IFNULL(total,0)) amount - FROM tmp.ticketTotal + SELECT SUM(IFNULL(totalWithVat,0)) amount + FROM ticket + WHERE clientFk = vClient + AND refFk IS NULL + AND shipped BETWEEN vDateIni AND vDateEnd UNION ALL SELECT SUM(amountPaid) amount FROM receipt @@ -41213,10 +40794,6 @@ BEGIN AND `status` = 'ok' ) t; - DROP TEMPORARY TABLE IF EXISTS - tmp.ticket, - tmp.ticketTotal; - RETURN vDebt; END ;; DELIMITER ; @@ -42191,6 +41768,50 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `expedition_checkRoute` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` FUNCTION `expedition_checkRoute`(vPalletFk INT,vExpeditionFk INT) RETURNS tinyint(1) + DETERMINISTIC +BEGIN +/** +* Comprueba si las expediciones del pallet son todas +* de la misma ruta. +* +* @param vExpeditionFk numero de expedition a comprobar +* @param vPalletFk numero de pallet +* @return vHasDistinctRoutes +*/ + DECLARE vRouteFk INT; + DECLARE vHasDistinctRoutes BOOL; + + SELECT t.routeFk INTO vRouteFk + FROM vn.expedition e + JOIN vn.ticket t ON e.ticketFk = t.id + WHERE e.id = vExpeditionFk; + + SELECT COUNT(*) > 0 INTO vHasDistinctRoutes + FROM vn.expeditionScan es + JOIN vn.expedition e ON es.expeditionFk = e.id + JOIN vn.ticket t ON e.ticketFk = t.id + WHERE es.palletFk = vPalletFk + AND t.routeFk <> vRouteFk; + + RETURN vHasDistinctRoutes; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP FUNCTION IF EXISTS `floramondoNewItemFk__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43707,6 +43328,7 @@ BEGIN DECLARE vDiameter INT; DECLARE vPackageFk VARCHAR(50); + DECLARE vCoeficient DOUBLE DEFAULT 1.08; SELECT MAX(LEFT(value,3)) INTO vDiameter FROM vn.itemTag it @@ -43714,7 +43336,7 @@ BEGIN WHERE it.itemFk = vItemFk AND t.overwrite = 'diameter'; - SELECT 8000 + (FLOOR(vc.ccLength / vDiameter) * FLOOR(vc.ccWidth / vDiameter)) + SELECT 8000 + FLOOR(vc.ccLength * vc.ccWidth / (vCoeficient * PI() * (vDiameter / 2) * (vDiameter / 2))) INTO vPackageFk FROM vn.volumeConfig vc; @@ -45865,9 +45487,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -45892,7 +45514,7 @@ BEGIN WHERE warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL; CALL vn.buyUltimateFromInterval(vWarehouseFk, CURDATE(), vDate); - +-- INSERT IGNORE INTO REPLACE INTO tmp.buyUltimate SELECT itemFk, buyFk, warehouseFk FROM tmp.buyUltimateFromInterval @@ -45936,7 +45558,7 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval - (INDEX (itemFk), INDEX(buyFk)) ENGINE = MEMORY + (UNIQUE (itemFk, warehouseFk), INDEX(buyFk), INDEX(itemFk)) ENGINE = MEMORY SELECT b.itemFk, t.warehouseInFk warehouseFk, @@ -45951,6 +45573,37 @@ BEGIN AND NOT b.isIgnored AND b.quantity > 0 GROUP BY itemFk, warehouseInFk; + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed) + SELECT + b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND b.price2 > 0 + AND NOT b.isIgnored + GROUP BY itemFk, warehouseInFk; + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed) + SELECT + b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND b.quantity = 0 + GROUP BY itemFk, warehouseInFk; + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -45961,9 +45614,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -46024,14 +45677,7 @@ BEGIN SET ic.grams = b.weight * 1000 / b.packing WHERE ic.itemFk = vItemFk AND ic.warehouseFk = vWarehouse; - /* - IF vSize IS NULL AND vPackageFk > '' THEN - INSERT INTO vn.mail(`subject`,`body`,`sender`) - VALUES (CONCAT('Articulo sin medida ', vItemFk), - CONCAT('Se ha añadido el artículo ', vItemFk, ' sin medida a la entrada ', vEntryFk, - ' con el cubo ', vPackageFk), - 'ekt@verdnatura.es'); - END IF;*/ + END IF; SELECT isFeedStock INTO vIsFeedStock @@ -46984,9 +46630,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -47009,7 +46655,6 @@ proc: BEGIN * @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg) */ DECLARE vClientFk INT; - DECLARE vGeneralInflationCoefficient INT DEFAULT 1; DECLARE vMinimumDensityWeight INT DEFAULT 167; DECLARE vBoxVolume BIGINT; DECLARE vSpecialPriceComponent INT DEFAULT 10; @@ -47029,6 +46674,11 @@ proc: BEGIN DECLARE vRangeLogifloraDays INT DEFAULT 3; DECLARE vVisibleCache INT; DECLARE vRappelComponent INT DEFAULT 44; + DECLARE vIsZonePremium BOOL; + + SELECT (COUNT(*) > 0) INTO vIsZonePremium + FROM vn.zoneFilter zf + WHERE zf.zoneFk = vZoneFk; SELECT vc.standardFlowerBox * 1000 INTO vBoxVolume FROM vn.volumeConfig vc; @@ -47050,7 +46700,6 @@ proc: BEGIN IF (NOT vIsLogifloraAllowed AND vVNHWarehouseFk != vWarehouseFk) OR (vn.isLogifloraDay(vShipped, vWarehouseFk) = FALSE) - OR (vIsFrenchVNHBuyer = FALSE AND NOW() BETWEEN '2021-05-21' AND '2021-05-25 12:00') -- Eliminar al pasar la fecha THEN @@ -47098,6 +46747,19 @@ proc: BEGIN AND IFNULL(sub.itemFk,0) = 0 AND IFNULL(v.visible ,0) = 0); + END IF; + + -- Eliminem productes de la oferta que no deuen vore les zones PREMIUM + IF vIsZonePremium THEN + + DELETE tl.* + FROM tmp.ticketLot tl + JOIN item i ON i.id = tl.itemFk + LEFT JOIN vn.zoneFilter zf ON zf.itemTypeFk = i.typeFk + AND zf.zoneFk = vZoneFk + AND i.`size` <= zf.sizeMax + WHERE zf.id IS NULL ; + END IF; @@ -47159,20 +46821,20 @@ proc: BEGIN tcc.rate3 - b.buyingValue - b.freightValue - b.packageValue - b.comissionValue FROM tmp.ticketComponentCalculate tcc JOIN buy b ON b.id = tcc.buyFk; - - -- French Offer: revisar a partir de Mayo 2021 + /* + -- French Offer: revisar a partir de Mayo 2021 IF vIsFrenchVNHBuyer THEN INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) SELECT tcc.warehouseFk, tcc.itemFk, vFrenchOffer, - - tcc.rate3 + b.buyingValue + b.freightValue + b.packageValue + b.comissionValue + ((b.buyingValue + b.freightValue + b.packageValue + b.comissionValue) * 0.06) + - tcc.rate3 + b.buyingValue + b.freightValue + b.packageValue + b.comissionValue + ((b.buyingValue + b.freightValue + b.packageValue + b.comissionValue) * 0.18) FROM tmp.ticketComponentCalculate tcc JOIN buy b ON b.id = tcc.buyFk; - + END IF; - +*/ DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentBase; CREATE TEMPORARY TABLE tmp.ticketComponentBase ENGINE = MEMORY SELECT tc.itemFk, ROUND(SUM(tc.cost), 4) AS base, tc.warehouseFk @@ -47241,7 +46903,7 @@ proc: BEGIN SELECT tcc.warehouseFK, tcc.itemFk, vDeliveryComponent, - vGeneralInflationCoefficient * ROUND(ic.cm3delivery * (IFNULL(zo.price,5000) - IFNULL(zo.bonus,0)) / vBoxVolume, 4) cost + z.inflation * ROUND(ic.cm3delivery * (IFNULL(zo.price,5000) - IFNULL(zo.bonus,0)) / vBoxVolume, 4) cost FROM tmp.ticketComponentCalculate tcc JOIN item i ON i.id = tcc.itemFk JOIN tmp.zoneOption zo ON zo.zoneFk = vZoneFk @@ -47284,7 +46946,7 @@ proc: BEGIN INSERT INTO tmp.ticketComponent SELECT tcc.warehouseFk, tcc.itemFk, - vRappelComponent, + IFNULL(c.componentFk ,vRappelComponent), SUM(tcc.cost) * ((1/(1-c.rappel/100)) -1) sumCost FROM tmp.ticketComponentCopy tcc JOIN vn.clientChain cc ON cc.clientFk = vClientFk @@ -47332,6 +46994,14 @@ proc: BEGIN AND tcc.packing > 0 AND tcc.available >= tcc.packing) GROUP BY tcs.warehouseFk, tcs.itemFk; + IF vIsZonePremium THEN + + DELETE + FROM tmp.ticketComponentRate + WHERE rate = 1; + + END IF; + INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) SELECT tcc.warehouseFk, @@ -47584,7 +47254,7 @@ BEGIN DELETE FROM vn.awb WHERE created < TIMESTAMPADD(YEAR,-2,CURDATE()); -- Borra los ficheros gestDoc - INSERT INTO vn.printServerQueue(priorityFk, reportFk)VALUES(1,11); + INSERT INTO vn.printServerQueue(priorityFk, labelReportFk)VALUES(1,11); DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete; DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete; @@ -47852,9 +47522,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -47863,6 +47533,7 @@ BEGIN /** * Congela diariamente aquellos clientes que son morosos sin recobro, * pero que no sean trabajadores, + * y que el riesgo no sea menor que cero * hasta que no se gire la remesa no se congelan a los clientes de giro */ @@ -47873,7 +47544,16 @@ BEGIN WHERE invoiceFk LIKE 'REMESA%' AND payed > util.firstDayOfMonth(CURDATE()) limit 1; - + + DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; + CREATE TEMPORARY TABLE tmp.clientGetDebt + SELECT clientFk + FROM bs.defaulter + WHERE created = CURDATE() + AND amount; + + CALL clientGetDebt(CURDATE()); + UPDATE client c JOIN bi.defaulters d ON d.client = c.id AND d.date = CURDATE() JOIN config ON TRUE @@ -47881,14 +47561,18 @@ BEGIN LEFT JOIN worker w ON w.id = u.id LEFT JOIN recovery r ON r.clientFk = c.id AND r.finished IS NULL LEFT JOIN payMethod pm ON pm.id = c.payMethodFk + LEFT JOIN tmp.risk rk ON rk.clientFk = c.id SET c.isFreezed = TRUE, d.frozened = CURDATE(), u.active = FALSE - WHERE d.amount > config.defaultersMaxAmount + WHERE (d.amount > config.defaultersMaxAmount + AND IFNULL(rk.risk,0) >= 0) AND c.typeFk = 'normal' AND r.id IS NULL AND w.id IS NULL AND (vIsRemittanced OR pm.code <> 'bankDraft'); + + DROP TEMPORARY TABLE tmp.clientGetDebt; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -47918,19 +47602,7 @@ BEGIN DECLARE vEnded DATETIME; SET vEnded = TIMESTAMP(IFNULL(vDate, CURDATE()), '23:59:59'); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - CREATE TEMPORARY TABLE tmp.ticket - (INDEX (ticketFk)) - ENGINE = MEMORY - SELECT id ticketFk, c.clientFk - FROM ticket t - JOIN tmp.clientGetDebt c ON c.clientFk = t.clientFk - WHERE refFk IS NULL - AND shipped BETWEEN vStarted AND vEnded; - CALL ticketGetTotal(); - DROP TEMPORARY TABLE IF EXISTS tClientRisk; CREATE TEMPORARY TABLE tClientRisk ENGINE = MEMORY @@ -47955,9 +47627,11 @@ BEGIN GROUP BY t.clientFk; INSERT INTO tClientRisk - SELECT t.clientFk, total - FROM tmp.ticketTotal tt - JOIN tmp.ticket t ON t.ticketFk = tt.ticketFk; + SELECT t.clientFk, totalWithVat + FROM ticket t + JOIN tmp.clientGetDebt c ON c.clientFk = t.clientFk + WHERE refFk IS NULL + AND shipped BETWEEN vStarted AND vEnded; DROP TEMPORARY TABLE IF EXISTS tmp.risk; CREATE TEMPORARY TABLE tmp.risk @@ -48100,85 +47774,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `clientGetDebt__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `clientGetDebt__`(vDate DATE) -BEGIN -/** - * Calcula el riesgo para los clientes activos - * - * @table tmp.clientGetDebt(clientFk) - * @param vDate Fecha maxima de los registros - * @return tmp.risk - */ - DECLARE vStarted DATETIME DEFAULT TIMESTAMPADD(DAY, - DAYOFMONTH(CURDATE()) - 5, CURDATE()); - DECLARE vEnded DATETIME; - - SET vEnded = TIMESTAMP(IFNULL(vDate, CURDATE()), '23:59:59'); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - CREATE TEMPORARY TABLE tmp.ticket - (INDEX (ticketFk)) - ENGINE = MEMORY - SELECT id ticketFk, c.clientFk - FROM ticket t - JOIN tmp.clientGetDebt c ON c.clientFk = t.clientFk - WHERE refFk IS NULL - AND shipped BETWEEN vStarted AND vEnded; - - CALL ticketGetTotal(); - - DROP TEMPORARY TABLE IF EXISTS tClientRisk; - CREATE TEMPORARY TABLE tClientRisk - ENGINE = MEMORY - SELECT cr.customer_id clientFk, SUM(cr.amount) amount - FROM bi.customer_risk cr - JOIN tmp.clientGetDebt c ON c.clientFk = cr.customer_id - GROUP BY cr.customer_id; - - INSERT INTO tClientRisk - SELECT c.clientFk, SUM(r.amountPaid) - FROM receipt r - JOIN tmp.clientGetDebt c ON c.clientFk = r.clientFk - WHERE r.payed > vEnded - GROUP BY c.clientFk; - - INSERT INTO tClientRisk - SELECT t.clientFk, CAST(-SUM(t.amount) / 100 AS DECIMAL(10,2)) - FROM hedera.tpvTransaction t - JOIN tmp.clientGetDebt c ON c.clientFk = t.clientFk - WHERE t.receiptFk IS NULL - AND t.status = 'ok' - GROUP BY t.clientFk; - - INSERT INTO tClientRisk - SELECT t.clientFk, total - FROM tmp.ticketTotal tt - JOIN tmp.ticket t ON t.ticketFk = tt.ticketFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.risk; - CREATE TEMPORARY TABLE tmp.risk - (PRIMARY KEY (clientFk)) - ENGINE = MEMORY - SELECT clientFk, SUM(amount) risk - FROM client c - JOIN tClientRisk cr ON cr.clientFk = c.id - WHERE c.isActive - GROUP BY c.id; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientGreugeSpray` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49411,7 +49006,7 @@ CREATE DEFINER=`root`@`%` PROCEDURE `collectionSticker_print`(vCollectionFk INT, BEGIN DECLARE vLabelReport INT; - SELECT labelReport INTO vLabelReport + SELECT labelReportFk INTO vLabelReport FROM vn.sector WHERE id = vSectorFk; @@ -49423,7 +49018,7 @@ BEGIN WHERE collectionFk = vCollectionFk ON DUPLICATE KEY UPDATE labelCount = labelCount + 1; - INSERT INTO vn.printServerQueue(reportFk, param1, workerFk) + INSERT INTO vn.printServerQueue(labelReportFk, param1, workerFk) SELECT vLabelReport, vCollectionFk, getUser(); END IF; @@ -49742,8 +49337,19 @@ CREATE DEFINER=`root`@`%` PROCEDURE `collection_increaseQuantity`( vSaleFk INT, vQuantity INT) BEGIN + + DECLARE vDescription VARCHAR(100); DECLARE vOriginalQuantity INT; + DECLARE vConcept VARCHAR(100); + DECLARE vOrigin INT; + + SELECT concept INTO vConcept FROM vn.sale WHERE id = vSaleFk; + SELECT ticketFk INTO vOrigin FROM vn.sale WHERE id = vSaleFk; + SELECT CONCAT("Cambio cantidad ",vConcept," a ", vQuantity) INTO vDescription; + INSERT INTO vn.ticketLog (originFk, userFk, action , description) + VALUES(vOrigin, vn.getUser(), 'update', vDescription); + SELECT quantity INTO vOriginalQuantity FROM vn.sale WHERE id = vSaleFk; UPDATE `vn`.`sale` SET `quantity` = vQuantity,`originalQuantity` = vOriginalQuantity WHERE (`id` = vSaleFk); @@ -51008,6 +50614,44 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `company_getFiscaldata` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `company_getFiscaldata`(workerFk INT) +BEGIN + +DECLARE vCompanyFk INT; + + SELECT IFNULL(uc.companyFk, rc.defaultCompanyFk) + INTO vCompanyFk + FROM vn.routeConfig rc + LEFT JOIN userConfig uc ON uc.userFk = workerFk; + + + SELECT + s.name AS name , + s.NIF AS nif , + s.street AS street , + s.city AS city , + s.postCode AS postCode + + FROM vn.company c + JOIN vn.worker w ON w.id = c.workerManagerFk + JOIN vn.supplier s ON s.id = c.id + WHERE c.id = vCompanyFk; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `conveyorExpedition_Add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51021,22 +50665,52 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `conveyorExpedition_Add`(vDate DATE) BEGIN + + DECLARE startingMinute INT; + TRUNCATE vn.conveyorExpedition; + INSERT INTO vn.conveyorExpedition( expeditionFk, + created, + length, + width, + height, + routeFk, + productionMinute) + SELECT e.id, + e.created, + 10 * p.depth as depth, + 10 * p.width as width, + 10 * p.height as height, + IFNULL(t.routeFk,am.agencyFk) routeFk, + hour(e.created) * 60 + minute(e.created) + FROM vn.expedition e + JOIN vn.ticket t ON t.id = e.ticketFk + JOIN vn.packaging p ON p.id = e.packagingFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + WHERE t.warehouseFk IN (60,1,44) + AND e.created BETWEEN vDate AND util.dayend(vDate) + AND p.height < 140 + AND p.width < 60 + AND p.depth < 125; +/* INSERT INTO vn.conveyorExpedition( expeditionFk, created, conveyorBuildingClassFk, length, width, height, - routeFk) + routeFk, + productionMinute) SELECT e.id, e.created, IF(e.itemFk = 94,1,4), 10 * p.depth as depth, 10 * p.width as width, 10 * p.height as height, - IFNULL(t.routeFk,am.agencyFk) routeFk + IFNULL(t.routeFk,am.agencyFk) routeFk, + hour(e.created) * 60 + minute(e.created) FROM vn.expedition e JOIN vn.ticket t ON t.id = e.ticketFk JOIN vn.packaging p ON p.id = e.packagingFk @@ -51072,6 +50746,12 @@ BEGIN AND p.height < 160 AND p.width < 60 AND p.depth < 125; + */ + SELECT MIN(productionMinute) INTO startingMinute + FROM vn.conveyorExpedition ce ; + + UPDATE vn.conveyorExpedition + SET productionMinute = productionMinute - startingMinute; END ;; DELIMITER ; @@ -53426,18 +53106,37 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `expeditionPallet_PrintSet`(vPalletFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `expeditionPallet_PrintSet`(vPalletFk INT,vSectorFk INT) BEGIN + DECLARE vLabel INT; + DECLARE vPrinterFk INT; + UPDATE vn.expeditionPallet SET isPrint = FALSE - WHERE id = vPalletFk; + WHERE id = vPalletFk; + + SELECT labelReportFk + INTO vLabel + FROM sector + WHERE id=vSectorFk; + + SELECT printerFk + INTO vPrinterFk + FROM sector + WHERE id=vSectorFk; + + + INSERT INTO vn2008.Colas +(Id_Cola, Id_Impresora, Id_Prioridad, Id_Informe, Id_Estado, Hora_Inicio, Hora_Fin, Cola, Id_Trabajador, Cola2, Cola3, error) +VALUES(NULL, vPrinterFK, NULL, vLabel, 1, NULL, NULL, vPalletFk, NULL, vSectorFk, NULL, NULL); + END ;; DELIMITER ; @@ -53763,6 +53462,32 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `freelance_getInfo` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `freelance_getInfo`(workerFk INT) +BEGIN + SELECT s.name, s.street, s.city, s.nif, s.postCode + FROM route r + JOIN agencyMode am ON r.agencyModeFk = am.id + JOIN agency a ON am.agencyFk = a.id + JOIN supplier s ON a.supplierFk = s.id + WHERE r.workerFk = workerFk + ORDER BY r.id DESC + LIMIT 1; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `fustControl` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53891,7 +53616,7 @@ BEGIN JOIN vn.address a ON a.id = t.addressFk JOIN vn.province p2 ON p2.id = a.provinceFk JOIN vn.country c ON c.id = p2.countryFk - WHERE t.shipped BETWEEN '2021-05-04' AND '2021-05-06' + WHERE t.shipped BETWEEN vFromDated AND util.dayend(vToDated) AND wa.name = 'VNH' AND p.isPackageReturnable AND c.country = 'FRANCIA' @@ -54820,6 +54545,130 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `inventory_repair` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `inventory_repair`() +BEGIN + + DROP TEMPORARY TABLE IF EXISTS tmp.lastEntry; + CREATE TEMPORARY TABLE tmp.lastEntry + (PRIMARY KEY (buyFk)) + SELECT + i.id AS itemFk, + w.id AS warehouseFk, + w.name AS warehouse, + tr.landed, + b.id AS buyFk, + b.entryFk, + b.isIgnored, + b.price2, + b.price3, + b.stickers, + b.packing, + b.grouping, + b.groupingMode, + b.weight, + i.stems, + b.quantity, + b.buyingValue, + b.packageFk , + s.id AS supplierFk, + s.name AS supplier + FROM itemType it + RIGHT JOIN (entry e + LEFT JOIN supplier s ON s.id = e.supplierFk + RIGHT JOIN buy b ON b.entryFk = e.id + LEFT JOIN item i ON i.id = b.itemFk + LEFT JOIN ink ON ink.id = i.inkFk + LEFT JOIN travel tr ON tr.id = e.travelFk + LEFT JOIN warehouse w ON w.id = tr.warehouseInFk + LEFT JOIN origin o ON o.id = i.originFk + ) ON it.id = i.typeFk + LEFT JOIN edi.ekt ek ON b.ektFk = ek.id + WHERE (b.packageFk = "--" OR b.price2 = 0 OR b.packing = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,CURDATE())) AND s.name = 'INVENTARIO'; + + DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOk; + CREATE TEMPORARY TABLE tmp.lastEntryOk + (PRIMARY KEY (buyFk)) + SELECT + i.id AS itemFk, + w.id AS warehouseFk, + w.name AS warehouse, + tr.landed, + b.id AS buyFk, + b.entryFk, + b.isIgnored, + b.price2, + b.price3, + b.stickers, + b.packing, + b.grouping, + b.groupingMode, + b.weight, + i.stems, + b.quantity, + b.buyingValue, + b.packageFk , + s.id AS supplierFk, + s.name AS supplier + FROM itemType it + RIGHT JOIN (entry e + LEFT JOIN supplier s ON s.id = e.supplierFk + RIGHT JOIN buy b ON b.entryFk = e.id + LEFT JOIN item i ON i.id = b.itemFk + LEFT JOIN ink ON ink.id = i.inkFk + LEFT JOIN travel tr ON tr.id = e.travelFk + LEFT JOIN warehouse w ON w.id = tr.warehouseInFk + LEFT JOIN origin o ON o.id = i.originFk + ) ON it.id = i.typeFk + LEFT JOIN edi.ekt ek ON b.ektFk = ek.id + WHERE b.packageFk != "--" AND b.price2 != 0 AND b.packing != 0 AND b.buyingValue > 0 AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-2,CURDATE())) + ORDER BY tr.landed DESC; + + DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOkGroup; + CREATE TEMPORARY TABLE tmp.lastEntryOkGroup + (INDEX (warehouseFk,itemFk)) + SELECT * + FROM tmp.lastEntryOk tmp + GROUP BY tmp.itemFk,tmp.warehouseFk; + + UPDATE buy b + JOIN tmp.lastEntry lt ON lt.buyFk = b.id + JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk + SET b.packageFk = eo.packageFk WHERE b.packageFk = "--"; + + UPDATE buy b + JOIN tmp.lastEntry lt ON lt.buyFk = b.id + JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk + SET b.price2 = eo.price2 WHERE b.price2 = 0 ; + + UPDATE buy b + JOIN tmp.lastEntry lt ON lt.buyFk = b.id + JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk + SET b.packing = eo.packing WHERE b.packing = 0; + + UPDATE buy b + JOIN tmp.lastEntry lt ON lt.buyFk = b.id + JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk + SET b.buyingValue = eo.buyingValue WHERE b.buyingValue = 0; + + DROP TEMPORARY TABLE tmp.lastEntry; + DROP TEMPORARY TABLE tmp.lastEntryOk; + DROP TEMPORARY TABLE tmp.lastEntryOkGroup; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceExpenceMake` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56423,13 +56272,87 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `invoiceOutDelete`(vRef VARCHAR(15)) +BEGIN + DECLARE vAsien INTEGER; + DECLARE vSendMail BOOL; + DECLARE vBody TEXT; + + SELECT ASIEN INTO vAsien + FROM XDiario + WHERE SERIE = SUBSTRING(vRef, 1, 1) + AND FACTURA = SUBSTRING(vRef, 2, LENGTH(vRef)-1) + LIMIT 1; + + SELECT IF(enlazado OR enlazadoSage, TRUE, FALSE), + CONCAT(' + + + + + + + ', + GROUP_CONCAT(CONCAT(' + + + + + + + ' + ) SEPARATOR ' ' + ), + '
FECHASUBCTACONTRACONCEPTOEURODEBEEUROHABER
', IFNULL(FECHA,''), '', IFNULL(SUBCTA,''), '', IFNULL(CONTRA,''), '', IFNULL(CONCEPTO,''), '', IFNULL(EURODEBE,''), '', IFNULL(EUROHABER,''), '
') + INTO vSendMail, vBody + FROM XDiario + WHERE ASIEN = vAsien; + + DELETE FROM XDiario + WHERE ASIEN = vAsien; + + IF vSendMail THEN + INSERT INTO mail(sender, replyTo, `subject`, body) + SELECT 'administracion@verdnatura.es', + 'noreply@verdnatura.es', + CONCAT('Eliminada factura ' ,vRef), + CONCAT('
+

Se ha eliminado el asiento ', vAsien, ' que estaba enlazado en SAGE/CONTAPLUS, vinculado a la factura ', vRef ,'

+ ', vBody, ' +
'); + END IF; + + UPDATE ticket + SET refFk = NULL + WHERE refFk = vRef; + + DELETE + FROM invoiceOut + WHERE ref = vRef; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `invoiceOutDelete__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `invoiceOutDelete__`(vRef VARCHAR(15)) BEGIN UPDATE ticket @@ -56446,17 +56369,17 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `invoiceOutFix_BI_RE_IVA` */; +/*!50003 DROP PROCEDURE IF EXISTS `invoiceOutFix_BI_RE_IVA__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `invoiceOutFix_BI_RE_IVA`() +CREATE DEFINER=`root`@`%` PROCEDURE `invoiceOutFix_BI_RE_IVA__`() BEGIN DECLARE done BOOL DEFAULT FALSE; @@ -56822,13 +56745,74 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `invoiceOut_newFromClient`(vClientFk INT, vSerial CHAR(1), vShipped DATE, vCompanyFk INT, vTaxArea VARCHAR(25), OUT vInvoiceId INT) +CREATE DEFINER=`root`@`%` PROCEDURE `invoiceOut_newFromClient`(vClientFk INT, vSerial CHAR(2), vMaxShipped DATE, vCompanyFk INT, vTaxArea VARCHAR(25), vRef VARCHAR(25), OUT vInvoiceId INT) +BEGIN +/** + * Factura los tickets de un cliente hasta una fecha dada + * @param vClientFk Id del cliente a facturar + * @param vSerial Serie de factura + * @param vMaxShipped Fecha hasta la cual cogera tickets para facturar + * @param vCompanyFk Id de la empresa desde la que se factura + * @param vTaxArea Tipo de iva en relacion a la empresa y al cliente, NULL por defecto + * @param vRef Referencia de la factura en caso que se quiera forzar, NULL por defecto + * @return vInvoiceId factura + */ + + DECLARE vIsRefEditable BOOLEAN; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + IF vRef IS NOT NULL THEN + SELECT isRefEditable INTO vIsRefEditable + FROM invoiceOutSerial + WHERE code = vSerial; + + IF NOT vIsRefEditable THEN + CALL util.throw('serial non editable'); + END IF; + END IF; + + START TRANSACTION; + CALL invoiceFromClient(vMaxShipped, vClientFk, vCompanyFk); + CALL invoiceOut_new(vSerial, CURDATE(), vTaxArea, vInvoiceId); + + UPDATE invoiceOut + SET `ref` = vRef + WHERE id = vInvoiceId + AND vRef IS NOT NULL; + + IF vSerial <> 'R' AND NOT ISNULL(vInvoiceId) AND vInvoiceId <> 0 THEN + + CALL invoiceOutBooking(vInvoiceId); + INSERT INTO printServerQueue(priorityFk, labelReportFk, param1) VALUES(1, 3, vInvoiceId); + END IF; + COMMIT; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `invoiceOut_newFromClient__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `invoiceOut_newFromClient__`(vClientFk INT, vSerial CHAR(1), vShipped DATE, vCompanyFk INT, vTaxArea VARCHAR(25), OUT vInvoiceId INT) BEGIN /** * Factura los tickets de un cliente @@ -56853,13 +56837,13 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `invoiceOut_newFromTicket`(vTicketFk INT, vSerial CHAR(1), vTaxArea VARCHAR(25), vRef VARCHAR(25), OUT vInvoiceId INT) +CREATE DEFINER=`root`@`%` PROCEDURE `invoiceOut_newFromTicket`(vTicketFk INT, vSerial CHAR(2), vTaxArea VARCHAR(25), vRef VARCHAR(25), OUT vInvoiceId INT) BEGIN /** * Factura un ticket @@ -56896,7 +56880,7 @@ BEGIN IF vSerial <> 'R' AND NOT ISNULL(vInvoiceId) AND vInvoiceId <> 0 THEN CALL invoiceOutBooking(vInvoiceId); IF account.myUser_getId() IS NOT NULL THEN - INSERT INTO printServerQueue(priorityFk, reportFk, param1, workerFk) VALUES(1, 3, vInvoiceId, account.myUser_getId()); + INSERT INTO printServerQueue(priorityFk, labelReportFk, param1, workerFk) VALUES(1, 3, vInvoiceId, account.myUser_getId()); END IF; END IF; @@ -57335,7 +57319,7 @@ BEGIN JOIN entry e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN supplier s ON s.id = e.supplierFk - JOIN alertLevel al ON al.alertLevel = + JOIN alertLevel al ON al.id = CASE WHEN tr.isReceived != FALSE THEN 3 WHEN tr.isDelivered THEN 1 @@ -57365,7 +57349,7 @@ BEGIN JOIN travel tr ON tr.id = e.travelFk JOIN warehouse w ON w.id = tr.warehouseOutFk JOIN supplier s ON s.id = e.supplierFk - JOIN alertLevel al ON al.alertLevel = + JOIN alertLevel al ON al.id = CASE WHEN tr.isReceived != FALSE THEN 3 WHEN tr.isDelivered THEN 1 @@ -57384,7 +57368,7 @@ BEGIN SELECT t.shipped as date, NULL as `in`, s.quantity as `out`, - al.alertLevel as alertLevel, + al.id as alertLevel, st.name AS stateName, t.nickname as name, t.refFk as reference, @@ -57397,7 +57381,7 @@ BEGIN LEFT JOIN ticketState ts ON ts.ticket = t.id LEFT JOIN state st ON st.code = ts.code JOIN client c ON c.id = t.clientFk - JOIN alertLevel al ON al.alertLevel = + JOIN alertLevel al ON al.id = CASE WHEN t.shipped < vCurdate THEN 3 WHEN t.shipped > vDayEnd THEN 0 @@ -57542,6 +57526,49 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemFreight_Show` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `itemFreight_Show`(vItemFk INT, vWarehouseFk INT) +BEGIN + + SELECT cm3 Volumen_Entrada, + cm3delivery Volumen_Salida, + i.compression Compresion_del_Articulo, + it.compression Compresion_del_Tipo, + p.volume Volumen_del_embalaje, + p.width Ancho_del_embalaje, + p.`depth` Largo_del_embalaje, + b.packageFk , + IFNULL(p.height, i.`size`) + 10 Altura, + b.packing Packing_Entrada, + i.packingOut Packing_Salida, + i.id itemFk, + b.id buyFk, + b.entryFk, + w.name warehouseFk + FROM vn.itemCost ic + JOIN vn.item i ON i.id = ic.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + LEFT JOIN cache.last_buy lb ON lb.item_id = ic.itemFk AND lb.warehouse_id = ic.warehouseFk + LEFT JOIN vn.buy b ON b.id = lb.buy_id + LEFT JOIN vn.packaging p ON p.id = b.packageFk + LEFT JOIN vn.warehouse w ON w.id = ic.warehouseFk + WHERE ic.itemFk = vItemFk + AND ic.warehouseFk = vWarehouseFk; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemFuentesBalance` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57947,14 +57974,19 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `itemPlacementSupplyStockGetTargetList`(vItemFk INT,vSectorFk INT) BEGIN - DECLARE vWarehouseFk INT; + -- DECLARE vWarehouseFk INT; DECLARE vWarehouseAliasFk INT; - + /* SELECT s.warehouseFk , w.aliasFk INTO vWarehouseFk, vWarehouseAliasFk FROM vn.sector s JOIN vn.warehouse w ON w.id = s.warehouseFk WHERE s.id = vSectorFk; - + */ + SELECT w.aliasFk INTO vWarehouseAliasFk + FROM vn.sector s + JOIN vn.warehouse w ON w.id = s.warehouseFk + WHERE s.id = vSectorFk; + SELECT ish.shelvingFk shelving, p.code parking, sum(ish.visible) as stockTotal, @@ -57963,7 +57995,7 @@ BEGIN FROM vn.itemShelving ish JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk - LEFT JOIN vn.coolerPathDetail cpd ON CAST(cpd.hallway AS DECIMAL(3,0)) = p.column + -- LEFT JOIN vn.coolerPathDetail cpd ON CAST(cpd.hallway AS DECIMAL(3,0)) = p.column JOIN vn.sector sc ON sc.id = p.sectorFk JOIN vn.warehouse w ON w.id = sc.warehouseFk WHERE w.aliasFk = vWarehouseAliasFk @@ -57971,42 +58003,6 @@ BEGIN AND ish.itemFk = vItemFk GROUP BY ish.id ORDER BY ish.priority DESC; - /* - SELECT shelving, parking, sum(visible) as stockTotal,created,`order` - FROM - ( - SELECT `ispss`.`itemShelvingFk` AS `itemShelvingFk`, - `ispss`.`itemFk` AS `itemFk`, - `ispss`.`quantity` AS `quantity`, - `ispss`.`packing` AS `packing`, - `ispss`.`stock` AS `stock`, - `ispss`.`longName` AS `longName`, - `ispss`.`size` AS `size`, - `ispss`.`subName` AS `subName`, - `ispss`.`shelving` AS `shelving`, - `ispss`.`parking` AS `parking`, - `ispss`.`created` AS `created`, - `ispss`.`priority` AS `priority`, - `ispss`.`parkingFk` AS `parkingFk`, - `ispss`.`sectorFk` AS `sectorFk`, - IFNULL(p.pickingOrder,0) as `order` - FROM vn.itemShelvingPlacementSupplyStock ispss - JOIN vn.itemShelving ish ON ish.itemFk = vItemFk - JOIN vn.shelving sh ON sh.code = ish.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk - LEFT JOIN vn.coolerPathDetail cpd ON CAST(cpd.hallway AS DECIMAL(3,0)) = p.column - JOIN vn.sector sc ON sc.id = p.sectorFk - JOIN vn.warehouse w ON w.id = sc.warehouseFk - WHERE ispss.itemFk = vItemFk - AND w.aliasFk = vWarehouseAliasFk - -- AND p.sectorFk = vSectorFk - AND stock > 0 - AND ispss.sectorFk IN (SELECT id FROM vn.sector WHERE warehouseFk = vWarehouseFk) - ORDER BY priority DESC - ) sub - GROUP BY shelving - ORDER BY parking ASC; - */ END ;; @@ -58219,7 +58215,7 @@ BEGIN DECLARE vGrouping INT; DECLARE vBox INT; DECLARE vPacking INT; - DECLARE vRoundQuantity INT; + DECLARE vRoundQuantity INT DEFAULT 1; SELECT s.ticketFk, LEAST(s.quantity, vQuantity), s.itemFk,t.shipped,t.warehouseFk INTO vTicketFk, vQuantity, vItemFk,vDate,vWarehouseFk @@ -60348,9 +60344,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -60386,13 +60382,13 @@ BEGIN ( SELECT tr.landed AS shipped, b.quantity AS `in`, NULL AS `out`, - al.alertLevel AS alertLevel, + al.id AS alertLevel, st.name AS stateName, s.name AS name, e.ref AS reference, e.id AS origin, s.id AS clientFk, - IF(al.alertLevel = 3, TRUE, FALSE) isPicked, + IF(al.id = 3, TRUE, FALSE) isPicked, FALSE AS isTicket, b.id lineFk, NULL `order`, @@ -60401,7 +60397,7 @@ BEGIN JOIN entry e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN supplier s ON s.id = e.supplierFk - JOIN alertLevel al ON al.alertLevel = + JOIN alertLevel al ON al.id = CASE WHEN tr.shipped < CURDATE() THEN 3 WHEN tr.shipped = CURDATE() AND tr.isReceived = TRUE THEN 3 @@ -60416,25 +60412,25 @@ BEGIN UNION ALL SELECT tr.shipped, - NULL as `in`, - b.quantity AS `out`, - al.alertLevel AS alertLevel, - st.name AS stateName, - s.name AS name, - e.ref AS reference, - e.id AS origin, - s.id AS clientFk, - IF(al.alertLevel = 3, TRUE, FALSE) isPicked, - FALSE AS isTicket, + NULL, + b.quantity, + al.id, + st.name, + s.name, + e.ref, + e.id, + s.id, + IF(al.id = 3, TRUE, FALSE), + FALSE, b.id, - NULL `order`, - NULL AS clientType + NULL, + NULL FROM buy b JOIN entry e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN warehouse w ON w.id = tr.warehouseOutFk JOIN supplier s ON s.id = e.supplierFk - JOIN alertLevel al ON al.alertLevel = + JOIN alertLevel al ON al.id = CASE WHEN tr.shipped < CURDATE() THEN 3 WHEN tr.shipped = CURDATE() AND tr.isReceived = TRUE THEN 3 @@ -60451,26 +60447,26 @@ BEGIN UNION ALL SELECT DATE(t.shipped), - NULL as `in`, - s.quantity AS `out`, - al.alertLevel AS alertLevel, - st.name AS stateName, - t.nickname AS name, - t.refFk AS reference, - t.id AS origin, + NULL, + s.quantity, + al.id, + st.name, + t.nickname, + t.refFk, + t.id, t.clientFk, - stk.id AS isPicked, - TRUE AS isTicket, + stk.id, + TRUE, s.id, st.`order`, - ct.code AS clientType + ct.code FROM sale s JOIN ticket t ON t.id = s.ticketFk LEFT JOIN ticketState ts ON ts.ticket = t.id LEFT JOIN state st ON st.code = ts.code JOIN client c ON c.id = t.clientFk JOIN clientType ct ON ct.id = c.clientTypeFk - JOIN alertLevel al ON al.alertLevel = + JOIN alertLevel al ON al.id = CASE WHEN t.shipped < curdate() THEN 3 WHEN t.shipped > util.dayEnd(curdate()) THEN 0 @@ -64098,15 +64094,7 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `productionSectorList`(vSectorFk INT) BEGIN - /* - DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; - CREATE TEMPORARY TABLE tmp.clientGetDebt - SELECT DISTINCT t.clientFk - FROM vn.ticket t - JOIN vn.itemShelvingAvailable isa ON isa.ticketFk = t.id; - - CALL vn.clientGetDebt(CURDATE()); - */ + DECLARE vWarehouseFk INT; SELECT warehouseFk INTO vWarehouseFk @@ -64125,7 +64113,29 @@ BEGIN ( SELECT * FROM ( - SELECT isa.*, + SELECT isa.saleFk, + isa.Modificado, + isa.ticketFk, + isa.isPicked, + isa.itemFk, + isa.quantity, + CONCAT(isa.concept,' ',i.itemPackingTypeFk ) concept , + isa.`size`, + isa.Estado, + isa.sectorProdPriority, + isa.available, + isa.sectorFk, + isa.matricula, + isa.parking, + isa.itemShelving, + isa.Agency, + isa.shipped, + isa.`grouping`, + isa.packing, + isa.`hour`, + isa.isPreviousPreparable, + isa.physicalVolume, + isa.warehouseFk , cast(max(isa.quantity mod isa.packing) as DECIMAL(10,0)) as picos, sum(isa.available) as totalAvailable, IF (HOUR(isa.shipped),HOUR(isa.shipped), HOUR(isa.`hour`)) Hora, @@ -64137,7 +64147,6 @@ BEGIN JOIN vn.sector s ON s.id = isa.sectorFk AND s.warehouseFk = isa.warehouseFk JOIN vn.ticket t ON t.id = isa.ticketFk JOIN vn.client c ON c.id = t.clientFk - -- JOIN tmp.risk r ON r.clientFk = c.id JOIN tmp.productionBuffer pb ON pb.ticketFk = t.id JOIN vn.packagingConfig pc WHERE IF(s.isPreviousPreparedByPacking, @@ -65126,6 +65135,123 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `routeMonitor_calculate` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `routeMonitor_calculate`(vDate DATE) +BEGIN + + DECLARE vDateEND DATETIME; + + SET vDateEND = util.dayend(vDate); + SET vDate = TIMESTAMPADD(DAY,-1,vDate); + + DROP TEMPORARY TABLE IF EXISTS tmp.routesMonitor; + + CREATE TEMPORARY TABLE tmp.routesMonitor + (INDEX (routeFk)) + ENGINE = MEMORY + SELECT DISTINCT(t.routeFk) routeFk + FROM vn.ticket t + WHERE t.shipped BETWEEN vDate AND vDateEND + AND t.routeFk IS NOT NULL; + + INSERT IGNORE INTO routesMonitor(routeFk) + SELECT routeFk + FROM tmp.routesMonitor; + + UPDATE routesMonitor rm + JOIN route r ON r.id = rm.routeFk + JOIN agencyMode a ON a.id = r.agencyModeFk + JOIN routeGate rg ON rg.routeFk = rm.routeFk + SET rm.`name` = a.name, + rm.dated = r.created, + rm.ticketFree = 0, + rm.ticketProduction = 0, + rm.ticketPacked = 0, + rm.dated = r.created, + rm.beachFk = rg.deviceId; + + UPDATE routesMonitor rm + JOIN(SELECT t.routeFk, COUNT(*) AS ticketFree + FROM vn.ticket t + JOIN tmp.routesMonitor rm ON rm.routeFk = t.routeFk + JOIN ticketLastState ts ON t.id = ts.ticketFk + JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk + JOIN state s ON s.id = tt.stateFk AND s.alertLevel = 0 + GROUP BY t.routeFk + ) sub ON sub.routeFk = rm.routeFk + SET rm.ticketFree = sub.ticketFree; + + UPDATE routesMonitor rm + JOIN(SELECT t.routeFk, COUNT(*) AS ticketPacked + FROM vn.ticket t + JOIN tmp.routesMonitor rm ON rm.routeFk = t.routeFk + JOIN ticketLastState ts ON t.id = ts.ticketFk + JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk + JOIN state s ON s.id = tt.stateFk AND s.alertLevel = 2 + GROUP BY t.routeFk + ) sub ON sub.routeFk = rm.routeFk + SET rm.ticketPacked = sub.ticketPacked; + + UPDATE routesMonitor rm + JOIN(SELECT t.routeFk, COUNT(*) AS ticketProduction + FROM vn.ticket t + JOIN tmp.routesMonitor rm ON rm.routeFk = t.routeFk + JOIN ticketLastState ts ON t.id = ts.ticketFk + JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk + JOIN state s ON s.id = tt.stateFk AND s.alertLevel = 3 + GROUP BY t.routeFk + ) sub ON sub.routeFk = rm.routeFk + SET rm.ticketProduction = sub.ticketProduction; + + UPDATE routesMonitor rm + JOIN( SELECT t.routeFk, COUNT(*) AS packages + FROM vn.ticket t + JOIN tmp.routesMonitor rm ON rm.routeFk = t.routeFk + JOIN expedition e ON e.ticketFk = t.id + GROUP BY t.routeFk + ) sub ON sub.routeFk = rm.routeFk + SET rm.packages = sub.packages; + + UPDATE routesMonitor rm + JOIN( SELECT t.routeFk, SUM(sv.volume) AS m3 + FROM vn.ticket t + JOIN tmp.routesMonitor rm ON rm.routeFk = t.routeFk + JOIN vn.saleVolume sv ON sv.ticketFk = t.id + GROUP BY t.routeFk + ) sub ON sub.routeFk = rm.routeFk + SET rm.m3 = sub.m3; + + UPDATE routesMonitor rm + JOIN( SELECT t.routeFk , sum(IFNULL(pk.volume, pk.width * pk.height * pk.`depth` )) / 1000000 m3boxes + FROM vn.ticket t + JOIN tmp.routesMonitor rm ON rm.routeFk = t.routeFk + JOIN vn.expedition e ON e.ticketFk = t.id + JOIN vn.packaging pk ON pk.id = e.packagingFk + GROUP BY t.routeFk + ) sub ON sub.routeFk = rm.routeFk + SET rm.m3boxes = sub.m3boxes; + + UPDATE routesMonitor rm + JOIN ticket t ON t.routeFk = rm.routeFk + JOIN zoneEstimatedDelivery zed ON zed.zoneFk = t.zoneFk + SET rm.etd = IFNULL(zed.hourEffective, zed.hourTheoretical); + + DROP TEMPORARY TABLE tmp.routesMonitor; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `routeSetOk` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65177,6 +65303,81 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `route_getTickets` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `route_getTickets`(vRouteFk INT) +BEGIN +/** + * Pasado un RouteFk devuelve la información + * de sus tickets. + * + * @param vRouteFk + * + * @select Información de los tickets + */ + + SELECT + t.id AS Id, + t.clientFk AS Client, + a.id AS Address, + a.nickname AS ClientName, + t.packages AS Packages, + a.street AS AddressName, + a.postalCode AS PostalCode, + a.city AS City, + sub2.itemPackingTypeFk AS PackingType, + c.phone AS ClientPhone, + c.mobile AS ClientMobile, + a.phone AS AddressPhone, + a.mobile AS AddressMobile, + tl.longitude AS Longitude, + tl.latitude AS Latitude, + wm.mediaValue AS SalePersonPhone, + tob.Note AS Note, + t.isSigned AS Signed, + st.id AS Polizon + FROM ticket t + JOIN client c ON t.clientFk = c.id + JOIN address a ON t.addressFk = a.id + LEFT JOIN ticketLocation tl ON tl.ticketFk = t.id + LEFT JOIN workerMedia wm ON wm.workerFk = c.salesPersonFk + LEFT JOIN + (SELECT tob.description AS Note, t.id + FROM ticketObservation tob + JOIN ticket t ON tob.ticketFk = t.id + JOIN observationType ot ON ot.id = tob.observationTypeFk + WHERE t.routeFk = vRouteFk + AND ot.code = 'delivery' + )tob ON tob.id = t.id + LEFT JOIN stowaway st ON st.shipFk = t.id + LEFT JOIN + (SELECT sub.ticketFk, + CONCAT('(', GROUP_CONCAT(DISTINCT sub.itemPackingTypeFk ORDER BY sub.items DESC SEPARATOR ','), ') ') itemPackingTypeFk + FROM (SELECT s.ticketFk , i.itemPackingTypeFk, COUNT(*) items + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + WHERE t.routeFk = vRouteFk + GROUP BY t.id,i.itemPackingTypeFk)sub + GROUP BY sub.ticketFk + ) sub2 ON sub2.ticketFk = t.id + WHERE t.routeFk = vRouteFk + GROUP BY t.id + ORDER BY t.priority; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `rutasAnalyze` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65389,17 +65590,17 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `saleItemShelvingDelete` */; +/*!50003 DROP PROCEDURE IF EXISTS `saleItemShelvingDelete__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `saleItemShelvingDelete`(vSaleFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `saleItemShelvingDelete__`(vSaleFk INT) BEGIN UPDATE vn.itemShelving ish @@ -65417,7 +65618,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `saleItemShelvingIsPicked` */; +/*!50003 DROP PROCEDURE IF EXISTS `saleItemShelvingIsPicked__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -65427,7 +65628,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `saleItemShelvingIsPicked`(vTicketFk INT, vIsPicked BOOL) +CREATE DEFINER=`root`@`%` PROCEDURE `saleItemShelvingIsPicked__`(vTicketFk INT, vIsPicked BOOL) BEGIN DECLARE vStateFk INT; @@ -65453,17 +65654,17 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `saleItemShelvingMake` */; +/*!50003 DROP PROCEDURE IF EXISTS `saleItemShelvingMake__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `saleItemShelvingMake`(IN `vTicketFk` INT, IN `vSectorFk` INT) +CREATE DEFINER=`root`@`%` PROCEDURE `saleItemShelvingMake__`(IN `vTicketFk` INT, IN `vSectorFk` INT) BEGIN SET @rest:= CAST(0 AS DECIMAL(10,0)); @@ -66349,6 +66550,281 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `sale_getProblems` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `sale_getProblems`(IN vIsTodayRelative TINYINT(1)) +BEGIN +/** + * Calcula los problemas de cada venta + * para un conjunto de tickets. + * + * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular + * @return tmp.sale_problems + */ + DECLARE vWarehouse INT; + DECLARE vDate DATE; + DECLARE vAvailableCache INT; + DECLARE vDone INT DEFAULT 0; + DECLARE vComponentCount INT; + + DECLARE vCursor CURSOR FOR + SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, CURDATE(), date(tt.shipped)) + FROM tmp.sale_getProblems tt + WHERE DATE(tt.shipped) BETWEEN CURDATE() + AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), CURDATE()); + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; + + DROP TEMPORARY TABLE IF EXISTS tmp.sale_problems; + CREATE TEMPORARY TABLE tmp.sale_problems ( + ticketFk INT(11), + saleFk INT(11), + isFreezed INTEGER(1) DEFAULT 0, + risk DECIMAL(10,2) DEFAULT 0, + hasTicketRequest INTEGER(1) DEFAULT 0, + isAvailable INTEGER(1) DEFAULT 1, + itemShortage VARCHAR(250), + isTaxDataChecked INTEGER(1) DEFAULT 1, + itemDelay VARCHAR(250), + hasComponentLack INTEGER(1), + PRIMARY KEY (ticketFk, saleFk) + ) ENGINE = MEMORY; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; + CREATE TEMPORARY TABLE tmp.ticket_list + (PRIMARY KEY (ticketFk)) + ENGINE = MEMORY + SELECT tp.ticketFk, c.id clientFk + FROM tmp.sale_getProblems tp + JOIN vn.client c ON c.id = tp.clientFk; + + SELECT COUNT(*) INTO vComponentCount + FROM vn.component c + WHERE c.isRequired; + + INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk) + SELECT tl.ticketFk, (COUNT(DISTINCT s.id) * vComponentCount > COUNT(c.id)), s.id + FROM tmp.ticket_list tl + JOIN vn.sale s ON s.ticketFk = tl.ticketFk + LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id + LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired + GROUP BY tl.ticketFk, s.id; + + INSERT INTO tmp.sale_problems(ticketFk, isFreezed) + SELECT DISTINCT tl.ticketFk, TRUE + FROM tmp.ticket_list tl + JOIN vn.client c ON c.id = tl.clientFk + WHERE c.isFreezed + ON DUPLICATE KEY UPDATE + isFreezed = c.isFreezed; + + DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; + CREATE TEMPORARY TABLE tmp.clientGetDebt + (PRIMARY KEY (clientFk)) + ENGINE = MEMORY + SELECT DISTINCT clientFk + FROM tmp.ticket_list; + + CALL clientGetDebt(CURDATE()); + + INSERT INTO tmp.sale_problems(ticketFk, risk) + SELECT DISTINCT tl.ticketFk, r.risk + FROM tmp.ticket_list tl + JOIN vn.ticket t ON t.id = tl.ticketFk + JOIN vn.agencyMode a ON t.agencyModeFk = a.id + JOIN tmp.risk r ON r.clientFk = t.clientFk + JOIN vn.client c ON c.id = t.clientFk + JOIN vn.clientConfig cc + WHERE r.risk - cc.riskTolerance > c.credit + 10 + AND a.isRiskFree = FALSE + ON DUPLICATE KEY UPDATE + risk = r.risk; + + INSERT INTO tmp.sale_problems(ticketFk, hasTicketRequest) + SELECT DISTINCT tl.ticketFk, TRUE + FROM tmp.ticket_list tl + JOIN vn.ticketRequest tr ON tr.ticketFk = tl.ticketFk + WHERE tr.isOK IS NULL + ON DUPLICATE KEY UPDATE + hasTicketRequest = TRUE; + + OPEN vCursor; + + WHILE NOT vDone + DO + FETCH vCursor INTO vWarehouse, vDate; + + CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouse, vDate); + + INSERT INTO tmp.sale_problems(ticketFk, isAvailable, saleFk) + SELECT tl.ticketFk, FALSE, s.id + FROM tmp.ticket_list tl + JOIN vn.ticket t ON t.id = tl.ticketFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it on it.id = i.typeFk + LEFT JOIN cache.available av ON av.item_id = i.id + AND av.calc_id = vAvailableCache + WHERE date(t.shipped) = vDate + AND it.categoryFk != 6 + AND IFNULL(av.available, 0) < 0 + AND s.isPicked = FALSE + AND NOT i.generic + AND vWarehouse = t.warehouseFk + GROUP BY tl.ticketFk + ON DUPLICATE KEY UPDATE + isAvailable = FALSE, saleFk = VALUES(saleFk); + + INSERT INTO tmp.sale_problems(ticketFk, itemShortage, saleFk) + SELECT ticketFk, problem, saleFk + FROM ( + SELECT tl.ticketFk, CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')) problem, s.id AS saleFk + FROM tmp.ticket_list tl + JOIN vn.ticket t ON t.id = tl.ticketFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it on it.id = i.typeFk + LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk + LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache + WHERE IFNULL(av.available, 0) < 0 + AND s.quantity > IFNULL(issw.visible, 0) + AND s.quantity > 0 + AND s.isPicked = FALSE + AND s.reserved = FALSE + AND it.categoryFk != 6 + AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) + AND NOT i.generic + AND CURDATE() = vDate + AND t.warehouseFk = vWarehouse + GROUP BY tl.ticketFk LIMIT 1) sub + ON DUPLICATE KEY UPDATE + itemShortage = sub.problem, saleFk = sub.saleFk; + + INSERT INTO tmp.sale_problems(ticketFk, itemDelay, saleFk) + SELECT ticketFk, problem, saleFk + FROM ( + SELECT tl.ticketFk, GROUP_CONCAT('I: ',i.id, ' ', i.longName, ' ') problem, s.id AS saleFk + FROM tmp.ticket_list tl + JOIN vn.ticket t ON t.id = tl.ticketFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it on it.id = i.typeFk + LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk + WHERE s.quantity > IFNULL(issw.visible, 0) + AND s.quantity > 0 + AND s.isPicked = FALSE + AND s.reserved = FALSE + AND it.categoryFk != 6 + AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) + AND NOT i.generic + AND CURDATE() = vDate + AND t.warehouseFk = vWarehouse + GROUP BY tl.ticketFk LIMIT 1) sub + ON DUPLICATE KEY UPDATE + itemDelay = sub.problem, saleFk = sub.saleFk; + END WHILE; + + CLOSE vCursor; + + INSERT INTO tmp.sale_problems(ticketFk, isTaxDataChecked) + SELECT DISTINCT tl.ticketFk, FALSE + FROM tmp.ticket_list tl + JOIN vn.client c ON c.id = tl.clientFk + WHERE c.isTaxDataChecked = FALSE + ON DUPLICATE KEY UPDATE + isTaxDataChecked = FALSE; + + DROP TEMPORARY TABLE + tmp.clientGetDebt, + tmp.ticket_list; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `sale_getProblemsByTicket` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `sale_getProblemsByTicket`(IN vTicketFk INT, IN vIsTodayRelative TINYINT(1)) +BEGIN +/** + * Calcula los problemas de cada venta + * para un conjunto de tickets. + * + * @return Problems result + */ + DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems; + CREATE TEMPORARY TABLE tmp.sale_getProblems + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT t.id ticketFk, t.clientFk, t.warehouseFk, t.shipped + FROM ticket t + WHERE t.id = vTicketFk; + + CALL sale_getProblems(vIsTodayRelative); + + SELECT * FROM tmp.sale_problems; + + DROP TEMPORARY TABLE + tmp.sale_getProblems, + tmp.sale_problems; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `sale_PriceFix` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `sale_PriceFix`(vTicketFk INT) +BEGIN + + DELETE sc.* + FROM vn.saleComponent sc + JOIN vn.sale s ON s.id = sc.saleFk + JOIN vn.component c ON c.id = sc.componentFk + JOIN vn.componentType ct ON ct.id = c.typeFk + WHERE s.ticketFk = vTicketFk + AND ct.`type` = 'otros'; + + UPDATE vn.sale s + JOIN ( + SELECT sc.saleFk, sum(sc.value ) price + FROM vn.saleComponent sc + JOIN vn.sale s ON s.id = sc.saleFk + WHERE s.ticketFk = vTicketFk + GROUP BY sc.saleFk) sub ON sub.saleFk = s.id + SET s.price = sub.price; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `sale_updateOriginalQuantity` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66735,9 +67211,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -66781,7 +67257,7 @@ proc: BEGIN REPLACE vn.ticketParking(ticketFk,parkingFk) VALUES (vShelvingFk, vParkingFk); - CALL vn.ticketStatePrevious(vShelvingFk); + CALL vn.ticket_setPreviousState(vShelvingFk); ELSE @@ -68534,70 +69010,13 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketClosureMultiWarehouse__`(vDateTo DATE) -BEGIN -/** - * Inserta los tickets de todos los almacenes en la tabla temporal - * para ser cerrados. - * - * @param vDate Fecha del cierre - */ - DECLARE vDateToEndDay DATETIME DEFAULT util.dayEnd(vDateTo); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure; - - CREATE TEMPORARY TABLE tmp.ticketClosure ENGINE = MEMORY ( - SELECT - t.id AS ticketFk - FROM expedition e - INNER JOIN ticket t ON t.id = e.ticketFk - INNER JOIN warehouse w ON w.id = t.warehouseFk AND hasComission - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - WHERE - ts.alertLevel = 2 - AND DATE(t.shipped) BETWEEN DATE_ADD(vDateTo, INTERVAL -2 DAY) AND vDateTo - AND t.refFk IS NULL - GROUP BY e.ticketFk); - - CALL ticketClosure(); - - INSERT INTO mail (sender, replyTo, subject, body) - SELECT 'jgallego@verdnatura.es', 'jgallego@verdnatura.es', 'Tickets enrutados y NO preparados', - GROUP_CONCAT(ticketFk) tickets - FROM ticket t - JOIN ticketState ts ON t.id = ts.ticketFk - JOIN alertLevel al ON al.alertLevel = ts.alertLevel - JOIN agencyMode am ON am.id = t.agencyModeFk - JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE shipped BETWEEN vDateTo AND vDateToEndDay - AND al.code NOT IN('DELIVERED','PACKED') - AND t.routeFk - HAVING tickets IS NOT NULL; - - DROP TEMPORARY TABLE tmp.ticketClosure; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketClosureMultiWarehouse__2` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketClosureMultiWarehouse__2`(vDateTo DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `ticketClosureMultiWarehouse__`(vDateTo DATE) BEGIN /** * Inserta los tickets de todos los almacenes en la tabla temporal @@ -68776,136 +69195,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketClosure__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketClosure__`() -BEGIN -/** - * @deprecated Use ticket_close() - * Realiza el cierre de todos los - * tickets de la table ticketClosure. - */ - DECLARE vDone BOOL; - DECLARE vClientFk INT; - DECLARE vTicketFk INT; - DECLARE vIsTaxDataChecked BOOL; - DECLARE vCompanyFk INT; - DECLARE vShipped DATE; - DECLARE vPriority INT DEFAULT 1; - DECLARE vReportDeliveryNote INT DEFAULT 1; - DECLARE vNewInvoiceId INT; - DECLARE vHasDailyInvoice BOOL; - DECLARE vWithPackage BOOL; - DECLARE vHasToInvoice BOOL; - - DECLARE cur CURSOR FOR - SELECT ticketFk FROM tmp.ticketClosure; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN - RESIGNAL; - END; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure2; - CREATE TEMPORARY TABLE tmp.ticketClosure2 - SELECT ticketFk FROM tmp.ticketClosure; - INSERT INTO tmp.ticketClosure - SELECT id FROM stowaway s - JOIN tmp.ticketClosure2 tc ON s.shipFk = tc.ticketFk; - OPEN cur; - - proc: LOOP - SET vDone = FALSE; - - FETCH cur INTO vTicketFk; - - IF vDone THEN - LEAVE proc; - END IF; - - -- ticketClosure start - SELECT - c.id, - c.isTaxDataChecked, - t.companyFk, - t.shipped, - co.hasDailyInvoice, - w.isManaged, - c.hasToInvoice - INTO vClientFk, - vIsTaxDataChecked, - vCompanyFk, - vShipped, - vHasDailyInvoice, - vWithPackage, - vHasToInvoice - FROM ticket t - JOIN `client` c ON c.id = t.clientFk - JOIN province p ON p.id = c.provinceFk - JOIN country co ON co.id = p.countryFk - JOIN warehouse w ON w.id = t.warehouseFk - WHERE t.id = vTicketFk; - - INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity) - (SELECT vTicketFk, p.id, COUNT(*) - FROM expedition e - JOIN packaging p ON p.itemFk = e.itemFk - WHERE e.ticketFk = vTicketFk AND p.isPackageReturnable - AND vWithPackage - GROUP BY p.itemFk); - - -- No retornables o no catalogados - INSERT INTO sale (itemFk, ticketFk, concept, quantity, price, isPriceFixed) - (SELECT e.itemFk, vTicketFk, i.name, COUNT(*) AS amount, getSpecialPrice(e.itemFk, vClientFk), 1 - FROM expedition e - JOIN item i ON i.id = e.itemFk - LEFT JOIN packaging p ON p.itemFk = i.id - WHERE e.ticketFk = vTicketFk AND IFNULL(p.isPackageReturnable, 0) = 0 - AND getSpecialPrice(e.itemFk, vClientFk) > 0 - GROUP BY e.itemFk); - - IF(vHasDailyInvoice) AND vHasToInvoice THEN - - -- Facturacion rapida - CALL ticketTrackingAdd(vTicketFk, 'DELIVERED', NULL); - -- Facturar si está contabilizado - IF vIsTaxDataChecked THEN - CALL invoiceOut_newFromClient( - vClientFk, - (SELECT invoiceSerial(vClientFk, vCompanyFk, 'M')), - vShipped, - vCompanyFk, - NULL, - vNewInvoiceId); - END IF; - ELSE - -- Albaran_print - CALL ticketTrackingAdd(vTicketFk, (SELECT vn.getAlert3State(vTicketFk)), NULL); - -- Comentar al pasar a nuevo cierre - INSERT INTO printServerQueue(priorityFk, reportFk, param1) VALUES(vPriority, vReportDeliveryNote, vTicketFk); - -- INSERT INTO - END IF; - - -- ticketClosure end - END LOOP; - - CLOSE cur; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure2; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketCollection_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -69687,8 +69976,9 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetProblems`(IN vIsTodayRelative TINYINT(1)) BEGIN /** - * Hay una versión en salix que machacará toda esta función/procedimiento avisa - * a joan de los cambios que quieres hacer. + * @deprecated Use ticket_getProblems() instead + * + * Hay que revisar los dos procesos y unificarlos. No son equivalentes. PAK 04/06/21 * */ DECLARE vWarehouse INT; @@ -69696,10 +69986,12 @@ BEGIN DECLARE vAvailableCache INT; DECLARE vDone INT DEFAULT 0; DECLARE vComponentCount INT; + DECLARE vHasUbications BOOL; DECLARE vCursor CURSOR FOR - SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, CURDATE(), date(tt.shipped)) + SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, CURDATE(), date(tt.shipped)), w.hasUbications FROM tmp.ticketGetProblems tt + JOIN vn.warehouse w ON w.id = tt.warehouseFk WHERE DATE(tt.shipped) BETWEEN CURDATE() AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), CURDATE()); @@ -69731,9 +70023,13 @@ BEGIN WHERE c.isRequired; INSERT INTO tmp.ticketProblems(ticketFk, componentLack) - SELECT tl.ticketFk, (COUNT(DISTINCT s.id) * vComponentCount > COUNT(c.id)) + SELECT tl.ticketFk, + (COUNT(DISTINCT s.id) * (vComponentCount - (dm.code = 'PICKUP')) > COUNT(c.id)) FROM tmp.ticketList tl JOIN vn.sale s ON s.ticketFk = tl.ticketFk + JOIN vn.ticket t ON t.id = tl.ticketFk + JOIN vn.agencyMode am ON am.id = t.agencyModeFk + JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired GROUP BY tl.ticketFk; @@ -69780,7 +70076,7 @@ BEGIN WHILE NOT vDone DO - FETCH vCursor INTO vWarehouse, vDate; + FETCH vCursor INTO vWarehouse, vDate, vHasUbications; CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouse, vDate); @@ -69802,56 +70098,61 @@ BEGIN GROUP BY tl.ticketFk ON DUPLICATE KEY UPDATE isAvailable = 0; -/* - INSERT INTO tmp.ticketProblems(ticketFk, itemShortage) - SELECT ticketFk, problem - FROM ( - SELECT tl.ticketFk, CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')) problem - FROM tmp.ticketList tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it on it.id = i.typeFk - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache - WHERE IFNULL(av.available, 0) < 0 - AND s.quantity > IFNULL(issw.visible, 0) - AND s.quantity > 0 - AND s.isPicked = FALSE - AND s.reserved = FALSE - AND it.categoryFk != 6 - AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) - AND NOT i.generic - AND CURDATE() = vDate - AND t.warehouseFk = vWarehouse - GROUP BY tl.ticketFk LIMIT 1) sub - ON DUPLICATE KEY UPDATE - itemShortage = sub.problem; -*/ - INSERT INTO tmp.ticketProblems(ticketFk, itemDelay) - SELECT ticketFk, problem - FROM ( - SELECT tl.ticketFk, GROUP_CONCAT('I: ',i.id, ' ', i.longName, ' ') problem - FROM tmp.ticketList tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it on it.id = i.typeFk - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - WHERE s.quantity > IFNULL(issw.visible, 0) - AND s.quantity > 0 - AND s.isPicked = FALSE - AND s.reserved = FALSE - AND it.categoryFk != 6 - AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) - AND NOT i.generic - AND CURDATE() = vDate - AND t.warehouseFk = vWarehouse - GROUP BY tl.ticketFk LIMIT 1) sub - ON DUPLICATE KEY UPDATE - itemDelay = sub.problem; - END WHILE; + IF vHasUbications THEN + + INSERT INTO tmp.ticketProblems(ticketFk, itemShortage) + SELECT ticketFk, problem + FROM ( + SELECT tl.ticketFk, CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')) problem + FROM tmp.ticketList tl + JOIN vn.ticket t ON t.id = tl.ticketFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it on it.id = i.typeFk + LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk + LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache + WHERE IFNULL(av.available, 0) < 0 + AND s.quantity > IFNULL(issw.visible, 0) + AND s.quantity > 0 + AND s.isPicked = FALSE + AND s.reserved = FALSE + AND it.categoryFk != 6 + AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) + AND NOT i.generic + AND CURDATE() = vDate + AND t.warehouseFk = vWarehouse + GROUP BY tl.ticketFk) sub + ON DUPLICATE KEY UPDATE + itemShortage = sub.problem; + + INSERT INTO tmp.ticketProblems(ticketFk, itemDelay) + SELECT ticketFk, problem + FROM ( + SELECT tl.ticketFk, GROUP_CONCAT('I: ',i.id, ' ', i.longName, ' ') problem + FROM tmp.ticketList tl + JOIN vn.ticket t ON t.id = tl.ticketFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it on it.id = i.typeFk + LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk + WHERE s.quantity > IFNULL(issw.visible, 0) + AND s.quantity > 0 + AND s.isPicked = FALSE + AND s.reserved = FALSE + AND it.categoryFk != 6 + AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) + AND NOT i.generic + AND CURDATE() = vDate + AND t.warehouseFk = vWarehouse + GROUP BY tl.ticketFk) sub + ON DUPLICATE KEY UPDATE + itemDelay = sub.problem; + + END IF; + + END WHILE; + CLOSE vCursor; INSERT INTO tmp.ticketProblems(ticketFk, isTaxDataChecked) @@ -69864,8 +70165,7 @@ BEGIN DROP TEMPORARY TABLE tmp.clientGetDebt, - tmp.ticketList; - + tmp.ticketList; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -70304,14 +70604,13 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetTotal`() - READS SQL DATA BEGIN /** * Calcula el total con IVA para un conjunto de tickets. @@ -70320,12 +70619,12 @@ BEGIN * @return tmp.ticketTotal Total para cada ticket */ CALL ticket_getTax(NULL); - + DROP TEMPORARY TABLE IF EXISTS tmp.ticketTotal; CREATE TEMPORARY TABLE tmp.ticketTotal (INDEX (ticketFk)) ENGINE = MEMORY - SELECT t.ticketFk, + SELECT t.ticketFk, IFNULL(SUM(ta.taxableBase + ta.tax), 0.0) AS total, SUM(ta.taxableBase) totalWithoutVat FROM tmp.ticket t @@ -70927,17 +71226,17 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketToInvoiceByClient` */; +/*!50003 DROP PROCEDURE IF EXISTS `ticketToInvoiceByClient__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketToInvoiceByClient`( +CREATE DEFINER=`root`@`%` PROCEDURE `ticketToInvoiceByClient__`( vStarted DATE, vEnded DATETIME, vClient INT, @@ -71072,6 +71371,9 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ticketToPrePrepare`(IN vIdTicket INT, IN viewAll BOOL, IN vSectorFk INT) BEGIN +/* Tickets de preparacion previa (artificial) 21/03/2021 PAK +*/ + /* Tickets de preparacion previa (artificial) 21/03/2021 PAK */ @@ -71105,7 +71407,8 @@ IF viewAll IS true THEN stpp.Id_Movimiento_mark, stpp.Id_Trabjador, stpp.Id_Article, - CONCAT('(', i.itemPackingTypeFk,') ', stpp.Concepte) Concepte, + i.itemPackingTypeFk packingType, + stpp.Concepte Concepte, stpp.subName, stpp.Cantidad, stpp.original_quantity, @@ -71883,9 +72186,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -71989,6 +72292,7 @@ BEGIN vShipped, vCompanyFk, NULL, + NULL, vNewInvoiceId); END IF; ELSE @@ -72115,6 +72419,7 @@ BEGIN vShipped, vCompanyFk, NULL, + NULL, vNewInvoiceId); END IF; ELSE @@ -72182,7 +72487,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ticket_componentMakeUpdate`(IN vTicketFk INT, IN vClientFk INT, IN vAgencyModeFk INT, IN vAddressFk INT, IN vZoneFk INT, IN vWarehouseFk TINYINT, @@ -72190,12 +72495,21 @@ CREATE DEFINER=`root`@`%` PROCEDURE `ticket_componentMakeUpdate`(IN vTicketFk IN IN vLanded DATE, IN vIsDeleted TINYINT(1), IN vHasToBeUnrouted TINYINT(1), IN vOption INT) BEGIN -/** + /** * Hay una versión en salix que machacará toda esta función/procedimiento avisa * a carlosjr de los cambios que quieres hacer. - * + */ + + + + + + + +/** * Modifica en el ticket los campos que se le pasan por parámetro - * y cambia sus componentes + * y cambia sus componentes. + * Este procedimiento es transacionado en Salix * * @param vTicketFk Id del ticket a modificar * @param vClientFk nuevo cliente @@ -72212,16 +72526,9 @@ BEGIN */ DECLARE vPrice DECIMAL(10,2); DECLARE vBonus DECIMAL(10,2); - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; CALL ticket_componentPreview (vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk); - START TRANSACTION; - IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN UPDATE ticket t @@ -72254,10 +72561,8 @@ BEGIN t.id = vTicketFk; IF vHasToBeUnrouted THEN - UPDATE ticket t - SET t.routeFk = NULL, - t.shipped = TIMESTAMP(DATE(t.shipped), 0) - WHERE t.id = vTicketFk; + UPDATE ticket t SET t.routeFk = NULL + WHERE t.id = vTicketFk; END IF; IF vOption <> 8 THEN @@ -72266,9 +72571,7 @@ BEGIN (PRIMARY KEY (saleFk)) ENGINE = MEMORY SELECT id AS saleFk, vWarehouseFk warehouseFk - FROM sale s - LEFT JOIN vn.saleCloned sc ON sc.saleClonedFk = s.id - WHERE s.ticketFk = vTicketFk AND sc.saleClonedFk IS NULL; + FROM sale s WHERE s.ticketFk = vTicketFk; DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; CREATE TEMPORARY TABLE tmp.ticketComponent @@ -72279,7 +72582,6 @@ BEGIN DROP TEMPORARY TABLE tmp.sale; DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; END IF; - COMMIT; DROP TEMPORARY TABLE tmp.zoneGetShipped, tmp.ticketComponentPreview; END ;; @@ -72788,6 +73090,51 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_getProblems` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_getProblems`(IN vIsTodayRelative TINYINT(1)) +BEGIN +/** + * Calcula los problemas para un conjunto de tickets. + * Agrupados por ticket + * + * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular + * @return tmp.ticket_problems + */ + CALL sale_getProblems(vIsTodayRelative); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket_problems; + CREATE TEMPORARY TABLE tmp.ticket_problems + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT + ticketFk, + MAX(p.isFreezed) AS isFreezed, + MAX(p.risk) AS risk, + MAX(p.hasTicketRequest) AS hasTicketRequest, + MIN(p.isAvailable) AS isAvailable, + MAX(p.itemShortage) AS itemShortage, + MIN(p.isTaxDataChecked) AS isTaxDataChecked, + MAX(p.hasComponentLack) AS hasComponentLack + FROM tmp.sale_problems p + GROUP BY ticketFk; + + DROP TEMPORARY TABLE + tmp.sale_problems; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_getShip` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72814,20 +73161,19 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_getTax`(vTaxArea VARCHAR(25)) - READS SQL DATA +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_getTax`(IN vTaxArea VARCHAR(25)) BEGIN /** * Calcula la base imponible, el IVA y el recargo de equivalencia para * un conjunto de tickets. * * @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular - * @return tmp.ticketAmount - * @return tmp.ticketTax Impuesto desglosado para cada ticket. + * @return tmp.ticketAmount (ticketFk, taxableBase, tax, code) + * @return tmp.ticketTax (ticketFk, pgcFk, taxableBase, rate, code) Impuesto desglosado para cada ticket. */ DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; CREATE TEMPORARY TABLE tmp.addressCompany @@ -72838,50 +73184,50 @@ BEGIN JOIN ticket t ON t.id = tmpTicket.ticketFk; CALL addressTaxArea (); - + IF vTaxArea > '' THEN UPDATE tmp.addressTaxArea SET areaFk = vTaxArea; END IF; /* Solo se calcula la base imponible (taxableBase) y el impuesto se calculará posteriormente - * No se debería cambiar el sistema por problemas con los decimales + * No se debería cambiar el sistema por problemas con los decimales */ DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax; CREATE TEMPORARY TABLE tmp.ticketTax - (INDEX (ticketFk)) + (PRIMARY KEY (ticketFk, code, rate)) ENGINE = MEMORY - SELECT * FROM ( - SELECT tmpTicket.ticketFk, - bp.pgcFk, - SUM(s.quantity * s.price * (100 - s.discount)/100 ) AS taxableBase, - pgc.rate, - tc.code, - bp.priority - FROM tmp.ticket tmpTicket - JOIN sale s ON s.ticketFk = tmpTicket.ticketFk - JOIN item i ON i.id = s.itemFk - JOIN ticket t ON t.id = tmpTicket.ticketFk - JOIN supplier su ON su.id = t.companyFk - JOIN tmp.addressTaxArea ata - ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk - JOIN itemTaxCountry itc - ON itc.itemFk = i.id AND itc.countryFk = su.countryFk - JOIN bookingPlanner bp - ON bp.countryFk = su.countryFk - AND bp.taxAreaFk = ata.areaFk - AND bp.taxClassFk = itc.taxClassFk - JOIN pgc ON pgc.code = bp.pgcFk - JOIN taxClass tc ON tc.id = bp.taxClassFk - GROUP BY tmpTicket.ticketFk, pgc.code,pgc.rate - HAVING taxableBase != 0) t - ORDER BY priority; + SELECT * FROM ( + SELECT tmpTicket.ticketFk, + bp.pgcFk, + SUM(s.quantity * s.price * (100 - s.discount)/100 ) AS taxableBase, + pgc.rate, + tc.code, + bp.priority + FROM tmp.ticket tmpTicket + JOIN sale s ON s.ticketFk = tmpTicket.ticketFk + JOIN item i ON i.id = s.itemFk + JOIN ticket t ON t.id = tmpTicket.ticketFk + JOIN supplier su ON su.id = t.companyFk + JOIN tmp.addressTaxArea ata + ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk + JOIN itemTaxCountry itc + ON itc.itemFk = i.id AND itc.countryFk = su.countryFk + JOIN bookingPlanner bp + ON bp.countryFk = su.countryFk + AND bp.taxAreaFk = ata.areaFk + AND bp.taxClassFk = itc.taxClassFk + JOIN pgc ON pgc.code = bp.pgcFk + JOIN taxClass tc ON tc.id = bp.taxClassFk + GROUP BY tmpTicket.ticketFk, pgc.code, pgc.rate + HAVING taxableBase != 0) t3 + ORDER BY priority; DROP TEMPORARY TABLE IF EXISTS tmp.ticketServiceTax; CREATE TEMPORARY TABLE tmp.ticketServiceTax - (PRIMARY KEY (ticketFk, rate,code)) + (PRIMARY KEY (ticketFk, code, rate)) ENGINE = MEMORY - SELECT tt.ticketFk, + SELECT tt.ticketFk, pgc.code pgcFk, SUM(ts.quantity * ts.price) AS taxableBase, pgc.rate, @@ -72891,31 +73237,34 @@ BEGIN JOIN ticket t ON t.id = tt.ticketFk JOIN supplier su ON su.id = t.companyFk JOIN tmp.addressTaxArea ata - ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk + ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk JOIN bookingPlanner bp ON bp.countryFk = su.countryFk AND bp.taxAreaFk = ata.areaFk AND bp.taxClassFk = ts.taxClassFk - JOIN pgc ON pgc.code = bp.pgcFk + JOIN pgc ON pgc.code = bp.pgcFk JOIN taxClass tc ON tc.id = bp.taxClassFk GROUP BY tt.ticketFk, pgc.code HAVING taxableBase != 0; - INSERT INTO tmp.ticketTax (ticketFk, pgcFk, taxableBase, rate, code) - SELECT ts.ticketFk, ts.pgcFk, ts.taxableBase, ts.rate, ts.code - FROM tmp.ticketServiceTax ts - ON DUPLICATE KEY UPDATE ticketTax.taxableBase = ticketTax.taxableBase + VALUES (taxableBase); + INSERT INTO tmp.ticketTax (ticketFk, pgcFk, taxableBase, rate, code) + SELECT ts.ticketFk, ts.pgcFk, ts.taxableBase, ts.rate, ts.code + FROM tmp.ticketServiceTax ts + ON DUPLICATE KEY UPDATE ticketTax.taxableBase = VALUES (taxableBase) + ticketTax.taxableBase ; DROP TEMPORARY TABLE IF EXISTS tmp.ticketAmount; CREATE TEMPORARY TABLE tmp.ticketAmount (INDEX (ticketFk)) ENGINE = MEMORY - SELECT ticketFk, taxableBase, SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax,code + SELECT ticketFk, + taxableBase, + SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax, + code FROM tmp.ticketTax GROUP BY ticketFk, code; - DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; - DROP TEMPORARY TABLE IF EXISTS tmp.addressTaxArea; + DROP TEMPORARY TABLE tmp.addressCompany; + DROP TEMPORARY TABLE tmp.addressTaxArea; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -73034,6 +73383,120 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_getTax___` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_getTax___`(vTaxArea VARCHAR(25)) + READS SQL DATA +BEGIN +/** + * Calcula la base imponible, el IVA y el recargo de equivalencia para + * un conjunto de tickets. + * + * @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular + * @return tmp.ticketAmount + * @return tmp.ticketTax Impuesto desglosado para cada ticket. + */ + DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; + CREATE TEMPORARY TABLE tmp.addressCompany + (INDEX (addressFk, companyFk)) + ENGINE = MEMORY + SELECT DISTINCT t.addressFk, t.companyFk + FROM tmp.ticket tmpTicket + JOIN ticket t ON t.id = tmpTicket.ticketFk; + + CALL addressTaxArea (); + + IF vTaxArea > '' THEN + UPDATE tmp.addressTaxArea + SET areaFk = vTaxArea; + END IF; + /* Solo se calcula la base imponible (taxableBase) y el impuesto se calculará posteriormente + * No se debería cambiar el sistema por problemas con los decimales + */ + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax; + CREATE TEMPORARY TABLE tmp.ticketTax + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT * FROM ( + SELECT tmpTicket.ticketFk, + bp.pgcFk, + SUM(s.quantity * s.price * (100 - s.discount)/100 ) AS taxableBase, + pgc.rate, + tc.code, + bp.priority + FROM tmp.ticket tmpTicket + JOIN sale s ON s.ticketFk = tmpTicket.ticketFk + JOIN item i ON i.id = s.itemFk + JOIN ticket t ON t.id = tmpTicket.ticketFk + JOIN supplier su ON su.id = t.companyFk + JOIN tmp.addressTaxArea ata + ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk + JOIN itemTaxCountry itc + ON itc.itemFk = i.id AND itc.countryFk = su.countryFk + JOIN bookingPlanner bp + ON bp.countryFk = su.countryFk + AND bp.taxAreaFk = ata.areaFk + AND bp.taxClassFk = itc.taxClassFk + JOIN pgc ON pgc.code = bp.pgcFk + JOIN taxClass tc ON tc.id = bp.taxClassFk + GROUP BY tmpTicket.ticketFk, pgc.code,pgc.rate + HAVING taxableBase != 0) t + ORDER BY priority; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketServiceTax; + CREATE TEMPORARY TABLE tmp.ticketServiceTax + (PRIMARY KEY (ticketFk, rate,code)) + ENGINE = MEMORY + SELECT tt.ticketFk, + pgc.code pgcFk, + SUM(ts.quantity * ts.price) AS taxableBase, + pgc.rate, + tc.code + FROM tmp.ticket tt + JOIN ticketService ts ON ts.ticketFk = tt.ticketFk + JOIN ticket t ON t.id = tt.ticketFk + JOIN supplier su ON su.id = t.companyFk + JOIN tmp.addressTaxArea ata + ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk + JOIN bookingPlanner bp + ON bp.countryFk = su.countryFk + AND bp.taxAreaFk = ata.areaFk + AND bp.taxClassFk = ts.taxClassFk + JOIN pgc ON pgc.code = bp.pgcFk + JOIN taxClass tc ON tc.id = bp.taxClassFk + GROUP BY tt.ticketFk, pgc.code + HAVING taxableBase != 0; + + INSERT INTO tmp.ticketTax (ticketFk, pgcFk, taxableBase, rate, code) + SELECT ts.ticketFk, ts.pgcFk, ts.taxableBase, ts.rate, ts.code + FROM tmp.ticketServiceTax ts + ON DUPLICATE KEY UPDATE ticketTax.taxableBase = ticketTax.taxableBase + VALUES (taxableBase); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketAmount; + CREATE TEMPORARY TABLE tmp.ticketAmount + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT ticketFk, taxableBase, SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax,code + FROM tmp.ticketTax + GROUP BY ticketFk, code; + + DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; + DROP TEMPORARY TABLE IF EXISTS tmp.addressTaxArea; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_insertZone` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73470,6 +73933,57 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setPreviousState` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_setPreviousState`(vTicketFk INT) +BEGIN + + DECLARE vControlFk INT; + + SELECT MAX(inter_id) INTO vControlFk + FROM vncontrol.inter + WHERE Id_Ticket = vTicketFk; + + IF (SELECT s.code + FROM vn.state s + JOIN vncontrol.inter i ON i.state_id = s.id + WHERE i.inter_id = vControlFk) + = 'PREVIOUS_PREPARATION' THEN + + SELECT inter_id + INTO vControlFk + FROM vncontrol.inter i + JOIN vn.state s ON i.state_id = s.id + WHERE Id_Ticket = vTicketFk + AND inter_id < vControlFk + AND s.code != 'PREVIOUS_PREPARATION' + ORDER BY inter_id DESC + LIMIT 1; + + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT s.nextStateFk, i.Id_Ticket, account.myUser_getId() + FROM vncontrol.inter i + JOIN vn.state s ON i.state_id = s.id + WHERE inter_id = vControlFk; + + END IF; + + SELECT TRUE AS IsUpdated; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_splitItemPackingType` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74309,6 +74823,44 @@ proc: BEGIN */ CALL vn.workerTimeControl_check(vUserFk,vDated,vTabletFk); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `tpvTransaction_checkStatus` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `tpvTransaction_checkStatus`() +BEGIN +/** + * + * Envia mail con los cobros web no + * trasladados a la ficha del cliente. + * + */ + INSERT INTO mail (sender,replyTo,subject,body) + SELECT 'administracion@verdnatura.es', + 'noreply@verdnatura.es', + CONCAT('Cobro web no trasladado a la ficha del cliente ', t.clientFk), + CONCAT('Hay un importe de ', t.amount/100, '€ del cliente ', t.clientFk, ' con fecha ', t.created, + ', que no se ha trasladado a recibos. Si nos ha llegado el importe al banco confirme el pago en + + https://salix.verdnatura.es/#!/client/',t.clientFk,'/web-payment') + FROM hedera.tpvTransaction t + WHERE t.receiptFk IS NULL + AND t.status = 'ok' + AND t.created < DATE_ADD(NOW(),INTERVAL - 2 DAY) + GROUP BY t.clientFk; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -74983,7 +75535,6 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `workerCreate`( vFirstname VARCHAR(50), vSurnames VARCHAR(50), - vFi VARCHAR(9), vWorkerCode CHAR(3), vBossFk INT, vUserFk INT @@ -74993,8 +75544,8 @@ BEGIN * Create new worker * */ - INSERT INTO worker(id, code, firstName, lastName, fi, userFk, bossFk) - VALUES (vUserFk, vWorkerCode, vFirstname, vSurnames, vFi, vUserFk, vBossFk); + INSERT INTO worker(id, code, firstName, lastName, userFk, bossFk) + VALUES (vUserFk, vWorkerCode, vFirstname, vSurnames, vUserFk, vBossFk); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -76095,7 +76646,7 @@ proc: BEGIN ) THEN SELECT "Dias con fichadas impares" AS problem; -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody; + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody; CALL mail_insert(vTo,vTo,'error al fichar',vBody); LEAVE proc; END IF; @@ -76116,7 +76667,7 @@ proc: BEGIN IF(LENGTH(vCalendarStateType)) THEN SELECT vCalendarStateType AS problem; -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody; + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody; CALL mail_insert(vTo,vTo,'error al fichar',vBody); LEAVE proc; @@ -76135,7 +76686,7 @@ proc: BEGIN ) = 0 THEN SELECT "No hay un contrato en vigor" AS problem; -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody; + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody; CALL mail_insert(vTo,vTo,'error al fichar',vBody); LEAVE proc; @@ -76158,7 +76709,7 @@ proc: BEGIN IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA SELECT "Descansos 36 h" AS problem; -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Descansos 36 h") INTO vBody; + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 36 h") INTO vBody; CALL mail_insert(vTo,vTo,'error al fichar',vBody); LEAVE proc; END IF; @@ -76177,7 +76728,7 @@ proc: BEGIN IF vTimedWorked > vDayWorkMax THEN SELECT "Jornadas" AS problem; -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Jornadas") INTO vBody; + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Jornadas") INTO vBody; CALL mail_insert(vTo,vTo,'error al fichar',vBody); LEAVE proc; END IF; @@ -76713,6 +77264,282 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_sendMail`(vWeek INT, vYear INT, vWorkerFk INT) BEGIN +/** + * Inserta en la tabla vn.mail para notificar a los empleados que teletrabajan de las jornadas que se han registrado. + * Inserta fichadas en el casos que se determina que el empleado está realizando teletrabajo + * + * @param vWeek + * @param vYear + * @param vWorkerFk -> En el caso de querer generarlo para todos los empleados deberá de informarse como NULL + */ + DECLARE vStarted VARCHAR(25); + DECLARE vEnded VARCHAR(25); + DECLARE vDone BOOL; + DECLARE vSender VARCHAR(255); + DECLARE vSenderOld VARCHAR(255); + DECLARE vDated DATE; + DECLARE vTimeWorkDecimal DECIMAL(5,2); + DECLARE vTimeWorkSexagesimal VARCHAR(5); + DECLARE vTimeWorkedDecimal DECIMAL(5,2); + DECLARE vTimeWorkedSexagesimal VARCHAR(5); + DECLARE vTimeWorkDecimalTotal DECIMAL(5,2); + DECLARE vTimeTable VARCHAR(100); + DECLARE vTimeTableDecimal DECIMAL(5,2); + DECLARE vWorkerFkOld INTEGER; + DECLARE vBusinessFk INTEGER; + DECLARE vHeader TEXT; + DECLARE vBody TEXT; + DECLARE vFooter TEXT; + DECLARE vReturn INTEGER; + DECLARE vAbsenceType VARCHAR(50); + DECLARE vWorkerInfo VARCHAR(90); + DECLARE vPermissionRate DECIMAL(5,2); + DECLARE vIsTeleworking BOOL; + DECLARE vIsTeleworkingOld BOOL; + + DECLARE vCursor CURSOR FOR + SELECT CONCAT(u.name, '@verdnatura.es'), u.id, tb.dated, tb.timeWorkDecimal, LEFT(tb.timeWorkSexagesimal,5) timeWorkSexagesimal, + tb.timeTable, tc.timeWorkDecimal timeWorkedDecimal, LEFT(tc.timeWorkSexagesimal,5) timeWorkedSexagesimal, tb.type, tb.businessFk,tb.permissionRate, d.isTeleworking + FROM tmp.timeBusinessCalculate tb + JOIN user u ON u.id = tb.userFk + JOIN department d ON d.id = tb.departmentFk + JOIN postgresql.business b ON b.business_id = tb.businessFk + JOIN company c ON c.id = b.provider_id + LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated + JOIN (SELECT tb.userFk, + SUM(IF(tb.type IS NULL, + IF(tc.timeWorkDecimal > 0, FALSE, IF(tb.timeWorkDecimal > 0, TRUE, FALSE)), + TRUE))isTeleworkingWeek + FROM tmp.timeBusinessCalculate1 tb + LEFT JOIN tmp.timeControlCalculate1 tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated + GROUP BY tb.userFk + HAVING isTeleworkingWeek > 0 + )sub ON sub.userFk = u.id + WHERE d.hasToRefill AND + IFNULL(vWorkerFk,u.id) = u.id AND + c.code = 'VNL' + ORDER BY u.id, tb.dated; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + DROP TABLE IF EXISTS tmp.timeControlCalculate; + DROP TABLE IF EXISTS tmp.timeBusinessCalculate; + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; + DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate1; + DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate1; + + SELECT CONCAT (MIN(dated), ' 00:00:00'), CONCAT (MAX(dated), ' 23:59:59') INTO vStarted, vEnded + FROM time + WHERE year = vYear AND + week = vWeek; + + DELETE FROM workerTimeControl + WHERE IFNULL(vWorkerFk, userFk) = userFk AND + timed BETWEEN vStarted AND vEnded AND + isSendMail; + + UPDATE workerTimeControlMail + SET updated = NOW(), state = 'SENDED' + WHERE year = vYear AND + week = vWeek AND + IFNULL(vWorkerFk, workerFk) = workerFk ; + + IF vWorkerFk IS NULL THEN + CALL timeControl_calculateAll(vStarted,vEnded); + CALL timeBusiness_calculateAll(vStarted,vEnded); + ELSE + CALL timeControl_calculateByUser(vWorkerFk,vStarted,vEnded); + CALL timeBusiness_calculateByUser(vWorkerFk,vStarted,vEnded); + END IF; + + CREATE TEMPORARY TABLE tmp.timeControlCalculate1 + SELECT * FROM tmp.timeControlCalculate; + CREATE TEMPORARY TABLE tmp.timeBusinessCalculate1 + SELECT * FROM tmp.timeBusinessCalculate; + + SET vTimeWorkDecimalTotal = 0; + SET vBody= ''; + OPEN vCursor; + FETCH vCursor INTO vSender, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk, vPermissionRate, vIsTeleworking ; + SET vWorkerFkOld = vWorkerFk ; + SET vSenderOld = vSender; +proc: LOOP + IF vDone THEN + LEAVE proc; + END IF; + + IF vTimeWorkDecimal>0 AND vTimeWorkedDecimal IS NULL AND IFNULL(vPermissionRate, TRUE) THEN + IF vTimeTable IS NULL THEN + INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) + SELECT vWorkerFk, CONCAT(vDated,' 08:00'), TRUE, 'in', TRUE; + IF vTimeWorkDecimal >= 5 THEN + INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) + SELECT vWorkerFk, CONCAT(vDated,' 09:00'), TRUE, 'middle', TRUE; + INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) + SELECT vWorkerFk, CONCAT(vDated,' 09:20'), TRUE, 'middle', TRUE; + END IF; + INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) + SELECT vWorkerFk,CONCAT(vDated,' ', LEFT (SEC_TO_TIME(28800 + (vTimeWorkDecimal * 3600)), 5)), TRUE, 'out', TRUE; + ELSE + SELECT SUM(TIME_TO_SEC(j.end)-TIME_TO_SEC(j.start))/3600 INTO vTimeTableDecimal + FROM postgresql.journey j + WHERE j.business_id = vBusinessFk AND + j.day_id = WEEKDAY(vDated)+1; + IF vTimeWorkDecimal = vTimeTableDecimal THEN + INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) + SELECT vWorkerFk, CONCAT(vDated, ' ', j.start), TRUE, TRUE + FROM postgresql.journey j + WHERE j.business_id = vBusinessFk AND + j.day_id = WEEKDAY(vDated)+1; + + INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) + SELECT vWorkerFk, CONCAT(vDated, ' ', j.end), TRUE, TRUE + FROM postgresql.journey j + WHERE j.business_id = vBusinessFk AND + j.day_id = WEEKDAY(vDated)+1; + ELSE + INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) + SELECT vWorkerFk, CONCAT(vDated, ' ', MIN(j.start)), TRUE, TRUE + FROM postgresql.journey j + WHERE j.business_id = vBusinessFk AND + j.day_id = WEEKDAY(vDated)+1; + INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) + SELECT vWorkerFk, CONCAT(vDated, ' ', SEC_TO_TIME(TIME_TO_SEC(MIN(j.start)) + (vTimeWorkDecimal * 3600))), TRUE, TRUE + FROM postgresql.journey j + WHERE j.business_id = vBusinessFk AND + j.day_id = WEEKDAY(vDated)+1; + END IF; + + IF vTimeWorkDecimal >= 5 THEN + INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) + SELECT vWorkerFk, CONCAT(vDated, ' ', SEC_TO_TIME(TIME_TO_SEC(MIN(j.start)) + 3600)), TRUE, TRUE + FROM postgresql.journey j + WHERE j.business_id = vBusinessFk AND + j.day_id = WEEKDAY(vDated)+1; + INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) + SELECT vWorkerFk, CONCAT(vDated, ' ', SEC_TO_TIME(TIME_TO_SEC(MIN(j.start)) + 4800)), TRUE, TRUE + FROM postgresql.journey j + WHERE j.business_id = vBusinessFk AND + j.day_id = WEEKDAY(vDated)+1; + END IF; + + UPDATE workerTimeControl wtc + JOIN (SELECT id FROM workerTimeControl + WHERE userFk = vWorkerFk AND + timed BETWEEN vDated AND CONCAT(vDated, ' 23:59:59') + ORDER BY timed ASC + LIMIT 1)sub on sub.id= wtc.id + SET direction = 'in' ; + + UPDATE workerTimeControl wtc + JOIN (SELECT id FROM workerTimeControl + WHERE userFk = vWorkerFk AND + timed BETWEEN vDated AND CONCAT(vDated, ' 23:59:59') + ORDER BY timed DESC + LIMIT 1)sub on sub.id= wtc.id + SET direction = 'out' ; + + END IF; + END IF; + + SELECT CONCAT(IFNULL(vBody,""), " + ", DATE_FORMAT(vDated, "%d/%m/%Y"), " + ", CASE WEEKDAY(vDated)+1 + WHEN 1 THEN 'Lunes' + WHEN 2 THEN 'Martes' + WHEN 3 THEN 'Miércoles' + WHEN 4 THEN 'Jueves' + WHEN 5 THEN 'Viernes' + WHEN 6 THEN 'Sábado' + WHEN 7 THEN 'Domingo' + END , " + ", IFNULL(GROUP_CONCAT(MID(timed, 12, 5) ORDER BY timed ASC SEPARATOR ' - '), " - ")," + ", IFNULL(vAbsenceType, IF (vTimeWorkedDecimal>0, "Presencial", IF(vTimeWorkDecimal>0, "Teletrabajo", " - "))), " + ", IFNULL(vTimeWorkedSexagesimal,IF(IFNULL(vPermissionRate, TRUE), vTimeWorkDecimal, 0)), " + ") INTO vBody + FROM workerTimeControl + WHERE userFk = vWorkerFk AND + timed BETWEEN vDated AND CONCAT(vDated," 23:59:59"); + SET vTimeWorkDecimalTotal = vTimeWorkDecimalTotal + IFNULL(vTimeWorkedDecimal, IF( IFNULL(vPermissionRate, TRUE), vTimeWorkDecimal, 0)); + SET vDone = FALSE; + FETCH vCursor INTO vSender, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk, vPermissionRate, vIsTeleworking; + + IF vWorkerFk <> vWorkerFkOld OR vDone THEN + SELECT CONCAT( IFNULL(nif, ''), ' - ', firstName, ' ', name ) INTO vWorkerInfo + FROM postgresql.person + WHERE id_trabajador = vWorkerFkOld; + SET vHeader = CONCAT("


+
+

", vWorkerInfo , "

+ + + + + + + + + + + + "); + + SET vFooter = CONCAT(" + + + + +
+ Según la información recogida en el sistema adjuntamos la tabla con los registros de las horas trabajadas en el período indicado. + Si está conforme tiene que contestar indicando únicamente la palabra OK, en caso contrario puede contestar detallando la causa de la disconformidad. + Rogamos nos conteste lo antes posible. +

+
FechaDíaFichadasDescripciónHoras
TOTAL", IFNULL(LEFT (SEC_TO_TIME(vTimeWorkDecimalTotal * 3600), 5), 0), "
+
"); + + IF vIsTeleworkingOld THEN + INSERT INTO mail(sender, replyto, subject, body) + VALUES (vSenderOld, + 'timecontrol@verdnatura.es', + CONCAT('Registro de horas semana ', vWeek, ' año ', vYear) , + CONCAT(vHeader, ' ' , vBody, ' ', vFooter)); + + INSERT IGNORE INTO workerTimeControlMail (workerFk, year, week) + VALUES(vWorkerFkOld, vYear, vWeek); + END IF; + + SET vBody = ''; + SET vTimeWorkDecimalTotal = 0; + SET vWorkerFkOld = vWorkerFk ; + SET vIsTeleworkingOld = vIsTeleworking ; + SET vSenderOld = vSender; + END IF; + END LOOP; + CLOSE vCursor; + + DROP TABLE tmp.timeControlCalculate; + DROP TABLE tmp.timeBusinessCalculate; + DROP TABLE tmp.timeControlCalculate1; + DROP TABLE tmp.timeBusinessCalculate1; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_sendMail__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_sendMail__`(vWeek INT, vYear INT, vWorkerFk INT) +BEGIN /** * Inserta en la tabla vn.mail para notificar a los empleados que teletrabajan de las jornadas que se han registrado. * Inserta fichadas en el casos que se determina que el empleado está realizando teletrabajo @@ -76967,243 +77794,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_sendMail__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_sendMail__`(vWeek INT, vYear INT, vWorkerFk INT) -BEGIN -/** - * Inserta en la tabla vn.mail para notificar a los empleados que teletrabajan de las jornadas que se han registrado. - * Inserta fichadas en el casos que se determina que el empleado está realizando teletrabajo - * - * @param vWeek - * @param vYear - * @param vWorkerFk -> En el caso de querer generarlo para todos los empleados deberá de informarse como NULL - */ - DECLARE vStarted VARCHAR(25); - DECLARE vEnded VARCHAR(25); - DECLARE vDone BOOL; - DECLARE vSender VARCHAR(255); - DECLARE vSenderOld VARCHAR(255); - DECLARE vDated DATE; - DECLARE vTimeWorkDecimal DECIMAL(5,2); - DECLARE vTimeWorkSexagesimal VARCHAR(5); - DECLARE vTimeWorkedDecimal DECIMAL(5,2); - DECLARE vTimeWorkedSexagesimal VARCHAR(5); - DECLARE vTimeWorkDecimalTotal DECIMAL(5,2); - DECLARE vTimeTable VARCHAR(100); - DECLARE vTimeTableDecimal DECIMAL(5,2); - DECLARE vWorkerFkOld INTEGER; - DECLARE vBusinessFk INTEGER; - DECLARE vHeader TEXT; - DECLARE vBody TEXT; - DECLARE vFooter TEXT; - DECLARE vReturn INTEGER; - DECLARE vAbsenceType VARCHAR(50); - DECLARE vWorkerInfo VARCHAR(90); - - DECLARE vCursor CURSOR FOR - SELECT CONCAT(u.name, '@verdnatura.es'), u.id, tb.dated, tb.timeWorkDecimal, LEFT(tb.timeWorkSexagesimal,5) timeWorkSexagesimal, - tb.timeTable, tc.timeWorkDecimal timeWorkedDecimal, LEFT(tc.timeWorkSexagesimal,5) timeWorkedSexagesimal, tb.type, tb.businessFk - FROM tmp.timeBusinessCalculate tb - JOIN user u ON u.id = tb.userFk - JOIN department d ON d.id = tb.departmentFk - JOIN postgresql.business b ON b.business_id = tb.businessFk - JOIN company c ON c.id = b.provider_id - LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated - WHERE d.isTeleworking AND - IFNULL(vWorkerFk,u.id) = u.id AND - c.code = 'VNL' - ORDER BY u.id, tb.dated; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - DROP TABLE IF EXISTS tmp.timeControlCalculate; - DROP TABLE IF EXISTS tmp.timeBusinessCalculate; - DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; - DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; - - SELECT CONCAT (MIN(dated), ' 00:00:00'), CONCAT (MAX(dated), ' 23:59:59') INTO vStarted, vEnded - FROM time - WHERE year = vYear AND - week = vWeek; - - DELETE FROM workerTimeControl - WHERE IFNULL(vWorkerFk, userFk) = userFk AND - timed BETWEEN vStarted AND vEnded AND isSendMail; - - UPDATE workerTimeControlMail - SET updated = NOW(), state = 'SENDED' - WHERE year = vYear AND - week = vWeek AND - IFNULL(vWorkerFk, workerFk) = workerFk ; - - IF vWorkerFk IS NULL THEN - CALL timeControl_calculateAll(vStarted,vEnded); - CALL timeBusiness_calculateAll(vStarted,vEnded); - ELSE - CALL timeControl_calculateByUser(vWorkerFk,vStarted,vEnded); - CALL timeBusiness_calculateByUser(vWorkerFk,vStarted,vEnded); - END IF; - - SET vTimeWorkDecimalTotal = 0; - SET vBody= ''; - OPEN vCursor; - FETCH vCursor INTO vSender, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk ; - SET vWorkerFkOld = vWorkerFk ; - SET vSenderOld = vSender; - proc: LOOP - IF vDone THEN - LEAVE proc; - END IF; - - IF vTimeTable IS NULL AND vTimeWorkDecimal>0 AND vTimeWorkedDecimal IS NULL THEN - INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) - SELECT vWorkerFk, CONCAT(vDated,' 08:00'), TRUE, 'in', TRUE; - IF vTimeWorkDecimal >= 5 THEN - INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) - SELECT vWorkerFk, CONCAT(vDated,' 09:00'), TRUE, 'middle', TRUE; - INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) - SELECT vWorkerFk, CONCAT(vDated,' 09:20'), TRUE, 'middle', TRUE; - END IF; - INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) - SELECT vWorkerFk,CONCAT(vDated,' ', LEFT (SEC_TO_TIME(28800 + (vTimeWorkDecimal * 3600)), 5)), TRUE, 'out', TRUE; - ELSEIF vTimeWorkDecimal>0 AND vTimeWorkedDecimal IS NULL THEN - SELECT SUM(TIME_TO_SEC(j.end)-TIME_TO_SEC(j.start))/3600 INTO vTimeTableDecimal - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND j.day_id = WEEKDAY(vDated)+1; - IF vTimeWorkDecimal = vTimeTableDecimal THEN - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', j.start), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND j.day_id = WEEKDAY(vDated)+1; - - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', j.end), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND j.day_id = WEEKDAY(vDated)+1; - ELSE - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', MIN(j.start)), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND j.day_id = WEEKDAY(vDated)+1; - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', SEC_TO_TIME(TIME_TO_SEC(MIN(j.start)) + (vTimeWorkDecimal * 3600))), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND j.day_id = WEEKDAY(vDated)+1; - END IF; - - IF vTimeWorkDecimal >= 5 THEN - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', SEC_TO_TIME(TIME_TO_SEC(MIN(j.start)) + 3600)), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND j.day_id = WEEKDAY(vDated)+1; - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', SEC_TO_TIME(TIME_TO_SEC(MIN(j.start)) + 4800)), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND j.day_id = WEEKDAY(vDated)+1; - END IF; - - UPDATE workerTimeControl wtc - JOIN (SELECT id FROM workerTimeControl - WHERE userFk = vWorkerFk AND - timed BETWEEN vDated AND CONCAT(vDated, ' 23:59:59') - ORDER BY timed ASC - LIMIT 1)sub on sub.id= wtc.id - SET direction = 'in' ; - - UPDATE workerTimeControl wtc - JOIN (SELECT id FROM workerTimeControl - WHERE userFk = vWorkerFk AND - timed BETWEEN vDated AND CONCAT(vDated, ' 23:59:59') - ORDER BY timed DESC - LIMIT 1)sub on sub.id= wtc.id - SET direction = 'out' ; - - END IF; - - SELECT CONCAT(IFNULL(vBody,""), " - ", DATE_FORMAT(vDated, "%d/%m/%Y"), " - ", CASE WEEKDAY(vDated)+1 - WHEN 1 THEN 'Lunes' - WHEN 2 THEN 'Martes' - WHEN 3 THEN 'Miércoles' - WHEN 4 THEN 'Jueves' - WHEN 5 THEN 'Viernes' - WHEN 6 THEN 'Sábado' - WHEN 7 THEN 'Domingo' - END , " - ", IFNULL(GROUP_CONCAT(MID(timed,12,5) ORDER BY timed ASC SEPARATOR ' - '), " - ")," - ", IFNULL(vAbsenceType, IF (vTimeWorkedDecimal>0, "Presencial", IF(vTimeWorkDecimal>0,"Teletrabajo", " - "))), " - ", IFNULL(vTimeWorkedSexagesimal, vTimeWorkSexagesimal) , " - ") INTO vBody - FROM workerTimeControl - WHERE userFk = vWorkerFk AND - timed BETWEEN vDated AND CONCAT(vDated," 23:59:59"); - SET vTimeWorkDecimalTotal = vTimeWorkDecimalTotal + IFNULL(vTimeWorkedDecimal, vTimeWorkDecimal); - SET vDone = FALSE; - FETCH vCursor INTO vSender, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk ; - - IF vWorkerFk <> vWorkerFkOld OR vDone THEN - SELECT CONCAT( IFNULL(nif, ''), ' - ', firstName, ' ', name ) INTO vWorkerInfo - FROM postgresql.person - WHERE id_trabajador = vWorkerFkOld; - SET vHeader = CONCAT("


-
-

", vWorkerInfo , "

- - - - - - - - - - - - "); - - SET vFooter = CONCAT(" - - - - -
- Según la información recogida en el sistema adjuntamos la tabla con los registros de las horas trabajadas en el período indicado. - Si está conforme tiene que contestar indicando únicamente la palabra OK, en caso contrario puede contestar detallando la causa de la disconformidad. - Rogamos nos conteste lo antes posible. -

-
FechaDíaFichadasDescripciónHoras
TOTAL", IFNULL(LEFT (SEC_TO_TIME(vTimeWorkDecimalTotal * 3600), 5), 0), "
-
"); - INSERT INTO mail(sender, replyto, subject, body) - VALUES (vSenderOld, 'timecontrol@verdnatura.es', CONCAT('Registro de horas semana ', vWeek, ' año ', vYear) , CONCAT(vHeader,' ' , vBody,' ', vFooter)); - - INSERT IGNORE INTO workerTimeControlMail (workerFk, year,week) - VALUES(vWorkerFkOld, vYear, vWeek); - SET vBody = ''; - SET vTimeWorkDecimalTotal = 0; - SET vWorkerFkOld = vWorkerFk ; - SET vSenderOld = vSender; - END IF; - END LOOP; - CLOSE vCursor; - - DROP TABLE IF EXISTS tmp.timeControlCalculate; - DROP TABLE IF EXISTS tmp.timeBusinessCalculate; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_sendMail____` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -78138,6 +78728,8 @@ BEGIN THEN CAST(((12 * blp.importepactado) / (52 * tb.hoursWeek)) * 4 AS DECIMAL(10,2)) WHEN tb.type = 'Vacaciones' OR tb.type = 'Baja enfermedad común' OR tb.type = 'Permiso retribuido' OR tb.type = 'Festivo' THEN CAST(((12 * blp.importepactado) / (52 * tb.hoursWeek)) * 8 AS DECIMAL(10,2)) + WHEN tb.type = 'Maternidad/Paternidad' + THEN 0 END FROM worker w JOIN tmp.timeBusinessCalculate tb ON tb.userFk = w.id @@ -78145,7 +78737,7 @@ BEGIN JOIN time tm ON tm.dated = tb.dated WHERE tb.dated BETWEEN vDateFrom AND vDateTo AND w.id = vWorkerFk AND - tb.type IN ('Vacaciones 1/2 día', 'Vacaciones', 'Baja enfermedad común','Festivo','Permiso retribuido 1/2 día','Permiso retribuido') + tb.type IN ('Vacaciones 1/2 día', 'Vacaciones', 'Baja enfermedad común','Festivo','Permiso retribuido 1/2 día','Permiso retribuido', 'Maternidad/Paternidad') GROUP BY tb.dated; INSERT INTO tmp.workerSalaryRoleDelivery (workerFk, @@ -78230,12 +78822,12 @@ BEGIN CREATE TEMPORARY TABLE tmp.daysToDelete SELECT dated FROM tmp.workerSalaryRoleDelivery d - WHERE d.description IN ('Baja enfermedad común'); + WHERE d.description IN ('Baja enfermedad común', 'Maternidad/Paternidad'); DELETE d FROM tmp.workerSalaryRoleDelivery d JOIN tmp.daysToDelete dd on dd.dated = d.dated - WHERE d.description NOT IN ('Baja enfermedad común'); + WHERE d.description NOT IN ('Baja enfermedad común', 'Maternidad/Paternidad'); INSERT INTO tmp.workerSalaryRoleDelivery (workerFk,dated,id,packages,hours,km,m3Delivery,m3Load,amountDelivery,amountLoad,AmountKm,description, extra) SELECT workerFk, @@ -78661,9 +79253,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -78674,7 +79266,7 @@ BEGIN CREATE TEMPORARY TABLE tmp.total ENGINE = MEMORY - SELECT st.workerFk, Count(t.id) AS CuentaDeId_Ticket + SELECT st.workerFk, Count(t.id) AS saleCount FROM state ss JOIN vn.saleTracking st ON st.stateFk = ss.id JOIN vn.sale s ON s.id = st.saleFk @@ -78682,8 +79274,16 @@ BEGIN JOIN worker w ON st.workerFk = w.id WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND ss.code = vStateCode GROUP BY st.workerFk; - - SELECT w.code, w.firstName, w.lastName, CAST(tmp.total.CuentaDeId_Ticket AS DECIMAL(10,0)) AS Totaltickets, CAST(sub.CuentaDeTicketFk AS DECIMAL(10,0)) AS Fallos + + INSERT INTO tmp.total + SELECT e.workerFk, Count(DISTINCT t.id) AS saleCount + FROM expedition e + JOIN ticket t ON e.ticketFk = t.id + JOIN worker w ON e.workerFk = w.id + WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + GROUP BY e.workerFk; + + SELECT w.code, w.firstName, w.lastName, CAST(MAX(tmp.total.saleCount) AS DECIMAL(10,0)) AS Totaltickets, CAST(sub.CuentaDeTicketFk AS DECIMAL(10,0)) AS Fallos FROM tmp.total JOIN worker w ON w.id = tmp.total.workerFk LEFT JOIN ( @@ -78694,7 +79294,8 @@ BEGIN JOIN claimResponsible cr ON cd.claimResponsibleFk = cr.id WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND cr.description=vDepartment GROUP BY cd.workerFk - )sub ON tmp.total.workerFk = sub.workerFk; + )sub ON tmp.total.workerFk = sub.workerFk + GROUP BY w.code; DROP TEMPORARY TABLE tmp.total; @@ -80856,7 +81457,7 @@ CREATE TABLE `inter` ( `odbc_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `Id_Ticket` int(11) DEFAULT NULL, `Id_Trabajador` int(11) DEFAULT NULL, - `Id_Supervisor` int(11) DEFAULT NULL, + `Id_Supervisor` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`inter_id`), KEY `currante` (`Id_Trabajador`), KEY `responsable` (`Id_Supervisor`), @@ -83157,7 +83758,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemInk` AS select `i`.`longName` AS `longName`,`i`.`inkFk` AS `inkFk` from (`item` `i` join `ink` on((`ink`.`id` = `i`.`inkFk`))) where `ink`.`isRealColor` group by `i`.`longName` */; +/*!50001 VIEW `itemInk` AS select `i`.`longName` AS `longName`,`i`.`inkFk` AS `inkFk`,`ink`.`name` AS `color` from (`item` `i` join `ink` on((`ink`.`id` = `i`.`inkFk`))) where `ink`.`isRealColor` group by `i`.`longName` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -84093,6 +84694,25 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `ticketLocation` +-- + +/*!50001 DROP TABLE IF EXISTS `ticketLocation`*/; +/*!50001 DROP VIEW IF EXISTS `ticketLocation`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `ticketLocation` AS select `tl`.`Id_Ticket` AS `ticketFk`,`tl`.`longitude` AS `longitude`,`tl`.`latitude` AS `latitude` from `vn2008`.`ticket_location` `tl` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `ticketMRW` -- @@ -84145,7 +84765,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketPackingList` AS select `t`.`nickname` AS `nickname`,`t`.`id` AS `ticketFk`,`am`.`name` AS `agencyMode`,`am`.`flag` AS `flag`,`p`.`name` AS `province`,`s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity` from ((((`ticket` `t` join `address` `a` on((`a`.`id` = `t`.`addressFk`))) join `province` `p` on((`p`.`id` = `a`.`provinceFk`))) join `agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) left join `sale` `s` on((`s`.`ticketFk` = `t`.`id`))) */; +/*!50001 VIEW `ticketPackingList` AS select `t`.`nickname` AS `nickname`,`t`.`id` AS `ticketFk`,`am`.`name` AS `agencyMode`,`am`.`flag` AS `flag`,`p`.`name` AS `province`,`s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`sv`.`litros` AS `litros` from (((((`ticket` `t` join `address` `a` on((`a`.`id` = `t`.`addressFk`))) join `province` `p` on((`p`.`id` = `a`.`provinceFk`))) join `agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) left join `sale` `s` on((`s`.`ticketFk` = `t`.`id`))) left join `saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -84501,12 +85121,12 @@ USE `vn`; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerTimeControlUserInfo` AS select `u`.`id` AS `userFk`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`u`.`name` AS `user`,`u`.`password` AS `password`,`u`.`bcryptPassword` AS `bcryptPassword`,`wd`.`departmentFk` AS `departmentFk`,left(`w`.`fi`,8) AS `dni` from ((`account`.`user` `u` join `vn`.`worker` `w` on((`w`.`userFk` = `u`.`id`))) left join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `w`.`id`))) */; +/*!50001 VIEW `workerTimeControlUserInfo` AS select `u`.`id` AS `userFk`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`u`.`name` AS `user`,`u`.`password` AS `password`,`u`.`bcryptPassword` AS `bcryptPassword`,`wd`.`departmentFk` AS `departmentFk`,left(`c`.`fi`,8) AS `dni` from (((`account`.`user` `u` join `vn`.`worker` `w` on((`w`.`userFk` = `u`.`id`))) join `vn`.`client` `c` on((`c`.`id` = `u`.`id`))) left join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `w`.`id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -84621,4 +85241,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-05-25 10:34:01 +-- Dump completed on 2021-06-22 14:38:24 diff --git a/db/export-data.sh b/db/export-data.sh index 5292e8f6a..96adc7ab6 100755 --- a/db/export-data.sh +++ b/db/export-data.sh @@ -40,6 +40,7 @@ TABLES=( vn alertLevel bookingPlanner + businessType cplusInvoiceType472 cplusInvoiceType477 cplusRectificationType