diff --git a/db/changes/10330-jun2021/00-invoiceLog.sql b/db/changes/10330-jun2021/00-invoiceLog.sql deleted file mode 100644 index 899c6c63f..000000000 --- a/db/changes/10330-jun2021/00-invoiceLog.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/changes/10340-summer/00-ACL.sql b/db/changes/10340-summer/00-ACL.sql deleted file mode 100644 index dff946e4b..000000000 --- a/db/changes/10340-summer/00-ACL.sql +++ /dev/null @@ -1,15 +0,0 @@ -DELETE FROM `salix`.`ACL` WHERE id = 189; -DELETE FROM `salix`.`ACL` WHERE id = 188; -UPDATE `salix`.`ACL` tdms SET tdms.accessType = '*' - WHERE tdms.id = 165; - -INSERT INTO `salix`.`ACL` (model, principalId, property, accessType) - VALUES - ('InvoiceInTax','administrative', '*', '*'), - ('InvoiceInLog','administrative', '*', 'READ'); - -INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) - VALUES - ('InvoiceOut', 'createManualInvoice', 'WRITE', 'ALLOW', 'ROLE', 'invoicing'), - ('InvoiceOut', 'globalInvoicing', 'WRITE', 'ALLOW', 'ROLE', 'invoicing'); - diff --git a/db/changes/10340-summer/00-buy_importReference.sql b/db/changes/10340-summer/00-buy_importReference.sql deleted file mode 100644 index f6bdc059c..000000000 --- a/db/changes/10340-summer/00-buy_importReference.sql +++ /dev/null @@ -1,14 +0,0 @@ -create table `vn`.`itemMatchProperties` -( - itemFk int not null, - name varchar(80) not null, - producer varchar(80) not null, - size int not null, - constraint itemMatchProperties_pk - primary key (itemFk, name, producer, size), - constraint itemFk___fk - foreign key (itemFk) references item (id) - on update cascade on delete cascade -) -comment 'Propiedades para encontrar articulos equivalentes en verdnatura'; - diff --git a/db/changes/10340-summer/00-invoiceFromClient.sql b/db/changes/10340-summer/00-invoiceFromClient.sql deleted file mode 100644 index d198e873d..000000000 --- a/db/changes/10340-summer/00-invoiceFromClient.sql +++ /dev/null @@ -1,21 +0,0 @@ -drop procedure `vn`.`invoiceFromClient`; - -DELIMITER $$ -$$ -create - definer = root@`%` procedure `vn`.`invoiceFromClient`(IN vMaxTicketDate datetime, IN vClientFk INT, IN vCompanyFk INT) -BEGIN - DECLARE vMinTicketDate DATE DEFAULT TIMESTAMPADD(YEAR, -3, CURDATE()); - SET vMaxTicketDate = util.dayend(vMaxTicketDate); - - DROP TEMPORARY TABLE IF EXISTS `ticketToInvoice`; - CREATE TEMPORARY TABLE `ticketToInvoice` - (PRIMARY KEY (`id`)) - ENGINE = MEMORY - SELECT id FROM ticket t - WHERE t.clientFk = vClientFk - AND t.refFk IS NULL - AND t.companyFk = vCompanyFk - AND (t.shipped BETWEEN vMinTicketDate AND vMaxTicketDate); -END;;$$ -DELIMITER ; diff --git a/db/changes/10340-summer/00-invoiceOut_newFromClient.sql b/db/changes/10340-summer/00-invoiceOut_newFromClient.sql deleted file mode 100644 index b4d4f916b..000000000 --- a/db/changes/10340-summer/00-invoiceOut_newFromClient.sql +++ /dev/null @@ -1,45 +0,0 @@ -drop procedure `vn`.`invoiceOut_newFromClient`; - -DELIMITER $$ -$$ -create - definer = root@`%` procedure `vn`.`invoiceOut_newFromClient`(IN vClientFk int, IN vSerial char(2), IN vMaxShipped date, - IN vCompanyFk int, IN vTaxArea varchar(25), - IN 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; - - 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; - - 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); - END IF; -END;;$$ -DELIMITER ; diff --git a/db/changes/10340-summer/00-invoiceOut_newFromTicket.sql b/db/changes/10340-summer/00-invoiceOut_newFromTicket.sql deleted file mode 100644 index 15be3d83c..000000000 --- a/db/changes/10340-summer/00-invoiceOut_newFromTicket.sql +++ /dev/null @@ -1,38 +0,0 @@ -drop procedure `vn`.`invoiceOut_newFromTicket`; - -DELIMITER $$ -$$ -create - definer = root@`%` procedure `vn`.`invoiceOut_newFromTicket`(IN vTicketFk int, IN vSerial char(2), IN vTaxArea varchar(25), - IN vRef varchar(25), OUT vInvoiceId int) -BEGIN -/** - * Factura un ticket - * @param vTicketFk Id del ticket - * @param vSerial Serie de factura - * @param vTaxArea Area de la factura en caso de querer forzarlo, - * en la mayoria de los casos poner NULL - * @return vInvoiceId - */ - DECLARE vIsRefEditable BOOLEAN; - CALL invoiceFromTicket(vTicketFk); - CALL invoiceOut_new(vSerial, CURDATE(), vTaxArea, vInvoiceId); - - 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; - - UPDATE invoiceOut - SET `ref` = vRef - WHERE id = vInvoiceId; - END IF; - - IF vSerial <> 'R' AND NOT ISNULL(vInvoiceId) AND vInvoiceId <> 0 THEN - CALL invoiceOutBooking(vInvoiceId); - END IF; -END;;$$ -DELIMITER ; diff --git a/db/changes/10340-summer/00-sample.sql b/db/changes/10340-summer/00-sample.sql deleted file mode 100644 index d4858ac72..000000000 --- a/db/changes/10340-summer/00-sample.sql +++ /dev/null @@ -1,7 +0,0 @@ -ALTER TABLE `vn`.`sample` ADD COLUMN - (`datepickerEnabled` TINYINT(1) NOT NULL DEFAULT 0); - -ALTER TABLE `vn`.`sample` MODIFY code VARCHAR(25) charset utf8 NOT NULL; - -INSERT INTO `vn`.`sample` (code, description, isVisible, hasCompany, hasPreview, datepickerEnabled) - VALUES ('client-debt-statement', 'Extracto del cliente', 1, 0, 1, 1); \ No newline at end of file diff --git a/db/changes/10340-summer/00-ticket_close.sql b/db/changes/10340-summer/00-ticket_close.sql deleted file mode 100644 index a8086549c..000000000 --- a/db/changes/10340-summer/00-ticket_close.sql +++ /dev/null @@ -1,109 +0,0 @@ -drop procedure `vn`.`ticket_close`; - -DELIMITER $$ -$$ -create - definer = root@`%` procedure `vn`.`ticket_close`() -BEGIN -/** - * Realiza el cierre de todos los - * tickets de la tabla tmp.ticket_close. - * - * @table tmp.ticket_close(ticketFk) Identificadores de los tickets a cerrar - */ - DECLARE vDone BOOL; - DECLARE vClientFk INT; - DECLARE vCurTicketFk INT; - DECLARE vIsTaxDataChecked BOOL; - DECLARE vCompanyFk INT; - DECLARE vShipped DATE; - DECLARE vNewInvoiceId INT; - DECLARE vHasDailyInvoice BOOL; - DECLARE vWithPackage BOOL; - DECLARE vHasToInvoice BOOL; - - DECLARE cur CURSOR FOR - SELECT ticketFk FROM tmp.ticket_close; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN - RESIGNAL; - END; - - OPEN cur; - - proc: LOOP - SET vDone = FALSE; - - FETCH cur INTO vCurTicketFk; - - IF vDone THEN - LEAVE proc; - END IF; - - -- Fetch ticket data - 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 = vCurTicketFk; - - INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity) - (SELECT vCurTicketFk, p.id, COUNT(*) - FROM expedition e - JOIN packaging p ON p.itemFk = e.itemFk - WHERE e.ticketFk = vCurTicketFk 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, vCurTicketFk, 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 = vCurTicketFk AND IFNULL(p.isPackageReturnable, 0) = 0 - AND getSpecialPrice(e.itemFk, vClientFk) > 0 - GROUP BY e.itemFk); - - CALL vn.zonePromo_Make(); - - IF(vHasDailyInvoice) AND vHasToInvoice THEN - - -- Facturacion rapida - CALL ticketTrackingAdd(vCurTicketFk, 'DELIVERED', NULL); - -- Facturar si está contabilizado - IF vIsTaxDataChecked THEN - CALL invoiceOut_newFromClient( - vClientFk, - (SELECT invoiceSerial(vClientFk, vCompanyFk, 'M')), - vShipped, - vCompanyFk, - NULL, - NULL, - vNewInvoiceId); - END IF; - ELSE - CALL ticketTrackingAdd(vCurTicketFk, (SELECT vn.getAlert3State(vCurTicketFk)), NULL); - END IF; - END LOOP; - - CLOSE cur; -END;;$$ -DELIMITER ; diff --git a/db/changes/10340-summer/00-ticket_closeAll.sql b/db/changes/10340-summer/00-ticket_closeAll.sql deleted file mode 100644 index 6441f2c1a..000000000 --- a/db/changes/10340-summer/00-ticket_closeAll.sql +++ /dev/null @@ -1,118 +0,0 @@ -drop procedure `vn`.`ticket_closeAll`; - -DELIMITER $$ -$$ -create definer = root@`%` procedure `vn`.`ticket_closeAll__`() -BEGIN -/** - * Realiza el cierre de todos los - * tickets de la tabla tmp.ticketClosure. - * - * @param vTicketFk Id del ticket - */ - DECLARE vDone BOOL; - DECLARE vClientFk INT; - DECLARE vCurTicketFk INT; - DECLARE vIsTaxDataChecked BOOL; - DECLARE vCompanyFk INT; - DECLARE vShipped DATE; - 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 vCurTicketFk; - - 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 = vCurTicketFk; - - INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity) - (SELECT vCurTicketFk, p.id, COUNT(*) - FROM expedition e - JOIN packaging p ON p.itemFk = e.itemFk - WHERE e.ticketFk = vCurTicketFk 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, vCurTicketFk, 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 = vCurTicketFk AND IFNULL(p.isPackageReturnable, 0) = 0 - AND getSpecialPrice(e.itemFk, vClientFk) > 0 - GROUP BY e.itemFk); - - CALL vn.zonePromo_Make(); - - IF(vHasDailyInvoice) AND vHasToInvoice THEN - - -- Facturacion rapida - CALL ticketTrackingAdd(vCurTicketFk, 'DELIVERED', NULL); - -- Facturar si está contabilizado - IF vIsTaxDataChecked THEN - CALL invoiceOut_newFromClient( - vClientFk, - (SELECT invoiceSerial(vClientFk, vCompanyFk, 'M')), - vShipped, - vCompanyFk, - NULL, - NULL, - vNewInvoiceId); - END IF; - ELSE - CALL ticketTrackingAdd(vCurTicketFk, (SELECT vn.getAlert3State(vCurTicketFk)), NULL); - END IF; - END LOOP; - - CLOSE cur; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure; -END;;$$ -DELIMITER ; - diff --git a/db/changes/10340-summer/00-ticket_closeByTicket.sql b/db/changes/10340-summer/00-ticket_closeByTicket.sql deleted file mode 100644 index a24ea5ad9..000000000 --- a/db/changes/10340-summer/00-ticket_closeByTicket.sql +++ /dev/null @@ -1,34 +0,0 @@ -drop procedure `vn`.`ticket_closeByTicket`; - -DELIMITER $$ -$$ -create - definer = root@`%` procedure `vn`.`ticket_closeByTicket`(IN vTicketFk int) -BEGIN - -/** - * Inserta el ticket en la tabla temporal - * para ser cerrado. - * - * @param vTicketFk Id del ticket - */ - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket_close; - CREATE TEMPORARY TABLE tmp.ticket_close ENGINE = MEMORY ( - SELECT - t.id AS ticketFk - FROM expedition e - INNER JOIN ticket t ON t.id = e.ticketFk - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - JOIN alertLevel al ON al.id = ts.alertLevel - WHERE - al.code = 'PACKED' - AND t.id = vTicketFk - AND t.refFk IS NULL - GROUP BY e.ticketFk); - - CALL ticket_close(); - - DROP TEMPORARY TABLE tmp.ticket_close; -END;;$$ -DELIMITER ; diff --git a/db/changes/10340-summer/01-credit_request.sql b/db/changes/10340-summer/01-credit_request.sql deleted file mode 100644 index 821623326..000000000 --- a/db/changes/10340-summer/01-credit_request.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO `vn`.`sample` (`code`, `description`, `isVisible`, `hasCompany`, `hasPreview`) - VALUES ('credit-request', 'Solicitud de crédito', 1, 1, 1); \ No newline at end of file diff --git a/db/changes/10350-august/00-supplierAccountTrigger.sql b/db/changes/10350-august/00-supplierAccountTrigger.sql deleted file mode 100644 index a71b01126..000000000 --- a/db/changes/10350-august/00-supplierAccountTrigger.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TRIGGER vn.supplierAccount_AfterInsert; diff --git a/db/changes/10350-august/00-ticket_afterUpdate.sql b/db/changes/10350-august/00-ticket_afterUpdate.sql deleted file mode 100644 index 7f579d7b6..000000000 --- a/db/changes/10350-august/00-ticket_afterUpdate.sql +++ /dev/null @@ -1,33 +0,0 @@ -DROP TRIGGER IF EXISTS vn.ticket_afterUpdate; - -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`%` TRIGGER vn.`ticket_afterUpdate` - AFTER UPDATE ON `ticket` - FOR EACH ROW -BEGIN - - IF !(NEW.id <=> OLD.id) - OR !(NEW.warehouseFk <=> OLD.warehouseFk) - OR !(NEW.shipped <=> OLD.shipped) THEN - CALL stock.log_add('ticket', NEW.id, OLD.id); - END IF; - - IF !(NEW.clientFk <=> OLD.clientFk) - OR !(NEW.addressFk <=> OLD.addressFk) - OR !(NEW.companyFk <=> OLD.companyFk) THEN - CALL ticket_requestRecalc(NEW.id); - END IF; - - IF NEW.clientFk = 2067 AND !(NEW.clientFk <=> OLD.clientFk) THEN - -- Fallo que se insertan no se sabe como tickets en este cliente - INSERT INTO vn.mail SET - `sender` = 'jgallego@verdnatura.es', - `replyTo` = 'jgallego@verdnatura.es', - `subject` = 'Modificado ticket al cliente 2067', - `body` = CONCAT(account.myUserGetName(), ' ha modificado el ticket ', - NEW.id); - END IF; - -END$$ -DELIMITER ; diff --git a/db/changes/10370-pickles/00-silexACL.sql b/db/changes/10370-pickles/00-silexACL.sql new file mode 100644 index 000000000..82623baf0 --- /dev/null +++ b/db/changes/10370-pickles/00-silexACL.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.silexACL MODIFY module VARCHAR(50) NOT NULL; +ALTER TABLE vn.silexACL MODIFY method VARCHAR(50) NOT NULL; \ No newline at end of file diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index 9cb7e9a0c..8151ce601 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -19,10 +19,10 @@ USE `util`; -- -- Dumping data for table `config` -- - + LOCK TABLES `config` WRITE; /*!40000 ALTER TABLE `config` DISABLE KEYS */; -INSERT INTO `config` VALUES (1,'10330',0,'production',NULL); +INSERT INTO `config` VALUES (1,'10360',0,'production',NULL); /*!40000 ALTER TABLE `config` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -34,7 +34,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:42:28 +-- Dump completed on 2021-10-20 8:38:20 USE `account`; -- MariaDB dump 10.19 Distrib 10.6.4-MariaDB, for Linux (x86_64) -- @@ -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 equipo/departamento',1,'2017-05-19 07:04:58','2021-06-30 13:29:30'),(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'); +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 equipo/departamento',1,'2017-05-19 07:04:58','2021-06-30 13:29:30'),(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'),(102,'preservedBoss','Responsable preservado',1,'2021-09-14 13:45:37','2021-09-14 13:45:37'); /*!40000 ALTER TABLE `role` ENABLE KEYS */; UNLOCK TABLES; @@ -68,17 +68,17 @@ 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),(150,15,56),(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),(153,48,35),(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),(152,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); +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),(150,15,56),(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),(153,48,35),(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),(152,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),(154,102,1); /*!40000 ALTER TABLE `roleInherit` ENABLE KEYS */; UNLOCK TABLES; --- +-- -- Dumping data for table `roleRole` -- LOCK TABLES `roleRole` WRITE; /*!40000 ALTER TABLE `roleRole` DISABLE KEYS */; -INSERT INTO `roleRole` VALUES (44924,1,1),(44925,1,2),(44926,1,3),(44930,1,6),(44929,1,11),(44927,1,70),(44928,1,76),(44841,2,2),(44843,2,6),(44842,2,11),(44723,3,3),(44725,3,6),(44724,3,11),(44695,5,1),(44702,5,2),(44701,5,3),(44694,5,5),(44706,5,6),(44705,5,11),(44699,5,13),(44703,5,18),(44696,5,21),(44697,5,33),(44704,5,53),(44700,5,70),(44698,5,76),(44995,6,6),(44888,9,1),(44885,9,2),(44872,9,3),(44870,9,5),(44893,9,6),(44862,9,9),(44867,9,11),(44920,9,13),(44902,9,15),(44903,9,16),(44869,9,17),(44918,9,18),(44917,9,19),(44904,9,20),(44916,9,21),(44921,9,22),(44891,9,30),(44892,9,31),(44889,9,32),(44899,9,33),(44873,9,34),(44877,9,35),(44914,9,36),(44896,9,37),(44897,9,38),(44868,9,39),(44894,9,40),(44895,9,41),(44874,9,42),(44875,9,43),(44865,9,44),(44866,9,45),(44882,9,47),(44884,9,48),(44911,9,49),(44913,9,50),(44905,9,51),(44906,9,52),(44898,9,53),(44900,9,54),(44901,9,55),(44886,9,56),(44887,9,57),(44909,9,58),(44910,9,59),(44912,9,60),(44915,9,61),(44907,9,62),(44876,9,64),(44908,9,65),(44919,9,66),(44871,9,67),(44883,9,69),(44922,9,70),(44880,9,71),(44881,9,72),(44890,9,73),(44923,9,74),(44879,9,75),(44863,9,76),(44864,9,100),(44878,9,101),(44642,11,6),(44641,11,11),(45456,13,1),(45457,13,2),(45458,13,3),(45462,13,6),(45461,13,11),(45455,13,13),(45459,13,70),(45460,13,76),(45082,15,1),(45086,15,2),(45085,15,3),(45089,15,6),(45088,15,11),(45074,15,15),(45075,15,35),(45080,15,36),(45083,15,44),(45087,15,47),(45076,15,49),(45077,15,56),(45079,15,58),(45084,15,70),(45081,15,75),(45078,15,76),(45096,16,1),(45101,16,2),(45100,16,3),(45107,16,6),(45106,16,11),(45091,16,13),(45092,16,15),(45090,16,16),(45095,16,35),(45102,16,36),(45105,16,44),(45104,16,47),(45094,16,49),(45097,16,56),(45103,16,58),(45099,16,70),(45098,16,75),(45093,16,76),(44668,17,1),(44677,17,2),(44676,17,3),(44666,17,5),(44689,17,6),(44685,17,11),(44671,17,13),(44681,17,15),(44670,17,16),(44659,17,17),(44682,17,18),(44680,17,19),(44660,17,20),(44672,17,21),(44674,17,33),(44679,17,35),(44691,17,36),(44661,17,37),(44662,17,39),(44693,17,44),(44692,17,47),(44688,17,49),(44678,17,50),(44683,17,53),(44684,17,56),(44673,17,57),(44690,17,58),(44686,17,59),(44663,17,64),(44669,17,65),(44664,17,67),(44675,17,70),(44667,17,74),(44687,17,75),(44665,17,76),(45386,18,1),(45389,18,2),(45388,18,3),(45392,18,6),(45391,18,11),(45385,18,18),(45390,18,70),(45387,18,76),(45379,19,1),(45382,19,2),(45381,19,3),(45384,19,6),(45383,19,11),(45375,19,13),(45376,19,18),(45373,19,19),(45374,19,21),(45377,19,53),(45380,19,70),(45378,19,76),(45116,20,1),(45122,20,2),(45121,20,3),(45134,20,6),(45131,20,11),(45109,20,13),(45115,20,15),(45110,20,16),(45128,20,18),(45114,20,19),(45108,20,20),(45123,20,21),(45113,20,35),(45130,20,36),(45133,20,44),(45132,20,47),(45119,20,49),(45117,20,50),(45127,20,53),(45118,20,56),(45125,20,57),(45129,20,58),(45126,20,59),(45111,20,65),(45120,20,70),(45124,20,75),(45112,20,76),(45367,21,1),(45370,21,2),(45369,21,3),(45372,21,6),(45371,21,11),(45363,21,13),(45364,21,18),(45362,21,21),(45365,21,53),(45368,21,70),(45366,21,76),(45467,22,1),(45472,22,2),(45471,22,3),(45474,22,6),(45473,22,11),(45464,22,13),(45466,22,18),(45465,22,21),(45463,22,22),(45468,22,53),(45470,22,70),(45469,22,76),(44967,30,1),(44973,30,2),(44972,30,3),(44956,30,5),(44984,30,6),(44981,30,11),(44964,30,13),(44969,30,15),(44963,30,16),(44970,30,18),(44968,30,19),(44957,30,20),(44966,30,21),(44958,30,22),(44955,30,30),(44965,30,33),(44974,30,35),(44983,30,36),(44986,30,44),(44985,30,47),(44980,30,49),(44975,30,50),(44959,30,53),(44979,30,56),(44977,30,57),(44982,30,58),(44976,30,59),(44960,30,64),(44962,30,65),(44971,30,70),(44978,30,75),(44961,30,76),(44988,31,1),(44989,31,2),(44990,31,3),(44994,31,6),(44993,31,11),(44987,31,31),(44991,31,70),(44992,31,76),(44932,32,1),(44933,32,2),(44934,32,3),(44938,32,6),(44937,32,11),(44931,32,32),(44935,32,70),(44936,32,76),(45055,33,33),(44727,34,1),(44732,34,2),(44731,34,3),(44735,34,6),(44734,34,11),(44728,34,13),(44729,34,33),(44726,34,34),(44730,34,70),(44733,34,76),(44770,35,1),(44775,35,2),(44774,35,3),(44777,35,6),(44776,35,11),(44769,35,35),(44773,35,70),(44771,35,75),(44772,35,76),(45281,36,1),(45283,36,2),(45282,36,3),(45287,36,6),(45286,36,11),(45278,36,36),(45279,36,44),(45280,36,47),(45284,36,70),(45285,36,76),(45027,37,1),(45032,37,2),(45031,37,3),(45034,37,6),(45033,37,11),(45026,37,37),(45030,37,70),(45028,37,74),(45029,37,76),(45041,38,1),(45044,38,2),(45043,38,3),(45046,38,6),(45045,38,11),(45036,38,13),(45037,38,37),(45035,38,38),(45038,38,64),(45042,38,70),(45040,38,74),(45039,38,76),(44651,39,1),(44656,39,2),(44655,39,3),(44644,39,5),(44658,39,6),(44657,39,11),(44649,39,13),(44648,39,18),(44645,39,21),(44650,39,33),(44643,39,39),(44652,39,53),(44653,39,56),(44646,39,57),(44654,39,70),(44647,39,76),(44997,40,1),(45000,40,2),(44999,40,3),(45008,40,6),(45007,40,11),(45002,40,36),(44996,40,40),(45005,40,44),(45004,40,47),(44998,40,49),(45003,40,58),(45001,40,70),(45006,40,76),(45016,41,1),(45020,41,2),(45019,41,3),(45025,41,6),(45024,41,11),(45010,41,13),(45011,41,35),(45017,41,36),(45012,41,40),(45009,41,41),(45023,41,44),(45022,41,47),(45014,41,49),(45021,41,58),(45018,41,70),(45015,41,75),(45013,41,76),(44742,42,1),(44747,42,2),(44746,42,3),(44750,42,6),(44749,42,11),(44737,42,35),(44740,42,36),(44736,42,42),(44744,42,44),(44748,42,47),(44738,42,49),(44743,42,58),(44745,42,70),(44741,42,75),(44739,42,76),(44755,43,1),(44761,43,2),(44760,43,3),(44767,43,6),(44766,43,11),(44752,43,13),(44754,43,35),(44762,43,36),(44753,43,42),(44751,43,43),(44765,43,44),(44764,43,47),(44756,43,49),(44763,43,58),(44759,43,70),(44758,43,75),(44757,43,76),(44624,44,1),(44625,44,2),(44626,44,3),(44630,44,6),(44629,44,11),(44623,44,44),(44627,44,70),(44628,44,76),(44634,45,1),(44636,45,2),(44635,45,3),(44640,45,6),(44639,45,11),(44632,45,13),(44633,45,44),(44631,45,45),(44637,45,70),(44638,45,76),(44811,47,1),(44812,47,2),(44813,47,3),(44817,47,6),(44816,47,11),(44810,47,47),(44814,47,70),(44815,47,76),(44835,48,1),(44838,48,2),(44837,48,3),(44840,48,6),(44839,48,11),(44830,48,13),(44831,48,35),(44832,48,47),(44829,48,48),(44836,48,70),(44834,48,75),(44833,48,76),(45222,49,1),(45225,49,2),(45224,49,3),(45228,49,6),(45227,49,11),(45218,49,36),(45221,49,44),(45220,49,47),(45217,49,49),(45219,49,58),(45223,49,70),(45226,49,76),(45270,50,1),(45275,50,2),(45274,50,3),(45277,50,6),(45276,50,11),(45257,50,13),(45269,50,18),(45258,50,21),(45259,50,35),(45266,50,36),(45272,50,44),(45271,50,47),(45260,50,49),(45256,50,50),(45268,50,53),(45264,50,56),(45261,50,57),(45265,50,58),(45262,50,59),(45273,50,70),(45267,50,75),(45263,50,76),(45136,51,1),(45141,51,2),(45140,51,3),(45144,51,6),(45143,51,11),(45135,51,51),(45139,51,70),(45137,51,74),(45138,51,75),(45142,51,76),(45154,52,1),(45159,52,2),(45158,52,3),(45161,52,6),(45160,52,11),(45146,52,13),(45156,52,18),(45147,52,19),(45153,52,21),(45148,52,35),(45149,52,51),(45145,52,52),(45155,52,53),(45157,52,70),(45151,52,74),(45152,52,75),(45150,52,76),(45048,53,1),(45049,53,2),(45050,53,3),(45054,53,6),(45053,53,11),(45047,53,53),(45051,53,70),(45052,53,76),(45057,54,1),(45058,54,2),(45059,54,3),(45063,54,6),(45062,54,11),(45056,54,54),(45060,54,70),(45061,54,76),(45067,55,1),(45069,55,2),(45068,55,3),(45073,55,6),(45072,55,11),(45065,55,13),(45066,55,54),(45064,55,55),(45070,55,70),(45071,55,76),(44845,56,1),(44846,56,2),(44847,56,3),(44851,56,6),(44850,56,11),(44844,56,56),(44848,56,70),(44849,56,76),(44856,57,1),(44859,57,2),(44858,57,3),(44861,57,6),(44860,57,11),(44853,57,13),(44854,57,56),(44852,57,57),(44857,57,70),(44855,57,76),(45188,58,1),(45189,58,2),(45190,58,3),(45194,58,6),(45193,58,11),(45187,58,58),(45191,58,70),(45192,58,76),(45199,59,1),(45209,59,2),(45208,59,3),(45216,59,6),(45215,59,11),(45196,59,13),(45206,59,18),(45198,59,21),(45200,59,35),(45210,59,36),(45214,59,44),(45213,59,47),(45201,59,49),(45197,59,50),(45205,59,53),(45212,59,56),(45202,59,57),(45211,59,58),(45195,59,59),(45207,59,70),(45204,59,75),(45203,59,76),(45239,60,1),(45251,60,2),(45250,60,3),(45230,60,5),(45255,60,6),(45254,60,11),(45235,60,13),(45248,60,18),(45238,60,21),(45237,60,33),(45240,60,35),(45245,60,36),(45231,60,37),(45253,60,44),(45252,60,47),(45241,60,49),(45232,60,50),(45247,60,53),(45243,60,56),(45233,60,57),(45244,60,58),(45242,60,59),(45229,60,60),(45249,60,70),(45236,60,74),(45246,60,75),(45234,60,76),(45292,61,1),(45296,61,2),(45295,61,3),(45299,61,6),(45298,61,11),(45289,61,13),(45290,61,36),(45291,61,44),(45293,61,47),(45288,61,61),(45294,61,70),(45297,61,76),(45162,62,62),(44768,64,64),(45170,65,1),(45179,65,2),(45178,65,3),(45186,65,6),(45185,65,11),(45168,65,13),(45181,65,18),(45164,65,19),(45171,65,21),(45165,65,35),(45176,65,36),(45184,65,44),(45183,65,47),(45172,65,49),(45166,65,50),(45180,65,53),(45182,65,56),(45173,65,57),(45175,65,58),(45174,65,59),(45163,65,65),(45177,65,70),(45169,65,75),(45167,65,76),(45420,66,1),(45416,66,2),(45403,66,3),(45401,66,5),(45425,66,6),(45419,66,9),(45398,66,11),(45451,66,13),(45434,66,15),(45435,66,16),(45400,66,17),(45450,66,18),(45449,66,19),(45436,66,20),(45448,66,21),(45452,66,22),(45423,66,30),(45424,66,31),(45421,66,32),(45431,66,33),(45404,66,34),(45408,66,35),(45446,66,36),(45428,66,37),(45429,66,38),(45399,66,39),(45426,66,40),(45427,66,41),(45405,66,42),(45406,66,43),(45396,66,44),(45397,66,45),(45413,66,47),(45415,66,48),(45443,66,49),(45445,66,50),(45437,66,51),(45438,66,52),(45430,66,53),(45432,66,54),(45433,66,55),(45417,66,56),(45418,66,57),(45441,66,58),(45442,66,59),(45444,66,60),(45447,66,61),(45439,66,62),(45407,66,64),(45440,66,65),(45393,66,66),(45402,66,67),(45414,66,69),(45453,66,70),(45411,66,71),(45412,66,72),(45422,66,73),(45454,66,74),(45410,66,75),(45394,66,76),(45395,66,100),(45409,66,101),(44711,67,1),(44719,67,2),(44718,67,3),(44708,67,5),(44722,67,6),(44721,67,11),(44716,67,13),(44715,67,18),(44710,67,21),(44712,67,33),(44709,67,37),(44720,67,53),(44707,67,67),(44717,67,70),(44714,67,74),(44713,67,76),(44822,69,1),(44826,69,2),(44825,69,3),(44828,69,6),(44827,69,11),(44819,69,35),(44820,69,47),(44818,69,69),(44824,69,70),(44821,69,75),(44823,69,76),(45478,70,6),(45476,70,11),(45475,70,70),(45477,70,76),(44792,71,1),(44795,71,2),(44794,71,3),(44799,71,6),(44798,71,11),(44793,71,58),(44796,71,70),(44791,71,71),(44797,71,76),(44804,72,1),(44806,72,2),(44805,72,3),(44809,72,6),(44808,72,11),(44801,72,13),(44802,72,18),(44807,72,70),(44800,72,72),(44803,72,76),(44945,73,1),(44950,73,2),(44949,73,3),(44940,73,5),(44954,73,6),(44953,73,11),(44947,73,13),(44951,73,18),(44941,73,19),(44944,73,21),(44943,73,33),(44952,73,53),(44942,73,64),(44948,73,70),(44939,73,73),(44946,73,76),(45479,74,74),(44789,75,75),(44790,76,76),(45326,100,1),(45322,100,2),(45308,100,3),(45306,100,5),(45331,100,6),(45325,100,9),(45303,100,11),(45358,100,13),(45340,100,15),(45341,100,16),(45305,100,17),(45356,100,18),(45355,100,19),(45342,100,20),(45354,100,21),(45359,100,22),(45329,100,30),(45330,100,31),(45327,100,32),(45337,100,33),(45309,100,34),(45313,100,35),(45352,100,36),(45334,100,37),(45335,100,38),(45304,100,39),(45332,100,40),(45333,100,41),(45310,100,42),(45311,100,43),(45301,100,44),(45302,100,45),(45319,100,47),(45321,100,48),(45349,100,49),(45351,100,50),(45343,100,51),(45344,100,52),(45336,100,53),(45338,100,54),(45339,100,55),(45323,100,56),(45324,100,57),(45347,100,58),(45348,100,59),(45350,100,60),(45353,100,61),(45345,100,62),(45312,100,64),(45346,100,65),(45357,100,66),(45307,100,67),(45320,100,69),(45360,100,70),(45317,100,71),(45318,100,72),(45328,100,73),(45361,100,74),(45315,100,75),(45316,100,76),(45300,100,100),(45314,100,101),(44782,101,1),(44786,101,2),(44785,101,3),(44788,101,6),(44787,101,11),(44779,101,13),(44780,101,35),(44784,101,70),(44781,101,75),(44783,101,76),(44778,101,101); +INSERT INTO `roleRole` VALUES (45782,1,1),(45783,1,2),(45784,1,3),(45788,1,6),(45787,1,11),(45785,1,70),(45786,1,76),(45698,2,2),(45700,2,6),(45699,2,11),(45580,3,3),(45582,3,6),(45581,3,11),(45552,5,1),(45559,5,2),(45558,5,3),(45551,5,5),(45563,5,6),(45562,5,11),(45556,5,13),(45560,5,18),(45553,5,21),(45554,5,33),(45561,5,53),(45557,5,70),(45555,5,76),(45853,6,6),(45745,9,1),(45742,9,2),(45729,9,3),(45727,9,5),(45750,9,6),(45719,9,9),(45724,9,11),(45778,9,13),(45759,9,15),(45760,9,16),(45726,9,17),(45776,9,18),(45775,9,19),(45761,9,20),(45774,9,21),(45779,9,22),(45748,9,30),(45749,9,31),(45746,9,32),(45756,9,33),(45730,9,34),(45734,9,35),(45772,9,36),(45753,9,37),(45754,9,38),(45725,9,39),(45751,9,40),(45752,9,41),(45731,9,42),(45732,9,43),(45722,9,44),(45723,9,45),(45739,9,47),(45741,9,48),(45769,9,49),(45771,9,50),(45762,9,51),(45763,9,52),(45755,9,53),(45757,9,54),(45758,9,55),(45743,9,56),(45744,9,57),(45766,9,58),(45767,9,59),(45770,9,60),(45773,9,61),(45764,9,62),(45733,9,64),(45765,9,65),(45777,9,66),(45728,9,67),(45740,9,69),(45780,9,70),(45737,9,71),(45738,9,72),(45747,9,73),(45781,9,74),(45736,9,75),(45720,9,76),(45721,9,100),(45735,9,101),(45768,9,102),(45499,11,6),(45498,11,11),(46324,13,1),(46325,13,2),(46326,13,3),(46330,13,6),(46329,13,11),(46323,13,13),(46327,13,70),(46328,13,76),(45940,15,1),(45944,15,2),(45943,15,3),(45947,15,6),(45946,15,11),(45932,15,15),(45933,15,35),(45938,15,36),(45941,15,44),(45945,15,47),(45934,15,49),(45935,15,56),(45937,15,58),(45942,15,70),(45939,15,75),(45936,15,76),(45954,16,1),(45959,16,2),(45958,16,3),(45965,16,6),(45964,16,11),(45949,16,13),(45950,16,15),(45948,16,16),(45953,16,35),(45960,16,36),(45963,16,44),(45962,16,47),(45952,16,49),(45955,16,56),(45961,16,58),(45957,16,70),(45956,16,75),(45951,16,76),(45525,17,1),(45534,17,2),(45533,17,3),(45523,17,5),(45546,17,6),(45542,17,11),(45528,17,13),(45538,17,15),(45527,17,16),(45516,17,17),(45539,17,18),(45537,17,19),(45517,17,20),(45529,17,21),(45531,17,33),(45536,17,35),(45548,17,36),(45518,17,37),(45519,17,39),(45550,17,44),(45549,17,47),(45545,17,49),(45535,17,50),(45540,17,53),(45541,17,56),(45530,17,57),(45547,17,58),(45543,17,59),(45520,17,64),(45526,17,65),(45521,17,67),(45532,17,70),(45524,17,74),(45544,17,75),(45522,17,76),(46253,18,1),(46256,18,2),(46255,18,3),(46259,18,6),(46258,18,11),(46252,18,18),(46257,18,70),(46254,18,76),(46246,19,1),(46249,19,2),(46248,19,3),(46251,19,6),(46250,19,11),(46242,19,13),(46243,19,18),(46240,19,19),(46241,19,21),(46244,19,53),(46247,19,70),(46245,19,76),(45974,20,1),(45980,20,2),(45979,20,3),(45992,20,6),(45989,20,11),(45967,20,13),(45973,20,15),(45968,20,16),(45986,20,18),(45972,20,19),(45966,20,20),(45981,20,21),(45971,20,35),(45988,20,36),(45991,20,44),(45990,20,47),(45977,20,49),(45975,20,50),(45985,20,53),(45976,20,56),(45983,20,57),(45987,20,58),(45984,20,59),(45969,20,65),(45978,20,70),(45982,20,75),(45970,20,76),(46234,21,1),(46237,21,2),(46236,21,3),(46239,21,6),(46238,21,11),(46230,21,13),(46231,21,18),(46229,21,21),(46232,21,53),(46235,21,70),(46233,21,76),(46335,22,1),(46340,22,2),(46339,22,3),(46342,22,6),(46341,22,11),(46332,22,13),(46334,22,18),(46333,22,21),(46331,22,22),(46336,22,53),(46338,22,70),(46337,22,76),(45825,30,1),(45831,30,2),(45830,30,3),(45814,30,5),(45842,30,6),(45839,30,11),(45822,30,13),(45827,30,15),(45821,30,16),(45828,30,18),(45826,30,19),(45815,30,20),(45824,30,21),(45816,30,22),(45813,30,30),(45823,30,33),(45832,30,35),(45841,30,36),(45844,30,44),(45843,30,47),(45838,30,49),(45833,30,50),(45817,30,53),(45837,30,56),(45835,30,57),(45840,30,58),(45834,30,59),(45818,30,64),(45820,30,65),(45829,30,70),(45836,30,75),(45819,30,76),(45846,31,1),(45847,31,2),(45848,31,3),(45852,31,6),(45851,31,11),(45845,31,31),(45849,31,70),(45850,31,76),(45790,32,1),(45791,32,2),(45792,32,3),(45796,32,6),(45795,32,11),(45789,32,32),(45793,32,70),(45794,32,76),(45913,33,33),(45584,34,1),(45589,34,2),(45588,34,3),(45592,34,6),(45591,34,11),(45585,34,13),(45586,34,33),(45583,34,34),(45587,34,70),(45590,34,76),(45627,35,1),(45632,35,2),(45631,35,3),(45634,35,6),(45633,35,11),(45626,35,35),(45630,35,70),(45628,35,75),(45629,35,76),(46147,36,1),(46149,36,2),(46148,36,3),(46153,36,6),(46152,36,11),(46144,36,36),(46145,36,44),(46146,36,47),(46150,36,70),(46151,36,76),(45885,37,1),(45890,37,2),(45889,37,3),(45892,37,6),(45891,37,11),(45884,37,37),(45888,37,70),(45886,37,74),(45887,37,76),(45899,38,1),(45902,38,2),(45901,38,3),(45904,38,6),(45903,38,11),(45894,38,13),(45895,38,37),(45893,38,38),(45896,38,64),(45900,38,70),(45898,38,74),(45897,38,76),(45508,39,1),(45513,39,2),(45512,39,3),(45501,39,5),(45515,39,6),(45514,39,11),(45506,39,13),(45505,39,18),(45502,39,21),(45507,39,33),(45500,39,39),(45509,39,53),(45510,39,56),(45503,39,57),(45511,39,70),(45504,39,76),(45855,40,1),(45858,40,2),(45857,40,3),(45866,40,6),(45865,40,11),(45860,40,36),(45854,40,40),(45863,40,44),(45862,40,47),(45856,40,49),(45861,40,58),(45859,40,70),(45864,40,76),(45874,41,1),(45878,41,2),(45877,41,3),(45883,41,6),(45882,41,11),(45868,41,13),(45869,41,35),(45875,41,36),(45870,41,40),(45867,41,41),(45881,41,44),(45880,41,47),(45872,41,49),(45879,41,58),(45876,41,70),(45873,41,75),(45871,41,76),(45599,42,1),(45604,42,2),(45603,42,3),(45607,42,6),(45606,42,11),(45594,42,35),(45597,42,36),(45593,42,42),(45601,42,44),(45605,42,47),(45595,42,49),(45600,42,58),(45602,42,70),(45598,42,75),(45596,42,76),(45612,43,1),(45618,43,2),(45617,43,3),(45624,43,6),(45623,43,11),(45609,43,13),(45611,43,35),(45619,43,36),(45610,43,42),(45608,43,43),(45622,43,44),(45621,43,47),(45613,43,49),(45620,43,58),(45616,43,70),(45615,43,75),(45614,43,76),(45481,44,1),(45482,44,2),(45483,44,3),(45487,44,6),(45486,44,11),(45480,44,44),(45484,44,70),(45485,44,76),(45491,45,1),(45493,45,2),(45492,45,3),(45497,45,6),(45496,45,11),(45489,45,13),(45490,45,44),(45488,45,45),(45494,45,70),(45495,45,76),(45668,47,1),(45669,47,2),(45670,47,3),(45674,47,6),(45673,47,11),(45667,47,47),(45671,47,70),(45672,47,76),(45692,48,1),(45695,48,2),(45694,48,3),(45697,48,6),(45696,48,11),(45687,48,13),(45688,48,35),(45689,48,47),(45686,48,48),(45693,48,70),(45691,48,75),(45690,48,76),(46088,49,1),(46091,49,2),(46090,49,3),(46094,49,6),(46093,49,11),(46084,49,36),(46087,49,44),(46086,49,47),(46083,49,49),(46085,49,58),(46089,49,70),(46092,49,76),(46136,50,1),(46141,50,2),(46140,50,3),(46143,50,6),(46142,50,11),(46123,50,13),(46135,50,18),(46124,50,21),(46125,50,35),(46132,50,36),(46138,50,44),(46137,50,47),(46126,50,49),(46122,50,50),(46134,50,53),(46130,50,56),(46127,50,57),(46131,50,58),(46128,50,59),(46139,50,70),(46133,50,75),(46129,50,76),(45994,51,1),(45999,51,2),(45998,51,3),(46002,51,6),(46001,51,11),(45993,51,51),(45997,51,70),(45995,51,74),(45996,51,75),(46000,51,76),(46012,52,1),(46017,52,2),(46016,52,3),(46019,52,6),(46018,52,11),(46004,52,13),(46014,52,18),(46005,52,19),(46011,52,21),(46006,52,35),(46007,52,51),(46003,52,52),(46013,52,53),(46015,52,70),(46009,52,74),(46010,52,75),(46008,52,76),(45906,53,1),(45907,53,2),(45908,53,3),(45912,53,6),(45911,53,11),(45905,53,53),(45909,53,70),(45910,53,76),(45915,54,1),(45916,54,2),(45917,54,3),(45921,54,6),(45920,54,11),(45914,54,54),(45918,54,70),(45919,54,76),(45925,55,1),(45927,55,2),(45926,55,3),(45931,55,6),(45930,55,11),(45923,55,13),(45924,55,54),(45922,55,55),(45928,55,70),(45929,55,76),(45702,56,1),(45703,56,2),(45704,56,3),(45708,56,6),(45707,56,11),(45701,56,56),(45705,56,70),(45706,56,76),(45713,57,1),(45716,57,2),(45715,57,3),(45718,57,6),(45717,57,11),(45710,57,13),(45711,57,56),(45709,57,57),(45714,57,70),(45712,57,76),(46046,58,1),(46047,58,2),(46048,58,3),(46052,58,6),(46051,58,11),(46045,58,58),(46049,58,70),(46050,58,76),(46057,59,1),(46067,59,2),(46066,59,3),(46074,59,6),(46073,59,11),(46054,59,13),(46064,59,18),(46056,59,21),(46058,59,35),(46068,59,36),(46072,59,44),(46071,59,47),(46059,59,49),(46055,59,50),(46063,59,53),(46070,59,56),(46060,59,57),(46069,59,58),(46053,59,59),(46065,59,70),(46062,59,75),(46061,59,76),(46105,60,1),(46117,60,2),(46116,60,3),(46096,60,5),(46121,60,6),(46120,60,11),(46101,60,13),(46114,60,18),(46104,60,21),(46103,60,33),(46106,60,35),(46111,60,36),(46097,60,37),(46119,60,44),(46118,60,47),(46107,60,49),(46098,60,50),(46113,60,53),(46109,60,56),(46099,60,57),(46110,60,58),(46108,60,59),(46095,60,60),(46115,60,70),(46102,60,74),(46112,60,75),(46100,60,76),(46158,61,1),(46162,61,2),(46161,61,3),(46165,61,6),(46164,61,11),(46155,61,13),(46156,61,36),(46157,61,44),(46159,61,47),(46154,61,61),(46160,61,70),(46163,61,76),(46020,62,62),(45625,64,64),(46028,65,1),(46037,65,2),(46036,65,3),(46044,65,6),(46043,65,11),(46026,65,13),(46039,65,18),(46022,65,19),(46029,65,21),(46023,65,35),(46034,65,36),(46042,65,44),(46041,65,47),(46030,65,49),(46024,65,50),(46038,65,53),(46040,65,56),(46031,65,57),(46033,65,58),(46032,65,59),(46021,65,65),(46035,65,70),(46027,65,75),(46025,65,76),(46287,66,1),(46283,66,2),(46270,66,3),(46268,66,5),(46292,66,6),(46286,66,9),(46265,66,11),(46319,66,13),(46301,66,15),(46302,66,16),(46267,66,17),(46318,66,18),(46317,66,19),(46303,66,20),(46316,66,21),(46320,66,22),(46290,66,30),(46291,66,31),(46288,66,32),(46298,66,33),(46271,66,34),(46275,66,35),(46314,66,36),(46295,66,37),(46296,66,38),(46266,66,39),(46293,66,40),(46294,66,41),(46272,66,42),(46273,66,43),(46263,66,44),(46264,66,45),(46280,66,47),(46282,66,48),(46311,66,49),(46313,66,50),(46304,66,51),(46305,66,52),(46297,66,53),(46299,66,54),(46300,66,55),(46284,66,56),(46285,66,57),(46308,66,58),(46309,66,59),(46312,66,60),(46315,66,61),(46306,66,62),(46274,66,64),(46307,66,65),(46260,66,66),(46269,66,67),(46281,66,69),(46321,66,70),(46278,66,71),(46279,66,72),(46289,66,73),(46322,66,74),(46277,66,75),(46261,66,76),(46262,66,100),(46276,66,101),(46310,66,102),(45568,67,1),(45576,67,2),(45575,67,3),(45565,67,5),(45579,67,6),(45578,67,11),(45573,67,13),(45572,67,18),(45567,67,21),(45569,67,33),(45566,67,37),(45577,67,53),(45564,67,67),(45574,67,70),(45571,67,74),(45570,67,76),(45679,69,1),(45683,69,2),(45682,69,3),(45685,69,6),(45684,69,11),(45676,69,35),(45677,69,47),(45675,69,69),(45681,69,70),(45678,69,75),(45680,69,76),(46346,70,6),(46344,70,11),(46343,70,70),(46345,70,76),(45649,71,1),(45652,71,2),(45651,71,3),(45656,71,6),(45655,71,11),(45650,71,58),(45653,71,70),(45648,71,71),(45654,71,76),(45661,72,1),(45663,72,2),(45662,72,3),(45666,72,6),(45665,72,11),(45658,72,13),(45659,72,18),(45664,72,70),(45657,72,72),(45660,72,76),(45803,73,1),(45808,73,2),(45807,73,3),(45798,73,5),(45812,73,6),(45811,73,11),(45805,73,13),(45809,73,18),(45799,73,19),(45802,73,21),(45801,73,33),(45810,73,53),(45800,73,64),(45806,73,70),(45797,73,73),(45804,73,76),(46347,74,74),(45646,75,75),(45647,76,76),(46192,100,1),(46188,100,2),(46174,100,3),(46172,100,5),(46197,100,6),(46191,100,9),(46169,100,11),(46225,100,13),(46206,100,15),(46207,100,16),(46171,100,17),(46223,100,18),(46222,100,19),(46208,100,20),(46221,100,21),(46226,100,22),(46195,100,30),(46196,100,31),(46193,100,32),(46203,100,33),(46175,100,34),(46179,100,35),(46219,100,36),(46200,100,37),(46201,100,38),(46170,100,39),(46198,100,40),(46199,100,41),(46176,100,42),(46177,100,43),(46167,100,44),(46168,100,45),(46185,100,47),(46187,100,48),(46216,100,49),(46218,100,50),(46209,100,51),(46210,100,52),(46202,100,53),(46204,100,54),(46205,100,55),(46189,100,56),(46190,100,57),(46213,100,58),(46214,100,59),(46217,100,60),(46220,100,61),(46211,100,62),(46178,100,64),(46212,100,65),(46224,100,66),(46173,100,67),(46186,100,69),(46227,100,70),(46183,100,71),(46184,100,72),(46194,100,73),(46228,100,74),(46181,100,75),(46182,100,76),(46166,100,100),(46180,100,101),(46215,100,102),(45639,101,1),(45643,101,2),(45642,101,3),(45645,101,6),(45644,101,11),(45636,101,13),(45637,101,35),(45641,101,70),(45638,101,75),(45640,101,76),(45635,101,101),(46076,102,1),(46077,102,2),(46078,102,3),(46082,102,6),(46081,102,11),(46079,102,70),(46080,102,76),(46075,102,102); /*!40000 ALTER TABLE `roleRole` ENABLE KEYS */; UNLOCK TABLES; @@ -120,7 +120,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:42:28 +-- Dump completed on 2021-10-20 8:38:22 USE `salix`; -- MariaDB dump 10.19 Distrib 10.6.4-MariaDB, for Linux (x86_64) -- @@ -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'),(244,'supplier','*','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'),(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'),(272,'InvoiceInLog','*','*','ALLOW','ROLE','employee'); +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'),(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'),(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'),(165,'TicketDms','*','*','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'),(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'),(244,'supplier','*','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'),(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','employee'),(270,'SupplierAddress','*','*','ALLOW','ROLE','employee'),(271,'SalesMonitor','*','*','ALLOW','ROLE','employee'),(272,'InvoiceInLog','*','*','ALLOW','ROLE','employee'),(273,'InvoiceInTax','*','*','ALLOW','ROLE','administrative'),(274,'InvoiceInLog','*','READ','ALLOW','ROLE','administrative'),(275,'InvoiceOut','createManualInvoice','WRITE','ALLOW','ROLE','invoicing'),(276,'InvoiceOut','globalInvoicing','WRITE','ALLOW','ROLE','invoicing'); /*!40000 ALTER TABLE `ACL` ENABLE KEYS */; UNLOCK TABLES; @@ -176,7 +176,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:42:29 +-- Dump completed on 2021-10-20 8:38:23 USE `vn`; -- MariaDB dump 10.19 Distrib 10.6.4-MariaDB, for Linux (x86_64) -- @@ -200,7 +200,7 @@ USE `vn`; LOCK TABLES `alertLevel` WRITE; /*!40000 ALTER TABLE `alertLevel` DISABLE KEYS */; -INSERT INTO `alertLevel` VALUES ('FREE',0,0),('ON_PREPARATION',1,1),('PACKED',2,2),('DELIVERED',3,3); +INSERT INTO `alertLevel` VALUES ('FREE',0),('ON_PREPARATION',1),('PACKED',2),('DELIVERED',3); /*!40000 ALTER TABLE `alertLevel` ENABLE KEYS */; UNLOCK TABLES; @@ -210,7 +210,7 @@ UNLOCK TABLES; LOCK TABLES `bookingPlanner` WRITE; /*!40000 ALTER TABLE `bookingPlanner` DISABLE KEYS */; -INSERT INTO `bookingPlanner` VALUES (5,'2017-06-30 22:00:00','4770000002','WORLD',7,4,1),(6,'2017-06-30 22:00:00','4770000010','NATIONAL',3,1,1),(8,'2017-06-30 22:00:00','4770000021','NATIONAL',1,2,1),(9,'2017-06-30 22:00:00','4770000101','EQU',3,1,1),(11,'2017-06-30 22:00:00','4770000110','EQU',4,1,1),(12,'2017-06-30 22:00:00','4770000215','EQU',1,2,1),(13,'2017-06-30 22:00:00','4770000521','EQU',2,2,1),(15,'2017-06-30 22:00:00','4771000000','CEE',3,1,1),(16,'2017-06-30 22:00:00','4771000001','CEE',8,3,1),(19,'2017-07-05 11:54:58','4770000020','NATIONAL',7,4,1),(20,'2017-07-05 12:09:24','4771000000','CEE',1,2,1),(21,'2017-07-05 12:09:24','4771000000','CEE',7,4,1),(22,'2017-07-05 12:12:14','4770000002','WORLD',3,1,1),(23,'2017-07-05 12:12:14','4770000002','WORLD',1,2,1),(24,'2017-07-06 08:07:21','4770000002','WORLD',7,4,5),(25,'2017-07-06 08:07:21','HolandaRED','NATIONAL',3,1,5),(27,'2017-07-06 08:07:21','HolandaGEN','NATIONAL',1,2,5),(32,'2017-07-06 08:07:21','4771000000','CEE',3,1,5),(33,'2017-07-06 08:07:21','4771000001','CEE',8,3,5),(34,'2017-07-06 08:07:21','4770000020','NATIONAL',7,4,5),(35,'2017-07-06 08:07:21','4771000000','CEE',1,2,5),(36,'2017-07-06 08:07:21','4771000000','CEE',7,4,5),(37,'2017-07-06 08:07:21','4770000002','WORLD',3,1,5),(38,'2017-07-06 08:07:21','4770000002','WORLD',1,2,5),(70,'2017-07-06 08:08:48','4770000002','WORLD',7,4,30),(71,'2017-07-06 08:08:48','IGIC reduc','NATIONAL',3,1,30),(72,'2017-07-06 08:08:48','4770000020','NATIONAL',7,4,30),(73,'2017-07-06 08:08:48','IGIC gener','NATIONAL',1,2,30),(78,'2017-07-06 08:08:48','4770000020','NATIONAL',7,4,30),(79,'2017-07-06 08:08:48','4770000002','WORLD',3,1,30),(80,'2017-07-06 08:08:48','4770000002','WORLD',1,2,30),(81,'2017-07-05 22:00:00','IGIC cero','NATIONAL',5,5,30),(82,'2019-01-01 11:51:56','4770000504','EQU',5,5,1),(83,'2019-09-11 10:54:03','4770000405','EQU',6,5,1),(84,'2019-09-11 10:58:17','4770000004','NATIONAL',5,5,1),(85,'2019-09-18 22:00:00','4771000000','CEE',5,5,1); +INSERT INTO `bookingPlanner` VALUES (5,'2017-06-30 22:00:00','4770000002','WORLD',7,4,1),(6,'2017-06-30 22:00:00','4770000010','NATIONAL',3,1,1),(8,'2017-06-30 22:00:00','4770000021','NATIONAL',1,2,1),(9,'2017-06-30 22:00:00','4770000101','EQU',3,1,1),(11,'2017-06-30 22:00:00','4770000110','EQU',4,1,1),(12,'2017-06-30 22:00:00','4770000215','EQU',1,2,1),(13,'2017-06-30 22:00:00','4770000521','EQU',2,2,1),(15,'2017-06-30 22:00:00','4771000000','CEE',3,1,1),(16,'2017-06-30 22:00:00','4771000001','CEE',8,3,1),(19,'2017-07-05 11:54:58','4770000020','NATIONAL',7,4,1),(20,'2017-07-05 12:09:24','4771000000','CEE',1,2,1),(21,'2017-07-05 12:09:24','4771000000','CEE',7,4,1),(22,'2017-07-05 12:12:14','4770000002','WORLD',3,1,1),(23,'2017-07-05 12:12:14','4770000002','WORLD',1,2,1),(24,'2017-07-06 08:07:21','4770000002','WORLD',7,4,5),(25,'2017-07-06 08:07:21','HolandaRED','NATIONAL',3,1,5),(27,'2017-07-06 08:07:21','HolandaGEN','NATIONAL',1,2,5),(32,'2017-07-06 08:07:21','4771000000','CEE',3,1,5),(33,'2017-07-06 08:07:21','4771000001','CEE',8,3,5),(34,'2017-07-06 08:07:21','4770000020','NATIONAL',7,4,5),(35,'2017-07-06 08:07:21','4771000000','CEE',1,2,5),(36,'2017-07-06 08:07:21','4771000000','CEE',7,4,5),(37,'2017-07-06 08:07:21','4770000002','WORLD',3,1,5),(38,'2017-07-06 08:07:21','4770000002','WORLD',1,2,5),(70,'2017-07-06 08:08:48','4770000002','WORLD',7,4,30),(71,'2017-07-06 08:08:48','IGIC reduc','NATIONAL',3,1,30),(72,'2017-07-06 08:08:48','4770000020','NATIONAL',7,4,30),(73,'2017-07-06 08:08:48','IGIC gener','NATIONAL',1,2,30),(78,'2017-07-06 08:08:48','4770000020','NATIONAL',7,4,30),(79,'2017-07-06 08:08:48','4770000002','WORLD',3,1,30),(80,'2017-07-06 08:08:48','4770000002','WORLD',1,2,30),(81,'2017-07-05 22:00:00','IGIC cero','NATIONAL',5,5,30),(82,'2019-01-01 11:51:56','4770000504','EQU',5,5,1),(83,'2019-09-11 10:54:03','4770000405','EQU',6,5,1),(84,'2019-09-11 10:58:17','4770000004','NATIONAL',5,5,1),(85,'2019-09-18 22:00:00','4771000000','CEE',5,5,1),(86,'2021-10-13 22:00:00','4770000002','WORLD',5,5,1); /*!40000 ALTER TABLE `bookingPlanner` ENABLE KEYS */; UNLOCK TABLES; @@ -220,7 +220,7 @@ UNLOCK TABLES; 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'); +INSERT INTO `businessType` VALUES ('decoration','Decoración'),('events','Eventos'),('florist','Floristería'),('gardenCentre','Vivero'),('mortuary','Funeraria'),('officialOrganism','Organismo oficial'),('others','Otros'),('restoration','Restauración'),('wholesaler','Mayorista'); /*!40000 ALTER TABLE `businessType` ENABLE KEYS */; UNLOCK TABLES; @@ -360,7 +360,7 @@ UNLOCK TABLES; LOCK TABLES `state` WRITE; /*!40000 ALTER TABLE `state` DISABLE KEYS */; -INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1),(2,'Libre',2,0,'FREE',NULL,2,1,0,0,0,1,0,4,1),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0),(4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0),(5,'Preparación',6,1,'ON_PREPARATION',7,5,0,0,0,2,0,0,2,0),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0),(11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0),(20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0,0,0,0,0,4,1),(23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1),(25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0,0,1,0,0,2,0),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,0,0,0,1,1,1,3,0),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,0,0,1,1,0,1,3,0),(30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,3,0),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0),(33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0),(34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1),(35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0); +INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1),(2,'Libre',2,0,'FREE',NULL,2,1,0,0,0,1,0,4,1),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0),(4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0),(5,'Preparación',6,1,'ON_PREPARATION',7,5,0,0,0,2,0,0,2,0),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0),(11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0),(20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0,0,0,0,0,4,1),(23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1),(25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0,0,1,0,0,2,0),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,0,0,0,1,1,1,3,0),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,0,0,1,1,0,1,3,0),(30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,3,0),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0),(33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0),(34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1),(35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0),(36,'Control Previa',3,1,'PREVIOUS_CONTROL',1,36,0,1,0,1,0,1,3,0); /*!40000 ALTER TABLE `state` ENABLE KEYS */; UNLOCK TABLES; @@ -370,7 +370,7 @@ UNLOCK TABLES; LOCK TABLES `sample` WRITE; /*!40000 ALTER TABLE `sample` DISABLE KEYS */; -INSERT INTO `sample` VALUES (1,'Carta_1','Aviso inicial por saldo deudor',0,0,1),(2,'Carta_2','Reiteracion de aviso por saldo deudor',0,0,1),(3,'Cred_Up','Notificación de aumento de crédito',0,0,1),(4,'Cred_down','Notificación de reducción de crédito',0,0,1),(5,'Pet_CC','Petición de datos bancarios B2B',0,0,1),(6,'SolCredito','Solicitud de crédito',0,0,1),(7,'LeyPago','Ley de pagos',0,0,1),(8,'Pet_CC_Core','Petición de datos bancarios CORE',0,0,1),(9,'nueva_alta','Documento de nueva alta de cliente',0,0,1),(10,'client_welcome','Email de bienvenida para nuevo cliente',0,0,1),(11,'setup_printer','Email de instalación de impresora',0,0,1),(12,'client-welcome','Bienvenida como nuevo cliente',1,0,1),(13,'printer-setup','Instalación y configuración de impresora de coronas',1,0,1),(14,'sepa-core','Solicitud de domiciliación bancaria',1,1,0),(15,'letter-debtor-st','Aviso inicial por saldo deudor',1,1,1),(16,'letter-debtor-nd','Aviso reiterado por saldo deudor',1,1,1),(17,'client-lcr','Email de solicitud de datos bancarios LCR',0,1,1); +INSERT INTO `sample` VALUES (1,'Carta_1','Aviso inicial por saldo deudor',0,0,1,0),(2,'Carta_2','Reiteracion de aviso por saldo deudor',0,0,1,0),(3,'Cred_Up','Notificación de aumento de crédito',0,0,1,0),(4,'Cred_down','Notificación de reducción de crédito',0,0,1,0),(5,'Pet_CC','Petición de datos bancarios B2B',0,0,1,0),(6,'SolCredito','Solicitud de crédito',0,0,1,0),(7,'LeyPago','Ley de pagos',0,0,1,0),(8,'Pet_CC_Core','Petición de datos bancarios CORE',0,0,1,0),(9,'nueva_alta','Documento de nueva alta de cliente',0,0,1,0),(10,'client_welcome','Email de bienvenida para nuevo cliente',0,0,1,0),(11,'setup_printer','Email de instalación de impresora',0,0,1,0),(12,'client-welcome','Bienvenida como nuevo cliente',1,0,1,0),(13,'printer-setup','Instalación y configuración de impresora de coronas',1,0,1,0),(14,'sepa-core','Solicitud de domiciliación bancaria',1,1,0,0),(15,'letter-debtor-st','Aviso inicial por saldo deudor',1,1,1,0),(16,'letter-debtor-nd','Aviso reiterado por saldo deudor',1,1,1,0),(17,'client-lcr','Email de solicitud de datos bancarios LCR',0,1,1,0),(18,'client-debt-statement','Extracto del cliente',1,0,1,1),(19,'credit-request','Solicitud de crédito',1,1,1,0); /*!40000 ALTER TABLE `sample` ENABLE KEYS */; UNLOCK TABLES; @@ -380,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,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,0,NULL,0),(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),(126,NULL,'TALLER PRESERVADO',123,124,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL,0); +INSERT INTO `department` VALUES (1,NULL,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(22,NULL,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(23,NULL,'CAMARA',14,19,NULL,72,604,2,6,1,0,1,2,37,'/37/',NULL,0,NULL,0,1),(31,'IT','INFORMATICA',5,6,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica-cau',1,NULL,1,0),(34,NULL,'CONTABILIDAD',7,8,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(35,NULL,'FINANZAS',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(36,NULL,'LABORAL',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(37,NULL,'PRODUCCION',13,52,NULL,72,230,3,11,1,0,0,17,NULL,'/',NULL,0,NULL,0,1),(38,NULL,'SACADO',20,21,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(39,NULL,'ENCAJADO',22,23,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(41,NULL,'ADMINISTRACION',53,54,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(43,NULL,'VENTAS',55,78,NULL,0,NULL,NULL,NULL,0,0,0,11,NULL,'/',NULL,1,'direccioncomercial@verdnatura.es',1,0),(44,NULL,'GERENCIA',79,80,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(45,NULL,'LOGISTICA',81,82,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(46,NULL,'REPARTO',83,86,NULL,72,659,3,10,0,0,0,1,NULL,'/',NULL,0,NULL,0,0),(48,NULL,'ALMACENAJE',87,88,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL,0,NULL,0,0),(49,NULL,'PROPIEDAD',89,90,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(52,NULL,'CARGA AEREA',91,92,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(53,NULL,'MARKETING Y COMUNICACIÓN',93,94,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(54,NULL,'ORNAMENTALES',95,96,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(55,NULL,'TALLER NATURAL',97,98,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL,0,NULL,0,1),(56,NULL,'TALLER ARTIFICIAL',99,100,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL,0,NULL,0,1),(58,NULL,'CAMPOS',101,102,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL,0,NULL,1,0),(59,NULL,'MANTENIMIENTO',103,104,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(60,NULL,'RECLAMACIONES',105,106,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(61,NULL,'VNH',107,108,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(63,NULL,'VENTAS FRANCIA',56,57,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL,0,NULL,0,0),(66,NULL,'VERDNAMADRID',109,110,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(68,NULL,'COMPLEMENTOS',24,25,NULL,72,617,3,26,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(69,NULL,'VERDNABARNA',111,112,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(77,NULL,'PALETIZADO',84,85,NULL,72,230,4,15,1,0,1,0,46,'/46/',NULL,0,NULL,0,0),(80,NULL,'EQUIPO J VALLES',58,59,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo',1,NULL,1,0),(86,NULL,'LIMPIEZA',113,114,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(89,NULL,'COORDINACION',115,116,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL,0,NULL,0,0),(90,NULL,'TRAILER',117,118,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(91,NULL,'ARTIFICIAL',26,27,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(92,NULL,'EQUIPO SILVERIO',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo',1,NULL,1,0),(93,NULL,'CONFECCION',119,120,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(94,NULL,'EQUIPO J BROCAL',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo',1,NULL,1,0),(95,NULL,'EQUIPO C ZAMBRANO',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo',1,NULL,1,0),(96,NULL,'EQUIPO C LOPEZ',66,67,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo',1,NULL,1,0),(98,NULL,'EQUIPO RODRIGO',68,69,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo',1,NULL,1,0),(101,NULL,'EQUIPO J IBAÑEZ',70,71,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo',1,NULL,1,0),(102,NULL,'EQ ROJO FV RUBEN C',28,29,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,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,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,0),(105,NULL,'EQ MORADO FV MATOU',34,35,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,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,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,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,0),(111,NULL,'EQ REPONEDOR CAJAS',42,43,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,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,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,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,0),(115,NULL,'EQUIPO CLAUDI',72,73,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','csr_equipo',1,NULL,1,0),(120,NULL,'PCA PRODUCCION',46,47,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(121,NULL,'FV PRODUCCION',48,49,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(122,NULL,'PCA ALMACEN',50,51,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,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,0),(124,NULL,'CONTROL INTERNO',121,122,NULL,72,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(125,NULL,'EQUIPO MIRIAM MAR',76,77,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','mir_equipo',0,NULL,0,0),(126,NULL,'PRESERVADO',123,124,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL,0,0); /*!40000 ALTER TABLE `department` ENABLE KEYS */; UNLOCK TABLES; @@ -432,7 +432,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:42:30 +-- Dump completed on 2021-10-20 8:38:27 USE `cache`; -- MariaDB dump 10.19 Distrib 10.6.4-MariaDB, for Linux (x86_64) -- @@ -456,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'),(14,'lastBuy','00:30:00'); +INSERT INTO `cache` VALUES (1,'equalizator','00:19:00'),(2,'available','00:06:00'),(3,'stock','00:30:00'),(4,'last_buy','23:59: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','23:59:00'); /*!40000 ALTER TABLE `cache` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -468,7 +468,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:42:31 +-- Dump completed on 2021-10-20 8:38:28 USE `hedera`; -- MariaDB dump 10.19 Distrib 10.6.4-MariaDB, for Linux (x86_64) -- @@ -534,7 +534,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:42:31 +-- Dump completed on 2021-10-20 8:38:29 USE `postgresql`; -- MariaDB dump 10.19 Distrib 10.6.4-MariaDB, for Linux (x86_64) -- @@ -608,7 +608,7 @@ UNLOCK TABLES; LOCK TABLES `workcenter` WRITE; /*!40000 ALTER TABLE `workcenter` DISABLE KEYS */; -INSERT INTO `workcenter` VALUES (1,'Silla',20,NULL,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,1266,60,'Fenollars, 2',523549),(10,NULL,NULL,NULL,NULL,NULL,NULL); +INSERT INTO `workcenter` VALUES (1,'Silla',20,NULL,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,2867,5,'Av constitución 3',554145),(6,'Vilassar',88,88038,2,'Cami del Crist, 33',556412),(7,'Tenerife',NULL,NULL,10,NULL,NULL),(8,NULL,NULL,NULL,NULL,NULL,NULL),(9,'Algemesi',20,1348,60,'Fenollars, 2',523549),(10,NULL,NULL,NULL,NULL,NULL,NULL); /*!40000 ALTER TABLE `workcenter` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -620,7 +620,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:42:32 +-- Dump completed on 2021-10-20 8:38:30 USE `sage`; -- MariaDB dump 10.19 Distrib 10.6.4-MariaDB, for Linux (x86_64) -- @@ -676,4 +676,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:42:32 +-- Dump completed on 2021-10-20 8:38:31 diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index a52e24736..f06916fd3 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1766,16 +1766,16 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`) INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`) VALUES (1, 1, 69), - (5, 1, 442), + (5, 1, 442), (9, 1, 442), (18, 3, 567); - -INSERT INTO `vn`.`receipt`(`id`, `invoiceFk`, `amountPaid`, `amountUnpaid`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate`) + +INSERT INTO `vn`.`receipt`(`id`, `invoiceFk`, `amountPaid`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate`) VALUES - (1, 'Cobro web', 100.50, 0.00, CURDATE(), 9, 1, 1101, CURDATE(), 442, 1), - (2, 'Cobro web', 200.50, 0.00, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 9, 1, 1101, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 442, 1), - (3, 'Cobro en efectivo', 300.00, 100.00, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 9, 1, 1102, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 442, 0), - (4, 'Cobro en efectivo', 400.00, -50.00, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 9, 1, 1103, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 442, 0); + (1, 'Cobro web', 100.50, CURDATE(), 9, 1, 1101, CURDATE(), 442, 1), + (2, 'Cobro web', 200.50, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 9, 1, 1101, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 442, 1), + (3, 'Cobro en efectivo', 300.00, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 9, 1, 1102, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 442, 0), + (4, 'Cobro en efectivo', 400.00, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 9, 1, 1103, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 442, 0); INSERT INTO `vn`.`workerTeam`(`id`, `team`, `workerFk`) VALUES diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 1565e029f..734a926d1 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -198,6 +198,22 @@ CREATE TABLE `mailAliasAccount` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Mail alias that is assigned to each account'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `mailClientAccess` +-- + +DROP TABLE IF EXISTS `mailClientAccess`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `mailClientAccess` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `client` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `action` set('OK','REJECT') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'REJECT', + PRIMARY KEY (`id`), + UNIQUE KEY `mailFrom` (`client`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `mailConfig` -- @@ -227,6 +243,22 @@ CREATE TABLE `mailForward` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Mail forwarding'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `mailSenderAccess` +-- + +DROP TABLE IF EXISTS `mailSenderAccess`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `mailSenderAccess` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `sender` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `action` set('OK','REJECT') NOT NULL DEFAULT 'REJECT', + PRIMARY KEY (`id`), + UNIQUE KEY `mailFrom` (`sender`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `myRole` -- @@ -501,7 +533,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 user_afterUpdate AFTER UPDATE @@ -521,12 +553,14 @@ BEGIN IF !(NEW.`role` <=> OLD.`role`) THEN - INSERT INTO vn.mail SET - `sender` = 'jgallego@verdnatura.es', - `replyTo` = 'jgallego@verdnatura.es', - `subject` = 'Rol modificado', - `body` = CONCAT(myUserGetName(), ' ha modificado el rol del usuario ', - NEW.`name`, ' de ', OLD.role, ' a ', NEW.role); + CALL vn.mail_insert('jgallego@verdnatura.es', + 'jgallego@verdnatura.es', + 'Rol modificado', + CONCAT( + myUserGetName(), + ' ha modificado el rol del usuario ', + NEW.`name`, ' de ', OLD.role, ' a ', NEW.role) + ); END IF; END */;; DELIMITER ; @@ -2735,14 +2769,14 @@ CREATE TABLE `indicators` ( `lastMonthLostClients` int(11) DEFAULT NULL, `lastMonthNewClients` int(11) DEFAULT NULL, `lastMonthWebBuyingRate` decimal(5,4) DEFAULT NULL, - `productionHours` decimal(10,1) DEFAULT NULL, - `dailyWorkersCost` decimal(10,0) DEFAULT NULL, - `volumeM3` decimal(10,0) DEFAULT NULL, - `salesValue` decimal(10,0) DEFAULT NULL, - `valueM3` decimal(10,0) DEFAULT NULL, - `hoursM3` decimal(5,2) DEFAULT NULL, - `workerCostM3` decimal(10,1) DEFAULT NULL, - `salesWorkersCostRate` decimal(10,2) DEFAULT NULL, + `productionHours__` decimal(10,1) DEFAULT NULL, + `dailyWorkersCost__` decimal(10,0) DEFAULT NULL, + `volumeM3__` decimal(10,0) DEFAULT NULL, + `salesValue__` decimal(10,0) DEFAULT NULL, + `valueM3__` decimal(10,0) DEFAULT NULL, + `hoursM3__` decimal(5,2) DEFAULT NULL, + `workerCostM3__` decimal(10,1) DEFAULT NULL, + `salesWorkersCostRate__` decimal(10,2) DEFAULT NULL, `thisWeekSales` decimal(10,2) DEFAULT NULL, `lastYearWeekSales` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`updated`) @@ -2801,14 +2835,14 @@ SET character_set_client = utf8; `incLastMonthNewClients` tinyint NOT NULL, `lastMonthWebBuyingRate` tinyint NOT NULL, `incLastMonthWebBuyingRate` tinyint NOT NULL, - `productionHours` tinyint NOT NULL, - `dailyWorkersCost` tinyint NOT NULL, - `volumeM3` tinyint NOT NULL, - `salesValue` tinyint NOT NULL, - `valueM3` tinyint NOT NULL, - `hoursM3` tinyint NOT NULL, - `workerCostM3` tinyint NOT NULL, - `salesWorkersCostRate` tinyint NOT NULL, + `productionHours__` tinyint NOT NULL, + `dailyWorkersCost__` tinyint NOT NULL, + `volumeM3__` tinyint NOT NULL, + `salesValue__` tinyint NOT NULL, + `valueM3__` tinyint NOT NULL, + `hoursM3__` tinyint NOT NULL, + `workerCostM3__` tinyint NOT NULL, + `salesWorkersCostRate__` tinyint NOT NULL, `thisWeekSales` tinyint NOT NULL, `lastYearWeekSales` tinyint NOT NULL ) ENGINE=MyISAM */; @@ -2838,14 +2872,14 @@ CREATE TABLE `m3` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `m3Silla` +-- Temporary table structure for view `m3Silla__` -- -DROP TABLE IF EXISTS `m3Silla`; -/*!50001 DROP VIEW IF EXISTS `m3Silla`*/; +DROP TABLE IF EXISTS `m3Silla__`; +/*!50001 DROP VIEW IF EXISTS `m3Silla__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE TABLE `m3Silla` ( +/*!50001 CREATE TABLE `m3Silla__` ( `fecha` tinyint NOT NULL, `year` tinyint NOT NULL, `month` tinyint NOT NULL, @@ -2857,34 +2891,6 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `m3analisis` --- - -DROP TABLE IF EXISTS `m3analisis`; -/*!50001 DROP VIEW IF EXISTS `m3analisis`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `m3analisis` ( - `fecha` tinyint NOT NULL, - `year` tinyint NOT NULL, - `month` tinyint NOT NULL, - `week` tinyint NOT NULL, - `day` tinyint NOT NULL, - `dayName` tinyint NOT NULL, - `Volumen` tinyint NOT NULL, - `Euros` tinyint NOT NULL, - `Departamento` tinyint NOT NULL, - `Horas` tinyint NOT NULL, - `Salarios` tinyint NOT NULL, - `tiempoM3` tinyint NOT NULL, - `valorM3` tinyint NOT NULL, - `costeLaboralM3` tinyint NOT NULL, - `costeEuros` tinyint NOT NULL, - `precioHora` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `manaCustomer` -- @@ -2962,28 +2968,6 @@ CREATE TABLE `mermasCache__` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Temporary table structure for view `mermas__` --- - -DROP TABLE IF EXISTS `mermas__`; -/*!50001 DROP VIEW IF EXISTS `mermas__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `mermas__` ( - `Comprador` tinyint NOT NULL, - `Familia` tinyint NOT NULL, - `Referencia` tinyint NOT NULL, - `Item` tinyint NOT NULL, - `Cantidad` tinyint NOT NULL, - `Coste_Unitario` tinyint NOT NULL, - `Importe` tinyint NOT NULL, - `Cliente` tinyint NOT NULL, - `ticketFk` tinyint NOT NULL, - `Fecha` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `nightTask` -- @@ -3139,6 +3123,47 @@ CREATE TABLE `produccion` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `s1_ticketDetail` +-- + +DROP TABLE IF EXISTS `s1_ticketDetail`; +/*!50001 DROP VIEW IF EXISTS `s1_ticketDetail`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `s1_ticketDetail` ( + `ticketFk` tinyint NOT NULL, + `ticketAmount` tinyint NOT NULL, + `ticketLines` tinyint NOT NULL, + `ticketM3` tinyint NOT NULL, + `shipped` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `s21_saleDetail` +-- + +DROP TABLE IF EXISTS `s21_saleDetail`; +/*!50001 DROP VIEW IF EXISTS `s21_saleDetail`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `s21_saleDetail` ( + `dia` tinyint NOT NULL, + `año` tinyint NOT NULL, + `mes` tinyint NOT NULL, + `concepto` tinyint NOT NULL, + `unidades` tinyint NOT NULL, + `precio` tinyint NOT NULL, + `venta` tinyint NOT NULL, + `familia` tinyint NOT NULL, + `comprador` tinyint NOT NULL, + `itemFk` tinyint NOT NULL, + `ticketFk` tinyint NOT NULL, + `volume` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `salaries2018` -- @@ -3425,6 +3450,25 @@ CREATE TABLE `waste` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `workerLabourDataByMonth` +-- + +DROP TABLE IF EXISTS `workerLabourDataByMonth`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workerLabourDataByMonth` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `code` varchar(25) COLLATE utf8_unicode_ci NOT NULL, + `month` int(2) NOT NULL, + `year` int(4) NOT NULL, + `total` int(5) NOT NULL COMMENT 'Número de empleados', + `permanent` int(5) NOT NULL COMMENT 'Número de empleados fijos', + PRIMARY KEY (`id`), + KEY `workerLabourDataByMonth_graph_idx` (`code`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `workerMana` -- @@ -3498,13 +3542,13 @@ CREATE TABLE `workerSpeed__` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `zone_ETD` +-- Table structure for table `zone_ETD__` -- -DROP TABLE IF EXISTS `zone_ETD`; +DROP TABLE IF EXISTS `zone_ETD__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `zone_ETD` ( +CREATE TABLE `zone_ETD__` ( `zoneFk` int(11) DEFAULT NULL, `totalVolume` decimal(5,1) DEFAULT NULL, `remainingVolume` decimal(5,1) DEFAULT NULL, @@ -3987,6 +4031,38 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `bs` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; +/*!50003 DROP PROCEDURE IF EXISTS `carteras_add2` */; +/*!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 `carteras_add2`() +BEGIN +/** + * Inserta en "bs.carteras". + */ + DELETE FROM bs.carteras + WHERE Año >= YEAR(CURDATE()) - 1; + + INSERT INTO bs.carteras(Año,Mes,CodigoTrabajador,Peso) + SELECT t.year AS Año, t.month AS Mes, w.code AS CodigoTrabajador, SUM(v.importe) AS Peso + FROM vn.time t + JOIN bs.ventas v on t.dated = v.fecha + JOIN vn.client c on c.id = v.Id_Cliente + JOIN vn.worker w ON w.id = c.salesPersonFk + WHERE t.year >= YEAR(CURDATE()) - 1 + GROUP BY w.code, t.year , t.month; +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 `clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4449,6 +4525,40 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `bs` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; +/*!50003 DROP PROCEDURE IF EXISTS `compradores_add2` */; +/*!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 `compradores_add2`(IN vYear INT, IN vWeekFrom INT, IN vWeekTo INT) +BEGIN +/** + * Sustituye los registros de "bs.compradores". + * + * @param vYear: año ventas + * @param vWeekFrom: semana desde + * @param vWeekTo: semana hastas + */ + REPLACE bs.compradores + SELECT it.workerFk AS Id_Trabajador, vYear AS año, tm.week AS semana, SUM(importe) AS importe, 0 AS comision + FROM bs.ventas v + JOIN vn.time tm ON tm.dated = v.fecha + JOIN vn.itemType it ON it.id = v.tipo_id + WHERE tm.year = vYear + AND tm.week BETWEEN vWeekFrom AND vWeekTo + AND it.categoryFk != 6 + GROUP BY it.workerFk, tm.week; +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 `compradores_add_launcher` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4679,6 +4789,84 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `bs` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; +/*!50003 DROP PROCEDURE IF EXISTS `fondo_evolution_add2` */; +/*!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 `fondo_evolution_add2`() +BEGIN +/** + * Inserta en la tabla fondo_maniobra los saldos acumulados en los ultimos 365 dias + */ + DECLARE datFEC DATE DEFAULT '2015-01-01'; + + SELECT TIMESTAMPADD(DAY,1,MAX(fecha)) + INTO datFEC + FROM bs.fondo_maniobra; + + WHILE datFEC < CURDATE() DO + + IF DAY(datFEC) MOD 28 = 0 THEN -- esto solo sirve para no aburrirse mientras esperamos... + SELECT datFEC; + END IF; + + REPLACE bs.fondo_maniobra(Fecha, clientes_facturas, clientes_cobros,proveedores_facturas,proveedores_pagos, fondo) + SELECT datFEC AS Fecha, Facturas, Cobros,Recibidas,Pagos, Facturas + Cobros + Recibidas + Pagos + FROM ( + SELECT SUM(io.amount) AS Facturas + FROM vn.invoiceOut io + JOIN vn.client c ON io.clientFk = c.id + WHERE c.isRelevant + AND io.companyFk <> 1381 + AND io.issued BETWEEN '2011-01-01' AND datFEC + ) fac + JOIN ( + SELECT - SUM(r.amountPaid) AS Cobros + FROM vn.receipt r + JOIN vn.client c ON r.clientFk = c.id + WHERE c.isRelevant + AND r.companyFk <> 1381 + AND r.payed BETWEEN '2011-01-01' AND datFEC + ) cob + JOIN ( + SELECT - SUM(id.amount) AS Recibidas + FROM vn.invoiceIn ii + JOIN vn.invoiceInDueDay id ON ii.id = id.invoiceInFk + WHERE ii.companyFk <> 1381 + AND ii.issued BETWEEN '2015-01-01' AND datFEC + ) rec + JOIN ( + SELECT SUM(p.amount) AS Pagos + FROM vn.payment p + WHERE p.companyFk <>1381 + AND p.received BETWEEN '2015-01-01' AND datFEC + ) pag; + + UPDATE bs.fondo_maniobra + JOIN ( + SELECT AVG(fondo) AS media + FROM bs.fondo_maniobra + WHERE fecha <= datFEC + ) sub + SET fondo_medio = media WHERE fecha = datFEC; + + SET datFEC = TIMESTAMPADD(DAY,1,datFEC); + + 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 `fruitsEvolution` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4713,9 +4901,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 ;; @@ -4752,8 +4940,7 @@ BEGIN WHERE shipped <= vDated ) WHERE updated = vDated; - - + -- Tasa de morosidad con respecto a las ventas del último mes UPDATE indicators SET latePaymentRate = @@ -4847,7 +5034,8 @@ BEGIN WHERE date_send BETWEEN oneMonthBefore AND vDated ) WHERE updated = vDated; - + + /* -- Indicadores de producción UPDATE indicators i JOIN productionIndicators pi ON pi.dated = i.updated @@ -4860,7 +5048,8 @@ BEGIN i.workerCostM3 = pi.workerCostM3, i.salesWorkersCostRate = pi.salesWorkersCostRate WHERE updated BETWEEN oneMonthBefore AND vDated; - + */ + -- CAP Para el calculo de las ventas agrupado por semanas SELECT week @@ -5386,7 +5575,6 @@ BEGIN DECLARE myDepLft INT; DECLARE myDepRgt INT; - -- Trabajadores CALL vn.dayMinuteWorker(vDateStart,vDateEnd); -- Genera la tabla tmp.dayMinuteWorker CALL vn.workerDepartmentByDate(vDate); @@ -5396,17 +5584,16 @@ BEGIN SELECT vDate,sum(wdd.costeHora) / 60 as Bruto FROM tmp.dayMinuteWorker dmw JOIN tmp.workerDepartmentByDate wdd ON wdd.userFk = dmw.userFk - WHERE Almacen IN (1,44) + WHERE warehouseName = 'Algemesi' AND wdd.isProduction; - + UPDATE bs.produccion p JOIN (SELECT sum(volume) as m3 FROM vn.saleVolume sv JOIN vn.ticket t ON sv.ticketFk = t.id JOIN vn.warehouse w ON w.id = t.warehouseFk - JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk WHERE t.shipped BETWEEN vDateStart AND vDateEnd - AND wa.name = 'Silla' + AND w.name = 'Algemesi' ) sub SET p.m3 = sub.m3, p.eurosM3 = p.cost / sub.m3 @@ -5415,7 +5602,6 @@ BEGIN DROP TEMPORARY TABLE tmp.dayMinuteWorker; DROP TEMPORARY TABLE tmp.workerDepartmentByDate; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -5693,9 +5879,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 = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!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 ;; @@ -5833,16 +6019,6 @@ BEGIN GROUP BY scd.substituteFk, c.id, t.`month` ON DUPLICATE KEY UPDATE substitutionBorrowed = VALUES(substitutionBorrowed); - 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; - - DROP TEMPORARY TABLE tmp.workerItemType; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6702,6 +6878,129 @@ 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 `workerLabour_getData` */; +/*!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 `workerLabour_getData`() +BEGIN +/** + * Carga los datos de la plantilla de trabajadores, altas y bajas en la tabla workerLabourDataByMonth para facilitar el cálculo del gráfico en grafana. + * Se carga el día 21 de cada mes, elimina los registros del último año y los vuelve a calcular + * + */ + DECLARE vFristDay DATE; + DECLARE vLastDay DATE; + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vDateStarted DATE; + DECLARE vDateEnded DATE; + + DECLARE vCursor CURSOR FOR + SELECT util.firstDayOfMonth(t.dated), LAST_DAY(t.dated) + FROM vn.time t + WHERE t.dated BETWEEN vDateStarted AND vDateEnded + GROUP BY year,month; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + IF DAY(CURDATE()) = 21 THEN + + SELECT util.firstDayOfMonth(DATE_SUB(CURDATE(), INTERVAL 12 MONTH)), + LAST_DAY(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) + INTO vDateStarted, + vDateEnded; + + DELETE FROM workerLabourDataByMonth + WHERE CONCAT(`year`, '-',`month`, '-01') BETWEEN vDateStarted AND vDateEnded; + + OPEN vCursor; + + l: LOOP + SET vDone = FALSE; + + FETCH vCursor INTO vFristDay, vLastDay; + + IF vDone THEN + LEAVE l; + END IF; + + -- Altas periodo + INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) + SELECT 'hiring', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(pc.isPermanent) + FROM vn.workerLabour w + JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk + JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk + JOIN postgresql.person p ON p.id_trabajador = w.workerFk + LEFT JOIN vn2008.payroll_contratos pc ON pc.CodContrato = bl.cod_contrato + LEFT JOIN (SELECT w.workerFk + FROM vn.workerLabour w + LEFT JOIN (SELECT ended, workerFk FROM vn.workerLabour) wl ON wl.ended = DATE_SUB(w.started, INTERVAL 1 DAY) + AND wl.workerFk = w.workerFk + WHERE w.started BETWEEN vFristDay AND vLastDay AND wl.ended + )sub ON sub.workerFk = w.workerFk + WHERE wc.center_id IS NOT NULL + AND w.started BETWEEN vFristDay AND vLastDay + AND sub.workerFk IS NULL + AND NOT p.isFreelance; + + -- Bajas periodo + INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) + SELECT 'layoffs', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(pc.isPermanent) + FROM vn.workerLabour w + JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk + JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk + JOIN postgresql.person p ON p.id_trabajador = w.workerFk + LEFT JOIN vn2008.payroll_contratos pc ON pc.CodContrato = bl.cod_contrato + LEFT JOIN (SELECT started, workerFk FROM vn.workerLabour) wl ON wl.started >= w.ended + AND wl.workerFk = w.workerFk + WHERE wc.center_id IS NOT NULL + AND w.ended BETWEEN vFristDay AND vLastDay + AND wl.started IS NULL + AND NOT p.isFreelance; + + -- Anterior al periodo + SET vLastDay = LAST_DAY(DATE_SUB(vFristDay, INTERVAL 1 DAY)); + + INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) + SELECT 'staff', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(pc.isPermanent) + FROM vn.workerLabour w + JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk + JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk + JOIN postgresql.person p ON p.id_trabajador = w.workerFk + LEFT JOIN vn2008.payroll_contratos pc ON pc.CodContrato = bl.cod_contrato + WHERE wc.center_id IS NOT NULL + AND vLastDay BETWEEN started AND IFNULL(ended, vLastDay) + AND NOT p.isFreelance; + + -- Discapacidad + INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) + SELECT 'disabled', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(pc.isPermanent) + FROM vn.workerLabour w + JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk + JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk + JOIN postgresql.person p ON p.id_trabajador = w.workerFk + LEFT JOIN vn2008.payroll_contratos pc ON pc.CodContrato = bl.cod_contrato + WHERE wc.center_id IS NOT NULL + AND vLastDay BETWEEN started AND IFNULL(ended, vLastDay) + AND p.isDisable + AND NOT p.isFreelance; + + END LOOP; + CLOSE vCursor; + + 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 `workerProductivity_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6780,7 +7079,39 @@ BEGIN GROUP BY s.ticketFk, t.warehouseFk )sub2 JOIN account.role r ON r.name='packager' - GROUP BY sub2.warehouseFk,sub2.workerFk, sub2.shipped; + GROUP BY sub2.warehouseFk,sub2.workerFk, sub2.shipped; + + -- REVISADORES + INSERT INTO workerProductivity(dated, wareHouseFk, workerFk, volume, seconds, roleFk) + SELECT sub2.shipped, + sub2.warehouseFk, + sub2.workerFK, + SUM(sub2.volume), + SUM(sub2.seconds), + r.id + FROM (SELECT t.warehouseFk, + SUM(s.volume) volume, + sub.workerFk, + DATE(t.shipped) shipped, + sub.seconds + w.minSeconsPackager seconds + FROM vn.saleVolume s + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN(SELECT st.workerFk, t.id ticketFk,TIME_TO_SEC(TIMEDIFF( MAX(st.created), MIN(st.created))) seconds + FROM vn.state ss + JOIN vn.saleTracking st ON st.stateFk = ss.id + JOIN vn.worker w ON st.workerFk = w.id + JOIN vn.sale s ON s.id = st.saleFk + JOIN vn.ticket t ON s.ticketFk = t.id + WHERE ss.code = 'CHECKED' AND + t.shipped >= vDateFrom + GROUP BY t.id + )sub ON sub.ticketFk = t.id + JOIN workerProductivityConfig w ON TRUE + WHERE t.shipped >= vDateFrom + GROUP BY s.ticketFk, t.warehouseFk + )sub2 + JOIN account.role r ON r.name='checker' + GROUP BY sub2.warehouseFk,sub2.workerFk, sub2.shipped; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6982,24 +7313,6 @@ CREATE TABLE `last_buy` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `last_buy__` --- - -DROP TABLE IF EXISTS `last_buy__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `last_buy__` ( - `item_id` int(10) unsigned NOT NULL, - `warehouse_id` smallint(5) unsigned NOT NULL, - `buy_id` int(10) unsigned DEFAULT NULL, - `landing` date DEFAULT NULL, - UNIQUE KEY `item_id` (`item_id`,`warehouse_id`) USING HASH, - KEY `buy_id` (`buy_id`), - KEY `warehouse_id` (`warehouse_id`) USING BTREE -) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `prod_graphic_source` -- @@ -8371,6 +8684,8 @@ CREATE TABLE `VMPSettings` ( `firstSupplyResponseId` int(11) DEFAULT NULL, `ApiId` int(11) DEFAULT NULL, `ApiKey` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `isBlocked` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'product source not allowed', + `isVNHSupplier` tinyint(1) DEFAULT '0' COMMENT 'The account belongs to VNH', PRIMARY KEY (`VMPID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -8425,7 +8740,9 @@ DROP TABLE IF EXISTS `clientFHAdminNumber`; CREATE TABLE `clientFHAdminNumber` ( `fhAdminNumber` int(11) NOT NULL, `clientFk` int(11) NOT NULL, - PRIMARY KEY (`clientFk`) + PRIMARY KEY (`clientFk`), + KEY `clientFHAdminNumber_fk_idx` (`fhAdminNumber`), + CONSTRAINT `clientFHAdminNumber_fk` FOREIGN KEY (`fhAdminNumber`) REFERENCES `vn`.`company` (`fhAdminNumber`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -9650,11 +9967,11 @@ 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' */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ekt_load`(IN `vSelf` INT) BEGIN @@ -9671,7 +9988,8 @@ BEGIN -- Carga los datos necesarios del EKT - SELECT ref, qty, package, putOrderFk, i2.id INTO vRef, vQty, vPackage, vPutOrderFk, vItem + SELECT ref, qty, package, putOrderFk, i2.id + INTO vRef, vQty, vPackage, vPutOrderFk, vItem FROM ekt e LEFT JOIN item i ON e.ref = i.id LEFT JOIN edi.putOrder po ON po.id = e.putOrderFk @@ -9988,9 +10306,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 = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!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 ;; @@ -10047,6 +10365,21 @@ BEGIN -- Generates the barcode IF vAgj != 0 AND vAgj IS NOT NULL + THEN + SET vBarcode = CONCAT( + LPAD(vAuction, 2, 0), + LPAD(IFNULL(vClock, 99), 2, 0), + LPAD(DAYOFYEAR(vDate), 3, 0), + IF(vClock IS NULL OR vClock = 99, + LPAD(vAgj, 8, 0), + CONCAT(LPAD(vAgj, 5, 0), '010') + ) + ); + END IF; + + -- Generates the barcode + + /*IF vAgj != 0 AND vAgj IS NOT NULL THEN SET vBarcode = CONCAT( LPAD(vAuction, 2, 0), @@ -10058,7 +10391,7 @@ BEGIN ), '0' ); - END IF; + END IF;*/ -- Rewrites the kop parameter @@ -10074,7 +10407,8 @@ BEGIN SET vKop = IFNULL(vRewriteKop, vKop); -- Inserts the new transaction - + call util.debugAdd('vBarcode',vBarcode); + call util.debugAdd('vDeliveryNumber',vDeliveryNumber); SET vIsDuplicated = FALSE; INSERT INTO ekt SET barcode = IFNULL(vBarcode, barcode) @@ -10170,7 +10504,7 @@ BEGIN END IF; -- Registers the exchange - + INSERT INTO `exchange` SET mailFk = vMailFk ,typeFk = vType @@ -10221,6 +10555,14 @@ proc: BEGIN SET vStartingTime = NOW(); + IF NOW() < '2021-10-14 12:00' THEN + + LEAVE proc; + + END IF; + + CALL util.debugAdd('edi.floramondo_offerRefresh',CONCAT('MaxItemId:' ,(SELECT MAX(id) FROM vn.item))); + -- CALL vn.clean_logiflora(); -- Refresca las fotos de los items existentes, con prioridad baja (0.7 seg) @@ -10256,7 +10598,10 @@ proc: BEGIN -- select now(),'Antes de crear edi.offer'; DROP TEMPORARY TABLE IF EXISTS edi.offer; - CREATE TEMPORARY TABLE edi.offer (INDEX (`srID`), INDEX (`EmbalageCode`)) ENGINE = MEMORY + CREATE TEMPORARY TABLE edi.offer (INDEX (`srID`), INDEX (`EmbalageCode`), + INDEX (`ef1`), INDEX (`ef2`), INDEX (`ef3`), INDEX (`ef4`),INDEX (`ef5`), INDEX (`ef6`), + INDEX (`s1Value`), INDEX (`s2Value`), INDEX (`s3Value`), INDEX (`s4Value`),INDEX (`s5Value`), INDEX (`s6Value`)) + ENGINE = MEMORY SELECT so.*, ev1.type_description s1Value, ev2.type_description s2Value, ev3.type_description s3Value, ev4.type_description s4Value, ev5.type_description s5Value, ev6.type_description s6Value, eif1.feature ef1, eif2.feature ef2, eif3.feature ef3, eif4.feature ef4, eif5.feature ef5, eif6.feature ef6 @@ -10283,7 +10628,22 @@ proc: BEGIN DROP TEMPORARY TABLE tmp; - + DELETE o + FROM edi.offer o + LEFT JOIN vn.tag t1 ON t1.ediTypeFk = o.ef1 AND t1.overwrite = 'size' + LEFT JOIN vn.tag t2 ON t2.ediTypeFk = o.ef2 AND t2.overwrite = 'size' + LEFT JOIN vn.tag t3 ON t3.ediTypeFk = o.ef3 AND t3.overwrite = 'size' + LEFT JOIN vn.tag t4 ON t4.ediTypeFk = o.ef4 AND t4.overwrite = 'size' + LEFT JOIN vn.tag t5 ON t5.ediTypeFk = o.ef5 AND t5.overwrite = 'size' + LEFT JOIN vn.tag t6 ON t6.ediTypeFk = o.ef6 AND t6.overwrite = 'size' + JOIN vn.floramondoConfig fc ON TRUE + WHERE (t1.id IS NOT NULL AND CONVERT(s1Value, UNSIGNED) > fc.itemMaxSize) + OR(t2.id IS NOT NULL AND CONVERT(s2Value, UNSIGNED) > fc.itemMaxSize) + OR(t3.id IS NOT NULL AND CONVERT(s3Value, UNSIGNED) > fc.itemMaxSize) + OR(t4.id IS NOT NULL AND CONVERT(s4Value, UNSIGNED) > fc.itemMaxSize) + OR(t5.id IS NOT NULL AND CONVERT(s5Value, UNSIGNED) > fc.itemMaxSize) + OR(t6.id IS NOT NULL AND CONVERT(s6Value, UNSIGNED) > fc.itemMaxSize); + START TRANSACTION; -- Actualizamos el campo supplyResponseFk para aquellos articulos que ya estan creados y reutilizamos @@ -10499,8 +10859,7 @@ proc: BEGIN UPDATE vn.floramondoConfig SET nextLanded = vLanded WHERE vLanded IS NOT NULL; - - + -- Elimina la oferta obsoleta UPDATE vn.buy b JOIN vn.entry e ON e.id = b.entryFk @@ -11571,12 +11930,13 @@ ON `order` FOR EACH ROW BEGIN IF NEW.address_id = 2850 THEN -- Fallo que se insertan no se sabe como tickets en este cliente - INSERT INTO vn.mail SET - `sender` = 'jgallego@verdnatura.es', - `replyTo` = 'jgallego@verdnatura.es', - `subject` = 'Creada order al address 2850', - `body` = CONCAT(account.myUserGetName(), ' ha creado la order ', - NEW.id); + CALL vn.mail_insert( + 'jgallego@verdnatura.es', + 'noreply@verdnatura.es', + 'Creada order al address 2850', + CONCAT(account.myUserGetName(), ' ha creado la order ',NEW.id) + ); + END IF; END */;; DELIMITER ; @@ -14229,9 +14589,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 ;; @@ -14295,23 +14655,15 @@ BEGIN END; -- Carga los datos del pedido - SELECT o.date_send, o.address_id, o.note, - o.confirmed, a.clientFk, o.company_id, o.agency_id + a.clientFk, o.company_id, o.agency_id INTO vDelivery, vAddress, vNotes, - vIsConfirmed, vClientId, vCompanyId, vAgencyModeId + vClientId, vCompanyId, vAgencyModeId FROM hedera.`order` o JOIN vn.address a ON a.id = o.address_id WHERE o.id = vOrder; - -- Comprueba que el pedido no está confirmado - - IF vIsConfirmed THEN - CALL util.throw ('ORDER_ALREADY_CONFIRMED'); - END IF; - - -- Comprueba que el pedido no está vacío - + -- Comprueba que el pedido no est? vac?o SELECT COUNT(*) > 0 INTO vOk FROM order_row WHERE order_id = vOrder AND amount > 0; @@ -14319,12 +14671,10 @@ BEGIN CALL util.throw ('ORDER_EMPTY'); END IF; - -- Carga las fechas de salida de cada almacén - + -- Carga las fechas de salida de cada almac?n CALL vn.zone_getShipped (vDelivery, vAddress, vAgencyModeId, FALSE); - -- Trabajador que realiza la acción - + -- Trabajador que realiza la acci?n IF vUserId IS NULL THEN SELECT employeeFk INTO vUserId FROM orderConfig; END IF; @@ -14392,7 +14742,7 @@ BEGIN SET orderFk = vOrder, ticketFk = vTicket; - -- Añade las notas + -- A?ade las notas IF vNotes IS NOT NULL AND vNotes != '' THEN @@ -14404,7 +14754,7 @@ BEGIN `description` = CONCAT(VALUES(`description`),'. ', `description`); END IF; - -- Añade los movimientos y sus componentes + -- A?ade los movimientos y sus componentes OPEN cRows; @@ -14492,19 +14842,10 @@ BEGIN LIMIT 1; END IF; - - -- Actualiza la caché - CALL cache.available_refresh(vCalc,FALSE,vWarehouse,vShipment); - - UPDATE cache.available - SET available = GREATEST(0,available - vAmount) - WHERE item_id = vItem - AND calc_id = vCalc; - - END LOOP; - - CLOSE cRows; + END LOOP; + + CLOSE cRows; -- Fija el coste DROP TEMPORARY TABLE IF EXISTS tComponents; @@ -14529,6 +14870,18 @@ BEGIN CLOSE cDates; DELETE FROM basketOrder WHERE orderFk = vOrder; + + SELECT o.confirmed INTO vIsConfirmed + FROM hedera.`order` o + JOIN vn.address a ON a.id = o.address_id + WHERE o.id = vOrder; + + -- Comprueba que el pedido no est? confirmado + + IF vIsConfirmed THEN + CALL util.throw ('ORDER_ALREADY_CONFIRMED'); + END IF; + UPDATE `order` SET confirmed = TRUE, confirm_date = NOW() WHERE id = vOrder; @@ -17292,7 +17645,7 @@ CREATE TABLE `erte_COVID19` ( `personFk` int(11) NOT NULL, `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`personFk`), - CONSTRAINT `erte_COVID19_fk1` FOREIGN KEY (`personFk`) REFERENCES `person` (`person_id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `erte_COVID19_FK` FOREIGN KEY (`personFk`) REFERENCES `vn`.`person` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -17315,7 +17668,7 @@ CREATE TABLE `income_employee` ( KEY `fincometype_id` (`id_incomeType`), KEY `fperson_id` (`person_id`), CONSTRAINT `fincometype_id` FOREIGN KEY (`id_incomeType`) REFERENCES `incometype_employee` (`id_incometype`) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT `fperson_id` FOREIGN KEY (`person_id`) REFERENCES `person` (`person_id`) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT `income_employee_FK` FOREIGN KEY (`person_id`) REFERENCES `vn`.`person` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -17441,13 +17794,38 @@ CREATE TABLE `periodos` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `person` +-- Temporary table structure for view `person` -- DROP TABLE IF EXISTS `person`; +/*!50001 DROP VIEW IF EXISTS `person`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `person` ( + `person_id` tinyint NOT NULL, + `name` tinyint NOT NULL, + `nickname` tinyint NOT NULL, + `nif` tinyint NOT NULL, + `birth` tinyint NOT NULL, + `firstname` tinyint NOT NULL, + `p2` tinyint NOT NULL, + `nis` tinyint NOT NULL, + `id_trabajador` tinyint NOT NULL, + `isDisable` tinyint NOT NULL, + `isFreelance` tinyint NOT NULL, + `isSsDiscounted` tinyint NOT NULL, + `sex` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `person__` +-- + +DROP TABLE IF EXISTS `person__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `person` ( +CREATE TABLE `person__` ( `person_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(60) NOT NULL, `nickname` varchar(15) DEFAULT NULL, @@ -17520,7 +17898,7 @@ CREATE TABLE `profile` ( PRIMARY KEY (`profile_id`), KEY `profile_person_id_idx` (`person_id`), KEY `profile_profile_type_id_idx` (`profile_type_id`), - CONSTRAINT `person_fk` FOREIGN KEY (`person_id`) REFERENCES `person` (`person_id`) ON UPDATE CASCADE + CONSTRAINT `profile_FK` FOREIGN KEY (`person_id`) REFERENCES `vn`.`person` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -23277,6 +23655,27 @@ CREATE TABLE `versionUser` ( -- -- Dumping events for database 'util' -- +/*!50106 SET @save_time_zone= @@TIME_ZONE */ ; +/*!50106 DROP EVENT IF EXISTS `slowLog_prune` */; +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' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `slowLog_prune` ON SCHEDULE EVERY 1 DAY STARTS '2021-10-08 00:00:00' ON COMPLETION PRESERVE ENABLE DO CALL util.slowLog_prune */ ;; +/*!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 */ ;; +DELIMITER ; +/*!50106 SET TIME_ZONE= @save_time_zone */ ; -- -- Dumping routines for database 'util' @@ -23532,6 +23931,28 @@ 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 `isLeapYear` */; +/*!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 `isLeapYear`(vYear INT) RETURNS tinyint(1) + DETERMINISTIC +BEGIN + + RETURN (DAYOFYEAR(CONCAT(vYear, "-02-29")) IS NOT NULL); + +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 `lang` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -24072,77 +24493,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 `findObject__` */; -/*!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 `findObject__`(vChain VARCHAR(45)) - READS SQL DATA -BEGIN -/** - * Devuelve un listado de todos los procedimientos, funciones - * eventos, disparadores y vistas que inluyen una cadena dada. - * - * @param vChain Cadena a buscar - * @select Listado de objetos - */ - SET vChain = CONCAT('%', vChain, '%'); - - SELECT * FROM - ( - SELECT - `db`, - `name`, - `type`, - `body`, - `created`, - `modified` - FROM `mysql`.`proc` - WHERE `body` LIKE vChain COLLATE utf8_general_ci - UNION ALL - SELECT - `db`, - `name`, - 'EVENT', - `body_utf8`, - `created`, - `modified` - FROM `mysql`.`event` - WHERE `body_utf8` LIKE vChain COLLATE utf8_general_ci - UNION ALL - SELECT - `EVENT_OBJECT_SCHEMA`, - `TRIGGER_NAME`, - 'TRIGGER', - `ACTION_STATEMENT`, - NULL, - NULL - FROM `information_schema`.`TRIGGERS` - WHERE `ACTION_STATEMENT` LIKE vChain COLLATE utf8_general_ci - UNION ALL - SELECT - `TABLE_SCHEMA`, - `TABLE_NAME`, - 'VIEW', - `VIEW_DEFINITION`, - NULL, - NULL - FROM `information_schema`.`VIEWS` - WHERE `VIEW_DEFINITION` LIKE vChain COLLATE utf8_general_ci - ) t - ORDER BY `db`, `name`; -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 `procNoOverlap` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -24264,6 +24614,37 @@ 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 `slowLog_prune` */; +/*!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 @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `slowLog_prune`() +BEGIN +/** + * Prunes MySQL slow query log table deleting all records older than one week. + */ + DECLARE vSlowQueryLog INT DEFAULT @@slow_query_log; + + SET GLOBAL slow_query_log = 'OFF'; + RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`; + + DELETE FROM `mysql`.`slow_log_temp` + WHERE start_time < TIMESTAMPADD(WEEK, -1, NOW()); + + RENAME TABLE `mysql`.`slow_log_temp` TO `mysql`.`slow_log`; + SET GLOBAL slow_query_log = vSlowQueryLog; +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 `throw` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -24504,7 +24885,8 @@ SET character_set_client = utf8; `name` tinyint NOT NULL, `rgb` tinyint NOT NULL, `code` tinyint NOT NULL, - `holidayEntitlementRate` tinyint NOT NULL + `holidayEntitlementRate` tinyint NOT NULL, + `discountRate` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; @@ -24921,7 +25303,6 @@ DROP TABLE IF EXISTS `alertLevel`; CREATE TABLE `alertLevel` ( `code` varchar(45) CHARACTER SET utf8 NOT NULL, `id` int(11) NOT NULL, - `alertLevel` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -25195,14 +25576,12 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`awb_au` AFTER UPDATE ON `awb` FOR EACH ROW -begin - +BEGIN +/* IF NEW.amount <> OLD.amount THEN - - CALL vn2008.buy_tarifas_awb(NEW.code); - + CALL vn2008.buy_tarifas_awb(NEW.code); END IF; - +*/ END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -25266,7 +25645,7 @@ CREATE TABLE `bank` ( KEY `foreignkey1_idx` (`cash`), KEY `Bancoscurrency_idx` (`currencyFk`), CONSTRAINT `Bancoscurrency` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`) ON UPDATE CASCADE, - CONSTRAINT `foreignkey1` FOREIGN KEY (`cash`) REFERENCES `accountingType` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT `bank_FK` FOREIGN KEY (`cash`) REFERENCES `accountingType` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Apunta a la vista vn.Accounting\nLa columna cash es la FK de vn.AccountingType'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26282,8 +26661,8 @@ CREATE TABLE `client` ( `email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `cc` varchar(23) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)', `dueDay` smallint(6) NOT NULL DEFAULT '5', - `receipt` int(11) DEFAULT '1' COMMENT 'obsoleta', - `isOfficial` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'obsoleta (comprobar)', + `receipt__` int(11) DEFAULT '1' COMMENT 'obsoleta', + `isOfficial__` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'obsoleta (comprobar)', `isTaxDataChecked` tinyint(1) NOT NULL DEFAULT '0', `mobile` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, `accountingAccount` varchar(10) CHARACTER SET utf8 NOT NULL, @@ -26299,7 +26678,7 @@ CREATE TABLE `client` ( `notes` text COLLATE utf8_unicode_ci COMMENT 'obsoleta (comprobar)', `administrativeNotes__` text COLLATE utf8_unicode_ci NOT NULL COMMENT 'obsoleta (comprobar)', `invoiceCopy__` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', - `hold` 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(10) unsigned DEFAULT NULL, `credit` decimal(10,2) NOT NULL DEFAULT '0.00', @@ -26447,7 +26826,7 @@ BEGIN IF vText IS NOT NULL THEN - INSERT INTO mail(sender, replyTo, `subject`, body) + INSERT INTO mail(receiver, replyTo, `subject`, body) SELECT CONCAT(IF(ac.id,u.name, 'jgallego'), '@verdnatura.es'), 'administracion@verdnatura.es', @@ -26482,9 +26861,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 ;; @@ -26500,12 +26879,13 @@ BEGIN WHERE id = NEW.defaultAddressFk; END IF; - IF NOT (NEW.provinceFk <=> OLD.provinceFk) THEN + IF NOT (NEW.provinceFk <=> OLD.provinceFk) OR NOT (NEW.isVies <=> OLD.isVies) THEN INSERT IGNORE INTO ticketRecalc (ticketFk) SELECT id FROM ticket t WHERE t.clientFk = NEW.id AND t.refFk IS NULL; END IF; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -26740,6 +27120,20 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Temporary table structure for view `clientPhoneBook` +-- + +DROP TABLE IF EXISTS `clientPhoneBook`; +/*!50001 DROP VIEW IF EXISTS `clientPhoneBook`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `clientPhoneBook` ( + `clientFk` tinyint NOT NULL, + `phone` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `clientProtected` -- @@ -27244,6 +27638,7 @@ CREATE TABLE `company` ( KEY `empresa_cliente_idx` (`clientFk`), KEY `Id_Proveedores_account` (`supplierAccountFk`), KEY `empresa_grupo_fk_idx` (`companyGroupFk`), + KEY `company_fhAdminNumber_IDX` (`fhAdminNumber`) USING BTREE, CONSTRAINT `company_ibfk_1` FOREIGN KEY (`workerManagerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `empresa_cliente` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `empresa_fk4` FOREIGN KEY (`supplierAccountFk`) REFERENCES `supplierAccount` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, @@ -27442,6 +27837,7 @@ CREATE TABLE `config` ( `ASIEN` bigint(20) DEFAULT NULL, `deviceHuntingMode` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Habilita el modo cazador para usuarios sin device registrado', `tractorHuntingMode` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Habilita el modo cazador para usuarios que no se han logeado un tractor para sacar', + `dayStartingHour` int(11) NOT NULL DEFAULT '3' COMMENT 'Hora a la que empieza una nueva jornada de producción', PRIMARY KEY (`id`), KEY `fechainv_idx` (`inventoried`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -27722,11 +28118,14 @@ BEGIN WHERE Nacion = NEW.country; IF ROW_COUNT() = 0 THEN - INSERT INTO vn.mail (sender, subject, body) - VALUES ('cau@verdnatura.es', - 'Actualizar tabla sage.Naciones', - CONCAT('Se ha insertado un nuevo país en la tabla vn.conuntry. Para el correcto funcionamiento del sistema de contabilidad es necesario actualizar la columna sage.Naciones.countryFk con el valor del nuevo país. - Hay que buscar el nuevo país: ', NEW.country, ' en la tabla sage.Naciones y actualizar el campo sage.Naciones.countryFk con el valor ', NEW.id)); + CALL mail_insert( + 'cau@verdnatura.es', + NULL, + 'Actualizar tabla sage.Naciones', + CONCAT('Se ha insertado un nuevo país en la tabla vn.conuntry. Para el correcto funcionamiento del sistema + de contabilidad es necesario actualizar la columna sage.Naciones.countryFk con el valor del nuevo país. + Hay que buscar el nuevo país: ', NEW.country, ' en la tabla sage.Naciones y actualizar el campo sage.Naciones.countryFk con el valor ', NEW.id) + ); END IF; END */;; @@ -28164,6 +28563,7 @@ CREATE TABLE `department` ( `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', + `hasToSendMail` tinyint(1) DEFAULT '0' COMMENT 'Para el envio de mail en el procedimiento workerTimeControl_sendMail()', PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`), KEY `fk_department_Trabajadores1_idx` (`workerFk`), @@ -28233,13 +28633,13 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; -- --- Table structure for table `departmentItemType` +-- Table structure for table `departmentItemType__` -- -DROP TABLE IF EXISTS `departmentItemType`; +DROP TABLE IF EXISTS `departmentItemType__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `departmentItemType` ( +CREATE TABLE `departmentItemType__` ( `id` int(11) NOT NULL AUTO_INCREMENT, `departmentFk` int(11) NOT NULL, `itemTypeFk` smallint(5) unsigned NOT NULL, @@ -28312,6 +28712,8 @@ CREATE TABLE `deviceLog` ( `android_id` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `userFk` int(11) DEFAULT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `nameApp` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `versionApp` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -28397,7 +28799,7 @@ DROP TABLE IF EXISTS `dms`; CREATE TABLE `dms` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dmsTypeFk` int(11) NOT NULL DEFAULT '1', - `reference` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `reference` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `description` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', `hardCopyNumber` mediumint(8) unsigned DEFAULT NULL, @@ -28406,10 +28808,10 @@ CREATE TABLE `dms` ( `hasFile` tinyint(4) NOT NULL DEFAULT '0', `workerFk` int(10) unsigned DEFAULT NULL, `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT '60', + `warehouseFk` smallint(5) unsigned DEFAULT '60', PRIMARY KEY (`id`), UNIQUE KEY `emp_id` (`companyFk`,`hardCopyNumber`,`warehouseFk`), - UNIQUE KEY `dms_hardCopyNumber_IDX` (`hardCopyNumber`,`warehouseFk`,`companyFk`) USING BTREE, + UNIQUE KEY `dms_hardCopyNumber_IDX` (`hardCopyNumber`,`warehouseFk`) USING BTREE, KEY `trabajador_id` (`workerFk`), KEY `warehouse_id` (`warehouseFk`), KEY `dms_dmsTypeFk_idx` (`dmsTypeFk`), @@ -29246,6 +29648,54 @@ CREATE TABLE `errorLogApp` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Guarda un registro de errores e la app de almacén'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `errorProduction` +-- + +DROP TABLE IF EXISTS `errorProduction`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `errorProduction` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `userFk` int(11) DEFAULT NULL, + `firstname` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `lastname` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `rol` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `ticketNumber` int(11) DEFAULT NULL, + `error` int(11) DEFAULT NULL, + `ratio` double DEFAULT NULL, + `volume` double DEFAULT NULL, + `hourStart` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `hourEnd` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `hourWorked` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `dated` date DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `errorProduction__` +-- + +DROP TABLE IF EXISTS `errorProduction__`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `errorProduction__` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `userFk` int(11) DEFAULT NULL, + `firstname` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `lastname` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `rol` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `ticketNumber` int(11) DEFAULT NULL, + `error` int(11) DEFAULT NULL, + `ratio` double DEFAULT NULL, + `volume` double DEFAULT NULL, + `month` int(11) DEFAULT NULL, + `year` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `erte` -- @@ -29705,7 +30155,8 @@ SET character_set_client = utf8; `beachFk` tinyint NOT NULL, `zona` tinyint NOT NULL, `province` tinyint NOT NULL, - `phone` tinyint NOT NULL + `phone` tinyint NOT NULL, + `workerCode` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; @@ -29734,6 +30185,22 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `expeditionTicket_NoBoxes` +-- + +DROP TABLE IF EXISTS `expeditionTicket_NoBoxes`; +/*!50001 DROP VIEW IF EXISTS `expeditionTicket_NoBoxes`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `expeditionTicket_NoBoxes` ( + `ticketFk` tinyint NOT NULL, + `warehouseFk` tinyint NOT NULL, + `routeFk` tinyint NOT NULL, + `description` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `expeditionTimeExpended` -- @@ -29763,8 +30230,11 @@ CREATE TABLE `expeditionTruck` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ETD` datetime DEFAULT NULL, `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `bufferFk` int(11) DEFAULT NULL COMMENT 'buffer destino de las cajas', PRIMARY KEY (`id`), - KEY `expeditionTruck_idx1` (`ETD`) + KEY `expeditionTruck_idx1` (`ETD`), + KEY `expeditionTruck_FK` (`bufferFk`), + CONSTRAINT `expeditionTruck_FK` FOREIGN KEY (`bufferFk`) REFERENCES `srt`.`buffer` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -29940,6 +30410,7 @@ CREATE TABLE `floramondoConfig` ( `MaxLatestDeliveryHour` int(11) DEFAULT NULL, `MaxLatestOrderHour` int(11) DEFAULT '12' COMMENT 'Hora máxima para aceptar pedidos hoy', `LastUpdated` datetime DEFAULT NULL, + `itemMaxSize` int(11) DEFAULT NULL COMMENT 'tamaño maximo de los articulos a mostrar', PRIMARY KEY (`id`), KEY `floramondoConfigWarehouseIn_idx` (`warehouseInFk`), KEY `floramondoConfigWarehouseOut_idx` (`warehouseOutFk__`), @@ -29968,6 +30439,20 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `floramondoNotOfferDay` +-- + +DROP TABLE IF EXISTS `floramondoNotOfferDay`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `floramondoNotOfferDay` ( + `dated` date NOT NULL, + `warehouseFk` int(11) NOT NULL DEFAULT '60', + PRIMARY KEY (`dated`,`warehouseFk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='no muestra oferta en floramondo para ese dia y almacen'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `fuelType` -- @@ -30014,6 +30499,45 @@ CREATE TABLE `genus` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `glsConfig` +-- + +DROP TABLE IF EXISTS `glsConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `glsConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `service` int(1) DEFAULT NULL, + `schedule` int(1) DEFAULT NULL, + `token` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `labelType` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, + `supplierFk` int(11) DEFAULT NULL, + `package` int(1) DEFAULT NULL, + `refund` int(1) DEFAULT NULL, + `weight` int(1) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `glsExpedition` +-- + +DROP TABLE IF EXISTS `glsExpedition`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `glsExpedition` ( + `expeditionFk` int(11) NOT NULL, + `barcode` bigint(20) unsigned DEFAULT NULL, + `uid` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `codexp` int(11) DEFAULT NULL, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`expeditionFk`), + CONSTRAINT `glsInfo_FK` FOREIGN KEY (`expeditionFk`) REFERENCES `expedition` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `greuge` -- @@ -30434,7 +30958,6 @@ DELIMITER ;; WHERE supplierRef = NEW.supplierRef AND supplierFk = NEW.supplierFk AND YEAR(issued) = YEAR(NEW.issued) - AND id <> NEW.id ) THEN CALL util.throw('reference duplicated'); END IF; @@ -30598,13 +31121,15 @@ BEGIN IF (NEW.dueDated <= CURDATE() AND vIsNotified) THEN - INSERT INTO vn.mail SET - `sender` = 'begonya@verdnatura.es', - `replyTo` = 'begonya@verdnatura.es', - `subject` = 'Añadido vencimiento en el pasado', - `body` = CONCAT(account.myUserGetName(), ' ha añadido un vencimiento de ', - NEW.amount,'€ en una fecha pasada en la recibida ', - NEW.invoiceInFk); + CALL mail_insert( + 'begonya@verdnatura.es', + 'begonya@verdnatura.es', + 'Añadido vencimiento en el pasado', + CONCAT( + account.myUserGetName(), ' ha añadido un vencimiento de ', + NEW.amount, '€ en una fecha pasada en la recibida ', NEW.invoiceInFk + ) + ); END IF; END */;; @@ -30636,13 +31161,15 @@ BEGIN IF (NEW.dueDated <= CURDATE() AND vIsNotified) THEN - INSERT INTO vn.mail SET - `sender` = 'begonya@verdnatura.es', - `replyTo` = 'begonya@verdnatura.es', - `subject` = 'Añadido vencimiento en el pasado', - `body` = CONCAT(account.myUserGetName(), ' ha añadido un vencimiento de ', - NEW.amount,'€ en una fecha pasada en la recibida ', - NEW.invoiceInFk); + CALL mail_insert( + 'begonya@verdnatura.es', + 'begonya@verdnatura.es', + 'Añadido vencimiento en el pasado', + CONCAT( + account.myUserGetName(), ' ha añadido un vencimiento de ', + NEW.amount,'€ en una fecha pasada en la recibida ',NEW.invoiceInFk + ) + ); END IF; END */;; @@ -30671,24 +31198,6 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `invoiceInEntry__` --- - -DROP TABLE IF EXISTS `invoiceInEntry__`; -/*!50001 DROP VIEW IF EXISTS `invoiceInEntry__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `invoiceInEntry__` ( - `id` tinyint NOT NULL, - `invoiceInFk` tinyint NOT NULL, - `entryFk` tinyint NOT NULL, - `percentage` tinyint NOT NULL, - `invoiceInAwbFk` tinyint NOT NULL, - `isBooked` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `invoiceInIntrastat` -- @@ -31178,7 +31687,7 @@ CREATE TABLE `item` ( `stars` int(11) DEFAULT NULL, `stemMultiplier` double NOT NULL DEFAULT '1' COMMENT 'este valor multiplica las unidades y divide los precios en el procedimiento edi.ekt_load', `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `packingOut` int(11) DEFAULT NULL COMMENT 'cantidad que cabe en una caja de verdnatura', + `packingOut` decimal(10,2) DEFAULT NULL COMMENT 'cantidad que cabe en una caja de verdnatura', PRIMARY KEY (`id`), UNIQUE KEY `item_supplyResponseFk_idx` (`supplyResponseFk`), KEY `Color` (`inkFk`), @@ -31254,15 +31763,17 @@ 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 = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!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`.`item_afterInsert` AFTER INSERT ON `item` FOR EACH ROW BEGIN + DECLARE vStandardFlowerBox INT; + CALL hedera.image_ref('catalog', NEW.image); INSERT INTO vn.itemTaxCountry(itemFk, countryFk) @@ -31273,12 +31784,16 @@ BEGIN 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;*/ + + IF NEW.packingOut THEN + SELECT standardFlowerBox * 1000 INTO vStandardFlowerBox + FROM volumeConfig; + + UPDATE itemCost ic + JOIN warehouse w ON w.id = ic.warehouseFk + SET cm3Delivery = vStandardFlowerBox / NEW.packingOut + WHERE ic.itemFk = NEW.id AND w.hasProduction; + END IF; END */;; DELIMITER ; @@ -31298,6 +31813,8 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`item_afterUpdate` AFTER UPDATE ON `item` FOR EACH ROW BEGIN + DECLARE vStandardFlowerBox INT; + IF !(NEW.image <=> OLD.image) THEN CALL hedera.image_unref('catalog', OLD.image); CALL hedera.image_ref('catalog', NEW.image); @@ -31305,8 +31822,15 @@ BEGIN IF NEW.density = 0 THEN CALL util.throw('error densidad = 0'); END IF; - IF (SELECT NEW.compression < minCompressionRate FROM vn.volumeConfig vc) AND NEW.compression < OLD.compression THEN - CALL util.throw('compression too low'); + + IF !(NEW.packingOut <=> OLD.packingOut) THEN + SELECT standardFlowerBox * 1000 INTO vStandardFlowerBox + FROM volumeConfig; + + UPDATE itemCost ic + JOIN warehouse w ON w.id = ic.warehouseFk + SET cm3Delivery = IFNULL(vStandardFlowerBox / NEW.packingOut, cm3) + WHERE itemFk = NEW.id AND w.hasProduction; END IF; END */;; DELIMITER ; @@ -31366,7 +31890,7 @@ DROP TABLE IF EXISTS `itemBotanical`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `itemBotanical` ( `itemFk` int(11) NOT NULL, - `botanical` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `botanical__` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `genusFk` int(11) NOT NULL, `specieFk` int(11) DEFAULT NULL, PRIMARY KEY (`itemFk`), @@ -31516,6 +32040,7 @@ BEGIN IF NEW.itemFk IN (95, 98) THEN SET NEW.cm3 = 0; END IF; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -31525,9 +32050,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 ;; @@ -31548,6 +32073,13 @@ BEGIN AND ic.itemFk = NEW.itemFk AND r.created >= CURDATE() GROUP BY r.id; + IF NEW.cm3Delivery = 0 AND NEW.warehouseFk = 60 THEN + CALL mail_insert( + 'jgallego@verdnatura.es', + NULL, + 'update cm3Delivery', + CONCAT('articulo: ', NEW.itemFk)); + END IF; END IF; END */;; DELIMITER ; @@ -31686,6 +32218,23 @@ CREATE TABLE `itemLog` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `itemMatchProperties` +-- + +DROP TABLE IF EXISTS `itemMatchProperties`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemMatchProperties` ( + `itemFk` int(11) NOT NULL, + `name` varchar(80) COLLATE utf8_unicode_ci NOT NULL, + `producer` varchar(80) COLLATE utf8_unicode_ci NOT NULL, + `size` int(11) NOT NULL, + PRIMARY KEY (`itemFk`,`name`,`producer`,`size`), + CONSTRAINT `itemFk___fk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Propiedades para encontrar articulos equivalentes en verdnatura'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemPackingType` -- @@ -32614,7 +33163,7 @@ CREATE TABLE `itemType` ( `gramsMin` int(11) DEFAULT NULL, `gramsMax` int(11) DEFAULT NULL, `order` int(11) DEFAULT '0', - `temperature` tinyint(1) unsigned NOT NULL DEFAULT '0', + `temperature__` tinyint(1) unsigned DEFAULT NULL, `categoryFk` int(10) unsigned 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', @@ -32714,6 +33263,25 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `itemTypeRestriction` +-- + +DROP TABLE IF EXISTS `itemTypeRestriction`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemTypeRestriction` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemTypeFk` smallint(5) unsigned NOT NULL, + `dated` date NOT NULL, + `minAmount` decimal(10,2) NOT NULL COMMENT 'importe mínimo en la linea de venta', + PRIMARY KEY (`id`), + UNIQUE KEY `itemTypeRestriction_UN` (`itemTypeFk`,`dated`), + KEY `itemTypeRestriction_dated_IDX` (`dated`,`itemTypeFk`) USING BTREE, + CONSTRAINT `itemTypeRestriction_itemType_id_fk` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemTypeTag` -- @@ -32855,7 +33423,10 @@ SET character_set_client = utf8; `stickers` tinyint NOT NULL, `packing` tinyint NOT NULL, `ref` tinyint NOT NULL, - `itemFk` tinyint NOT NULL + `itemFk` tinyint NOT NULL, + `pro` tinyint NOT NULL, + `ektRef` tinyint NOT NULL, + `agj` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; @@ -33028,6 +33599,20 @@ CREATE TABLE `machineWorker` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Registros horarios de vehículos de almacén por empleado'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `machineWorkerConfig` +-- + +DROP TABLE IF EXISTS `machineWorkerConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `machineWorkerConfig` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `maxHours` smallint(5) unsigned NOT NULL COMMENT 'Indicates how many hours a user record is reviewed to update or insert', + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `mail` -- @@ -33038,7 +33623,7 @@ DROP TABLE IF EXISTS `mail`; CREATE TABLE `mail` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `receiver` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `sender` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `sender` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `replyTo` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `subject` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `body` text COLLATE utf8_unicode_ci NOT NULL, @@ -33322,6 +33907,7 @@ CREATE TABLE `mobileAppVersionControl` ( `id` int(11) NOT NULL AUTO_INCREMENT, `appName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `version` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0', + `IsVersionCritical` tinyint(1) 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 */; @@ -33958,8 +34544,12 @@ CREATE TABLE `person` ( `isDisable` tinyint(1) NOT NULL DEFAULT '0', `isFreelance` tinyint(1) NOT NULL DEFAULT '0', `isSsDiscounted` tinyint(1) NOT NULL DEFAULT '0', + `nickname` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `p2` longtext COLLATE utf8_unicode_ci, + `sex` enum('M','F') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'F' COMMENT 'M Masculino F Femenino', PRIMARY KEY (`id`), UNIQUE KEY `nif` (`fi`), + UNIQUE KEY `person_UN` (`readerId`), KEY `nifIndex` (`fi`), KEY `workerFk_idx` (`workerFk`), CONSTRAINT `Person_ibfk_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE @@ -34531,7 +35121,7 @@ CREATE TABLE `profile` ( KEY `profileTypeFk` (`profileTypeFk`), CONSTRAINT `profile_ibfk_1` FOREIGN KEY (`personFk`) REFERENCES `person` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `profile_ibfk_2` FOREIGN KEY (`profileTypeFk`) REFERENCES `profileType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34800,7 +35390,7 @@ CREATE TABLE `receipt` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `invoiceFk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'nombre incorrecto, renombrar a description', `amountPaid` decimal(10,2) NOT NULL DEFAULT '0.00', - `amountUnpaid` decimal(10,2) NOT NULL DEFAULT '0.00', + `amountUnpaid__` decimal(10,2) NOT NULL DEFAULT '0.00', `payed` datetime DEFAULT NULL, `workerFk` int(10) unsigned DEFAULT NULL, `bankFk` int(11) DEFAULT '0', @@ -34887,19 +35477,21 @@ 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 ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`receipt_afterUpdate` AFTER UPDATE ON `receipt` FOR EACH ROW BEGIN IF NEW.isConciliate = FALSE AND NEW.payed > OLD.payed THEN - INSERT INTO vn.mail(`sender`, subject, `body`) - SELECT 'finanzas@verdnatura.es', - CONCAT(' Cambios de recibos del cliente: ', NEW.clientFk), - CONCAT('Se ha cambiado el recibo: ', NEW.Id, ' de ', OLD.payed, ' a ', NEW.payed); + CALL mail_insert( + 'finanzas@verdnatura.es', + NULL, + CONCAT('Cambios de recibos del cliente: ', NEW.clientFk), + CONCAT('Se ha cambiado el recibo: ', NEW.Id, ' de ', OLD.payed, ' a ', NEW.payed) + ); END IF; END */;; DELIMITER ; @@ -35586,9 +36178,9 @@ BEGIN UPDATE vn.collection c JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk - JOIN vn.item i ON i.id = NEW.itemFk + /*JOIN vn.item i ON i.id = NEW.itemFk AND (c.itemPackingTypeFk = i.itemPackingTypeFk - OR ISNULL(c.itemPackingTypeFk)) + OR ISNULL(c.itemPackingTypeFk))*/ SET c.salePickedCount = c.salePickedCount + IF(NEW.isPicked != 0, 1, -1); @@ -35598,9 +36190,9 @@ BEGIN UPDATE vn.collection c JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk - JOIN vn.item i ON i.id = NEW.itemFk + /*JOIN vn.item i ON i.id = NEW.itemFk AND (c.itemPackingTypeFk = i.itemPackingTypeFk - OR ISNULL(c.itemPackingTypeFk)) + OR ISNULL(c.itemPackingTypeFk))*/ SET c.saleTotalCount = c.saleTotalCount + IF(OLD.quantity = 0, 1, -1); END IF; @@ -35845,27 +36437,6 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `saleFreight__` --- - -DROP TABLE IF EXISTS `saleFreight__`; -/*!50001 DROP VIEW IF EXISTS `saleFreight__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `saleFreight__` ( - `ticketFk` tinyint NOT NULL, - `clientFk` tinyint NOT NULL, - `routeFk` tinyint NOT NULL, - `saleFk` tinyint NOT NULL, - `zoneFk` tinyint NOT NULL, - `companyFk` tinyint NOT NULL, - `shipped` tinyint NOT NULL, - `price` tinyint NOT NULL, - `freight` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `saleGoal` -- @@ -35916,7 +36487,7 @@ DROP TABLE IF EXISTS `saleMistake`; CREATE TABLE `saleMistake` ( `id` int(11) NOT NULL AUTO_INCREMENT, `saleFk` int(11) NOT NULL, - `userFk` int(10) unsigned NOT NULL, + `userFk` int(10) unsigned NOT NULL COMMENT 'Controlador', `typeFk` int(11) NOT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), @@ -36227,11 +36798,12 @@ DROP TABLE IF EXISTS `sample`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sample` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `code` varchar(20) CHARACTER SET utf8 NOT NULL, + `code` varchar(25) CHARACTER SET utf8 NOT NULL, `description` varchar(105) COLLATE utf8_unicode_ci NOT NULL, `isVisible` tinyint(1) unsigned NOT NULL DEFAULT '1', `hasCompany` tinyint(1) unsigned NOT NULL DEFAULT '0', `hasPreview` tinyint(1) unsigned NOT NULL DEFAULT '1', + `datepickerEnabled` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36288,7 +36860,7 @@ CREATE TABLE `sharingCart` ( KEY `Suplent` (`workerSubstitute`), CONSTRAINT `Suplent_key` FOREIGN KEY (`workerSubstitute`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `Trabajador_key` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -36530,6 +37102,23 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `silexACL` +-- + +DROP TABLE IF EXISTS `silexACL`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `silexACL` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `module` varchar(50) NOT NULL, + `method` varchar(50) NOT NULL, + `role` varchar(20) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `module_UNIQUE` (`module`,`method`,`role`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `sinister` -- @@ -36596,6 +37185,7 @@ CREATE TABLE `smartTag` ( `code` varchar(12) CHARACTER SET utf8 NOT NULL, `shelvingFk` varchar(10) CHARACTER SET utf8 DEFAULT NULL, `level` int(11) DEFAULT NULL, + PRIMARY KEY (`code`), KEY `smartTag_shelving_fk` (`shelvingFk`), CONSTRAINT `smartTag_shelving_fk` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -36984,6 +37574,7 @@ CREATE TABLE `supplier` ( `workerFk` int(10) unsigned DEFAULT NULL COMMENT 'Responsible for approving invoices', `supplierActivityFk` varchar(45) NOT NULL DEFAULT 'flowersPlants', `healthRegister` varchar(45) DEFAULT NULL, + `isPayMethodChecked` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Se ha validado la forma de pago', PRIMARY KEY (`id`), UNIQUE KEY `cuenta` (`account`), UNIQUE KEY `NIF` (`nif`), @@ -37034,33 +37625,6 @@ CREATE TABLE `supplierAccount` ( KEY `fk_banco_prov_account_idx` (`bankFk`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!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 supplierAccount_AfterInsert -AFTER INSERT -ON supplierAccount FOR EACH ROW -BEGIN - - INSERT INTO vn.mail(`sender`, subject, `body`) - SELECT 'finanzas@verdnatura.es', - CONCAT('Añadida cuenta bancaria al proveedor: ', NEW.supplierFk), - CONCAT(account.myUserGetName(), ' ha añadido: ', - NEW.iban, ', entidad: ', be.name, ', bic: ', be.bic) - FROM bankEntity be - WHERE be.id = NEW.bankEntityFk; -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 `supplierActivity` @@ -37593,6 +38157,7 @@ BEGIN AND r.id IN (OLD.routeFk,NEW.routeFk) AND r.created >= CURDATE() GROUP BY r.id; + call util.debugAdd(NEW.id,CONCAT(OLD.routeFk,' ',NEW.routeFk)); END IF; IF !(NEW.shipped <=> OLD.shipped) THEN @@ -37663,14 +38228,11 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `ticket_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER vn.`ticket_afterUpdate` AFTER UPDATE ON `ticket` 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.id <=> OLD.id) OR !(NEW.warehouseFk <=> OLD.warehouseFk) OR !(NEW.shipped <=> OLD.shipped) THEN @@ -37685,23 +38247,14 @@ BEGIN IF NEW.clientFk = 2067 AND !(NEW.clientFk <=> OLD.clientFk) THEN -- Fallo que se insertan no se sabe como tickets en este cliente - INSERT INTO vn.mail SET - `sender` = 'jgallego@verdnatura.es', - `replyTo` = 'jgallego@verdnatura.es', - `subject` = 'Modificado ticket al cliente 2067', - `body` = CONCAT(account.myUserGetName(), ' ha modificado el ticket ', - NEW.id); + CALL mail_insert( + 'jgallego@verdnatura.es', + 'jgallego@verdnatura.es', + 'Modificado ticket al cliente 2067', + CONCAT(account.myUserGetName(), ' ha modificado el ticket ',NEW.id) + ); END IF; - - IF !(NEW.addressFk <=> OLD.addressFk) THEN - DELETE FROM ticketObservation - WHERE ticketFk = NEW.id; - - INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) - SELECT NEW.id, ao.observationTypeFk, ao.description - FROM addressObservation ao - WHERE ao.addressFk = NEW.addressFk; - END IF; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -37758,6 +38311,7 @@ CREATE TABLE `ticketCollection` ( KEY `ticketCollection_fk1_idx` (`collectionFk`), KEY `ticketCollection_fk2_idx` (`ticketFk`), KEY `ticketCollection_smartTagFk_IDX` (`smartTagFk`) USING BTREE, + KEY `ticketCollection_created_IDX` (`created`) USING BTREE, CONSTRAINT `ticketCollection_fk1` FOREIGN KEY (`collectionFk`) REFERENCES `collection` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketCollection_fk2` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -37905,23 +38459,6 @@ CREATE TABLE `ticketDown_SelectionType` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Temporary table structure for view `ticketGetVolume__` --- - -DROP TABLE IF EXISTS `ticketGetVolume__`; -/*!50001 DROP VIEW IF EXISTS `ticketGetVolume__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `ticketGetVolume__` ( - `ticketFk` tinyint NOT NULL, - `routeFk` tinyint NOT NULL, - `saleFk` tinyint NOT NULL, - `shipped` tinyint NOT NULL, - `volume` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `ticketLabel_Source` -- @@ -38392,7 +38929,7 @@ CREATE TABLE `ticketService` ( `id` int(11) NOT NULL AUTO_INCREMENT, `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `quantity` int(11) NOT NULL DEFAULT '0', - `price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00', + `price` decimal(10,2) NOT NULL DEFAULT '0.00', `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT '2', `ticketFk` int(11) NOT NULL, `ticketServiceTypeFk` int(11) NOT NULL, @@ -39153,10 +39690,10 @@ CREATE TABLE `travelThermograph` ( `created` date NOT NULL, `warehouseFk` smallint(6) unsigned NOT NULL, `travelFk` int(10) unsigned DEFAULT NULL, - `temperature` enum('COOL','WARM') COLLATE utf8_unicode_ci NOT NULL, + `temperature` enum('COOL','WARM','DRY') COLLATE utf8_unicode_ci DEFAULT NULL, `result` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `dmsFk` int(11) DEFAULT NULL, - `temperatureFk` varchar(10) CHARACTER SET utf8 DEFAULT NULL COMMENT 'En la versión de Agosto de Salix se empezará a usar este campo y se actualizaran los anteriores mirando temperature.', + `temperatureFk` varchar(10) CHARACTER SET utf8 DEFAULT 'cool' COMMENT 'En la versión de Agosto de Salix se empezará a usar este campo y se actualizaran los anteriores mirando temperature.', PRIMARY KEY (`id`), KEY `thermograph_fk_idx` (`thermographFk`), KEY `gestdoc_fk_idx` (`dmsFk`), @@ -39170,6 +39707,28 @@ CREATE TABLE `travelThermograph` ( CONSTRAINT `travelThermographWarehouseFgn` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Registra cada termografo que se ha introducido en cada travel'; /*!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`.`travelThermograph_beforeInsert` BEFORE INSERT ON `travelThermograph` FOR EACH ROW +BEGIN + + IF NEW.temperature IS NULL THEN + SET NEW.temperature = UCASE(NEW.temperatureFk); + 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 */ ; -- -- Table structure for table `trolley` @@ -39314,45 +39873,6 @@ CREATE TABLE `vehicle` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `vehicleWarehouse` --- - -DROP TABLE IF EXISTS `vehicleWarehouse`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `vehicleWarehouse` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `numberPlate` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `model` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `tradeMark` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `numberSerial` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `vehicleWarehouse_UN` (`numberPlate`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Registros de vehículos utilizados en almacén'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `vehicleWarehouseTimeControl` --- - -DROP TABLE IF EXISTS `vehicleWarehouseTimeControl`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `vehicleWarehouseTimeControl` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `workerFk` int(10) unsigned NOT NULL, - `vehicleWarehouseFk` int(10) unsigned DEFAULT NULL, - `timed` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `direction` enum('in','out') COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `vehicleWarehouseTimeControl_worker_idx` (`workerFk`), - KEY `vehicleWarehouseTimeControl_FK` (`vehicleWarehouseFk`), - CONSTRAINT `vehicleWarehouseTimeControl_FK` FOREIGN KEY (`vehicleWarehouseFk`) REFERENCES `vehicleWarehouse` (`id`) ON UPDATE CASCADE, - CONSTRAINT `vehicleWarehouseTimeControl_worker` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Registros horarios de vehículos de almacén por empleado'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `volumeConfig` -- @@ -40100,6 +40620,54 @@ CREATE TABLE `workerTimeControl` ( CONSTRAINT `workerTimeControl_fk1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; /*!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`.`workerTimeControl_AI` AFTER INSERT ON `workerTimeControl` FOR EACH ROW +BEGIN + IF NEW.timed > DATE_ADD(NOW(), INTERVAL 1 DAY) THEN + CALL mail_insert( + 'cau@verdnatura.es', + NULL, + 'Fichada fuera de rango', + CONCAT('Se ha introducido una fichada con fecha/hora ', NEW.timed, ' del usuario ', NEW.userFk) + ); + 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 */ ; + +-- +-- Table structure for table `workerTimeControlConfig` +-- + +DROP TABLE IF EXISTS `workerTimeControlConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workerTimeControlConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `dayBreak` int(11) NOT NULL, + `dayBreakDriver` int(11) NOT NULL, + `shortWeekBreak` int(11) NOT NULL, + `longWeekBreak` int(11) NOT NULL, + `weekScope` int(11) NOT NULL, + `mailPass` varchar(45) COLLATE utf8_bin NOT NULL, + `mailHost` varchar(45) COLLATE utf8_bin NOT NULL, + `mailSuccessFolder` varchar(45) COLLATE utf8_bin NOT NULL, + `mailErrorFolder` varchar(45) COLLATE utf8_bin NOT NULL, + `mailUser` varchar(45) COLLATE utf8_bin NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='All values in seconds'; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `workerTimeControlConfig_` @@ -40537,6 +41105,7 @@ CREATE TABLE `zone` ( `isVolumetric` tinyint(1) NOT NULL DEFAULT '0', `inflation` decimal(5,2) NOT NULL DEFAULT '1.00', `m3Max` decimal(10,2) unsigned DEFAULT NULL, + `itemMaxSize` int(11) DEFAULT NULL COMMENT 'tamaño maximo de los articulos que esa ruta puede transportar', PRIMARY KEY (`id`), KEY `fk_zone_1_idx` (`warehouseFk__`), KEY `fk_zone_2_idx` (`agencyModeFk`), @@ -40888,14 +41457,14 @@ CREATE TABLE `zoneWarehouse` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `zone_ETD` +-- Temporary table structure for view `zone_ETD__` -- -DROP TABLE IF EXISTS `zone_ETD`; -/*!50001 DROP VIEW IF EXISTS `zone_ETD`*/; +DROP TABLE IF EXISTS `zone_ETD__`; +/*!50001 DROP VIEW IF EXISTS `zone_ETD__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE TABLE `zone_ETD` ( +/*!50001 CREATE TABLE `zone_ETD__` ( `zoneFk` tinyint NOT NULL, `HoraTeórica` tinyint NOT NULL, `volumenTotal` tinyint NOT NULL, @@ -40936,12 +41505,12 @@ 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_unicode_ci */ ;; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `envialiaThreHoldChecker` ON SCHEDULE EVERY 1 DAY STARTS '2019-02-07 07:00:00' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'comprueba el rango de numeros para las etiquetas de envialia' DO BEGIN +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `envialiaThreHoldChecker` ON SCHEDULE EVERY 1 DAY STARTS '2019-02-07 08:00:00' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'comprueba el rango de numeros para las etiquetas de envialia' DO BEGIN DECLARE vActualNumber BIGINT; DECLARE vEndRange BIGINT; DECLARE vIsAlreadyNotified BOOLEAN; @@ -40954,10 +41523,12 @@ DELIMITER ;; IF (vActualNumber+vNotificationThrehold) >= vEndRange AND vIsAlreadyNotified = FALSE THEN - INSERT INTO vn2008.mail (`to`, subject, text) - VALUES ('cau@verdnatura.es', - 'Hablar con envialia, acercandonos al numero final del rango permitido para las etiquetas', - CONCAT('Numero actual: ', vActualNumber, ' , numero final: ',vEndRange)); + CALL mail_insert( + 'cau@verdnatura.es', + NULL, + 'Hablar con envialia, acercandonos al numero final del rango permitido para las etiquetas', + CONCAT('Numero actual: ', vActualNumber, ' , numero final: ',vEndRange) + ); UPDATE envialiaConfig SET isAlreadyNotified = TRUE; END IF; @@ -40978,14 +41549,14 @@ 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' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`z-sysadmin`@`%`*/ /*!50106 EVENT `printQueue_check` ON SCHEDULE EVERY 10 MINUTE STARTS '2019-11-08 01:00:00' ON COMPLETION PRESERVE ENABLE COMMENT 'Notifica en caso de que el servidor de impresión este parado' DO BEGIN +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `printQueue_check` ON SCHEDULE EVERY 10 MINUTE STARTS '2019-11-08 02:00:00' ON COMPLETION PRESERVE ENABLE COMMENT 'Notifica en caso de que el servidor de impresión este parado' DO BEGIN DECLARE vCurrentCount INT; DECLARE vCheckSum INT; @@ -41051,10 +41622,12 @@ DELIMITER ;; CLOSE vCur; - INSERT INTO vn2008.mail (`to`, subject, text) - VALUES ('cau@verdnatura.es', - 'servidor de impresion parado', - CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas', vTableQueue, '')); + CALL mail_insert( + 'cau@verdnatura.es', + NULL, + 'Servidor de impresion parado', + CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas', vTableQueue, '') + ); UPDATE printingQueueCheck SET isAlreadyNotified = TRUE; END IF; @@ -41193,6 +41766,34 @@ 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 `workerTimeControl_sendMailByDepartment` */;; +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 = 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' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `workerTimeControl_sendMailByDepartment` ON SCHEDULE EVERY 1 WEEK STARTS '2021-09-29 12:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN + DECLARE vWeek,vYear INT; + + SELECT week,year INTO vWeek,vYear + FROM vn.time + WHERE dated IN (DATE_ADD(CURDATE(), INTERVAL -10 DAY), DATE_ADD(CURDATE(), INTERVAL -4 DAY)) + GROUP BY year,week + LIMIT 1; + + CALL vn.workerTimeControl_sendMailByDepartment(vWeek, vYear, NULL); +END */ ;; +/*!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 */ ;; @@ -41355,17 +41956,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 FUNCTION IF EXISTS `bionicCalcReverse` */; +/*!50003 DROP FUNCTION IF EXISTS `bionicCalcReverse__` */; /*!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 `bionicCalcReverse`(vWarehouse INT, +CREATE DEFINER=`root`@`%` FUNCTION `bionicCalcReverse__`(vWarehouse INT, vMargin DECIMAL(10,3), vRetailedPrice DECIMAL(10,3), vM3 DECIMAL(10,3), @@ -41777,89 +42378,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 FUNCTION 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 = 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`@`%` FUNCTION `clientGetDebt__`(vClient INT, vDate DATE) RETURNS decimal(10,2) - READS SQL DATA -BEGIN -/** - * Devuelve el saldo de un cliente. - * - * @param vClient Identificador del cliente - * @param vDate Fecha hasta la que tener en cuenta - * @return Saldo del cliente - */ - DECLARE vDateEnd DATETIME; - DECLARE vDateIni DATETIME; - DECLARE vDebt DECIMAL(10,2); - DECLARE vHasDebt BOOLEAN; - - SELECT COUNT(*) INTO vHasDebt - FROM `client` c - WHERE c.id = vClient AND c.typeFk = 'normal'; - - IF NOT vHasDebt THEN - RETURN 0; - END IF; - - SET vDate = IFNULL(vDate, CURDATE()); - - 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 - UNION ALL - SELECT SUM(amountPaid) amount - FROM receipt - WHERE clientFk = vClient - AND payed > vDateEnd - UNION ALL - SELECT SUM(amount) - FROM clientRisk - WHERE clientFk = vClient - UNION ALL - SELECT CAST(-SUM(amount) / 100 AS DECIMAL(10,2)) - FROM hedera.tpvTransaction - WHERE clientFk = vClient - AND receiptFk IS NULL - AND `status` = 'ok' - ) t; - - DROP TEMPORARY TABLE - tmp.ticket, - tmp.ticketTotal; - - RETURN vDebt; -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 `clientGetMana` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42823,34 +43341,6 @@ BEGIN 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 */ ; -/*!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 `floramondoNewItemFk__`() RETURNS int(11) - DETERMINISTIC -BEGIN - - DECLARE vItemFk INT; - - SELECT max(id) + 1 INTO vItemFk - FROM item - WHERE id BETWEEN 250000 AND 290000; - - RETURN vItemFk; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -42861,9 +43351,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 = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!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 ;; @@ -42875,6 +43365,14 @@ BEGIN DECLARE vEntryFk INT; DECLARE previousEntryFk INT; + IF (SELECT COUNT(*) + FROM vn.floramondoNotOfferDay + WHERE dated = vLanded + AND warehouseFk = vWarehouseFk) + THEN + RETURN NULL; + END IF; + SET vTravelFk = floramondo_getTravel(vLanded, vWarehouseFk); IF vLanded THEN @@ -42971,59 +43469,6 @@ BEGIN RETURN vTravelFk; -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 `floramondo_getTravel__` */; -/*!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 `floramondo_getTravel__`(vLanded DATE) RETURNS int(11) - READS SQL DATA -BEGIN - - DECLARE vTravelFk INT; - DECLARE vWarehouseOutName VARCHAR(50) DEFAULT 'Holanda'; - DECLARE vWarehouseInName VARCHAR(50) DEFAULT 'VNH'; - - IF vLanded THEN - SELECT IFNULL(MAX(tr.id),0) INTO vTravelFk - FROM vn.travel tr - JOIN vn.warehouse wIn ON wIn.id = tr.warehouseInFk - JOIN vn.warehouse wOut ON wOut.id = tr.warehouseOutFk - WHERE wIn.name = vWarehouseInName - AND wOut.name = vWarehouseOutName - AND landed = vLanded; - - IF NOT vTravelFk THEN - - INSERT INTO vn.travel(landed, shipped, warehouseInFk, warehouseOutFk, agencyFk) - SELECT vLanded, curdate(), wIn.id, wOut.id, am.id - FROM vn.warehouse wIn - JOIN vn.warehouse wOut ON wOut.name = vWarehouseOutName - JOIN vn.agencyMode am ON am.name = 'HOLANDA DIRECTO' - WHERE wIn.name = vWarehouseInName; - - SELECT MAX(tr.id) INTO vTravelFk - FROM vn.travel tr - JOIN vn.warehouse wIn ON wIn.id = tr.warehouseInFk - JOIN vn.warehouse wOut ON wOut.id = tr.warehouseOutFk - WHERE wIn.name = vWarehouseInName - AND wOut.name = vWarehouseOutName - AND landed = vLanded; - END IF; - END IF; - RETURN vTravelFk; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -44905,34 +45350,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 FUNCTION IF EXISTS `smartTag_nextLevel` */; -/*!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 `smartTag_nextLevel`(vShelvingFk VARCHAR(10)) RETURNS int(2) - DETERMINISTIC -BEGIN - - DECLARE vLevel INT; - - SELECT count(*) + 1 INTO vLevel - FROM smartTag st - WHERE st.shelvingFk = vShelvingFk COLLATE utf8_general_ci; - - RETURN vLevel; - -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 `specie_IsForbidden` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45345,19 +45762,10 @@ CREATE DEFINER=`root`@`%` FUNCTION `ticketTotalVolume`(vTicketId INT) RETURNS de READS SQL DATA BEGIN -- Devuelte el volumen total del ticket sumado - -- DECLARE vWarehouseId INTEGER; - -- DECLARE vShippedDate DATE; + DECLARE vVolume DECIMAL(10,3); - /* - SELECT warehouseFk, shipped INTO vWarehouseId,vShippedDate FROM vn.ticket WHERE id = vTicketId; - - SELECT IFNULL(SUM(s.quantity * i.compression * r.cm3)/1000000,0) INTO vVolume - FROM sale s - JOIN vn.item i ON i.id = s.itemFk - JOIN bi.rotacion r on r.Id_Article = s.itemFk AND r.warehouse_id = vWarehouseId - WHERE s.ticketFk = vTicketId; - */ - SELECT sum(volume) INTO vVolume + + SELECT SUM(volume) INTO vVolume FROM saleVolume WHERE ticketFk = vTicketId; RETURN vVolume; @@ -45505,6 +45913,39 @@ 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 `ticket_getWeight` */; +/*!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 `ticket_getWeight`(vTicketFk INT) RETURNS decimal(10,3) + READS SQL DATA +BEGIN +/** + * Devuelve el peso total del ticket + * + * @return Total peso + */ + + DECLARE vWeight DECIMAL(10,3); + + SELECT sum(weight) INTO vWeight + FROM saleVolume + WHERE ticketFk = vTicketFk; + + RETURN vWeight; + +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 `ticket_getWithParameters` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45868,71 +46309,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 FUNCTION IF EXISTS `vehicleWarehouseTimeControl_checkRegister` */; -/*!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 `vehicleWarehouseTimeControl_checkRegister`(vWorkerFk VARCHAR(10)) RETURNS tinyint(1) - READS SQL DATA -BEGIN -/** - * Comprueba si existen registros - * @return Devuelve TRUE en caso de que haya registros - */ - - IF (SELECT COUNT(*) - FROM vn.vehicleWarehouseTimeControl vwt - WHERE vwt.workerFk = vWorkerFk - AND vwt.timed >= TIMESTAMPADD(HOUR , -12,NOW())) - THEN - RETURN TRUE; - ELSE - RETURN FALSE; - 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 FUNCTION IF EXISTS `vehicleWarehouse_checkNumberPlate` */; -/*!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 `vehicleWarehouse_checkNumberPlate`(vNumberPlate VARCHAR(10)) RETURNS tinyint(1) - READS SQL DATA -BEGIN -/** - * Comprueba si existe matrícula - * @return Devuelve TRUE en caso de que exista - */ - - IF (SELECT COUNT(*) - FROM vn.vehicleWarehouse - WHERE numberPlate = vNumberPlate - ) THEN - RETURN TRUE; - ELSE - RETURN FALSE; - 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 FUNCTION IF EXISTS `workerIsBoss` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45992,6 +46368,42 @@ 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 `workerMachinery_isRegistered` */; +/*!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 `workerMachinery_isRegistered`(vWorkerFk VARCHAR(10)) RETURNS tinyint(1) + READS SQL DATA +BEGIN +/** + * Comprueba si existen registros en las últimas horas (maxHours de machineWorkerConfig) del trabajador vWorkerFk y si tiene a nulo la hora outTimed (indica la hora que deja el vehículo) + * + * @param vWorkerFk id del trabajador + * @return Devuelve TRUE/FALSE en caso de que haya o no registros + */ + + IF (SELECT COUNT(*) + FROM machineWorker m + WHERE m.workerFk = vWorkerFk + AND m.inTimed >= TIMESTAMPADD(HOUR , -(SELECT maxHours from machineWorkerConfig), NOW()) AND ISNULL(m.outTimed)) + THEN + RETURN TRUE; + ELSE + RETURN FALSE; + 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 FUNCTION IF EXISTS `workerTimeControl_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46582,135 +46994,6 @@ BEGIN AND tr.agencyFk IN (0, vAgency) GROUP BY Temp; -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 `algemesi_silla__` */; -/*!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 `algemesi_silla__`(vDate DATE, vItemFk INT, vQuantity INT) -BEGIN - -DECLARE done INT DEFAULT FALSE; -DECLARE vAlgemesiFk INT DEFAULT 60; -DECLARE vSillaFk INT DEFAULT 1; -DECLARE vTicketFk INT; -DECLARE vSaleFk INT; -DECLARE vClonTicket INT DEFAULT 0; -DECLARE i INT DEFAULT 0; - -DECLARE cur1 CURSOR FOR - select distinct s.ticketFk, s.id - from vn.sale s - join vn.ticket t ON t.id = s.ticketFk - left join vn.ticketStateToday tss ON tss.ticket = t.id - where t.shipped between vDate and util.dayend(vDate) - and t.warehouseFk = vAlgemesiFk - and s.itemFk IN (vItemFk) - and s.quantity < vQuantity - and IFNULL(tss.alertLevel,0) = 0 - -- limit 1 - ; - - -DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - -OPEN cur1; - -FETCH cur1 INTO vTicketFk, vSaleFk; - - WHILE done = 0 DO - - SELECT t.id INTO vClonTicket - FROM vn.ticket t - JOIN (SELECT t.addressFk, t.shipped - FROM vn.ticket t - left join vn.ticketStateToday tss ON tss.ticket = t.id - WHERE id = vTicketFk - and IFNULL(tss.alertLevel,0) = 0) sub USING(addressFk, shipped) - WHERE t.warehouseFk = vSillaFk - LIMIT 1; - - -- SELECT vTicketFk, vClonTicket; - - IF vClonTicket = 0 THEN - - INSERT INTO ticket ( - clientFk, - shipped, - addressFk, - agencyModeFk, - nickname, - warehouseFk, - companyFk, - landed, - zoneFk, - zonePrice, - zoneBonus, - routeFk - ) - SELECT - clientFk, - shipped, - addressFk, - agencyModeFk, - nickname, - vSillaFk, - companyFk, - landed, - zoneFk, - zonePrice, - zoneBonus, - routeFk - - FROM ticket - WHERE id = vTicketFk; - - SET vClonTicket = LAST_INSERT_ID(); - - -- SELECT 'lstID', vClonTicket; - - INSERT IGNORE INTO ticketObservation(ticketFk, observationTypeFk, description) - SELECT vClonTicket, ao.observationTypeFk, ao.description - FROM addressObservation ao - JOIN ticket t ON t.addressFk = ao.addressFk - WHERE t.id = vTicketFk; - - INSERT IGNORE INTO ticketLog - SET originFk = vClonTicket, userFk = account.myUser_getId(), `action` = 'insert', - description = CONCAT('Ha creado el ticket:', ' ', vClonTicket, ' clonando el ', vTicketFk); - - END IF; - - UPDATE vn.sale - SET ticketFk = vClonTicket - WHERE id = vSaleFk; - - - SET vClonTicket = 0; - - SET done = 0; - FETCH cur1 INTO vTicketFk, vSaleFk; - - SET i = i + 1; - - END WHILE; - - CLOSE cur1; - - SELECT i; - - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -46875,30 +47158,17 @@ BEGIN * de los leasing * */ - INSERT INTO mail (sender,replyTo,subject,body) + INSERT INTO mail (receiver,replyTo,subject,body) SELECT 'administracion@verdnatura.es' sender, 'noreply@verdnatura.es' replyTo, - CONCAT( - 'El seguro de la poliza ', - b.id, - ' ', - b.bank, - ' ha finalizado.' - ) subject, - CONCAT( - 'El seguro de la poliza ', - b.id, - ' ', - b.bank, - ' ha finalizado.' - ) body + CONCAT('El seguro de la poliza ',b.id,' ',b.bank,' ha finalizado.') subject, + CONCAT('El seguro de la poliza ',b.id,' ',b.bank,' ha finalizado.') body FROM vn.bankPolicy bp LEFT JOIN vn.supplier s ON s.id = bp.supplierFk LEFT JOIN vn.bank b ON b.id = bp.bankFk WHERE bp.insuranceExpired = CURDATE(); - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -47044,9 +47314,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 = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!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 ;; @@ -47063,13 +47333,15 @@ BEGIN DECLARE vPackageFk VARCHAR(10); DECLARE vStickers INT; DECLARE vPacking INT; + DECLARE vPackingOut DECIMAL(10,2); DECLARE vWarehouse INT; + DECLARE vStandardFlowerBox INT; DECLARE vWarehouseOut INT; DECLARE vIsMerchandise BOOL; DECLARE vIsFeedStock BOOL; - SELECT b.entryFk, b.itemFk, b.stickers, b.packing, p.id, i.`size` - INTO vEntryFk, vItemFk, vStickers, vPacking, vPackageFk, vSize + SELECT b.entryFk, b.itemFk, b.stickers, b.packing, i.packingOut + INTO vEntryFk, vItemFk, vStickers, vPacking, vPackingOut FROM buy b LEFT JOIN item i ON i.id = b.itemFk LEFT JOIN packaging p ON p.id = b.packageFk AND NOT p.isBox @@ -47081,26 +47353,22 @@ BEGIN JOIN travel t ON t.id = e.travelFk WHERE e.id = vEntryFk; - SELECT k.merchandise - INTO vIsMerchandise + SELECT k.merchandise m, vc.standardFlowerBox + INTO vIsMerchandise, vStandardFlowerBox FROM itemCategory k JOIN itemType it ON it.categoryFk = k.id JOIN item i ON i.typeFk = it.id + JOIN volumeConfig vc ON TRUE WHERE i.id = vItemFk; IF vIsMerchandise THEN - - REPLACE itemCost SET + + REPLACE itemCost SET itemFk = vItemFk, warehouseFk = vWarehouse, - cm3 = buy_getUnitVolume(vSelf); - - UPDATE vn.itemCost ic - JOIN vn.item i ON i.id = ic.itemFk - SET ic.cm3delivery = i.compression * ic.cm3 - WHERE ic.itemFk = vItemFk AND - ic.warehouseFk = vWarehouse; - + cm3 = buy_getUnitVolume(vSelf), + cm3Delivery = IFNULL((vStandardFlowerBox * 1000) / vPackingOut, buy_getUnitVolume(vSelf)); + UPDATE vn.itemCost ic JOIN cache.last_buy lb ON lb.item_id = ic.itemFk AND lb.warehouse_id = ic.warehouseFk JOIN vn.buy b ON b.id = lb.buy_id @@ -47126,94 +47394,6 @@ BEGIN END IF; 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 `buy_afterUpsert__` */; -/*!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 `buy_afterUpsert__`(vSelf INT) -BEGIN -/** - * Triggered actions when a buy is updated or inserted. - * - * @param vSelf The buy reference - */ - DECLARE vEntryFk INT; - DECLARE vItemFk INT; - DECLARE vStickers INT; - DECLARE vPacking INT; - DECLARE vWarehouse INT; - DECLARE vWarehouseOut INT; - DECLARE vIsMerchandise BOOL; - DECLARE vIsFeedStock BOOL; - - - SELECT entryFk, itemFk, stickers, packing - INTO vEntryFk, vItemFk, vStickers, vPacking - FROM buy - WHERE id = vSelf; - - SELECT t.warehouseInFk, t.warehouseOutFk - INTO vWarehouse, vWarehouseOut - FROM entry e - JOIN travel t ON t.id = e.travelFk - WHERE e.id = vEntryFk; - - SELECT k.merchandise - INTO vIsMerchandise - FROM itemCategory k - JOIN itemType it ON it.categoryFk = k.id - JOIN item i ON i.typeFk = it.id - WHERE i.id = vItemFk; - - IF vIsMerchandise THEN - - REPLACE itemCost SET - itemFk = vItemFk, - warehouseFk = vWarehouse, - cm3 = buy_getUnitVolume(vSelf); - - UPDATE vn.itemCost ic - JOIN vn.item i ON i.id = ic.itemFk - SET ic.cm3delivery = i.compression * ic.cm3 - WHERE ic.itemFk = vItemFk AND - ic.warehouseFk = vWarehouse; - - UPDATE vn.itemCost ic - JOIN cache.last_buy lb ON lb.item_id = ic.itemFk AND lb.warehouse_id = ic.warehouseFk - JOIN vn.buy b ON b.id = lb.buy_id - SET ic.grams = b.weight * 1000 / b.packing - WHERE ic.itemFk = vItemFk AND - ic.warehouseFk = vWarehouse; - END IF; - - SELECT isFeedStock INTO vIsFeedStock - FROM warehouse WHERE id = vWarehouseOut AND id <> 13; - - IF vIsFeedStock THEN - INSERT IGNORE INTO producer(`name`) - SELECT es.company_name - FROM buy b - JOIN edi.ekt be ON be.id = b.ektFk - JOIN edi.supplier es ON es.supplier_id = be.pro - WHERE b.id = vSelf; - - IF buy_hasNotifyPassport(vSelf, vItemFk) THEN - CALL vn.buy_notifyPassport(vSelf, vItemFk, vStickers, vPacking); - END IF; - END IF; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -47263,7 +47443,7 @@ BEGIN * Cálculo de volumen en líneas de compra * @table tmp.buy(buyFk) */ - SELECT ELT(it.temperature + 1,'Calientes','Frios','Secos') Temp, + SELECT t.name Temp, CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) * item_getVolume(b.itemFk, b.packageFk)) / vc.trolleyM3 / 1000000 ,1) AS DECIMAL(10,2)) carros , CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) * @@ -47273,6 +47453,7 @@ BEGIN JOIN volumeConfig vc JOIN item i ON i.id = b.itemFk JOIN itemType it ON it.id = i.typeFk + LEFT JOIN temperature t ON t.code = it.temperatureFk GROUP BY Temp; END ;; DELIMITER ; @@ -47391,9 +47572,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 ;; @@ -47438,10 +47619,10 @@ BEGIN b.price2 = @t2:= round(@t3 * (1 + ((r.rate2 - r.rate3)/100)),2), b.price2 = @t2:= IF(@t2 <= @t3,@t3 , @t2); - SELECT (b.buyingValue = b.price2), b.buyingValue , b.packageFk - INTO vFallo, vBuyingValue ,vPackageFk + SELECT (b.buyingValue = b.price2), b.buyingValue, b.packageFk + INTO vFallo, vBuyingValue, vPackageFk FROM vn.buy b - WHERE b.id = @buyId; + WHERE b.id = @buyId AND b.buyingValue <> 0.01; IF vFallo THEN @@ -47531,9 +47712,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 ;; @@ -47579,7 +47760,7 @@ BEGIN JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk WHERE calc_id = @calc_id - AND ic.merchandise; + AND ic.display; INSERT INTO tmp.camara(dated, place, m3) SELECT vDated, 'entradas', FLOOR(SUM(iei.amount * r.cm3) / 1000000) as m3 @@ -47588,7 +47769,7 @@ BEGIN JOIN vn.item i ON i.id = iei.item_id JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.merchandise + WHERE ic.display AND dat = vDated AND NOT received AND NOT isVirtualStock @@ -47601,7 +47782,7 @@ BEGIN JOIN vn.item i ON i.id = ieo.item_id JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.merchandise + WHERE ic.display AND dat = vDated AND NOT delivered AND NOT isVirtualStock @@ -47616,7 +47797,7 @@ BEGIN JOIN vn.itemCategory ic ON ic.id = it.categoryFk JOIN vn.ticketStateToday tst ON tst.ticket = io.ticketFk JOIN vn.ticket t ON t.id = io.ticketFk - WHERE ic.merchandise + WHERE ic.display AND ic.id != 7 AND t.clientFk NOT IN (200,400,50,450) AND dat BETWEEN vDated AND util.dayend(vDated) @@ -47634,7 +47815,7 @@ BEGIN JOIN vn.item i ON i.id = iei.item_id JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.merchandise + WHERE ic.display AND dat = vDated AND NOT isVirtualStock AND iei.warehouse_id = vWarehouseFk; @@ -47646,7 +47827,7 @@ BEGIN JOIN vn.item i ON i.id = ieo.item_id JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.merchandise + WHERE ic.display AND dat = vDated AND ieo.warehouse_id = vWarehouseFk; @@ -47658,7 +47839,7 @@ BEGIN JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk JOIN vn.ticket t ON t.id = io.ticketFk - WHERE ic.merchandise + WHERE ic.display AND dat BETWEEN vDated AND util.dayend(vDated) AND ic.id != 7 AND t.clientFk NOT IN (200,400,50,450) @@ -47685,7 +47866,7 @@ BEGIN JOIN vn.item i ON i.id = iei.item_id JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.merchandise + WHERE ic.display AND dat = vDated AND NOT isVirtualStock AND iei.warehouse_id = vWarehouseFk; @@ -47697,7 +47878,7 @@ BEGIN JOIN vn.item i ON i.id = ieo.item_id JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.merchandise + WHERE ic.display AND dat = vDated AND ieo.warehouse_id = vWarehouseFk; @@ -47709,7 +47890,7 @@ BEGIN JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk JOIN vn.ticket t ON t.id = io.ticketFk - WHERE ic.merchandise + WHERE ic.display AND dat BETWEEN vDated AND util.dayend(vDated) AND ic.id != 7 AND t.clientFk NOT IN (200,400,50,450) @@ -48198,6 +48379,7 @@ proc: BEGIN DECLARE vFrenchOffer INT DEFAULT 42; DECLARE vIsFrenchVNHBuyer BOOLEAN DEFAULT FALSE; DECLARE vVNHWarehouseFk INT DEFAULT 7; + DECLARE vFloramondoWarehouseFk INT DEFAULT 40; DECLARE vIsLogifloraAllowed BOOLEAN DEFAULT 0; DECLARE vMaxLogifloraDays INT; DECLARE vRangeLogifloraDays INT DEFAULT 3; @@ -48205,6 +48387,7 @@ proc: BEGIN DECLARE vRappelComponent INT DEFAULT 44; DECLARE vIsZonePremium BOOL; DECLARE vFrenchDiscount DECIMAL(3,2) DEFAULT 0.12; + DECLARE vIsCatalonianBuyer BOOL; -- PAK 18/10/21 SELECT (COUNT(*) > 0) INTO vIsZonePremium FROM vn.zoneFilter zf @@ -48217,20 +48400,34 @@ proc: BEGIN FROM address WHERE id = vAddressFk; - SELECT (c.country = 'FRANCIA' AND vWarehouseFk = vVNHWarehouseFk) + SELECT (c.country = 'FRANCIA' AND vWarehouseFk IN (vVNHWarehouseFk, vFloramondoWarehouseFk)) INTO vIsFrenchVNHBuyer FROM vn.country c JOIN vn.province p ON p.countryFk = c.id JOIN vn.address a ON a.provinceFk = p.id WHERE a.id = vAddressFk; - + + SELECT (p.name = 'Barcelona' AND vWarehouseFk = vVNHWarehouseFk) + INTO vIsCatalonianBuyer + FROM vn.province p + JOIN vn.address a ON a.provinceFk = p.id + WHERE a.id = vAddressFk; -- PAK 18/10/21 + SELECT travellingDays INTO vMaxLogifloraDays FROM edi.warehouseFloramondo WHERE warehouseFk = vWarehouseFk; - IF (NOT vIsLogifloraAllowed AND vVNHWarehouseFk != vWarehouseFk) - OR (vn.isLogifloraDay(vShipped, vWarehouseFk) = FALSE) - + -- Esto sirve para que los franceses compren sólo por las cuentas de VNH + DELETE tl.* + FROM tmp.ticketLot tl + JOIN vn.item i ON i.id = tl.itemFk + JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk + JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID + WHERE v.isVNHSupplier != vIsFrenchVNHBuyer; + + IF (NOT vIsLogifloraAllowed AND vVNHWarehouseFk != vWarehouseFk) + OR NOT vn.isLogifloraDay(vShipped, vWarehouseFk) + OR NOT(vIsCatalonianBuyer OR vIsFrenchVNHBuyer) THEN CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouseFk); @@ -48240,6 +48437,7 @@ proc: BEGIN LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk LEFT JOIN vn.buy b ON b.id = lb.buy_id LEFT JOIN vn.entry e ON e.id = b.entryFk + LEFT JOIN vn.supplier s ON s.id = e.supplierFk -- PAK 13/10/21 LEFT JOIN cache.visible v ON v.calc_id = vVisibleCache AND v.item_id = i.id LEFT JOIN (SELECT DISTINCT s.itemFk FROM vn.sale s @@ -48249,7 +48447,8 @@ proc: BEGIN AND t.shipped = vShipped AND t.zoneFk = vZoneFk) sub ON sub.itemFk = i.id WHERE (i.supplyResponseFk - AND IFNULL(e.isRaid,TRUE) + AND (IFNULL(e.isRaid,TRUE) + OR s.nickname = 'INVENTARIO') -- PAK 13/10/21 AND ISNULL(sub.itemFk) AND IFNULL(v.visible,0) = 0 AND vWarehouseFk = tl.warehouseFk); @@ -48291,8 +48490,14 @@ proc: BEGIN WHERE zf.id IS NULL ; END IF; - - + + -- Eliminem productes de la oferta que la zona no pot transportar + DELETE tl.* + FROM tmp.ticketLot tl + JOIN item i ON i.id = tl.itemFk + JOIN vn.zone z ON z.id = vZoneFk + WHERE i.size > z.itemMaxSize; + SET @rate2 := 0; SET @rate3 := 0; SET @minPrice := 0; @@ -48329,7 +48534,7 @@ proc: BEGIN ) tpf GROUP BY tpf.itemFk, tpf.warehouseFk ) pf ON pf.itemFk = tl.itemFk AND pf.warehouseFk = tl.warehouseFk - WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 AND ic.display <> 0 + WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 AND ic.merchandise <> 0 AND tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk; -- Coste @@ -48395,8 +48600,6 @@ proc: BEGIN WHERE wm.isPricesModifierActivated HAVING manaAuto <> 0; - - -- Precios especiales INSERT INTO tmp.ticketComponent SELECT tcb.warehouseFk, @@ -48627,7 +48830,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 `clean` */; +/*!50003 DROP PROCEDURE IF EXISTS `catalog_test` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -48637,6 +48840,169 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `catalog_test`() +proc: BEGIN +/** + * Calcula los articulos disponibles y sus precios + * + * @table tmp.item(itemFk) Listado de artículos a calcular + * @param vLanded Fecha de recepcion de mercancia + * @param vAddressFk Id del consignatario + * @param vAgencyModeFk Id de la agencia + * @return tmp.ticketCalculateItem(itemFk, available, producer, + * item, size, stems, category, inkFk, image, origin, price) + * @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk) + * @return tmp.ticketComponent + * @return tmp.ticketComponentPrice + * @return tmp.zoneGetShipped + */ + DECLARE vLanded DATE DEFAULT DATE_ADD(CURDATE(),INTERVAL 2 DAY); + DECLARE vAddressFk INT DEFAULT 24526; + DECLARE vAgencyModeFk INT DEFAULT 639; + DECLARE vAvailableCalc INT; + DECLARE vShipped DATE; + DECLARE vWarehouseFk SMALLINT; + DECLARE vZoneFk INT; + DECLARE vDone BOOL; + DECLARE cTravelTree CURSOR FOR + SELECT zoneFk, warehouseFk, shipped FROM tmp.zoneGetShipped; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + DROP TEMPORARY TABLE IF EXISTS tmp.item; + CREATE TEMPORARY TABLE tmp.item + ENGINE = MEMORY + SELECT 10 itemFk; + -- Establece los almacenes y las fechas que van a entrar al disponible +SELECT 1; + CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, FALSE); +SELECT 2; + DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; + CREATE TEMPORARY TABLE tmp.ticketLot( + `warehouseFk` smallint(5) unsigned NOT NULL, + `itemFk` int(11) NOT NULL, + `available` double DEFAULT NULL, + `buyFk` int(11) DEFAULT NULL, + `fix` tinyint(3) unsigned DEFAULT '0', + `zoneFk` int(11) NOT NULL, + KEY `itemFk` (`itemFk`), + KEY `item_warehouse` (`itemFk`,`warehouseFk`) USING HASH + ) ENGINE=MEMORY DEFAULT CHARSET=utf8; + CALL catalog_componentPrepare(); + +SELECT 3; + DROP TEMPORARY TABLE IF EXISTS tmp.ticketCalculateItem; + CREATE TEMPORARY TABLE tmp.ticketCalculateItem( + itemFk INT(11) NOT NULL, + available INT(11), + producer VARCHAR(50), + item VARCHAR(50), + size INT(10) UNSIGNED, + stems INT(11), + category VARCHAR(3), + inkFk VARCHAR(3), + image VARCHAR(50), + origin VARCHAR(3), + price DECIMAL(10,2), + priceKg DECIMAL(10,2), + PRIMARY KEY `itemFk` (`itemFk`) + ) ENGINE = MEMORY DEFAULT CHARSET=utf8; + + OPEN cTravelTree; + + l: LOOP + SET vDone = FALSE; + FETCH cTravelTree INTO vZoneFk, vWarehouseFk, vShipped; + + IF vDone THEN + LEAVE l; + END IF; + + CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); +SELECT '4', vWarehouseFk, vShipped ; + CALL buyUltimate (vWarehouseFk, vShipped); +SELECT 5; + INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk) + SELECT vWarehouseFk, + i.item_id, + IFNULL(i.available, 0), + bu.buyFk, + vZoneFk + FROM `cache`.available i + JOIN tmp.item br ON br.itemFk = i.item_id + LEFT JOIN item it ON it.id = i.item_id + LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = i.item_id + WHERE i.calc_id = vAvailableCalc + AND i.available > 0; + + DROP TEMPORARY TABLE tmp.buyUltimate; + + CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); +SELECT 6; + INSERT INTO tmp.ticketCalculateItem ( + itemFk, + available, + producer, + item, + size, + stems, + category, + inkFk, + image, + origin, + price, + priceKg) + SELECT + tl.itemFk, + SUM(tl.available) available, + p.name producer, + i.name item, + i.size size, + i.stems, + i.category, + i.inkFk, + i.image, + o.code origin, + bl.price, + bl.priceKg + FROM tmp.ticketLot tl + JOIN item i ON tl.itemFk = i.id + LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible + JOIN origin o ON o.id = i.originFk + JOIN ( + SELECT * + FROM (SELECT price, itemFk, priceKg + FROM tmp.ticketComponentPrice + WHERE warehouseFk = vWarehouseFk + ORDER BY (rate = 2) DESC) sub + GROUP BY itemFk + ) bl ON bl.itemFk = tl.itemFk + WHERE tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk + GROUP BY tl.itemFk + ON DUPLICATE KEY UPDATE available = available + VALUES(available); + + END LOOP; + + CLOSE cTravelTree; + DROP TEMPORARY TABLE tmp.item; +SELECT 7; + +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 `clean` */; +/*!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 `clean`() BEGIN DECLARE vDateShort DATETIME; @@ -48662,6 +49028,9 @@ BEGIN DELETE FROM itemShelving WHERE created < CURDATE() AND visible = 0; DELETE FROM ticketDown WHERE created < TIMESTAMPADD(DAY,-1,CURDATE()); DELETE FROM entryLog WHERE creationDate < vDateShort; + DELETE g FROM glsExpedition g + JOIN expedition e ON e.id = g.expeditionFk + WHERE e.created < v26Month; DELETE FROM expedition WHERE created < v26Month; DELETE FROM sms WHERE created < v18Month; DELETE FROM saleTracking WHERE created < vDateShort; @@ -48786,6 +49155,9 @@ BEGIN -- Borra los ficheros gestDoc INSERT INTO vn.printServerQueue(priorityFk, labelReportFk)VALUES(1,11); + + -- Borra los registros de collection y ticketcollection + DELETE FROM vn.collection WHERE created < vDateShort; DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete; DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete; @@ -49230,6 +49602,10 @@ BEGIN FETCH cur INTO vCreated, vIssued, vBalance; + IF vDate IS NULL THEN + SET vDate=vIssued; + END IF; + IF vDone THEN LEAVE proc; END IF; @@ -50228,7 +50604,7 @@ BEGIN SET SESSION group_concat_max_len = 1000000; -- IF (DAY(CURDATE()) = 5) THEN INSERT INTO - vn.mail (sender, + vn.mail (receiver, replyTo, subject, body) @@ -50251,9 +50627,9 @@ BEGIN CMR Ticket - - ', GROUP_CONCAT(' ', c.id, ' ', c.ticketFk, ' ' ORDER BY c.id SEPARATOR '' ), ' - + ' + , GROUP_CONCAT(' ', c.id, ' ', c.ticketFk, ' ' ORDER BY c.id SEPARATOR '' ), + '

Saludos cordiales, Dpto administración. @@ -50367,7 +50743,8 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.`grouping`; CREATE TEMPORARY TABLE tmp.`grouping` - ENGINE MEMORY + (INDEX(itemFk)) + ENGINE = MEMORY SELECT b.itemFk, CASE b.groupingMode WHEN 0 THEN 1 @@ -50377,7 +50754,7 @@ BEGIN FROM buy b JOIN cache.last_buy lb ON lb.buy_id = b.id WHERE lb.warehouse_id = vWarehouseFk - ; + GROUP BY b.itemFk; DROP TEMPORARY TABLE IF EXISTS tmp.grouping2; CREATE TEMPORARY TABLE tmp.grouping2 @@ -50446,14 +50823,14 @@ BEGIN UPDATE tmp.salePlacementList s1 JOIN tmp.salePlacementList_3 s3 ON s3.saleFk = s1.saleFk SET s1.saleOrder = s3.saleOrder; - - -- Nuevo campaña + /* + -- Anula el orden de antigüedad y ordena por ubicación */ UPDATE tmp.salePlacementList SET saleOrder = `order`; - + SELECT * FROM tmp.salePlacementList - ORDER BY saleOrder, IF(isPreviousPrepared,2,1), IF(visible > 0 OR itemShelvingSaleFk,1,2),priority; + ORDER BY visible <> 0 DESC,saleOrder, IF(isPreviousPrepared,2,1), IF(itemShelvingSaleFk,1,2),priority; DROP TEMPORARY TABLE tmp.sale, @@ -50473,9 +50850,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 = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!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 ;; @@ -50537,7 +50914,7 @@ CALL util.debugAdd("vCollectionFk",vn.getUser()); s.itemFk, s.quantity, i.longName, - i.size, + i.size, s.reserved, MAX(IF(st.semaphore <=> 1, TRUE, FALSE)) as isPreviousPrepared, MAX(IF(st.semaphore <=> 2, TRUE, FALSE)) as isPrepared, @@ -50555,18 +50932,27 @@ CALL util.debugAdd("vCollectionFk",vn.getUser()); LPAD(s.concept,30,' '), ' ', RPAD(IFNULL(i.size,''),5,' ') ) - ) as line1, + ) as line1, + '' cel1, TRIM(CONCAT(LPAD(IFNULL(ip.productor,''),30,' '), ' ',LPAD(IFNULL(o.code,''),4,' '))) as line2, + IF(s.quantity MOD b.packing, + CONCAT(CAST(s.quantity/b.`grouping` AS decimal(10,0)),' x ',b.`grouping`), + CONCAT(CAST(s.quantity / b.packing AS DECIMAL(10,0)),' pack de ',b.packing)) cel2, TRIM(CONCAT(ic.color, IF(MAX(IF(st.semaphore <=> 1, TRUE, FALSE)) AND t.id != t.showTicketFk, CONCAT(' [ TICKET ',t.id,' ] '),''), IFNULL(LPAD(st.parkingCode,40,' '),''))) as line3, + '' cel3, s.isAdded, str.originalQuantity as startQuantity, -- eliminar cuando tengamos la nueva apk c.workerFk, IFNULL(SUM(iss.quantity),0) as pickedQuantity FROM vn.sale s JOIN tmp.ticket t ON t.id = s.ticketFk + JOIN vn.ticket tt ON tt.id = t.id + JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND lb.warehouse_id = tt.warehouseFk + JOIN vn.buy b ON b.id = lb.buy_id JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.ticketCollection tc ON tc.ticketFk = t.id - JOIN vn.collection c ON c.id = tc.collectionFk + JOIN vn.collection c ON c.id = tc.collectionFk LEFT JOIN vn.saleTracking str ON str.saleFk = s.id AND str.isChecked = 1 LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id LEFT JOIN vn.state st ON st.id = str.stateFk @@ -50688,9 +51074,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 ;; @@ -50707,7 +51093,10 @@ BEGIN INTO vCollectionFk, vItemPackingTypeFk FROM vn.collection WHERE id = vParamFk; - + + -- Sergio debug insertado el 13-10-2021 +-- CALL util.debugAdd("collectionTicket_get",vn.getUser()); + IF !(vItemPackingTypeFk <=> 'V') THEN IF vCollectionFk THEN @@ -50851,6 +51240,50 @@ BEGIN CALL vn.sale_calculateComponent(vSaleFk, null); +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 `collection_checkFullyControlled` */; +/*!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 `collection_checkFullyControlled`(vWorkerFk INT, vCollectionFk INT ) +BEGIN +/** + * Comprueba que no hay ningún ticket pendiente de revisar de alguna colección del trabajador haya revisado ya + * @param vWorkerFk id del user + * @param vCollectionFk número de colección escaneada + * + */ + + SELECT tc.collectionFk + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN ticketCollection tc ON tc.ticketFk = t.id + JOIN (SELECT tc.collectionFk + FROM ticketState ts + JOIN ticketCollection tc ON tc.ticketFk = ts.ticketFk + WHERE ts.workerFk = vWorkerFk + AND tc.collectionFk <> vCollectionFk + AND tc.created >= CURDATE() + GROUP BY tc.collectionFk + )sub ON sub.collectionFk = tc.collectionFk + JOIN ticketState ts ON ts.ticketFk = t.id + WHERE t.shipped >= CURDATE() + AND ts.code IN ('ON_PREPARATION', 'PREPARED', 'PREVIOUS_PREPARATION', 'OK PREVIOUS') + AND s.quantity <>0 + + LIMIT 1; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -50941,6 +51374,73 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `collection_getTickets`(vParamFk INT) +BEGIN +/** + * Selecciona los tickets de una colección/ticket + * @param vParamFk ticketFk/collectionFk + * @return Retorna ticketFk, level, agencyName, warehouseFk, salesPersonFk, observaciones + */ + DECLARE vItemPackingTypeFk VARCHAR(1); + + -- Si los sacadores son los de pruebas, pinta los colores + SELECT itemPackingTypeFk INTO vItemPackingTypeFk + FROM vn.collection + WHERE id = vParamFk; + + SELECT t.id ticketFk, + IF (!(vItemPackingTypeFk <=> 'V'), cc.code,CONCAT(SUBSTRING('ABCDEFGH',tc.wagon, 1),'-',tc.`level` )) `level`, + am.name agencyName, + t.warehouseFk, + w.id salesPersonFk, + IFNULL(tob.description,'') observaciones + FROM vn.ticket t + LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN vn.collectionColors cc ON cc.wagon = tc.wagon + AND cc.shelve = tc.`level` + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk + LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id + AND tob.observationTypeFk = 1 + WHERE t.id = vParamFk + AND t.shipped >= CURDATE() + UNION ALL + SELECT t.id ticketFk, + IF(!(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`, + am.name agencyName, + t.warehouseFk, + w.id salesPersonFk, + IFNULL(tob.description, '') observaciones + FROM vn.ticket t + JOIN vn.ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN vn.collectionColors cc ON cc.wagon = tc.wagon + AND cc.shelve = tc.`level` + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk + LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id + AND tob.observationTypeFk = 1 + WHERE tc.collectionFk = vParamFk; + +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 `collection_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 `collection_getTickets__`(vParamFk INT) BEGIN DECLARE vAlertLevel INT; @@ -51045,24 +51545,23 @@ BEGIN IF vTicketFk IS NULL THEN SELECT c.name , co.id INTO vClientName,vConsignatario - FROM vn.client c - INNER JOIN vn.address co ON c.id = co.clientFk - WHERE c.id = vClientFk - LIMIT 1; + FROM vn.client c + INNER JOIN vn.address co ON c.id = co.clientFk + WHERE c.id = vClientFk + LIMIT 1; - INSERT INTO vn.ticket (clientFk,warehouseFk,shipped,nickname,addressFk,workerFk,agencyModeFk) - VALUES (vClientFk,vWarehouseFk,NOW(),vClientName,vConsignatario,vn.getUser(),2); + CALL ticketCreateWithUser(vClientFk, NOW(), vWarehouseFk, 442, vConsignatario, NULL, NULL, NULL, account.userGetId(), vTicketFk); SELECT t.id INTO vTicketFk FROM vn.ticket t WHERE t.created > DATE_SUB(NOW(), INTERVAL 1 DAY) AND t.clientFk = vClientFk AND t.warehouseFk = vWarehouseFk LIMIT 1; END IF; INSERT INTO vn.sale (itemFk, ticketFk, concept, quantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded) - SELECT itemFk, vTicketFk, CONCAT(concept," ",vn.getWorkerCode(), " ",LEFT(CAST(NOW() AS TIME),5)), vQuantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded - FROM vn.sale s WHERE s.id = vSaleFk; + SELECT itemFk, vTicketFk, CONCAT(concept," ",vn.getWorkerCode(), " ",LEFT(CAST(NOW() AS TIME),5)), vQuantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded + FROM vn.sale s WHERE s.id = vSaleFk; SELECT quantity INTO vOriginalQuantity FROM vn.sale WHERE id = vSaleFk; - UPDATE vn.sale SET originalQuantity = vOriginalQuantity ,quantity = vNewQuantity WHERE id = vSaleFk; + UPDATE vn.sale SET originalQuantity = vOriginalQuantity ,quantity = vNewQuantity WHERE id = vSaleFk; END ;; DELIMITER ; @@ -51588,534 +52087,6 @@ proc:BEGIN DROP TEMPORARY TABLE tmp.ticketToSplit; -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 `collection_newSmartTag2` */; -/*!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 `collection_newSmartTag2`(vSectorFk INT) -proc:BEGIN - - DECLARE vIsPreviousPrepared BOOLEAN; - DECLARE vCollectionFk INT; - DECLARE vWarehouseFk INT; - DECLARE vMaxTickets INT; - DECLARE vStateFk INT; - DECLARE vFirstTicketFk INT; - DECLARE vHour INT; - DECLARE vMinute INT; - DECLARE vWorker INT; - DECLARE vWorkerCode VARCHAR(3); - DECLARE vWagon INT; - DECLARE vWagonCounter INT; - DECLARE vShelve INT; - DECLARE vTicket INT; - DECLARE vTicketToSplit INT; - DECLARE myUserIsSalesPersonRole BOOLEAN; - DECLARE vPrintedTickets INT; - DECLARE vMaxTicketPrinted INT; - DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE hasAssignedTickets BOOLEAN; - DECLARE vMaxNotReadyCollections INT DEFAULT 0; - DECLARE vNotReadyCollections INT; - DECLARE vSectorCode VARCHAR(20); - DECLARE vWagons INT; - - /* SELECT w.code, w.id INTO vWorkerCode, vWorker - FROM vn.worker w - WHERE w.id = vn.getUser(); - */ - - SELECT 'VLC', 19263 INTO vWorkerCode, vWorker; - --- Si hay colecciones sin terminar, sale del proceso - SELECT count(*) INTO vNotReadyCollections - FROM vn.collection c - WHERE c.workerFk = 19263 - AND c.saleTotalCount > c.salePickedCount + 1 - AND c.created > TIMESTAMPADD(HOUR , -5,NOW()); - - IF vMaxNotReadyCollections < vNotReadyCollections THEN - - LEAVE proc; - - END IF; - - -- Establecemos el almacén y si es un sector de preparación previa, así como el estado para los tickets que se vayan preparando - SELECT isPreviousPrepared, warehouseFk, itemPackingTypeFk, code - INTO vIsPreviousPrepared, vWarehouseFk, vItemPackingTypeFk, vSectorCode - FROM vn.sector - WHERE id = vSectorFk; - - -- Cogemos el numero de wagons del trabajador - SELECT COUNT(ws.id) - FROM vn.workerShelving ws - WHERE ws.workerFk = vWorker - AND ws.collectionFk IS NULL - INTO vWagons; - - SET vMaxTicketPrinted = 6 * vWagons; - SET vMaxTickets = 3 * vWagons; - - - IF vIsPreviousPrepared THEN - - LEAVE proc; -- Hasta que tengamos el altillo, vamos a cancelar esta opcion - - SELECT id INTO vStateFk - FROM vn.state - WHERE `code` = 'PREVIOUS_PREPARATION'; - ELSE - - SELECT id INTO vStateFk - FROM vn.state - WHERE `code` = 'ON_PREPARATION'; - - END IF; - - -- Averiguamos si es comercial el usuario - SELECT FALSE -- (r.name = 'salesPerson') - INTO myUserIsSalesPersonRole - FROM account.user u - JOIN account.role r ON r.id = u.role - WHERE u.id = 19263; - - -- Se obtiene nº de colección y el buffer con los pedidos preparables - INSERT INTO vn.collection - SET workerFk = 19263, - itemPackingTypeFk = vItemPackingTypeFk; - - SELECT LAST_INSERT_ID() INTO vCollectionFk; - - - UPDATE workerShelving - SET collectionFk = vCollectionFk - WHERE workerFk = vWorker - AND collectionFk IS NULL; - - CALL vn.productionControl(vWarehouseFk, 0); - - -- Comprobamos si hay tickets asignados. En ese caso, nos centramos exclusivamente en esos tickets - -- y los sacamos independientemente de problemas o tamaños - SELECT COUNT(*) INTO hasAssignedTickets - FROM tmp.productionBuffer pb - JOIN vn.state s ON s.id = pb.state - WHERE s.code = 'PICKER_DESIGNED' - AND pb.workerCode = vWorkerCode - AND LENGTH(pb.problem) = 0; - - IF hasAssignedTickets THEN - - UPDATE vn.collection - SET itemPackingTypeFk = NULL - WHERE id = vCollectionFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketToSplit; - CREATE TEMPORARY TABLE tmp.ticketToSplit - SELECT pb.ticketFk - FROM tmp.productionBuffer pb - JOIN vn.state s ON s.id = pb.state - WHERE s.code = 'PICKER_DESIGNED' - AND pb.workerCode = vWorkerCode - AND LENGTH(pb.problem) = 0 - ORDER BY HH, - mm, - s.`order` DESC, - pb.m3 DESC; - - WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO - - SELECT MIN(ticketFk) INTO vTicketToSplit - FROM tmp.ticketToSplit; - - CALL vn.ticket_splitItemPackingType(vTicketToSplit); - - INSERT INTO vn.ticketCollection(ticketFk, collectionFk) - SELECT ticketFk, vCollectionFk - FROM tmp.ticketIPT; - - DELETE FROM tmp.ticketToSplit - WHERE ticketFk = vTicketToSplit; - - DROP TEMPORARY TABLE tmp.ticketIPT; - - END WHILE; - - CALL vn.productionControl(vWarehouseFk, 0); - - ELSE - - SELECT COUNT(*) INTO vPrintedTickets - FROM tmp.productionBuffer pb - JOIN vn.state s ON s.id = pb.state - JOIN vn.agencyMode am ON am.id = pb.agencyModeFk - JOIN vn.agency a ON a.id = am.agencyFk - WHERE pb.shipped = CURDATE() - AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) - AND s.isPreparable - AND (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH) - OR pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV) - OR pb.F > 0 AND vItemPackingTypeFk = 'F' AND ISNULL(pb.collectionF) - OR pb.P > 0 AND vItemPackingTypeFk = 'P' AND ISNULL(pb.collectionP)); - - SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets; - -- AutoPRINT - - IF vMaxTicketPrinted > 0 THEN - - INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT s2.id, pb.ticketFk, 19263 - FROM tmp.productionBuffer pb - JOIN vn.agencyMode am ON am.id = pb.agencyModeFk - JOIN vn.agency a ON a.id = am.agencyFk - JOIN vn.state s ON s.id = pb.state - JOIN vn.state s2 ON s2.code = 'PRINTED_AUTO' - JOIN vn.ticket t ON t.id = pb.ticketFk - WHERE pb.shipped = CURDATE() - AND LENGTH(pb.problem) = 0 - AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) - AND s.isPrintable - AND (pb.m3 > 0.05 OR s.isOK) - AND (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH) - OR pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV) - OR pb.F > 0 AND vItemPackingTypeFk = 'F' AND ISNULL(pb.collectionF) - OR pb.P > 0 AND vItemPackingTypeFk = 'P' AND ISNULL(pb.collectionP)) - AND t.created < TIMESTAMPADD(MINUTE, -10, NOW()) - ORDER BY HH, - mm, - s.`order` DESC, - pb.m3 DESC - LIMIT vMaxTicketPrinted; - - END IF; - - -- Se seleccionan los primeros tickets, asignando colección para dejarlos bloqueados a otros sacadores. - -- Se splitan los tickets preparables, para que solo tengan un tipo de empaquetado - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketToSplit; - CREATE TEMPORARY TABLE tmp.ticketToSplit - SELECT pb.ticketFk - FROM tmp.productionBuffer pb - JOIN vn.agencyMode am ON am.id = pb.agencyModeFk - JOIN vn.agency a ON a.id = am.agencyFk - JOIN vn.ticketStateToday tst ON tst.ticket = pb.ticketFk - JOIN vn.state s ON s.id = tst.state - WHERE ( pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH) - OR pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV) - OR pb.F > 0 AND vItemPackingTypeFk = 'F' AND ISNULL(pb.collectionF) - OR pb.P > 0 AND vItemPackingTypeFk = 'P' AND ISNULL(pb.collectionP)) - AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) - AND LENGTH(pb.problem) = 0 - AND s.isPreparable - AND NOT myUserIsSalesPersonRole - ORDER BY pb.HH, pb.mm, s.`order` DESC - LIMIT vMaxTickets; - - WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO - - SELECT MIN(ticketFk) INTO vTicketToSplit - FROM tmp.ticketToSplit; - - CALL vn.ticket_splitItemPackingType(vTicketToSplit); - - INSERT INTO vn.ticketCollection(ticketFk, collectionFk) - SELECT ticketFk, vCollectionFk - FROM tmp.ticketIPT - WHERE itemPackingTypeFk = vItemPackingTypeFk; - - DELETE FROM tmp.ticketToSplit - WHERE ticketFk = vTicketToSplit; - - DROP TEMPORARY TABLE tmp.ticketIPT; - - END WHILE; - - END IF; - - -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - CREATE TEMPORARY TABLE tmp.ticket - SELECT pb.ticketFk, - pb.`lines`, - pb.m3 * 1000 liters, - 0 as height, - 0 as shelve, - 0 as wagon, - pb.productionOrder, - pb.HH, - pb.mm - FROM tmp.productionBuffer pb - JOIN vn.ticketCollection tc ON tc.ticketFk = pb.ticketFk - WHERE tc.collectionFk = vCollectionFk - LIMIT vMaxTickets; - - -- Es importante que el primer ticket se coja en todos los casos - SET vFirstTicketFk = 0; - - SELECT ticketFk, HH, mm - INTO vFirstTicketFk, vHour, vMinute - FROM tmp.ticket - ORDER BY productionOrder DESC, HH, mm - LIMIT 1; - - -- Hay que excluir aquellos que no tengan la misma hora de preparación - DELETE - FROM tmp.ticket - WHERE HH != vHour - OR mm != vMinute; - - -- En el caso de pedidos de más volumen de un carro, la colección será monoticket. Pero si el primer pedido - -- no es monoticket, excluimos a los de más de un carro - IF (SELECT (t.liters > vc.trolleyM3 * 1000) - FROM tmp.ticket t - JOIN vn.volumeConfig vc - WHERE t.ticketFk = vFirstTicketFk) THEN - - DELETE - FROM tmp.ticket - WHERE ticketFk != vFirstTicketFk; - - ELSE - - DELETE t.* - FROM tmp.ticket t - JOIN vn.volumeConfig vc - WHERE t.liters > vc.trolleyM3 * 1000; - - END IF; - - -- Elimina los tickets bloqueados que no se van a preparar - DELETE tc.* - FROM vn.ticketCollection tc - LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk - AND t.ticketFk IS NULL; - - /* - * - * Construccion del tren - * - */ - - -- Establece altura máxima por pedido, porque las plantas no se pueden recostar. - UPDATE tmp.ticket t - JOIN - ( SELECT MAX(i.size) maxHeigth, - tc.ticketFk - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - JOIN vn.item i ON i.id = s.itemFk - WHERE i.itemPackingTypeFk = 'V' - AND tc.collectionFk = vCollectionFk - GROUP BY tc.ticketFk) sub ON sub.ticketFk = t.ticketFk - SET t.height = IFNULL(sub.maxHeigth,0); - - -- Vamos a generar una tabla con todas las posibilidades de asignacion de pedido - DROP TEMPORARY TABLE IF EXISTS tmp.wagonsVolumetry; - CREATE TEMPORARY TABLE tmp.wagonsVolumetry - SELECT cv.`level` as shelve, - 1 as wagon, - cv.`lines`, - cv.liters, - cv.height - FROM vn.collectionVolumetry cv; - - SET vWagonCounter = 1; - - WHILE vWagonCounter < vWagons DO - - SET vWagonCounter = vWagonCounter + 1; - - INSERT INTO tmp.wagonsVolumetry(shelve, wagon, `lines`, liters, height) - SELECT cv.`level` as shelve, - vWagonCounter as wagon, - cv.`lines`, - cv.liters, - cv.height - FROM vn.collectionVolumetry cv - WHERE cv.itemPackingTypeFk = IFNULL(vItemPackingTypeFk, 'H'); - - END WHILE; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelve; - CREATE TEMPORARY TABLE tmp.ticketShelve - SELECT ticketFk, shelve, wagon, linesDif, LitersDif, heightDif - FROM ( - SELECT t.ticketFk, - wv.shelve, - wv.wagon, - t.productionOrder, - CAST(wv.`lines` AS SIGNED) - t.`lines` as linesDif, - CAST(wv.liters AS SIGNED) - t.liters as litersDif, - CAST(wv.height AS SIGNED) - t.height as heightDif - FROM tmp.wagonsVolumetry wv - JOIN tmp.ticket t - ) sub - WHERE linesDif >= 0 - AND litersDif >= 0 - AND heightDif >= 0 - ORDER BY productionOrder DESC, linesDif, LitersDif, heightDif ; - - -- Insertamos una opcion virtual para carro completo. Todo ticket tiene que poder entrar en un carro completo.... - INSERT INTO tmp.ticketShelve(ticketFk, shelve, wagon, linesDif, LitersDif, heightDif) - SELECT t.ticketFk, 0, wv.wagon, 999, 999,999 - FROM tmp.ticket t - JOIN tmp.wagonsVolumetry wv - GROUP BY t.ticketFk, wv.wagon; - - SET vWagonCounter = 0; - - WHILE vWagonCounter < vWagons DO - - SET vWagonCounter = vWagonCounter + 1; - - -- Asignamos la primera balda util al primer pedido - IF vWagonCounter = 1 THEN - - SELECT shelve INTO vShelve - FROM tmp.ticketShelve - WHERE ticketFk = vFirstTicketFk - AND wagon = vWagonCounter - ORDER BY heightDif, litersDif, linesDif - LIMIT 1; - - ELSE - - SELECT shelve, ticketFk INTO vShelve, vFirstTicketFk - FROM tmp.ticketShelve - WHERE wagon = vWagonCounter - ORDER BY heightDif, litersDif, linesDif - LIMIT 1; - - END IF; - - IF vShelve > 0 THEN - - UPDATE tmp.ticket - SET shelve = vShelve, - wagon = vWagonCounter - WHERE ticketFk = vFirstTicketFk; - - DELETE FROM tmp.ticketShelve - WHERE ticketFk = vFirstTicketFk - OR (shelve = vShelve AND wagon = vWagonCounter); - - WHILE (SELECT COUNT(*) FROM tmp.ticketShelve WHERE wagon = vWagonCounter) DO - - SELECT ticketFk, shelve - INTO vTicket, vShelve - FROM tmp.ticketShelve - WHERE wagon = vWagonCounter - LIMIT 1; - - UPDATE tmp.ticket - SET shelve = vShelve, - wagon = vWagonCounter - WHERE ticketFk = vTicket; - - DELETE FROM tmp.ticketShelve - WHERE ticketFk = vTicket - OR (shelve = vShelve AND wagon = vWagonCounter); - - END WHILE; - - ELSE - - UPDATE tmp.ticket - SET shelve = 1, wagon = vWagonCounter - WHERE ticketFk = vFirstTicketFk; - - DELETE FROM tmp.ticketShelve - WHERE ticketFk = vFirstTicketFk - AND wagon != vWagonCounter; - - END IF; - - END WHILE; - - -- Eliminamos los que se han quedado sin balda - DELETE FROM tmp.ticket WHERE shelve = 0; - - -- Elimina los tickets bloqueados que no se van a preparar - DELETE tc.* - FROM vn.ticketCollection tc - LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk - AND t.ticketFk IS NULL; - - -- Elimina los tickets que ya estan en otra coleccion - DELETE tc.* - FROM vn.ticketCollection tc - JOIN vn.ticketCollection tc2 ON tc2.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk - AND tc2.collectionFk != vCollectionFk; - - -- Actualiza el estado de la colección - UPDATE vn.collection c - JOIN vn.state st ON st.code = 'ON_PREPARATION' - SET c.stateFk = st.id - WHERE c.id = vCollectionFk; - - -- Asigna las bandejas y las smartTags - SET @wagon := 0; - UPDATE vn.ticketCollection tc - JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk - JOIN (SELECT @wagon:=@wagon+1 as wagon, ws.shelvingFk - FROM workerShelving ws - WHERE ws.collectionFk = vCollectionFk) sub ON sub.wagon = t.wagon - JOIN smartTag s ON s.shelvingFk = sub.shelvingFk AND s.`level` = t.shelve - SET tc.`level` = t.shelve, tc.wagon = t.wagon, tc.smartTagFk = s.code; - - -- Actualiza el estado de los tickets - INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT vStateFk, ticketFk, 19263 - FROM vn.ticketCollection tc - WHERE tc.collectionFk = vCollectionFk; - - -- Aviso para la preparacion previa - INSERT INTO vn.ticketDown(ticketFk, collectionFk) - SELECT tc.ticketFk, tc.collectionFk - FROM vn.ticketCollection tc - WHERE tc.collectionFk = vCollectionFk; - - IF (SELECT count(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk) THEN - - CALL vn.salesMerge_byCollection(vCollectionFk); - - UPDATE vn.collection c - JOIN (SELECT count(*) saleTotalCount , - sum(s.isPicked != 0) salePickedCount - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk - AND s.quantity > 0 - ) sub - SET c.saleTotalCount = sub.saleTotalCount, - c.salePickedCount = sub.salePickedCount - WHERE c.id = vCollectionFk; - - SELECT vCollectionFk; - - ELSE - - DELETE FROM vn.collection WHERE id = vCollectionFk; - -- SELECT NULL; - - END IF; - - DROP TEMPORARY TABLE tmp.ticketToSplit; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -52157,12 +52128,16 @@ proc:BEGIN DECLARE vMaxNotReadyCollections INT DEFAULT 0; DECLARE vNotReadyCollections INT; DECLARE vSectorCode VARCHAR(20); -/* - IF vn.getUser() = 18890 THEN - CALL collection_newSmartTag(vSectorFk); + + /*IF NOT vn.deviceProductionUser_Exists(vn.getUser()) THEN + LEAVE proc; + END IF;*/ + CALL util.debugAdd('vn.collection_newWithWagon',CONCAT('sector: ',vSectorFk,' wagons:',vWagons)); + + SELECT w.code INTO vWorkerCode FROM vn.worker w WHERE w.id = vn.getUser(); @@ -53527,7 +53502,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 `cristalBall` */; +/*!50003 DROP PROCEDURE IF EXISTS `cristalBall__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -53537,7 +53512,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `cristalBall`() +CREATE DEFINER=`root`@`%` PROCEDURE `cristalBall__`() BEGIN /* *se utiliza en campaña @@ -53577,7 +53552,7 @@ FROM JOIN bi.rotacion r ON r.Id_Article = e.item_id AND r.warehouse_id = e.warehouse_id WHERE e.dat BETWEEN CURDATE() AND vLastDate AND e.warehouse_id = vWarehouse - AND ic.merchandise + AND ic.display AND e.isVirtualStock is FALSE GROUP BY e.dat, e.item_id @@ -53597,7 +53572,7 @@ FROM JOIN bi.rotacion r ON r.Id_Article = s.item_id AND r.warehouse_id = s.warehouse_id WHERE s.dat BETWEEN CURDATE() AND vLastDate AND s.warehouse_id = vWarehouse - AND ic.merchandise + AND ic.display GROUP BY date(s.dat), s.item_id UNION ALL @@ -53615,7 +53590,7 @@ FROM JOIN vn.itemCategory ic ON ic.id = it.categoryFk JOIN bi.rotacion r ON r.Id_Article = st.item_id AND r.warehouse_id = st.warehouse_id WHERE st.warehouse_id = vWarehouse - AND ic.merchandise + AND ic.display ) sub ORDER BY itemFk, dat, entra DESC) sub2 @@ -53786,79 +53761,74 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `dayMinuteWorker`(vDateFrom DATETIME, vDateTo DATETIME) BEGIN -DECLARE vDateStart DATETIME DEFAULT DATE(vDateFrom); -DECLARE vDateEnd DATETIME DEFAULT util.dayEnd(vDateTo); + DECLARE vDateStart DATE DEFAULT vDateFrom; + DECLARE vDateEnd DATETIME DEFAULT util.dayEnd(vDateTo); -SET @ordr := 0; -SET @user := 0; - -DROP TEMPORARY TABLE IF EXISTS tmp.dayMinuteWorker; -CREATE TEMPORARY TABLE tmp.dayMinuteWorker - ENGINE = MEMORY - SELECT sub3.id, - sub3.hh as Hora, - sub3.mm as Minuto, - sub3.userFk, - sub3.code as CodigoTrabajador, - sub3.firstname as Nombre, - sub3.lastName as Apellidos, - sub3.warehouseFk as Almacen, - w.name as NombreAlmacen - FROM vn.warehouse w - JOIN - ( - SELECT id, - hh, - mm, - userFk, - code, - firstname, - lastName, - @ordr := IF(@user != userFk,0,@ordr), - IF(@ordr MOD 2, 'presente','--') as estado, - @ordr := IFNULL(sub2.`order`,@ordr), - @user := IFNULL(sub2.`userFk`,@user), - warehouseFk - FROM - ( - SELECT dm.id, - dm.hh, - dm.mm, - users.userFk, - sub.`order`, - users.code, - firstName, - lastName, - users.warehouseFk - FROM dayMinute dm - JOIN - ( - SELECT DISTINCT wtc.userFk , - code , - firstName, - lastName, - IFNULL(warehouseFk,1) warehouseFk - FROM vn.workerTimeControl wtc - JOIN vn.worker w ON w.userFk = wtc.userFk - WHERE timed BETWEEN vDateStart AND vDateEnd - ) users - - LEFT JOIN - ( - SELECT `order`, - wtc.userFk, - hour(timed) * 100 + minute(timed) as dayMinuteFk - FROM vn.workerTimeControl wtc - WHERE timed BETWEEN vDateStart AND vDateEnd - ORDER BY wtc.userFk, `order` - ) sub ON sub.dayMinuteFk = dm.id AND sub.userFk = users.userFk - ORDER BY userFk,dm.id - ) sub2 - ) sub3 ON sub3.warehouseFk = w.id - WHERE estado = 'presente' - AND sub3.id BETWEEN HOUR(vDateFrom) *100 + MINUTE(vDateFrom) AND HOUR(vDateTo) *100 + MINUTE(vDateTo); --- SELECT * FROM tmp.dayMinuteWorker; + SET @ordr := 0; + SET @user := 0; + DROP TEMPORARY TABLE IF EXISTS tmp.dayMinuteWorker; + CREATE TEMPORARY TABLE tmp.dayMinuteWorker + SELECT sub3.id, + sub3.hh AS `Hour`, + sub3.mm AS Minut, + sub3.userFk, + sub3.code AS workerCode, + sub3.firstname AS name, + sub3.lastName AS surnames, + sub3.workcenterFk AS center, + w.name AS centerName, + w2.name AS warehouseName, + w2.hasProduction AS production + FROM postgresql.workcenter w + JOIN(SELECT id, + hh, + mm, + userFk, + code, + firstname, + lastName, + @ordr := IF(@user != userFk,0,@ordr), + IF(@ordr MOD 2, 'presente','--') AS state, + @ordr := IFNULL(sub2.`order`,@ordr), + @user := IFNULL(sub2.`userFk`,@user), + workcenterFk + FROM(SELECT dm.id, + dm.hh, + dm.mm, + users.userFk, + sub.`order`, + users.code, + firstName, + lastName, + users.workcenterFk + FROM dayMinute dm + JOIN(SELECT DISTINCT wtc.userFk , + code , + firstName, + lastName, + wl.workCenterFk + FROM vn.workerTimeControl wtc + JOIN vn.worker w ON w.userFk = wtc.userFk + JOIN vn.workerLabour wl ON wl.workerFK = w.id + AND wtc.timed BETWEEN wl.started AND IFNULL(wl.ended, CURDATE()) + WHERE wtc.timed BETWEEN vDateStart AND vDateEnd + ) users + LEFT JOIN(SELECT `order`, + wtc.userFk, + hour(wtc.timed) * 100 + minute(wtc.timed) as dayMinuteFk + FROM vn.workerTimeControl wtc + WHERE wtc.timed BETWEEN vDateStart AND vDateEnd + ORDER BY wtc.userFk, `order` + ) sub ON sub.dayMinuteFk = dm.id AND sub.userFk = users.userFk + ORDER BY userFk,dm.id + ) sub2 + ) sub3 ON sub3.workcenterFk = w.workcenter_id + JOIN vn.warehouse w2 ON w2.id = w.warehouseFk + WHERE state = 'presente' + AND sub3.id BETWEEN HOUR(vDateFrom) *100 + MINUTE(vDateFrom) + AND HOUR(vDateTo) *100 + MINUTE(vDateTo); + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -54118,6 +54088,59 @@ BEGIN ORDER BY depth, `name`; DROP TEMPORARY TABLE tNodes; +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 `deviceLog_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 `deviceLog_add`(vWorkerFk INT, vAppName VARCHAR(45), vAppVersion VARCHAR(45), vAndroid_id VARCHAR(100)) +BEGIN +/* + * Inserta registro en tabla devicelog el log del usuario conectado + * @param vAppName es el nombre de la app + * @param vAppVersion es la versión de la app + * @param vAndroid_id es el android_id del dispositivo que se ha logueado + */ + + INSERT INTO deviceLog (userFK, nameApp, versionApp, android_id) + VALUES(vWorkerFk, vAppName, vAppVersion, vAndroid_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 `deviceProductionUser_exists` */; +/*!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 `deviceProductionUser_exists`(vUserFk INT) +BEGIN + + SELECT COUNT(*) AS UserExists + FROM vn.deviceProductionUser dpu + WHERE dpu.userFk = vUserFk; + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -54177,6 +54200,61 @@ BEGIN FROM deviceProduction dp WHERE dp.android_id = vAndroid_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 `device_checkLogin` */; +/*!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 `device_checkLogin`(vUserFk INT, vAndroidID VARCHAR(50)) +BEGIN + +/* + * Comprueba si está registrado el dispositivo mediante su androidId + * + * @param vUSerFk el id del user + * @param vAndroidID es el identificador android_id del dispositivo + */ + DECLARE vIsAuthorized BOOL DEFAULT TRUE; + DECLARE vIsDepartment BOOL; + DECLARE vMessage VARCHAR(200); + + SELECT COUNT(*) INTO vIsDepartment + FROM vn.workerDepartment dp + JOIN department d ON d.id = dp.departmentFk + WHERE dp.workerFk = vUserFk AND d.name = "PRODUCCION"; + + IF vIsDepartment THEN + + SELECT COUNT(*) INTO vIsAuthorized + FROM vn.deviceProductionUser dpu + JOIN vn.deviceProduction dp ON dp.id = dpu.deviceProductionFk + WHERE dpu.userFk = vUserFk + AND dp.android_id = vAndroidID; + + + IF NOT vIsAuthorized THEN + + SET vMessage = 'Usuario no autorizado'; + + END IF; + + END IF; + + + #vIsAuthorized = TRUE; #Descomentar esta linea si se quiere quitar la comprobación de autorizacion + SELECT vIsAuthorized,vMessage; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -55413,7 +55491,7 @@ 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_unicode_ci */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -55473,7 +55551,7 @@ BEGIN NOT wIn.isFeedStock AND NOT e.isInventory AND NOT e.isRaid AND e.id = 158772 AND i.typeFk IS NOT NULL - AND ic.merchandise IS NOT FALSE; + AND ic.display IS NOT FALSE; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -55772,6 +55850,302 @@ 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 `entry_recalc` */; +/*!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 `entry_recalc`() +BEGIN +/** + * Comprueba que las ventas creadas entre un rango de fechas tienen componentes + * + * @param vCreatedFrom inicio del rango + * @param vCreatedTo fin del rango + */ + DECLARE v_done BOOL DEFAULT FALSE; + DECLARE vEntryFk INTEGER; + + DECLARE vCur CURSOR FOR + SELECT e.id FROM vn.entry e + JOIN vn.travel t ON t.id = e.travelFk + WHERE t.shipped >= '2021-10-08' AND t.warehouseInFk= 60; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET v_done = TRUE; + + OPEN vCur; + + l: LOOP + SET v_done = FALSE; + FETCH vCur INTO vEntryFk; + + IF v_done THEN + LEAVE l; + END IF; + + CALL vn2008.buy_tarifas_entry(vEntryFk); + END LOOP; + + CLOSE vCur; +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 `errorProduction_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 `errorProduction_add`(vAction VARCHAR(25), vDepartment VARCHAR(25), vStateCode VARCHAR(25) CHARSET utf8, vDatedFrom DATETIME, vDatedTo DATETIME) +BEGIN + /** + * Fill in the errorProduction table. + */ + DROP TEMPORARY TABLE IF EXISTS tmp.total; + + IF (vDepartment = 'Encajadores') + THEN + CREATE TEMPORARY TABLE tmp.total + ENGINE = MEMORY + SELECT e.workerFk, Count(DISTINCT t.id) AS ticketCount + FROM expedition e + JOIN ticket t ON e.ticketFk = t.id + WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + GROUP BY e.workerFk; + ELSE + CREATE TEMPORARY TABLE tmp.total + ENGINE = MEMORY + SELECT st.workerFk, Count(DISTINCT t.id) AS ticketCount + FROM state ss + JOIN vn.saleTracking st ON st.stateFk = ss.id + JOIN vn.sale s ON s.id = st.saleFk + JOIN ticket t ON s.ticketFk = t.id + WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo) AND ss.code = vStateCode + GROUP BY st.workerFk; + END IF; + + CALL timeControl_calculateAll(vDatedFrom, vDatedTo); + + INSERT INTO errorProduction(userFk, firstname, lastname, rol, ticketNumber, error, ratio, volume, hourStart, hourEnd, hourWorked, dated) + SELECT sub1.id, sub1.firstName, sub1.lastName, + CASE + WHEN vDepartment = 'Encajadores' THEN 'Encajador' + WHEN vDepartment = 'Sacadores' THEN 'Sacador' + ELSE 'Revisador' + END AS rol, + CAST(sub1.totalTickets AS DECIMAL(10,0)) AS totalTickets, + CAST(IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0) AS DECIMAL(10,0)) AS errors, + ((IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0))/sub1.totalTickets)*100 AS ratio, + IF(vDepartment = 'Revisadores', NULL, volume) AS volume, + sub1.hourStart AS hourStart, + sub1.hourEnd AS hourEnd, + sub1.hourWorked AS hourWorked, + vDatedFrom AS date + FROM( + SELECT w.id, w.code, w.firstName, w.lastName, t.ticketCount AS totalTickets, sub.errors, sub2.volume, SUBSTRING(tc.timed, 1, 5) AS hourStart, SUBSTRING(tc.timed, LENGTH(tc.timed)-4, 5) AS hourEnd, IFNULL(CAST(tc.timeWorkDecimal AS DECIMAL (10,2)) , 0) AS hourWorked + FROM tmp.total AS t + JOIN worker w ON w.id = t.workerFk + JOIN tmp.timeControlCalculate tc ON tc.userFk = t.workerFk + LEFT JOIN ( + SELECT COUNT(c.ticketFk) AS errors, cd.workerFk + FROM claimDevelopment cd + JOIN claim c ON cd.claimFk = c.id + JOIN ticket t ON c.ticketFk = t.id + 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 t.workerFk = sub.workerFk + LEFT JOIN ( -- Añadir volume + SELECT SUM(w.volume) AS volume, w.workerFk + FROM bs.workerProductivity w + INNER JOIN vn.`role` r ON r.id=w.roleFk + WHERE IF(vDepartment = 'Encajadores', r.name='packager', r.name='itemPicker') AND w.dated BETWEEN vDatedFrom AND vDatedTo + GROUP BY w.workerFk) sub2 ON w.id = sub2.workerFk + GROUP BY w.code) sub1 + LEFT JOIN( + SELECT sub1.workerFk, COUNT(id) AS errors + FROM ( + SELECT st.workerFk, t.id + FROM vn.saleMistake sm + JOIN vn.saleTracking st ON sm.saleFk = st.saleFk + JOIN state ss ON ss.id = st.stateFk + JOIN vncontrol.accion a ON a.accion_id = st.actionFk + JOIN vn.sale s ON s.id = sm.saleFk + JOIN vn.ticket t on t.id = s.ticketFk + WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo) AND a.accion = vAction AND ss.code = vStateCode + GROUP BY s.ticketFk + ) sub1 + GROUP BY sub1.workerFk) sub2 ON sub2.workerFk = sub1.id; + + DROP TEMPORARY TABLE tmp.timeControlCalculate; + DROP TEMPORARY TABLE tmp.total; +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 `errorProduction_addLauncher` */; +/*!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 `errorProduction_addLauncher`() +BEGIN + DECLARE vDatedFrom DATETIME; + DECLARE vDatedTo DATETIME; + + SELECT DATE_SUB(CURDATE(),INTERVAL 1 DAY), CONCAT(DATE_SUB(CURDATE(),INTERVAL 1 DAY),' 23:59:59') INTO vDatedFrom, vDatedTo; + + CALL vn.errorProduction_add('SACAR' ,'Sacadores','PREPARED', vDatedFrom, vDatedTo); + CALL vn.errorProduction_add('ENCAJAR' ,'Encajadores','PACKED', vDatedFrom, vDatedTo); + CALL vn.errorProduction_add('CONTROLAR' ,'Revisadores','CHECKED', vDatedFrom, vDatedTo); +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 `errorProduction_addLauncher__` */; +/*!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 `errorProduction_addLauncher__`() +BEGIN + DECLARE vDatedFrom DATETIME; + DECLARE vDatedTo DATETIME; + + IF (DAY(CURDATE()) = 5) THEN + SELECT util.firstDayOfMonth(DATE_SUB(CURDATE(),INTERVAL 1 MONTH)), CONCAT(LAST_DAY(DATE_SUB(CURDATE(),INTERVAL 1 MONTH)),' 23:59:59') INTO vDatedFrom, vDatedTo; + + CALL vn.errorProduction_add('SACAR' ,'Sacadores','PREPARED', vDatedFrom, vDatedTo); + CALL vn.errorProduction_add('ENCAJAR' ,'Encajadores','PACKED', vDatedFrom, vDatedTo); + CALL vn.errorProduction_add('CONTROLAR' ,'Revisadores','CHECKED', vDatedFrom, vDatedTo); + 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 `errorProduction_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 `errorProduction_add__`(vAction VARCHAR(25), vDepartment VARCHAR(25), vStateCode VARCHAR(25) CHARSET utf8, vDatedFrom DATETIME, vDatedTo DATETIME) +BEGIN + /** + * Fill in the errorProduction table. + */ + DROP TEMPORARY TABLE IF EXISTS tmp.total; + + IF (vDepartment = 'Encajadores') + THEN + CREATE TEMPORARY TABLE tmp.total + ENGINE = MEMORY + SELECT e.workerFk, Count(DISTINCT t.id) AS ticketCount + FROM expedition e + JOIN ticket t ON e.ticketFk = t.id + WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + GROUP BY e.workerFk; + ELSE + CREATE TEMPORARY TABLE tmp.total + ENGINE = MEMORY + SELECT st.workerFk, Count(DISTINCT t.id) AS ticketCount + FROM state ss + JOIN vn.saleTracking st ON st.stateFk = ss.id + JOIN vn.sale s ON s.id = st.saleFk + JOIN ticket t ON s.ticketFk = t.id + WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo) AND ss.code = vStateCode + GROUP BY st.workerFk; + END IF; + + + INSERT INTO errorProduction(userFk, firstname, lastname, rol, ticketNumber, error, ratio, volume, month, year) + SELECT sub1.id, sub1.firstName, sub1.lastName, + CASE + WHEN vDepartment = 'Encajadores' THEN 'Encajador' + WHEN vDepartment = 'Sacadores' THEN 'Sacador' + ELSE 'Revisador' + END AS rol, + CAST(sub1.totalTickets AS DECIMAL(10,0)) AS totalTickets, + CAST(IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0) AS DECIMAL(10,0)) AS errors, + ((IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0))/sub1.totalTickets)*100 AS ratio, + IF(vDepartment = 'Revisadores', NULL, volume) AS volume, + MONTH(vDatedFrom) AS month, + YEAR(vDatedFrom) AS year + FROM( + SELECT w.id, w.code, w.firstName, w.lastName, t.ticketCount AS totalTickets, sub.errors, sub2.volume + FROM tmp.total AS t + JOIN worker w ON w.id = t.workerFk + LEFT JOIN ( + SELECT COUNT(c.ticketFk) AS errors, cd.workerFk + FROM claimDevelopment cd + JOIN claim c ON cd.claimFk = c.id + JOIN ticket t ON c.ticketFk = t.id + 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 t.workerFk = sub.workerFk + LEFT JOIN ( -- Añadir volume + SELECT SUM(w.volume) AS volume, w.workerFk + FROM bs.workerProductivity w + INNER JOIN vn.`role` r ON r.id=w.roleFk + WHERE IF(vDepartment = 'Encajadores', r.name='packager', r.name='itemPicker') AND w.dated BETWEEN vDatedFrom AND vDatedTo + GROUP BY w.workerFk) sub2 ON w.id = sub2.workerFk + GROUP BY w.code) sub1 + LEFT JOIN( + SELECT sub1.workerFk, COUNT(id) AS errors + FROM ( + SELECT st.workerFk, t.id + FROM vn.saleMistake sm + JOIN vn.saleTracking st ON sm.saleFk = st.saleFk + JOIN state ss ON ss.id = st.stateFk + JOIN vncontrol.accion a ON a.accion_id = st.actionFk + JOIN vn.sale s ON s.id = sm.saleFk + JOIN vn.ticket t on t.id = s.ticketFk + WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo) AND a.accion = vAction AND ss.code = vStateCode + GROUP BY s.ticketFk + ) sub1 + GROUP BY sub1.workerFk) sub2 ON sub2.workerFk = sub1.id; + + DROP TEMPORARY TABLE tmp.total; +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 `expeditionGetFromRoute` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56199,6 +56573,93 @@ BEGIN LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk WHERE e.id = vExpeditionFk; +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 `expedition_StateGet` */; +/*!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 `expedition_StateGet`(vExpeditionFk INT) +BEGIN + + /* Devuelve una "ficha" con todos los datos relativos a la expedición + * + * param vExpeditionFk + */ + + DECLARE vTicketsPendientes INT; + DECLARE vEtiquetasTotales INT; + DECLARE vEtiquetasEscaneadas INT; + DECLARE vEtiquetasLeidasSorter INT; + DECLARE vRouteFk INT; + + SELECT t.routeFk INTO vRouteFk + FROM vn.ticket t + JOIN vn.expedition e ON e.ticketFk = t.id + WHERE e.id = vExpeditionFk; + + SELECT COUNT(*) INTO vTicketsPendientes + FROM vn.ticket t + LEFT JOIN vn.expedition e ON e.ticketFk = t.id + WHERE t.routeFk = vRouteFk + AND ISNULL(e.id); + + SELECT COUNT(*) INTO vEtiquetasTotales + FROM vn.expedition e + JOIN vn.ticket t ON t.id = e.ticketFk + WHERE t.routeFk = vRouteFk; + + SELECT COUNT(*) INTO vEtiquetasEscaneadas + FROM vn.expeditionScan es + JOIN vn.expedition e ON e.id = es.expeditionFk + JOIN vn.ticket t ON t.id = e.ticketFk + WHERE t.routeFk = vRouteFk; + + SELECT COUNT(*) INTO vEtiquetasLeidasSorter + FROM srt.expedition e + JOIN vn.expedition ve ON ve.id = e.id + LEFT JOIN vn.expeditionScan es ON es.expeditionFk = e.id + JOIN vn.ticket t ON t.id = ve.ticketFk + WHERE t.routeFk = vRouteFk + AND e.created != e.updated + AND ISNULL(es.expeditionFk); + + + SELECT e.ticketFk ticket, + t.nickname cliente, + a.city ciudad, + p.name provincia, + z.name zonaTicket, + am.name zonaRuta, + t.routeFk ruta, + rm.beachFk ubicacion, + et.ETD , + et.description camion, + vTicketsPendientes AS ticketsPendientes, + vEtiquetasTotales AS etiquetasTotales, + vEtiquetasEscaneadas AS etiquetasEscaneadas, + vEtiquetasLeidasSorter AS etiquetasSorter + FROM vn.expedition e + JOIN vn.ticket t ON t.id = e.ticketFk + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.province p ON p.id = a.provinceFk + JOIN vn.`zone`z ON z.id = t.zoneFk + LEFT JOIN vn.route r ON r.id = t.routeFk + LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk + LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id + LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk + WHERE e.id = vExpeditionFk; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -57616,7 +58077,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `vn` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceFromClient` */; -ALTER DATABASE `vn` CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -57626,32 +58086,26 @@ ALTER DATABASE `vn` CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `invoiceFromClient`(vMaxTicketDate DATETIME, vClient INT, vCompany INT) -BEGIN - - DECLARE vMinDateTicket DATE DEFAULT TIMESTAMPADD(YEAR, -3, CURDATE()); - - SET vMaxTicketDate = vn2008.DAYEND(vMaxTicketDate); +CREATE DEFINER=`root`@`%` PROCEDURE `invoiceFromClient`(IN vMaxTicketDate datetime, IN vClientFk INT, IN vCompanyFk INT) +BEGIN + DECLARE vMinTicketDate DATE DEFAULT TIMESTAMPADD(YEAR, -3, CURDATE()); + SET vMaxTicketDate = util.dayend(vMaxTicketDate); DROP TEMPORARY TABLE IF EXISTS `ticketToInvoice`; - CREATE TEMPORARY TABLE `ticketToInvoice` (PRIMARY KEY (`id`)) ENGINE = MEMORY - SELECT Id_Ticket id FROM vn2008.Tickets - WHERE Id_Cliente = vClient - AND Factura IS NULL - AND empresa_id = vCompany - AND (Fecha BETWEEN vMinDateTicket AND vMaxTicketDate) - ; - + SELECT id FROM ticket t + WHERE t.clientFk = vClientFk + AND t.refFk IS NULL + AND t.companyFk = vCompanyFk + AND (t.shipped BETWEEN vMinTicketDate AND vMaxTicketDate); 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 */ ; -ALTER DATABASE `vn` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceFromTicket` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58555,7 +59009,9 @@ BEGIN amount, foreignValue) SELECT vInvoiceInFk, - IF(payDay, vn2008.next_venc(created, detalle, payDay),TIMESTAMPADD(DAY, GREATEST(detalle, 2), created)), + IF(payDay, + IF(vn2008.next_venc(issued, detalle, payDay) < DATE_ADD(created, INTERVAL 2 DAY), DATE_ADD(created, INTERVAL 2 DAY), vn2008.next_venc(issued, detalle, payDay)), + TIMESTAMPADD(DAY, GREATEST(detalle, 2), created)), IF((@cont:=@cont + 1) < cont, TRUNCATE(venc / cont, 2),venc-(TRUNCATE(venc / cont, 2) * (cont - 1))), IF(@cont < cont, TRUNCATE(foreignValue / cont, 2), foreignValue - (TRUNCATE(foreignValue / cont, 2) * (cont - 1))) FROM ( SELECT SUM((1 + (IFNULL(ti.PorcentajeIva, 0) / 100)*(s.countryFk = s2.countryFk)) * iit.taxableBase)/COUNT(DISTINCT(pdd.detalle)) venc, @@ -58564,6 +59020,7 @@ BEGIN ii.companyFk, COUNT(DISTINCT(pdd.detalle)) cont, s.payDay, + ii.issued, DATE(ii.created) created FROM invoiceIn ii JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id @@ -59170,25 +59627,28 @@ BEGIN 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,''), '
') + 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; @@ -59197,14 +59657,16 @@ BEGIN 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, ' -
'); + CALL mail_insert( + '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 @@ -59624,13 +60086,15 @@ 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 = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!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 `invoiceOut_newFromClient`(vClientFk INT, vSerial CHAR(2), vMaxShipped DATE, vCompanyFk INT, vTaxArea VARCHAR(25), vRef VARCHAR(25), OUT vInvoiceId INT) +CREATE DEFINER=`root`@`%` PROCEDURE `invoiceOut_newFromClient`(IN vClientFk int, IN vSerial char(2), IN vMaxShipped date, + IN vCompanyFk int, IN vTaxArea varchar(25), + IN vRef varchar(25), OUT vInvoiceId int) BEGIN /** * Factura los tickets de un cliente hasta una fecha dada @@ -59644,12 +60108,7 @@ BEGIN */ DECLARE vIsRefEditable BOOLEAN; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - + IF vRef IS NOT NULL THEN SELECT isRefEditable INTO vIsRefEditable FROM invoiceOutSerial @@ -59660,7 +60119,6 @@ BEGIN END IF; END IF; - START TRANSACTION; CALL invoiceFromClient(vMaxShipped, vClientFk, vCompanyFk); CALL invoiceOut_new(vSerial, CURDATE(), vTaxArea, vInvoiceId); @@ -59670,11 +60128,8 @@ BEGIN 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 */ ; @@ -59716,13 +60171,14 @@ 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 = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!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 `invoiceOut_newFromTicket`(vTicketFk INT, vSerial CHAR(2), vTaxArea VARCHAR(25), vRef VARCHAR(25), OUT vInvoiceId INT) +CREATE DEFINER=`root`@`%` PROCEDURE `invoiceOut_newFromTicket`(IN vTicketFk int, IN vSerial char(2), IN vTaxArea varchar(25), + IN vRef varchar(25), OUT vInvoiceId int) BEGIN /** * Factura un ticket @@ -59733,13 +60189,6 @@ BEGIN * @return vInvoiceId */ DECLARE vIsRefEditable BOOLEAN; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - START TRANSACTION; CALL invoiceFromTicket(vTicketFk); CALL invoiceOut_new(vSerial, CURDATE(), vTaxArea, vInvoiceId); @@ -59758,12 +60207,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, labelReportFk, param1, workerFk) VALUES(1, 3, vInvoiceId, account.myUser_getId()); - END IF; END IF; - - COMMIT; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60294,8 +60738,6 @@ 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, @@ -60309,7 +60751,6 @@ BEGIN 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 @@ -60335,14 +60776,26 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `itemFuentesBalance`(vDaysInFuture INT) BEGIN + /* Se utiliza para calcular la necesidad de mover mercancia entre el almacén de fuentes y el nuestro + * + * @param vDaysInFuture Rango de dias para calcular entradas y salidas + * + */ + + DECLARE vWarehouseFk INT; + + SELECT s.warehouseFk INTO vWarehouseFk + FROM vn.sector s + WHERE s.code = 'FUENTES_PICASSE'; + CALL cache.stock_refresh(FALSE); - SELECT alt.itemFk, + SELECT fue.itemFk, i.longName, i.size, i.subName, v.amount as visible, - alt.reserva, + fue.reserva, sale.venta, IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) as compra, IFNULL(v.amount,0) + IFNULL(sale.venta,0) + IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) as saldo @@ -60352,32 +60805,33 @@ BEGIN FROM vn.itemShelving ish JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk - WHERE p.sectorFk = 37 + JOIN vn.sector s ON s.id = p.sectorFk + WHERE s.code = 'FUENTES_PICASSE' GROUP BY ish.itemFk - ) alt ON alt.itemFk = i.id - LEFT JOIN cache.stock v ON i.id = v.item_id AND v.warehouse_id = 1 + ) fue ON fue.itemFk = i.id + LEFT JOIN cache.stock v ON i.id = v.item_id AND v.warehouse_id = vWarehouseFk LEFT JOIN ( SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as venta FROM vn2008.item_out WHERE dat BETWEEN CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(curdate())) - AND warehouse_id = 1 + AND warehouse_id = vWarehouseFk GROUP BY item_id - ) sale ON sale.item_id = alt.itemFk + ) sale ON sale.item_id = fue.itemFk LEFT JOIN ( SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as compra FROM vn2008.item_entry_in WHERE dat BETWEEN CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(curdate())) - AND warehouse_id = 1 + AND warehouse_id = vWarehouseFk AND isVirtualStock = FALSE GROUP BY item_id - ) buy ON buy.item_id = alt.itemFk + ) buy ON buy.item_id = fue.itemFk LEFT JOIN ( SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as traslado FROM vn2008.item_entry_out WHERE dat BETWEEN CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(curdate())) - AND warehouse_id = 1 + AND warehouse_id = vWarehouseFk GROUP BY item_id - ) mov ON mov.item_id = alt.itemFk + ) mov ON mov.item_id = fue.itemFk ; @@ -62601,6 +63055,62 @@ proc:BEGIN WHERE nicho ORDER BY producer; +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 `itemShelving_inventory` */; +/*!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 `itemShelving_inventory`(vParkingFromFk INT, vParkingToFk INT) +BEGIN + + /* Devuelve un listado de ubicaciones a revisar + * + * @param vParkingFromFk Parking de partida, identificador de vn.parking + * @param vParkingToFk Parking de llegada, identificador de vn.parking + */ + + DECLARE vSectorFk INT; + DECLARE vPickingOrderFrom INT; + DECLARE vPickingOrderTo INT; + + SELECT p.sectorFk, p.pickingOrder INTO vSectorFk, vPickingOrderFrom + FROM vn.parking p + WHERE p.id = vParkingFromFk; + + SELECT p.pickingOrder INTO vPickingOrderTo + FROM vn.parking p + WHERE p.id = vParkingToFk; + + CALL vn.visible_getMisfit(vSectorFk); + + SELECT p.code parking , + ish.shelvingFk , + ish.itemFk, + i.longName, + ish.visible , + ish.visible / ish.packing packs, + ish.packing, + sm.visible - sm.parked faltan + FROM vn.itemShelving ish + JOIN vn.item i ON i.id = ish.itemFk + JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + WHERE p.pickingOrder BETWEEN vPickingOrderFrom AND vPickingOrderTo + AND p.sectorFk = vSectorFk + ORDER BY p.pickingOrder ; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -63576,6 +64086,102 @@ BEGIN ORDER BY shipped, alertLevel DESC, isTicket, `order` DESC, isPicked DESC, `in` DESC, `out` DESC ) AS itemDiary; +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 `item_getSimilar` */; +/*!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 `item_getSimilar`(vItemFk INT, vWarehouseFk INT, vDate DATE, vIsShowedByType BOOL) +BEGIN + +/** + * Propone articulos similares para posible cambio, + * ordenado con la cantidad de veces usado y segun sus caracteristicas + * + * @param vItemFk item id + * @param vWarehouseFk warehouse id + * @param vDate fecha para revisar disponible + * @param vIsShowedByType para mostrar solo artículos de ese tipo + */ + + DECLARE vCalcFk INT; + DECLARE vTypeFk INT; + + DECLARE vTag1 VARCHAR(25); + DECLARE vTag5 VARCHAR(25); + DECLARE vTag6 VARCHAR(25); + DECLARE vTag7 VARCHAR(25); + DECLARE vTag8 VARCHAR(25); + + DECLARE vValue1 VARCHAR(50); + DECLARE vValue5 VARCHAR(50); + DECLARE vValue6 VARCHAR(50); + DECLARE vValue7 VARCHAR(50); + DECLARE vValue8 VARCHAR(50); + + + SELECT typeFk, tag5, value5, tag6, value6, tag7, value7, tag8, value8, t1.name, it1.value + INTO vTypeFk, vTag5, vValue5, vTag6, vValue6, vTag7, vValue7, vTag8, vValue8, vTag1, vValue1 + FROM vn.item i + LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1 + LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk + WHERE i.id = vItemFk; + + CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDate); + + SELECT i.id itemFk, + i.longName, + i.subName, + i.tag5, + i.value5, + (i.value5 <=> vValue5 COLLATE utf8_general_ci) match5, + i.tag6, + i.value6, + (i.value6 <=> vValue6 COLLATE utf8_general_ci) match6, + i.tag7, + i.value7, + (i.value7 <=> vValue7 COLLATE utf8_general_ci) match7, + i.tag8, + i.value8, + (i.value8 <=> vValue8 COLLATE utf8_general_ci) match8, + a.available, + IFNULL(ip.counter,0) counter, + IF(b.groupingMode = 1, b.grouping, b.packing) as minQuantity + FROM vn.item i + JOIN cache.available a ON a.item_id = i.id + LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vItemFk + LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1 + LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk + LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk + LEFT JOIN vn.buy b ON b.id = lb.buy_id + WHERE a.calc_id = vCalcFk + AND available > 0 + AND IF(vIsShowedByType,i.typeFk = vTypeFk,true) + AND i.id != vItemFk + ORDER BY counter DESC, + (t1.name = vTag1 COLLATE utf8_general_ci) DESC, + (it1.value = vValue1 COLLATE utf8_general_ci) DESC, + (i.tag6 = vTag6 COLLATE utf8_general_ci) DESC, + (i.value6 = vValue6 COLLATE utf8_general_ci) DESC, + (i.tag5 = vTag5 COLLATE utf8_general_ci) DESC, + (i.value5 = vValue5 COLLATE utf8_general_ci) DESC, + (i.tag7 = vTag7 COLLATE utf8_general_ci) DESC, + (i.value7 = vValue7 COLLATE utf8_general_ci) DESC, + (i.tag8 = vTag8 COLLATE utf8_general_ci) DESC, + (i.value8 = vValue8 COLLATE utf8_general_ci) DESC; + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -64132,7 +64738,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 `item_setCompression` */; +/*!50003 DROP PROCEDURE IF EXISTS `item_setCompression__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -64142,7 +64748,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `item_setCompression`() +CREATE DEFINER=`root`@`%` PROCEDURE `item_setCompression__`() BEGIN /** * Actualiza la compression de los articulos con un packing.hasCompressionVariations = TRUE @@ -65038,7 +65644,7 @@ CREATE DEFINER=`root`@`%` PROCEDURE `machineWorker_update`(vPlate VARCHAR(10), v BEGIN /** - * Actualiza el registro correspondiente si el vWorkerFk ha registrado en las últimas 12 horas con vPlate, + * Actualiza el registro correspondiente si el vWorkerFk se ha registrado en las últimas horas (campo maxHours de machineWorkerConfig) con vPlate, * * @param vPlate número de matrícula * @param vWorkerFk id del trabajador @@ -65046,20 +65652,24 @@ BEGIN */ DECLARE vMachineFk INT(10); + DECLARE vMaxHours INT(10); SELECT m.id INTO vMachineFk FROM machine m WHERE m.plate = vPlate; + + SELECT maxHours INTO vMaxHours + FROM machineWorkerConfig; IF (SELECT COUNT(*) FROM machineWorker m WHERE m.workerFk = vWorkerFk - AND m.inTimed >= TIMESTAMPADD(HOUR , -12,NOW()) AND ISNULL(m.outTimed)) THEN + AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, NOW()) AND ISNULL(m.outTimed)) THEN UPDATE machineWorker m SET m.outTimed = CURRENT_TIMESTAMP() WHERE m.workerFk = vWorkerFk - AND m.inTimed >= TIMESTAMPADD(HOUR , -12,NOW()) + AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, NOW()) AND ISNULL(m.outTimed) AND m.machineFk = vMachineFk; @@ -65108,14 +65718,14 @@ 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 `mail_insert`( - vSender VARCHAR(50), + vReceiver VARCHAR(50), vReplyTo VARCHAR(50), vSubject VARCHAR(50), vBody VARCHAR(255)) @@ -65126,14 +65736,14 @@ BEGIN SELECT COUNT(*) INTO vIsRepeated FROM vn.mail WHERE creationDate >= CURDATE() - AND sender = vSender + AND `receiver` = vReceiver AND `replyTo` = vReplyTo AND `subject` = vSubject; IF NOT vIsRepeated THEN INSERT INTO vn.mail SET - `sender` = vSender, + `receiver` = vReceiver, `replyTo` = vReplyTo, `subject` = vSubject, `body` = vBody; @@ -66499,6 +67109,197 @@ BEGIN GROUP BY wj.userFk ORDER BY w.lastName, w.firstname; +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 `placement_test` */; +/*!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 `placement_test`(vParamFk INT(11)) +BEGIN + + DECLARE vCalcFk INT; + DECLARE vWarehouseFk INT; + DECLARE vWarehouseAliasFk INT; + DECLARE vCurrentYear INT DEFAULT YEAR(NOW()); + + DROP TEMPORARY TABLE IF EXISTS tmp.sale; + CREATE TEMPORARY TABLE tmp.sale + ENGINE = MEMORY + SELECT 0000000 as ticketFk, + 0000000 as saleFk, + 0000000 as itemFk, + FALSE as isStowaway, + 0 as quantity; + + INSERT INTO tmp.sale(ticketFk, saleFk, itemFk, isStowaway) + SELECT s.ticketFk, s.id, s.itemFk, FALSE + FROM vn.ticketCollection tc + JOIN vn.collection c ON c.id = tc.collectionFk + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + JOIN vn.item i ON i.id = s.itemFk + WHERE tc.collectionFk = vParamFk + AND (i.itemPackingTypeFk = c.itemPackingTypeFk OR ISNULL(c.itemPackingTypeFk)) + UNION ALL + SELECT s.ticketFk, s.id, s.itemFk, FALSE + FROM vn.sale s + WHERE s.ticketFk = vParamFk; + + + /* UNION ALL + SELECT sw.shipFk, s.id, s.itemFk, TRUE + FROM vn.sale s + JOIN vn.stowaway sw ON sw.id = s.ticketFk + JOIN vn.ticketCollection tc ON tc.ticketFk = sw.shipFk + WHERE tc.collectionFk = vParamFk; + + INSERT INTO tmp.sale(ticketFk, saleFk, itemFk, isStowaway) + SELECT s.ticketFk, s.id, s.itemFk, FALSE + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + WHERE s.ticketFk = vParamFk + AND t.shipped > '2020-01-01' + UNION ALL + SELECT sw.shipFk, s.id, s.itemFk, TRUE + FROM vn.sale s + JOIN vn.stowaway sw ON sw.id = s.ticketFk + WHERE sw.shipFk = vParamFk; + + DELETE FROM tmp.sale + WHERE saleFk = 0; + */ + SELECT t.warehouseFk, w.aliasFk + INTO vWarehouseFk, vWarehouseAliasFk + FROM vn.ticket t + JOIN tmp.sale ts ON ts.ticketFk = t.id + JOIN vn.warehouse w ON w.id = t.warehouseFk + LIMIT 1; + + CALL cache.visible_refresh(vCalcFk,FALSE,vWarehouseFk); + + UPDATE tmp.sale ts + JOIN ( SELECT itemFk, sum(visible) as visible + FROM vn.itemShelvingStock iss + JOIN vn.warehouse w ON w.id = iss.warehouseFk + WHERE w.aliasFk = vWarehouseAliasFk + GROUP BY iss.itemFk ) iss ON iss.itemFk = ts.itemFk + SET ts.quantity = iss.visible; + + DROP TEMPORARY TABLE IF EXISTS tmp.sale2; + CREATE TEMPORARY TABLE tmp.sale2 + ENGINE = MEMORY + SELECT * FROM tmp.sale; + + + DROP TEMPORARY TABLE IF EXISTS tmp.`grouping`; + CREATE TEMPORARY TABLE tmp.`grouping` + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT b.itemFk, + CASE b.groupingMode + WHEN 0 THEN 1 + WHEN 2 THEN b.packing + ELSE b.`grouping` + END AS `grouping` + FROM buy b + JOIN cache.last_buy lb ON lb.buy_id = b.id + WHERE lb.warehouse_id = vWarehouseFk + ; + + DROP TEMPORARY TABLE IF EXISTS tmp.grouping2; + CREATE TEMPORARY TABLE tmp.grouping2 + ENGINE = MEMORY + SELECT * FROM tmp.`grouping`; + + DROP TEMPORARY TABLE IF EXISTS tmp.salePlacementList; + CREATE TEMPORARY TABLE tmp.salePlacementList + ENGINE = MEMORY + + SELECT ts.saleFk, + ts.itemFk, + CONCAT( + IF( iss.id, + CONCAT('< ', IFNULL(wk.`code`, '---'),' > '), + ''), + p.`code`) COLLATE utf8_general_ci as placement , + sh.code COLLATE utf8_general_ci as shelving, + ish.created, + ish.visible, + IF(ts.isStowaway, - 100000, IF(ish.visible > 0 OR iss.id, 1, 100000)) * p.pickingOrder as `order`, + IFNULL(IF(sc.isPreviousPreparedByPacking, ish.packing, g.`grouping`),1) as `grouping`, + IF(iss.id, TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,iss.created)), TO_SECONDS(TIMESTAMPADD(YEAR,- year(ish.created),ish.created)) + TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,NOW()))) as priority, + 0 as saleOrder, + sc.isPreviousPrepared, + iss.id as itemShelvingSaleFk, + ts.ticketFk + ,iss.id + , st.saleFk as salePreviousPrepared + , iss.userFk + FROM tmp.sale ts + LEFT JOIN (SELECT DISTINCT saleFk + FROM vn.saleTracking st + JOIN vn.state s ON s.id = st.stateFk + WHERE st.isChecked + AND s.semaphore = 1) st ON st.saleFk = ts.saleFk + JOIN vn.itemShelving ish ON ish.itemFk = ts.itemFk + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + JOIN vn.sector sc ON sc.id = p.sectorFk + JOIN vn.warehouse w ON w.id = sc.warehouseFk + LEFT JOIN tmp.`grouping` g ON g.itemFk = ts.itemFk + LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = ts.saleFk AND iss.itemShelvingFk = ish.id + LEFT JOIN vn.worker wk ON wk.id = iss.userFk + WHERE w.aliasFk = vWarehouseAliasFk + HAVING (iss.id AND st.saleFk) OR salePreviousPrepared IS NULL + ; + + DROP TEMPORARY TABLE IF EXISTS tmp.salePlacementList_2; + CREATE TEMPORARY TABLE tmp.salePlacementList_2 + ENGINE MEMORY + SELECT saleFk, priority as olderPriority + FROM (SELECT saleFk, priority + FROM tmp.salePlacementList + ORDER BY IF(isPreviousPrepared,2,1), IF(visible > 0 OR itemShelvingSaleFk,1,2), priority + ) sub + GROUP BY saleFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.salePlacementList_3; + CREATE TEMPORARY TABLE tmp.salePlacementList_3 + ENGINE MEMORY + SELECT s1.saleFk, `order`as saleOrder + FROM tmp.salePlacementList s1 + JOIN tmp.salePlacementList_2 s2 ON s2.saleFk = s1.saleFk AND s2.olderPriority = s1.priority; + + UPDATE tmp.salePlacementList s1 + JOIN tmp.salePlacementList_3 s3 ON s3.saleFk = s1.saleFk + SET s1.saleOrder = s3.saleOrder; + /* + -- Anula el orden de antigüedad y ordena por ubicación */ + UPDATE tmp.salePlacementList + SET saleOrder = `order`; + + SELECT * + FROM tmp.salePlacementList + ORDER BY visible <> 0 DESC,saleOrder, IF(isPreviousPrepared,2,1), IF(itemShelvingSaleFk,1,2),priority; + + DROP TEMPORARY TABLE + tmp.sale, + tmp.sale2, + tmp.`grouping`, + tmp.grouping2, + tmp.salePlacementList_2, + tmp.salePlacementList_3; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66898,9 +67699,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 = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!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 ;; @@ -66911,6 +67712,8 @@ proc: BEGIN DECLARE vIsTodayRelative BOOLEAN; + CALL util.debugAdd('vn.productionControl',CONCAT('warehouse: ',vWarehouseFk,' scopeDays:',vScopeDays)); + SELECT isTodayRelative INTO vIsTodayRelative FROM vn.worker WHERE userFk = vn.getUser(); @@ -68125,7 +68928,7 @@ BEGIN LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id LEFT JOIN vn.address a ON a.id = t.addressFk LEFT JOIN vn.route r on r.id = t.routeFk - LEFT JOIN vn.zone_ETD ze ON ze.zoneFk = t.zoneFk + LEFT JOIN vn.zoneEstimatedDelivery ze ON ze.zoneFk = t.zoneFk LEFT JOIN vn.agencyMode agm on r.agencyModeFk =agm.id LEFT JOIN vn.zone zo ON t.zoneFk = zo.id WHERE tc.collectionFk = vCollectionFk @@ -68157,7 +68960,7 @@ BEGIN LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id LEFT JOIN vn.address a ON a.id = t.addressFk LEFT JOIN vn.route r on r.id = t.routeFk - LEFT JOIN vn.zone_ETD ze ON ze.zoneFk = t.zoneFk + LEFT JOIN vn.zoneEstimatedDelivery ze ON ze.zoneFk = t.zoneFk LEFT JOIN vn.agencyMode agm on r.agencyModeFk =agm.id LEFT JOIN vn.zone zo ON t.zoneFk = zo.id WHERE tc.collectionFk = vCollectionFk @@ -69846,7 +70649,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_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 `sale_checkNoComponents`(vCreatedFrom DATETIME, vCreatedTo DATETIME) BEGIN @@ -69863,12 +70666,16 @@ BEGIN DECLARE vCur CURSOR FOR SELECT s.id FROM sale s + JOIN ticket t ON t.id = s.ticketFk JOIN item i ON i.id = s.itemFk JOIN itemType tp ON tp.id = i.typeFk JOIN itemCategory ic ON ic.id = tp.categoryFk LEFT JOIN tmp.coste c ON c.id = s.id WHERE s.created >= vCreatedFrom AND s.created <= vCreatedTo AND c.id IS NULL + AND t.agencyModeFk IS NOT NULL + AND t.isDeleted IS FALSE + AND t.warehouseFk = 60 AND ic.merchandise != FALSE GROUP BY s.id; @@ -69887,7 +70694,7 @@ BEGIN JOIN itemCategory ic ON ic.id = tp.categoryFk JOIN saleComponent sc ON sc.saleFk = s.id JOIN component c ON c.id = sc.componentFk - JOIN componentType ct ON ct.id = c.typeFk AND ct.id = 1 + JOIN componentType ct ON ct.id = c.typeFk AND ct.id = 6 WHERE s.created >= vCreatedFrom AND ic.merchandise != FALSE; @@ -69906,8 +70713,8 @@ BEGIN FROM sale WHERE id = vSaleFk; - CALL util.debug(vTicketFk, vConcept); - -- CALL sale_calculateComponent(vSaleFk, 1); + CALL util.debugAdd(vTicketFk, vConcept); + CALL sale_calculateComponent(vSaleFk, 1); END LOOP; CLOSE vCur; @@ -69939,8 +70746,8 @@ BEGIN */ SET SESSION group_concat_max_len = 102400; - INSERT INTO mail (sender,replyTo,subject,body) - SELECT CONCAT(sub.name, '@verdnatura.es') sender, + INSERT INTO mail (receiver,replyTo,subject,body) + SELECT CONCAT(sub.name, '@verdnatura.es') receiver, 'noreply@verdnatura.es' replyTo, CONCAT( 'El ', @@ -70082,13 +70889,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 = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!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_getProblems`(IN vIsTodayRelative TINYINT(1)) +CREATE DEFINER=`root`@`%` PROCEDURE `sale_getProblems`(IN vIsTodayRelative tinyint(1)) BEGIN /** * Calcula los problemas de cada venta @@ -70117,6 +70924,7 @@ BEGIN saleFk INT(11), isFreezed INTEGER(1) DEFAULT 0, risk DECIMAL(10,2) DEFAULT 0, + hasHighRisk TINYINT(1) DEFAULT 0, hasTicketRequest INTEGER(1) DEFAULT 0, isAvailable INTEGER(1) DEFAULT 1, itemShortage VARCHAR(250), @@ -70167,8 +70975,8 @@ BEGIN CALL clientGetDebt(CURDATE()); - INSERT INTO tmp.sale_problems(ticketFk, risk) - SELECT DISTINCT tl.ticketFk, r.risk + INSERT INTO tmp.sale_problems(ticketFk, risk, hasHighRisk) + SELECT DISTINCT tl.ticketFk, r.risk, ((r.risk - cc.riskTolerance) > c.credit + 10) FROM tmp.ticket_list tl JOIN vn.ticket t ON t.id = tl.ticketFk JOIN vn.agencyMode a ON t.agencyModeFk = a.id @@ -70178,7 +70986,7 @@ BEGIN WHERE r.risk > c.credit + 10 AND a.isRiskFree = FALSE ON DUPLICATE KEY UPDATE - risk = r.risk; + risk = r.risk, hasHighRisk = ((r.risk - cc.riskTolerance) > c.credit + 10); INSERT INTO tmp.sale_problems(ticketFk, hasTicketRequest) SELECT DISTINCT tl.ticketFk, TRUE @@ -72951,7 +73759,7 @@ BEGIN FROM saleComponent sc JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk GROUP BY sc.saleFk) sc ON sc.saleFk = s.id - SET s.price = sumValue + SET s.price = sumValue / ((100 - s.discount) / 100) WHERE it.code != 'PRT' ; REPLACE INTO saleComponent(saleFk, componentFk, value) @@ -74056,40 +74864,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 `ticketListVolume__` */; -/*!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 `ticketListVolume__`(IN vTicketId INT) -BEGIN - - DECLARE vWarehouseId INTEGER; - DECLARE vShippedDate DATE; - - SELECT warehouseFk, shipped INTO vWarehouseId,vShippedDate FROM ticket WHERE id = vTicketId; - - SELECT s.quantity, - round(ic.cm3delivery * s.quantity / 1000000,3) as m3, - s.itemFk, - s.id AS saleFk, - s.concept, - t.agencyModeFk - FROM sale s - JOIN ticket t on t.id = s.ticketFk - JOIN itemCost ic ON ic.itemFk = s.itemFk AND ic.warehouseFk = t.warehouseFk - WHERE s.ticketFk = vTicketId; -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 `ticketManaToPromo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74976,44 +75750,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 `ticketVolumeByDate` */; -/*!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 `ticketVolumeByDate`(vDate DATE) -BEGIN - - DECLARE vDateStart DATETIME DEFAULT DATE(vDate); - DECLARE vDateEnd DATETIME DEFAULT util.dayEnd(vDate); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketVolumeByDate; - - CREATE TEMPORARY TABLE tmp.ticketVolumeByDate - ENGINE = MEMORY - SELECT s.ticketFk, - CAST(SUM(ic.cm3delivery * s.quantity) / 1000000 AS DECIMAL(10,2)) as m3 - FROM sale s - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory c ON c.id = it.categoryFk - JOIN vn.ticket t on t.id = s.ticketFk - JOIN vn.itemCost ic ON ic.itemFk = s.itemFk AND ic.warehouseFk = t.warehouseFk - WHERE c.merchandise - AND t.shipped BETWEEN vDateStart AND vDateEnd - GROUP BY s.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 DROP PROCEDURE IF EXISTS `ticketVolumeByDate_ventas` */; +/*!50003 DROP PROCEDURE IF EXISTS `ticketVolumeByDate_ventas_Artificial__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -75023,7 +75760,45 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketVolumeByDate_ventas`(vDate DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `ticketVolumeByDate_ventas_Artificial__`(vDate DATE) +BEGIN + + DECLARE vDateStart DATETIME DEFAULT DATE(vDate); + DECLARE vDateEnd DATETIME DEFAULT util.dayEnd(vDate); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketVolumeByDate_Artificial; + + CREATE TEMPORARY TABLE tmp.ticketVolumeByDate_Artificial + ENGINE = MEMORY + SELECT s.ticketFk, + CAST(SUM(r.cm3 * s.quantity) / 1000000 AS DECIMAL(10,2)) as m3 + FROM sale s + JOIN bs.ventas v ON v.Id_Movimiento = s.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.sector sc ON sc.id = i.sectorFk + JOIN vn.ticket t on t.id = s.ticketFk + JOIN bi.rotacion r ON r.Id_Article = s.itemFk AND r.warehouse_id = t.warehouseFk + WHERE sc.description = 'Artificial' + AND t.shipped BETWEEN vDateStart AND vDateEnd + GROUP BY s.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 DROP PROCEDURE IF EXISTS `ticketVolumeByDate_ventas__` */; +/*!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 `ticketVolumeByDate_ventas__`(vDate DATE) BEGIN DECLARE vDateStart DATETIME DEFAULT DATE(vDate); @@ -75052,38 +75827,37 @@ 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 `ticketVolumeByDate_ventas_Artificial` */; +/*!50003 DROP PROCEDURE IF EXISTS `ticketVolumeByDate__` */; /*!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 `ticketVolumeByDate_ventas_Artificial`(vDate DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `ticketVolumeByDate__`(vDate DATE) BEGIN DECLARE vDateStart DATETIME DEFAULT DATE(vDate); DECLARE vDateEnd DATETIME DEFAULT util.dayEnd(vDate); - DROP TEMPORARY TABLE IF EXISTS tmp.ticketVolumeByDate_Artificial; - - CREATE TEMPORARY TABLE tmp.ticketVolumeByDate_Artificial + DROP TEMPORARY TABLE IF EXISTS tmp.ticketVolumeByDate; + + CREATE TEMPORARY TABLE tmp.ticketVolumeByDate ENGINE = MEMORY SELECT s.ticketFk, - CAST(SUM(r.cm3 * s.quantity) / 1000000 AS DECIMAL(10,2)) as m3 + CAST(SUM(ic.cm3delivery * s.quantity) / 1000000 AS DECIMAL(10,2)) as m3 FROM sale s - JOIN bs.ventas v ON v.Id_Movimiento = s.id JOIN vn.item i ON i.id = s.itemFk - JOIN vn.sector sc ON sc.id = i.sectorFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory c ON c.id = it.categoryFk JOIN vn.ticket t on t.id = s.ticketFk - JOIN bi.rotacion r ON r.Id_Article = s.itemFk AND r.warehouse_id = t.warehouseFk - WHERE sc.description = 'Artificial' + JOIN vn.itemCost ic ON ic.itemFk = s.itemFk AND ic.warehouseFk = t.warehouseFk + WHERE c.merchandise AND t.shipped BETWEEN vDateStart AND vDateEnd - GROUP BY s.ticketFk; - + GROUP BY s.ticketFk; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -75220,6 +75994,56 @@ BEGIN FROM vn.sale s WHERE s.ticketFk = vOriginalTicket; +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_canMerge` */; +/*!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_canMerge`(vDated DATE, vScopeDays INT, vLitersMax INT, vLinesMax INT, vWarehouseFk INT) +BEGIN + + /* Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro + * + * @param vDated Fecha en cuestión + * @param vScopeDays Dias en el futuro a sondear + * @param vLitersMax Volumen máximo de los tickets a catapultar + * @param vLinesMax Número máximo de lineas de los tickets a catapultar + * @param vWarehouseFk Identificador de vn.warehouse + */ + + SELECT sv.ticketFk , + sum(litros) liters, + count(*) `lines`, + sub2.id ticketFuture, + sub2.shipped + FROM vn.saleVolume sv + JOIN vn.ticket t ON t.id = sv.ticketFk + LEFT JOIN ( + SELECT * FROM ( + SELECT t.addressFk , t.id, t.shipped + FROM vn.ticket t + WHERE t.shipped BETWEEN vDated + AND util.dayend(TIMESTAMPADD(DAY, vScopeDays,vDated)) + AND t.warehouseFk = vWarehouseFk + ORDER BY t.shipped) sub + GROUP BY sub.addressFk + ) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id + WHERE t.shipped BETWEEN vDated AND util.dayend(vDated) + AND t.warehouseFk = vWarehouseFk + GROUP BY sv.ticketFk + HAVING liters < vLitersMax AND `lines` < vLinesMax AND ticketFuture; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -75267,6 +76091,54 @@ BEGIN ON s.shipFk = tt.ticketFk SET t.clientFk = vNewClient; +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_checkFullyControlled` */; +/*!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_checkFullyControlled`(vWorkerFk INT, vTicketFk INT ) +BEGIN +/** + * Comprueba que no hay ningún ticket pendiente de revisar de alguna colección que haya revisado el trabajador + * @param vWorkerFk id del user + * @param vTicketFk número de ticket escaneada + * + */ + + SELECT t.id + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN ticketCollection tc ON tc.ticketFk = t.id + JOIN (SELECT tc.collectionFk + FROM ticketState ts + JOIN ticketCollection tc ON tc.ticketFk = ts.ticketFk + LEFT JOIN (SELECT tc.collectionFk + FROM ticketCollection tc + WHERE ticketFk = vTicketFk + AND tc.created >= CURDATE() + )sub ON sub.collectionFk = tc.collectionFk + WHERE ts.workerFk = vWorkerFk + AND sub.collectionFk IS NULL + AND tc.created >= CURDATE() + GROUP BY tc.collectionFk + )sub ON sub.collectionFk = tc.collectionFk + JOIN ticketState ts ON ts.ticketFk = t.id + WHERE ts.code IN ('ON_PREPARATION', 'PREPARED', 'PREVIOUS_PREPARATION', 'OK PREVIOUS') + AND t.shipped >= CURDATE() + AND s.quantity <>0 + LIMIT 1; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -75436,9 +76308,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 ;; @@ -75537,12 +76409,11 @@ BEGIN SELECT COUNT(*) INTO vMailSent FROM vn.mail - WHERE sender = vSalesPersonEmail + WHERE receiver = vSalesPersonEmail AND subject = vSubject; IF NOT vMailSent THEN - INSERT INTO vn.mail (`sender`,`subject`,`body`) - VALUES (vSalesPersonEmail, vSubject, vMessage); + CALL mail_insert(vSalesPersonEmail, NULL, vSubject, vMessage); END IF; CALL vn.ticketStateUpdate (vNewTicket, 'FIXING'); END IF; @@ -75733,19 +76604,19 @@ 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 = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!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_close`(vTicketFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_close`() BEGIN /** * Realiza el cierre de todos los - * tickets de la tabla ticketClosure. + * tickets de la tabla tmp.ticket_close. * - * @param vTicketFk Id del ticket + * @table tmp.ticket_close(ticketFk) Identificadores de los tickets a cerrar */ DECLARE vDone BOOL; DECLARE vClientFk INT; @@ -75759,20 +76630,13 @@ BEGIN DECLARE vHasToInvoice BOOL; DECLARE cur CURSOR FOR - SELECT ticketFk FROM tmp.ticketClosure; + SELECT ticketFk FROM tmp.ticket_close; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN RESIGNAL; END; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure; - CREATE TEMPORARY TABLE tmp.ticketClosure - SELECT vTicketFk AS ticketFk; - - INSERT INTO tmp.ticketClosure - SELECT id FROM stowaway s - WHERE s.shipFk = vTicketFk; OPEN cur; proc: LOOP @@ -75784,7 +76648,7 @@ BEGIN LEAVE proc; END IF; - -- ticketClosure start + -- Fetch ticket data SELECT c.id, c.isTaxDataChecked, @@ -75848,26 +76712,23 @@ BEGIN END LOOP; CLOSE cur; - - DROP TEMPORARY TABLE IF EXISTS 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 `ticket_closeAll` */; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_closeAll__` */; /*!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 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_closeAll`() +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_closeAll__`() BEGIN /** * Realiza el cierre de todos los @@ -75988,13 +76849,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 = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!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_closeByTicket`(vTicketFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_closeByTicket`(IN vTicketFk int) BEGIN /** @@ -76004,23 +76865,23 @@ BEGIN * @param vTicketFk Id del ticket */ - DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure; - - CREATE TEMPORARY TABLE tmp.ticketClosure ENGINE = MEMORY ( + DROP TEMPORARY TABLE IF EXISTS tmp.ticket_close; + CREATE TEMPORARY TABLE tmp.ticket_close ENGINE = MEMORY ( SELECT t.id AS ticketFk FROM expedition e INNER JOIN ticket t ON t.id = e.ticketFk LEFT JOIN ticketState ts ON ts.ticketFk = t.id + JOIN alertLevel al ON al.id = ts.alertLevel WHERE - ts.alertLevel = 2 + al.code = 'PACKED' AND t.id = vTicketFk AND t.refFk IS NULL GROUP BY e.ticketFk); - CALL ticket_close(vTicketFk); - - DROP TEMPORARY TABLE tmp.ticketClosure; + CALL ticket_close(); + + DROP TEMPORARY TABLE tmp.ticket_close; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -76635,13 +77496,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_unicode_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)) +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_getProblems`(IN vIsTodayRelative tinyint(1)) BEGIN /** * Calcula los problemas para un conjunto de tickets. @@ -76654,20 +77515,32 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_problems; CREATE TEMPORARY TABLE tmp.ticket_problems - (INDEX (ticketFk)) + (PRIMARY KEY (ticketFk)) ENGINE = MEMORY SELECT ticketFk, MAX(p.isFreezed) AS isFreezed, MAX(p.risk) AS risk, + MAX(p.hasHighRisk) AS hasHighRisk, 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 + MAX(p.hasComponentLack) AS hasComponentLack, + 0 AS totalProblems FROM tmp.sale_problems p GROUP BY ticketFk; + UPDATE tmp.ticket_problems tp + SET tp.totalProblems = ( + (tp.isFreezed) + + IF(tp.risk, TRUE, FALSE) + + (tp.hasTicketRequest) + + (tp.isAvailable = 0) + + (tp.isTaxDataChecked = 0) + + (tp.hasComponentLack) + ); + DROP TEMPORARY TABLE tmp.sale_problems; END ;; @@ -77081,6 +77954,40 @@ 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_merge` */; +/*!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_merge`(vSelf INT, vTicketTargetFk INT) +BEGIN + + /* Fusiona el primer ticket al segundo + * + * @param vSelf Número de ticket a fusionar + * @param vTicketTargetFk Ticket destino + * + */ + + UPDATE vn.sale s + SET s.ticketFk = vTicketTargetFk + WHERE s.ticketFk = vSelf; + + UPDATE vn.ticket t + SET t.shipped = TIMESTAMPADD(YEAR, - YEAR(NOW()) MOD 2000, t.shipped ) + WHERE t.id = vSelf; + +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_priceDifference` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -77737,10 +78644,10 @@ BEGIN * @table tmp.user(userFk) * @return tmp.timeBusinessCalculate */ - + DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; - - CREATE TEMPORARY TABLE tmp.timeBusinessCalculate + + CREATE TEMPORARY TABLE tmp.timeBusinessCalculate SELECT dated, businessFk, userFk, @@ -77757,7 +78664,8 @@ BEGIN type, permissionRate, hoursWeek, - discountRate + discountRate, + isAllowedToWork FROM(SELECT t.dated, b.business_id businessFk, w.userFk, @@ -77769,7 +78677,8 @@ BEGIN cs.type, cs.permissionRate, cs.discountRate, - cl.hours_week hoursWeek + cl.hours_week hoursWeek, + cs.isAllowedToWork FROM vn.time t LEFT JOIN postgresql.business b ON t.dated BETWEEN b.date_start AND ifnull(b.date_end, vDatedTo ) LEFT JOIN postgresql.profile AS pr ON b.client_id = pr.profile_id @@ -77787,8 +78696,7 @@ BEGIN WHERE t.dated BETWEEN vDatedFrom AND vDatedTo GROUP BY w.userFk,dated )sub; - - + UPDATE tmp.timeBusinessCalculate t LEFT JOIN postgresql.journey j ON j.business_id = t.businessFk SET t.timeWorkSeconds = t.hoursWeek / 5 * 3600, @@ -77798,21 +78706,21 @@ BEGIN t.timeBusinessSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600), t.timeBusinessDecimal = t.hoursWeek / 5 WHERE DAYOFWEEK(t.dated) IN(2,3,4,5,6) AND j.journey_id IS NULL ; - - UPDATE tmp.timeBusinessCalculate t + + UPDATE tmp.timeBusinessCalculate t SET t.timeWorkSeconds = t.timeWorkSeconds - (t.timeWorkSeconds * permissionRate) , t.timeWorkSexagesimal = SEC_TO_TIME ((t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate)) * 3600), t.timeWorkDecimal = t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate) WHERE permissionRate <> 0; - + UPDATE tmp.timeBusinessCalculate t JOIN vn.calendarHolidays ch ON ch.dated = t.dated JOIN postgresql.business_labour bl ON bl.business_id = t.businessFk AND bl.workcenter_id = ch.workcenterFk SET t.timeWorkSeconds = 0, t.timeWorkSexagesimal = 0, t.timeWorkDecimal = 0, - t.permissionrate = 1, - t.type = 'Festivo' + t.permissionrate = 1, + t.type = 'Festivo' WHERE t.type IS NULL; END ;; @@ -78284,63 +79192,6 @@ BEGIN DROP TEMPORARY TABLE tmp.`user`; -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 `timeControl_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 `timeControl_calculate__`(vDatedFrom DATETIME, vDatedTo DATETIME) -BEGIN - SET @vIsOdd := TRUE; - SET @vUser := NULL; - SET @vDated := NULL; - - DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; - - CREATE TEMPORARY TABLE tmp.timeControlCalculate - SELECT userFk, - dated, - IF( timeWork >= 18000, @timeWork:=timeWork + 1200, @timeWork:=timeWork) timeWorkSeconds, - SEC_TO_TIME(@timeWork ) timeWorkSexagesimal, - @timeWork / 3600 timeWorkDecimal, - timed - FROM (SELECT SUM(timeWork) timeWork, - userFk, - dated, - GROUP_CONCAT(DATE_FORMAT(sub.timed,"%H:%i") ORDER BY sub.timed ASC SEPARATOR ' - ') timed - FROM (SELECT IF(@vUser = wtc.userFk, @vUser :=@vUser, @vUser := wtc.userFk ), - IF(@vIsOdd, @vIsOdd := FALSE, @vIsOdd := TRUE ), - IF(direction='in', @vIsOdd := TRUE, @vIsOdd := @vIsOdd ), - IF(@vIsOdd, @vLastTimed:=UNIX_TIMESTAMP(timed),@vLastTimed:=@vLastTimed), - IF(@vIsOdd, 0, UNIX_TIMESTAMP(timed)-@vLastTimed) timeWork, - IF(direction='in', @vDated := DATE(wtc.timed), @vDated :=@vDated) dated, - wtc.userFk, - wtc.timed timed, - direction - FROM (SELECT wtc.* - FROM workerTimeControl wtc - JOIN tmp.`user` w ON w.userFk = wtc.userFk - WHERE wtc.timed BETWEEN vDatedFrom AND vDatedTo - ORDER BY userFk, timed ASC - ) wtc - WHERE wtc.timed BETWEEN vDatedFrom AND vDatedTo - ORDER BY userFk, timed ASC - ) sub - GROUP BY userFk, dated - ORDER BY userFk, dated - )sub2; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -78388,7 +79239,7 @@ BEGIN * trasladados a la ficha del cliente. * */ - INSERT INTO mail (sender,replyTo,subject,body) + INSERT INTO mail (receiver,replyTo,subject,body) SELECT 'administracion@verdnatura.es', 'noreply@verdnatura.es', CONCAT('Cobro web no trasladado a la ficha del cliente ', t.clientFk), @@ -79098,28 +79949,59 @@ 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 `vehicleWarehouseTimeControl_getHistorical` */; +/*!50003 DROP PROCEDURE IF EXISTS `visible_getMisfit` */; /*!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 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 `vehicleWarehouseTimeControl_getHistorical`(vNumberPLate VARCHAR(20), vWorkerFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `visible_getMisfit`(vSectorFk INT) BEGIN -/** - * Obtiene historial de la matrícula del trabajador, si es jefe de producción muestra el historial completo. -*/ - SELECT timed,workerFk,IF (direction="out","Salida","Entrada") direction - FROM vn.vehicleWarehouseTimeControl vwt - JOIN vn.vehicleWarehouse vw ON vw.numberPlate=vNumberPLate - WHERE vwt.vehicleWarehouseFk =vw.id - AND vwt.workerFk = IF(account.userHasRole(account.user_getNameFromId(vWorkerFk), 'productionAssi'), vwt.workerFk, vWorkerFk); + /* Devuelve una tabla temporal con los descuadres entre el visible teórico y lo ubicado en la práctica + * + * @param vSectorFk Identificador de vn.sector + * + * @return tmp.stockMisfit(itemFk, visible, parked) + */ + + DECLARE vCalcVisibleFk INT; + DECLARE vWarehouseFk INT; + + SELECT warehouseFk INTO vWarehouseFk + FROM vn.sector s + WHERE s.id = vSectorFk; + + CALL cache.visible_refresh(vCalcVisibleFk, FALSE, vWarehouseFk); + + DROP TEMPORARY TABLE IF EXISTS tmp.stockMisfit; + + CREATE TEMPORARY TABLE tmp.stockMisfit( + itemFk INT PRIMARY KEY, + visible INT NOT NULL DEFAULT 0, + parked INT NOT NULL DEFAULT 0) + ENGINE = MEMORY; + + INSERT INTO tmp.stockMisfit(itemFk, parked) + SELECT iss.itemFk , sum(iss.visible ) + FROM vn.itemShelvingStock iss + JOIN vn.sector s ON s.id = iss.sectorFk + WHERE vSectorFk IN (s.id, s.sonFk) + GROUP BY iss.itemFk; + + INSERT INTO tmp.stockMisfit(itemFk, visible) + SELECT v.item_id , v.visible + FROM cache.visible v + WHERE v.calc_id = vCalcVisibleFk + ON DUPLICATE KEY UPDATE visible = v.visible; + DELETE FROM tmp.stockMisfit + WHERE visible = parked; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -79186,66 +80068,6 @@ BEGIN CALL vn.warehouseFitting(vWhOrigin, vWhDestiny); -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 `weight_Put__` */; -/*!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 `weight_Put__`() -BEGIN - - SET @isModeInventory := TRUE; - - CALL cache.last_buy_refresh(FALSE); -- jgf 2020/09/14 cuelga la BBDD al actualizar varios - - DROP TEMPORARY TABLE IF EXISTS tmp.peso; - - CREATE TEMPORARY TABLE tmp.peso - SELECT lb.item_id, - i.longName, - lb.warehouse_id, - b.weight, - it.gramsMin * b.packing / 1000 as pesMin, - it.gramsMax * b.packing / 1000 as pesMax, - b.entryFk, - CAST(GREATEST(it.gramsMin * b.packing / 1000 , LEAST(IFNULL(b.weight, (it.gramsMax - it.gramsMin) * b.packing / 1000 / 2) , it.gramsMax * b.packing / 1000)) as decimal(10,2)) pesocorrecto - FROM cache.last_buy lb - JOIN vn.buy b ON b.id = lb.buy_id - JOIN vn.item i ON i.id = b.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.intrastat itr ON itr.id = i.intrastatFk - HAVING pesocorrecto > 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.buyTochange; - - CREATE TEMPORARY TABLE tmp.buyTochange - SELECT DISTINCT b.id, b.itemFk, b.entryFk - FROM cache.last_buy lb - JOIN vn.buy b ON b.id = lb.buy_id - JOIN (SELECT DISTINCT item_id itemFk FROM tmp.peso) sub using(itemFk) - WHERE b.weight is null; - - UPDATE tmp.buyTochange btc - JOIN vn.buy b ON b.id = btc.id - JOIN (SELECT item_id , pesocorrecto FROM tmp.peso GROUP BY item_id) p ON p.item_id = b.itemFk - SET b.weight = p.pesocorrecto; - - UPDATE vn.itemCost ic - JOIN cache.last_buy lb ON lb.item_id = ic.itemFk AND lb.warehouse_id = ic.warehouseFk - JOIN vn.buy b ON b.id = lb.buy_id - SET ic.grams = b.weight * 1000 / b.packing; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -79293,6 +80115,154 @@ 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 `workerCalendar_calculateBusiness` */; +/*!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 `workerCalendar_calculateBusiness`(vYear INT, vBusinessFk INT) +BEGIN + +/** + * Calcula los días y horas de vacaciones en función de un contrato y año + * + * @param vYear + * @param vBusinessFk + * @return tmp.workerCalendarCalculateBusiness (days, hours, daysEnjoyed, hoursEnjoyed) + */ + + DECLARE vStarted DATE; + DECLARE vEnded DATE; + DECLARE vDaysHoliday DECIMAL(5,2); + DECLARE vHoursWeek DECIMAL(5,2); + DECLARE vDaysToSubtract DECIMAL(5,2); + DECLARE vDaysHolidayEnjoyed DECIMAL(5,2); + DECLARE vDifDays INT; + + SELECT IF(b.date_start < CONCAT(vYear,"-01-01"), CONCAT(vYear,"-01-01"),b.date_start), + IF(b.date_end IS NULL OR YEAR(b.date_end)>vYear , CONCAT(vYear,"-12-31"), b.date_end), + IF(hasHolidayEntilement, w.days, 0), + c.hours_week + INTO vStarted, + vEnded, + vDaysHoliday, + vHoursWeek + FROM postgresql.business b + JOIN postgresql.business_labour_payroll blp ON blp.business_id = b.business_id + JOIN vn2008.payroll_contratos p ON p.CodContrato = cod_contrato + JOIN postgresql.business_labour bl ON bl.business_id = b.business_id + JOIN workCenterHoliday w ON w.workcenterFk = bl.workcenter_id + LEFT JOIN postgresql.calendar_labour_type c ON c.calendar_labour_type_id=bl.calendar_labour_type_id + WHERE b.business_id= vBusinessFk + AND w.year = vYear; + + DROP TEMPORARY TABLE IF EXISTS tmp.workerCalendarCalculateBusiness; + + IF vStarted < vEnded THEN + SET vDifDays = DAYOFYEAR(vEnded) - DAYOFYEAR(vStarted) + 1; + + SELECT IFNULL(SUM(holidayEntitlementRate), 0) , + SUM(-(discountRate - 1)) + INTO vDaysToSubtract, + vDaysHolidayEnjoyed + FROM workerCalendar w + JOIN absenceType a ON a.id = w.absenceTypeFk + WHERE w.businessFk = vBusinessFk + AND YEAR(dated) = vYear; + END IF; + + CREATE TEMPORARY TABLE tmp.workerCalendarCalculateBusiness + ENGINE = MEMORY + SELECT @days := IFNULL(ROUND((vDaysHoliday * (vDifDays - vDaysToSubtract) / IF(util.isLeapYear(vYear) , 366, 365)), 1), 0) days, + @days * (vHoursWeek / 5) hours, + @daysEnjoyed := IFNULL(ROUND(vDaysHolidayEnjoyed, 1), 0) daysEnjoyed, + @daysEnjoyed * (vHoursWeek / 5) hoursEnjoyed; +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 `workerCalendar_calculateYear` */; +/*!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 `workerCalendar_calculateYear`(vYear INT, vWorkerFk INT) +BEGIN + +/** + * Calcula los días y horas de vacaciones en función de un trabajador y año + * + * @param vYear + * @param vWorkerFk + * @return tmp.workerCalendarCalculateYear (days, hours, daysEnjoyed, hoursEnjoyed) + */ + + DECLARE vDone BOOL; + DECLARE vBusinessFk INT; + + DECLARE cur CURSOR FOR + SELECT b.business_id + FROM postgresql.business b + LEFT JOIN postgresql.profile AS pr ON pr.profile_id = b.client_id + LEFT JOIN postgresql.person AS p ON p.person_id = pr.person_id + WHERE vYear BETWEEN YEAR(b.date_start) AND IFNULL(YEAR(b.date_end), vYear ) + AND p.id_trabajador = vWorkerFk; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + DROP TEMPORARY TABLE IF EXISTS tmp.workerCalendarCalculateYear; + + CREATE TEMPORARY TABLE tmp.workerCalendarCalculateYear + (days DEC(5,2), + hours DEC(5,2), + daysEnjoyed DEC(5,2), + hoursEnjoyed DEC(5,2)) + ENGINE = MEMORY; + INSERT INTO tmp.workerCalendarCalculateYear VALUES(0, 0, 0, 0); + + OPEN cur; + + l: LOOP + SET vDone = FALSE; + FETCH cur INTO vBusinessFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL workerCalendar_calculateBusiness(vYear, vBusinessFk); + UPDATE tmp.workerCalendarCalculateYear w + JOIN tmp.workerCalendarCalculateBusiness wc + SET w.days = w.days + wc.days, + w.hours = w.hours + wc.hours, + w.daysEnjoyed = w.daysEnjoyed + wc.daysEnjoyed, + w.hoursEnjoyed = w.hoursEnjoyed + wc.hoursEnjoyed; + + DROP TEMPORARY TABLE tmp.workerCalendarCalculateBusiness; + + END LOOP; + + CLOSE cur; + +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 `workerCreate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -80130,6 +81100,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 `workerShelving_delete` */; +/*!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 `workerShelving_delete`(vWorkerFk INT, vBarcode VARCHAR(12)) +BEGIN +/* + * Borra de workerShelving el carro o etiqueta insertado por el trabajador + * @param vWorkerFk es id del trabajador + * @param vBarcode se puede pasar tanto el smarttag como el shelving + */ + DECLARE vIsShelvingFk BOOL; + + + SELECT COUNT(*) > 0 INTO vIsShelvingFk + FROM vn.shelving s + WHERE s.code = vBarcode COLLATE utf8_general_ci; + + + IF NOT vIsShelvingFk THEN + + SELECT st.shelvingFk INTO vBarcode + FROM vn.smartTag st + WHERE st.code = vBarcode COLLATE utf8_general_ci; + + END IF; + + DELETE FROM vn.workerShelving + WHERE shelvingFk = vBarcode COLLATE utf8_general_ci + AND workerFk = vWorkerFk ; + +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 `workerTimeControlAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -80948,6 +81961,544 @@ 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_clockIn` */; +/*!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_clockIn`(vWorker INT, vTimed DATETIME, vDirection VARCHAR(10)) +BEGIN +/** + * Verifica si el empleado puede fichar + * @param vWorker Identificador del trabajador + * @param vTimed valor de la fichada, IF vTimed IS NULL vTimed = NOW() + * @param vDirection solo se pueden pasa los valores del campo workerTimeControl.direction ENUM('in', 'out', 'middle') + * @return Si todo es correcto, retorna el número de id la tabla workerTimeControl. Si hay algún problema, devuelve el mesaje a que se debe mostrar al usuario + * Solo retorna el primer problema, en caso de no ocurrir ningún error se añadirá fichada a la tabla vn.workerTimeControl + */ + DECLARE vLastIn DATETIME; + DECLARE vLastOut DATETIME; + DECLARE vNextIn DATETIME; + DECLARE vLastDirection VARCHAR(6); + DECLARE vNextDirection VARCHAR(6); + DECLARE vDayBreak INT; + DECLARE vShortWeekBreak INT; + DECLARE vLongWeekBreak INT; + DECLARE vWeekScope INT; + DECLARE vGap INT; + DECLARE vMailTo VARCHAR(50) DEFAULT NULL; + DECLARE vUserName VARCHAR(50) DEFAULT NULL; + DECLARE vIsError BOOLEAN DEFAULT FALSE; + DECLARE vErrorMessage VARCHAR(255) DEFAULT NULL; + DECLARE vErrorCode VARCHAR(50); + DECLARE vDated DATE; + DECLARE vIsAllowedToWork VARCHAR(50); + DECLARE vDepartmentFk INT; + DECLARE vTimedLoop INT; + DECLARE vTimedLoopPrevious INT; + DECLARE vHasBreakWeek BOOLEAN DEFAULT FALSE; + DECLARE vManual BOOLEAN DEFAULT TRUE; + DECLARE vDone INT DEFAULT FALSE; + + DECLARE vCursor CURSOR FOR + SELECT UNIX_TIMESTAMP(NOW() - INTERVAL vGap SECOND) + UNION + SELECT UNIX_TIMESTAMP(NOW()) + UNION + (SELECT UNIX_TIMESTAMP(timed) + FROM workerTimeControl + WHERE timed BETWEEN (vTimed - INTERVAL vGap SECOND) AND vTimed AND + userFk = vWorker AND + direction IN ('in', 'out') + ORDER BY timed ASC); + + DECLARE vCursor2 CURSOR FOR + SELECT UNIX_TIMESTAMP(NOW() - INTERVAL vGap SECOND) + UNION + SELECT UNIX_TIMESTAMP(NOW()) + UNION + SELECT UNIX_TIMESTAMP(timed) + FROM workerTimeControl + WHERE timed BETWEEN vTimed AND (vTimed - INTERVAL vGap SECOND) AND + userFk = vWorker AND + direction IN ('in', 'out') + ORDER BY timed ASC; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + DECLARE EXIT HANDLER FOR SQLSTATE '45000' + BEGIN + + SELECT email, CONCAT(w.firstName, ' ', w.lastName) + INTO vMailTo, vUserName + FROM account.user u + JOIN worker w ON w.bossFk = u.id + WHERE w.id = vWorker; + + CASE vErrorCode + WHEN 'IS_NOT_ALLOWED_FUTURE' THEN + SELECT 'No se permite fichar a futuro' INTO vErrorMessage; + WHEN 'INACTIVE_BUSINESS' THEN + SELECT 'No hay un contrato en vigor' INTO vErrorMessage; + WHEN 'IS_NOT_ALLOWED_WORK' THEN + SELECT 'No está permitido trabajar' INTO vErrorMessage; + WHEN 'ODD_WORKERTIMECONTROL' THEN + SELECT 'Fichadas impares' INTO vErrorMessage; + WHEN 'BREAK_DAY' THEN + SELECT CONCAT('Descanso diario ', FORMAT(vDayBreak/3600, 0) , 'h.') INTO vErrorMessage; + WHEN 'BREAK_WEEK' THEN + SELECT CONCAT('Descanso semanal ', + FORMAT(vShortWeekBreak / 3600,0) ,'h. / ', + FORMAT(vLongWeekBreak / 3600, 0) ,'h.') INTO vErrorMessage; + WHEN 'WRONG_DIRECTION' THEN + SELECT 'Dirección incorrecta' INTO vErrorMessage; + ELSE + SELECT 'Error sin definir'INTO vErrorMessage; + END CASE; + + SELECT vErrorMessage `error`; + SELECT CONCAT(vUserName, ' no ha podido fichar por el siguiente problema: ', vErrorMessage) INTO vErrorMessage; + CALL mail_insert( vMailTo, vMailTo, 'Error al fichar', vErrorMessage); + + END; + + IF (vTimed IS NULL) THEN + SET vTimed = NOW(); + SET vManual = FALSE; + END IF; + + SET vDated = DATE(vTimed); + + SELECT IF(pc.category_name = 'Conductor +3500kg', wc.dayBreakDriver, wc.dayBreak), + wc.shortWeekBreak, + wc.longWeekBreak, + wc.weekScope + INTO vDayBreak, + vShortWeekBreak, + vLongWeekBreak, + vWeekScope + FROM workerLabour w + JOIN postgresql.business_labour bl ON bl.business_id = w.businessFk + JOIN postgresql.professional_category pc ON pc.professional_category_id = bl.professional_category_id + JOIN workerTimeControlConfig wc ON TRUE + WHERE w.workerFk = vWorker + AND vDated BETWEEN w.started AND IFNULL(w.ended, vDated); + + SELECT timed INTO vLastIn + FROM workerTimeControl + WHERE userFk = vWorker + AND direction = 'in' + AND timed < vTimed + ORDER BY timed DESC + LIMIT 1; + + SELECT timed INTO vLastOut + FROM workerTimeControl + WHERE userFk = vWorker + AND direction = 'out' + AND timed < vTimed + ORDER BY timed DESC + LIMIT 1; + + SELECT timed INTO vNextIn + FROM workerTimeControl + WHERE userFk = vWorker + AND direction = 'in' + AND timed > vTimed + ORDER BY timed ASC + LIMIT 1; + + SELECT direction INTO vNextDirection + FROM workerTimeControl + WHERE userFk = vWorker + AND timed > vTimed + ORDER BY timed ASC + LIMIT 1; + + SELECT direction INTO vLastDirection + FROM workerTimeControl + WHERE userFk = vWorker + AND timed < vTimed + ORDER BY timed DESC + LIMIT 1; + + -- FICHADAS A FUTURO + IF vTimed > DATE_ADD(NOW(), INTERVAL 60 SECOND) THEN + SET vErrorCode = 'IS_NOT_ALLOWED_FUTURE'; + CALL util.throw(vErrorCode); + END IF; + + -- CONTRATO EN VIGOR + IF vDayBreak IS NULL THEN + SET vErrorCode = 'INACTIVE_BUSINESS'; + CALL util.throw(vErrorCode); + END IF; + + -- VERIFICAR SI ESTÁ PERMITIDO TRABAJAR + CALL timeBusiness_calculateByWorker(vWorker, vDated, vDated); + SELECT isAllowedToWork INTO vIsAllowedToWork + FROM tmp.timeBusinessCalculate; + DROP TEMPORARY TABLE tmp.timeBusinessCalculate; + + IF NOT vIsAllowedToWork THEN + SET vErrorCode = 'IS_NOT_ALLOWED_WORK'; + CALL util.throw(vErrorCode); + END IF; + + -- DIRECCION CORRECTA + CALL vn.workerTimeControl_direction(vWorker, vTimed); + IF (SELECT IF(IF(option1 IN ('inMiddle', 'outMiddle'), 'middle', option1) <> vDirection + AND IF(option2 IN ('inMiddle', 'outMiddle'), 'middle', IFNULL(option2, '')) <> vDirection, TRUE , FALSE) + FROM tmp.workerTimeControlDirection) THEN + SET vIsError = TRUE; + END IF; + + DROP TEMPORARY TABLE tmp.workerTimeControlDirection; + IF vIsError = TRUE THEN + SET vErrorCode = 'WRONG_DIRECTION'; + CALL util.throw(vErrorCode); + END IF; + + -- FICHADAS IMPARES + IF (SELECT IF(vDirection = 'in', MOD(COUNT(*), 2) , IF (vDirection = 'out', NOT MOD(COUNT(*), 2), FALSE)) + FROM workerTimeControl + WHERE userFk = vWorker + AND timed BETWEEN vLastIn AND vTimed + ) THEN + SET vErrorCode = 'ODD_WORKERTIMECONTROL'; + CALL util.throw(vErrorCode); + END IF; + + -- DESCANSO DIARIO + CASE vDirection + WHEN 'in' THEN + IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) <= vDayBreak THEN + SET vIsError = TRUE; + END IF; + WHEN 'out' THEN + IF UNIX_TIMESTAMP(vNextIn) - UNIX_TIMESTAMP(vTimed) <= vDayBreak THEN + SET vIsError = TRUE; + END IF; + ELSE BEGIN END; + END CASE; + + IF vIsError THEN + SET vErrorCode = 'BREAK_DAY'; + CALL util.throw(vErrorCode); + END IF; + + -- VERIFICAR DESCANSO SEMANAL + IF (vDirection IN('in', 'out')) THEN + -- VERIFICA DESCANSO CORTO EN LA ÚLTIMA SEMANA + SET vGap = vWeekScope; + SET vTimedLoopPrevious = UNIX_TIMESTAMP((vTimed - INTERVAL vGap SECOND)); + SET vDone = FALSE; + OPEN vCursor; + l:LOOP + FETCH vCursor INTO vTimedLoop; + IF vDone THEN + LEAVE l; + END IF; + IF vShortWeekBreak - (vTimedLoop - vTimedLoopPrevious) < 0 THEN + SET vHasBreakWeek = TRUE; + LEAVE l; + END IF; + SET vTimedLoopPrevious = vTimedLoop; + END LOOP l; + CLOSE vCursor; + -- VERIFICA DESCANSO LARGO EN LA ÚLTIMAS 2 SEMANAS + IF NOT vHasBreakWeek THEN + SET vGap = vWeekScope * 2; + SET vTimedLoopPrevious = UNIX_TIMESTAMP((vTimed - INTERVAL vGap SECOND)); + SET vDone = FALSE; + OPEN vCursor; + l:LOOP + FETCH vCursor INTO vTimedLoop; + IF vDone THEN + LEAVE l; + END IF; + IF vLongWeekBreak - (vTimedLoop - vTimedLoopPrevious) < 0 THEN + SET vHasBreakWeek = TRUE; + LEAVE l; + END IF; + SET vTimedLoopPrevious = vTimedLoop; + END LOOP l; + CLOSE vCursor; + END IF; + + IF vManual THEN + -- VERIFICA DESCANSO CORTO EN LA PRÓXIMA SEMANA + SET vGap = vWeekScope; + SET vTimedLoopPrevious = vTimed; + SET vDone = FALSE; + OPEN vCursor; + l:LOOP + FETCH vCursor INTO vTimedLoop; + IF vDone THEN + LEAVE l; + END IF; + IF vShortWeekBreak - (vTimedLoop - vTimedLoopPrevious) < 0 THEN + SET vHasBreakWeek = TRUE; + LEAVE l; + END IF; + SET vTimedLoopPrevious = vTimedLoop; + END LOOP l; + CLOSE vCursor; + -- VERIFICA DESCANSO LARGO EN LAS PRÓXIMAS 2 SEMANAS + IF NOT vHasBreakWeek THEN + SET vGap = vWeekScope * 2; + SET vTimedLoopPrevious = vTimed; + SET vDone = FALSE; + OPEN vCursor; + l:LOOP + FETCH vCursor INTO vTimedLoop; + IF vDone THEN + LEAVE l; + END IF; + IF vShortWeekBreak - (vTimedLoop - vTimedLoopPrevious) < 0 THEN + SET vHasBreakWeek = TRUE; + LEAVE l; + END IF; + SET vTimedLoopPrevious = vTimedLoop; + END LOOP l; + CLOSE vCursor; + END IF; + END IF; + IF NOT vHasBreakWeek THEN + SET vErrorCode = 'BREAK_WEEK'; + CALL util.throw(vErrorCode); + END IF; + END IF; + + -- SE PERMITE FICHAR + INSERT INTO workerTimeControl(userFk, timed, direction, manual) + VALUES(vWorker, vTimed, vDirection, vManual); + + SELECT LAST_INSERT_ID() 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 `workerTimeControl_direction` */; +/*!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_direction`(vWorkerFk VARCHAR(10), vTimed DATETIME) +BEGIN +/** + * Devuelve que direcciones de fichadas son lógicas a partir de la anterior fichada + * @param vWorkerFk Identificador del trabajador + * @return (option1, option2) + * Los valores posibles de retorno son ('in', 'inMiddle', 'outMiddle', 'out') + */ + DECLARE vLastIn DATETIME ; + DECLARE vIsMiddleOdd BOOLEAN ; + + IF (vTimed IS NULL) THEN + SET vTimed = NOW(); + END IF; + + SELECT timed INTO vLastIn + FROM workerTimeControl + WHERE userFk = vWorkerFk + AND direction = 'in' + AND timed < vTimed + ORDER BY timed DESC + LIMIT 1; + + SELECT (COUNT(*)mod 2 = 1) INTO vIsMiddleOdd + FROM workerTimeControl + WHERE userFk = vWorkerFk + AND direction = 'middle' + AND timed BETWEEN vLastIn AND NOW(); + + DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlDirection; + + CREATE TEMPORARY TABLE tmp.workerTimeControlDirection + SELECT CASE WHEN w.direction ='in' THEN 'inMiddle' + WHEN w.direction = 'out' THEN 'in' + WHEN w.direction = 'middle' AND vIsMiddleOdd THEN 'outMiddle' + WHEN w.direction IS NULL THEN 'in' + ELSE 'inMiddle' + END option1, + CASE WHEN w.direction ='in' THEN 'out' + WHEN w.direction = 'out' THEN NULL + WHEN w.direction = 'middle' AND vIsMiddleOdd THEN NULL + WHEN w.direction IS NULL THEN NULL + ELSE 'out' + END option2 + FROM workerTimeControl w + WHERE w.timed <= vTimed + AND w.userFk = vWorkerFk + ORDER BY w.timed DESC + LIMIT 1; + + IF (SELECT IF(COUNT(*)=0, TRUE, FALSE) FROM tmp.workerTimeControlDirection ) THEN + INSERT INTO tmp.workerTimeControlDirection (option1, option2) + VALUES('in', NULL); + 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 `workerTimeControl_getClockIn` */; +/*!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_getClockIn`(vUserFk INT, vDated DATE) +BEGIN + +/** + * Muestra una tabla con los 7 días inmediatamente anteriores a la fecha proporcionada + * y las fichadas de cada dia, en columnas por día + * + */ + + CALL workerTimeControl_setOrder(vUserFk,TIMESTAMPADD(DAY,-8,vDated),vDated); + + DROP TEMPORARY TABLE IF EXISTS tmp.workerWeekTiming; + CREATE TEMPORARY TABLE tmp.workerWeekTiming + SELECT orden `orden`, + max(hace7dias) 7_dias_antes, + max(hace6dias) 6_dias_antes, + max(hace5dias) 5_dias_antes, + max(hace4dias) 4_dias_antes, + max(hace3dias) 3_dias_antes, + max(antesdeayer) 2_dias_antes, + max(ayer) 1_dia_antes, + max(hoy) mismo_dia + FROM + ( + SELECT IF(dias = 7, fichada, '') as hace7dias, + IF(dias = 6, fichada, '') as hace6dias, + IF(dias = 5, fichada, '') as hace5dias, + IF(dias = 4, fichada, '') as hace4dias, + IF(dias = 3, fichada, '') as hace3dias, + IF(dias = 2, fichada, '') as antesdeayer, + IF(dias = 1, fichada, '') as ayer, + IF(dias = 0, fichada, '') as hoy, + orden + + FROM + ( + SELECT `order` as orden, datediff(vDated, timed) as dias, date(timed) as fecha, TIME_FORMAT(timed,'%H:%i') as fichada + FROM vn.workerTimeControl wtc + WHERE userFk = vUserFk + AND timed >= TIMESTAMPADD(DAY, -7, vDated) + ) sub + )sub2 + GROUP BY orden; + + DROP TEMPORARY TABLE IF EXISTS tmp.workerWeekTiming_Aux; + CREATE TEMPORARY TABLE tmp.workerWeekTiming_Aux + SELECT * FROM tmp.workerWeekTiming; + + INSERT INTO tmp.workerWeekTiming( 7_dias_antes, 6_dias_antes, 5_dias_antes, 4_dias_antes, 3_dias_antes, 2_dias_antes, 1_dia_antes, mismo_dia) + VALUES('total','','','','','','',''); + + INSERT INTO tmp.workerWeekTiming( orden, 7_dias_antes, 6_dias_antes, 5_dias_antes, 4_dias_antes, 3_dias_antes, 2_dias_antes, 1_dia_antes, mismo_dia) + SELECT 0, + IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(7_dias_antes), TIME_TO_SEC(7_dias_antes)))),'%H:%i'),''), + IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(6_dias_antes), TIME_TO_SEC(6_dias_antes)))),'%H:%i'),''), + IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(5_dias_antes), TIME_TO_SEC(5_dias_antes)))),'%H:%i'),''), + IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(4_dias_antes), TIME_TO_SEC(4_dias_antes)))),'%H:%i'),''), + IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(3_dias_antes), TIME_TO_SEC(3_dias_antes)))),'%H:%i'),''), + IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(2_dias_antes), TIME_TO_SEC(2_dias_antes)))),'%H:%i'),''), + IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(1_dia_antes), TIME_TO_SEC(1_dia_antes)))),'%H:%i'),''), + '' + FROM tmp.workerWeekTiming_Aux; + + INSERT INTO tmp.workerWeekTiming_Aux( orden, 1_dia_antes) + SELECT 0, ROUND(( + IFNULL(TIME_TO_SEC(7_dias_antes),0) + + IFNULL(TIME_TO_SEC(6_dias_antes),0) + + IFNULL(TIME_TO_SEC(5_dias_antes),0) + + IFNULL(TIME_TO_SEC(4_dias_antes),0) + + IFNULL(TIME_TO_SEC(3_dias_antes),0) + + IFNULL(TIME_TO_SEC(2_dias_antes),0) + + IFNULL(TIME_TO_SEC(1_dia_antes),0) + ) / 3600,1) + FROM tmp.workerWeekTiming + WHERE orden = 0; + + + INSERT INTO tmp.workerWeekTiming( 7_dias_antes,6_dias_antes,5_dias_antes,4_dias_antes,3_dias_antes,2_dias_antes,1_dia_antes,mismo_dia) + SELECT '','','','','','',1_dia_antes,'' + FROM tmp.workerWeekTiming_Aux + WHERE orden = 0; + + SELECT 7_dias_antes, 6_dias_antes, 5_dias_antes, 4_dias_antes, 3_dias_antes, 2_dias_antes, 1_dia_antes, mismo_dia FROM tmp.workerWeekTiming; + + DROP TEMPORARY TABLE tmp.workerWeekTiming; + DROP TEMPORARY TABLE tmp.workerWeekTiming_Aux; + +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_login` */; +/*!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_login`(vWorkerFk VARCHAR(10)) +BEGIN +/** + * Consulta la información del usuario y los botones que tiene que activar en la tablet tras hacer login + * Solo retornará 1 ó 2 opciones de las 4 posibles + * @param vWorkerFk Identificador del trabajador + * @return (name, surname, userFk, departmentFk, button1, button2) + * Los valores posibles para button son ('in', 'inMiddle', 'outMiddle', 'out') + */ + CALL vn.workerTimeControl_direction(vWorkerFk, NOW()); + + SELECT wi.name, + wi.surname, + wi.userFk, + wi.departmentFk, + w.option1 button1, + w.option2 button2 + FROM workerTimeControlUserInfo wi + JOIN tmp.workerTimeControlDirection w + WHERE wi.userFk = vWorkerFk + LIMIT 1; + + DROP TEMPORARY TABLE tmp.workerTimeControlDirection; +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_remove` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -81085,8 +82636,8 @@ BEGIN DECLARE vStarted VARCHAR(25); DECLARE vEnded VARCHAR(25); DECLARE vDone BOOL; - DECLARE vSender VARCHAR(255); - DECLARE vSenderOld VARCHAR(255); + DECLARE vReceiver VARCHAR(255); + DECLARE vReceiverOld VARCHAR(255); DECLARE vDated DATE; DECLARE vTimeWorkDecimal DECIMAL(5,2); DECLARE vTimeWorkSexagesimal VARCHAR(5); @@ -81171,9 +82722,9 @@ BEGIN SET vTimeWorkDecimalTotal = 0; SET vBody= ''; OPEN vCursor; - FETCH vCursor INTO vSender, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk, vPermissionRate, vIsTeleworking ; + FETCH vCursor INTO vReceiver, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk, vPermissionRate, vIsTeleworking ; SET vWorkerFkOld = vWorkerFk ; - SET vSenderOld = vSender; + SET vReceiverOld = vReceiver; SET vIsTeleworkingOld = vIsTeleworking; proc: LOOP IF vDone THEN @@ -81274,7 +82825,7 @@ proc: LOOP 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; + FETCH vCursor INTO vReceiver, 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 @@ -81310,11 +82861,12 @@ proc: LOOP "); 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)); + CALL mail_insert( + vReceiverOld, + '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); @@ -81324,7 +82876,7 @@ proc: LOOP SET vTimeWorkDecimalTotal = 0; SET vWorkerFkOld = vWorkerFk; SET vIsTeleworkingOld = vIsTeleworking; - SET vSenderOld = vSender; + SET vReceiverOld = vReceiver; END IF; END LOOP; CLOSE vCursor; @@ -81339,7 +82891,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 `workerTimeControl_sendMail__` */; +/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_sendMailByDepartment` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -81349,263 +82901,148 @@ DELIMITER ; /*!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) +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_sendMailByDepartment`(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 - 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.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; + /** + * Inserta el registro de horario semanalmente de PRODUCCION, CAMARA, TALLER NATURAL y TALLER ARTIFICIAL en vn.mail. + * + * @param vWeek + * @param vYear + * @param vWorkerFk -> En el caso de querer generarlo para todos los empleados deberá de informarse como NULL + */ - 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 + DECLARE vDateStart DATETIME; + DECLARE vDateEnd DATETIME; + + SELECT CONCAT (MIN(dated), ' 00:00:00'), CONCAT (MAX(dated), ' 23:59:59') INTO vDateStart, vDateEnd 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); + WHERE year = vYear AND + week = vWeek; + + SET session group_concat_max_len = 15000; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; + DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; + DROP TEMPORARY TABLE IF EXISTS tmp.reportHours; + + IF vWorkerFk IS NULL THEN + CALL timeControl_calculateAll(vDateStart,vDateEnd); + CALL timeBusiness_calculateAll(vDateStart,vDateEnd); 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 ; - SET vWorkerFkOld = vWorkerFk ; - SET vSenderOld = vSender; - proc: LOOP - IF vDone THEN - LEAVE proc; - END IF; + CALL timeControl_calculateByUser(vWorkerFk,vDateStart,vDateEnd); + CALL timeBusiness_calculateByUser(vWorkerFk,vDateStart,vDateEnd); + 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; + CREATE TEMPORARY TABLE tmp.reportHours + SELECT t.dated, + IF (tm.hoursWeek IS NULL,'', GROUP_CONCAT(DATE_FORMAT(wtc.timed,'%H:%i') ORDER BY wtc.timed ASC SEPARATOR ' ') ) timeWorkDay, + IFNULL(tm.timeWorkDecimal,0) tm, + IFNULL(CAST(tc.timeWorkDecimal AS DECIMAL (10,2)) , 0) tc, + IFNULL(CAST(IFNULL(tc.timeWorkDecimal, 0) - IFNULL(tm.timeWorkDecimal, 0) AS DECIMAL (10,2)), 0) balance, + w.lastName, + w.firstname, + c.fi, + w.id, + MONTHNAME(t.dated) mes, + YEAR(t.dated) año, + w.userFk, + tm.hoursWeek, + tm.type, + wl.started, + wl.ended, + d.name, + tm.businessFk + FROM time t + LEFT JOIN tmp.timeBusinessCalculate tm ON tm.dated = t.dated + LEFT JOIN tmp.timeControlCalculate tc ON tc.dated = tm.dated AND tc.userFk = tm.userFk + LEFT JOIN vn.workerTimeControl wtc ON wtc.userFk = tm.userFk AND DATE(wtc.timed) = t.dated + LEFT JOIN workerLabour wl ON wl.workerFk = tm.userFk AND wl.businessFk = tm.businessFk + LEFT JOIN workCenter wc ON wc.id = wl.workCenterFk + LEFT JOIN department d ON d.id = wl.departmentFk + LEFT JOIN worker w ON w.id = tm.userFk + LEFT JOIN client c ON c.id = w.id + WHERE wc.name NOT IN ('VNH') + AND d.hasToSendMail + AND wl.ended >= CURDATE() + GROUP BY tm.userFk,t.dated + ORDER BY tm.userFk,t.dated; - 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; + INSERT INTO vn.mail (receiver, replyTo, subject, body) + SELECT eu.email, 'laboral@verdnatura.es', CONCAT('Registro de horas semana ', WEEK(CURDATE())-1, ' año ', YEAR(CURDATE())) , + CONCAT(' + + + + + + +
+

REGISTRO DE LA JORNADA DE LOS TRABAJADORES

+ + + + + + + + + + + + + + + + +
+ Según la información recogida en el sistema, adjuntamos tabla con los registros. Cualquier incidencia rogamos la comunique a laboral@verdnatura.es. +

+
Empresa: Verdnatura Levante SL
Trabajador: ',IFNULL(rh.firstname,' '),' ',IFNULL(rh.lastName,' '), ' NIF: ',IFNULL(rh.fi,' '), '
AÑO: ',IFNULL(rh.año,' '), ' MES: ',IFNULL(UPPER(rh.mes),' '), ' Calendario Laboral: ',IFNULL(rh.hoursWeek,' '),' horas semanales
+
+ + + + + + + + + ', + GROUP_CONCAT(DISTINCT '' ORDER BY rh.dated SEPARATOR ''), + ' + + + + + + +
Fecha:Día:Fichadas:Horas a trabajar:Horas trabajadas:Balance:
', DATE_FORMAT( rh.dated, '%d-%m-%y'), + ' ', CONCAT(UCASE(LEFT(DAYNAME(rh.dated), 1)), SUBSTRING(DAYNAME(rh.dated), 2)), + ' ', IFNULL(rh.timeWorkDay,' '),' ', IFNULL(rh.type,' '), + ' ', IF(rh.tm = 0,' ',rh.tm), + ' ', IF(rh.tc = 0,' ',rh.tc), + ' ', IF(rh.balance = 0,' ',rh.balance), '
Total horas trabajadas: ', SUM(rh.tc),'', SUM(rh.balance),'
+ ') + FROM tmp.reportHours rh + JOIN account.emailUser eu ON rh.id = eu.userFk + GROUP BY rh.id; - 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; - DROP TABLE IF EXISTS tmp.timeControlCalculate1; - DROP TABLE IF EXISTS tmp.timeBusinessCalculate1; + DROP TEMPORARY TABLE tmp.timeControlCalculate; + DROP TEMPORARY TABLE tmp.timeBusinessCalculate; + DROP TEMPORARY TABLE tmp.reportHours; 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 DROP PROCEDURE IF EXISTS `workerTimeControl_sendMailByDepartmentLauncher` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -81615,247 +83052,47 @@ DELIMITER ; /*!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) +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_sendMailByDepartmentLauncher`() 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 - 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.timeBusinessCalculate tb - LEFT JOIN tmp.timeControlCalculate 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.isTeleworking AND - IFNULL(vWorkerFk,u.id) = u.id AND - c.code = 'VNL' - ORDER BY u.id, tb.dated; + DECLARE vWeek,vYear INT; - 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 (DAYNAME(CURDATE()) = 'miércoles') THEN + SELECT week,year INTO vWeek,vYear + FROM vn.time + WHERE dated IN (DATE_ADD(CURDATE(), INTERVAL -10 DAY), DATE_ADD(CURDATE(), INTERVAL -4 DAY)) + GROUP BY year,week + LIMIT 1; + + CALL vn.workerTimeControl_sendMailByDepartment(vWeek, vYear, NULL); + 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 `workerTimeControl_setOrder` */; +/*!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_setOrder`(vUserFk INT, vStarted DATE, vFinished DATE) +BEGIN - 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; + SET @order := 0; + SET @day := '2000-01-01'; - 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; + UPDATE vn.workerTimeControl w + SET w.`order` = @order := IF(@day = @day := date(timed), @order, 0) + 1 + WHERE w.userFk = vUserFk + AND w.timed BETWEEN vStarted AND util.dayend(vFinished) + ORDER BY w.timed; - 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 */ ; @@ -82613,7 +83850,7 @@ BEGIN FROM tmp.workerSalaryRoleDelivery tb WHERE (tb.description IN ('Festivo') OR dayofweek(tb.dated)=1) AND tb.extra = 0 ; - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk,dated,id,packages,hours,km,m3Delivery,m3Load,amountDelivery,amountLoad,AmountKm,description, extra) +/* INSERT INTO tmp.workerSalaryRoleDelivery (workerFk,dated,id,packages,hours,km,m3Delivery,m3Load,amountDelivery,amountLoad,AmountKm,description, extra) SELECT workerFk, dated, d.id, @@ -82628,7 +83865,7 @@ BEGIN CONCAT('Plus festivo: ',description), extra FROM tmp.daysToRateHoliday d - LEFT JOIN routeConfig r ON TRUE; + LEFT JOIN routeConfig r ON TRUE;*/ DROP TEMPORARY TABLE IF EXISTS tmp.daysToDelete; CREATE TEMPORARY TABLE tmp.daysToDelete @@ -82640,23 +83877,6 @@ BEGIN FROM tmp.workerSalaryRoleDelivery d JOIN tmp.daysToDelete dd on dd.dated = d.dated 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, - dated, - d.id, - packages, - hours, - km, - m3Delivery, - m3Load, - amountDelivery * r.rateHoliday, - amountLoad * r.rateHoliday, - AmountKm * r.rateHoliday, - CONCAT('Plus festivo: ', description), - extra - FROM tmp.daysToRateHoliday d - LEFT JOIN routeConfig r ON TRUE; INSERT INTO tmp.workerSalaryRoleDelivery (workerFk, dated, @@ -82947,280 +84167,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 `worker_calculateSalaryRoleDelivery___` */; -/*!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 `worker_calculateSalaryRoleDelivery___`(vWorkerFk INTEGER,vDateFrom DATE,vDateTo DATE) -BEGIN -/** - * Calcula el salario de trabajadores para los departamentos de reparto, paletizado - * - * @param vDateFrom - * @param vDateTo - * @param vWorkerFk - * @return tmp.workerSalaryRoleDelivery - */ - DROP TEMPORARY TABLE IF EXISTS tmp.workerSalaryRoleDelivery; - - CREATE TEMPORARY TABLE tmp.workerSalaryRoleDelivery - SELECT w.id workerFk, - r.created dated, - r.id, - SUM(t.packages) packages, - CAST(time_to_sec(TIMEDIFF( DATE_FORMAT(r.finished, '%H:%i:%s'),DATE_FORMAT(r.time, '%H:%i:%s'))) / (60 * 60) AS DECIMAL(10, 1)) hours , - r.kmEnd-r.kmStart km, - r.m3 m3Delivery, - CAST(r.m3/loadWorker AS DECIMAL(10,2)) m3Load, - CAST(rc.m3Distribution*m3 AS DECIMAL(10,2)) amountDelivery, - CASE loadWorker - WHEN 1 THEN CAST(r.m3/ loadWorker*rc.load1m3 AS DECIMAL(10,2)) - WHEN 2 THEN CAST(r.m3/ loadWorker*rc.load2m3 AS DECIMAL(10,2)) - WHEN 3 THEN CAST(r.m3/ loadWorker*rc.load3m3 AS DECIMAL(10,2)) - WHEN 4 THEN CAST(r.m3/ loadWorker*rc.load4m3 AS DECIMAL(10,2)) - WHEN 5 THEN CAST(r.m3/ loadWorker*rc.load5m3 AS DECIMAL(10,2)) - ELSE CAST(r.m3/ loadWorker*rc.load6m3 AS DECIMAL(10,2)) - END amountLoad, - rc.kmRate*(r.kmEnd-r.kmStart) amountKm, - CAST('' AS CHAR(45)) description, - CAST( 0 AS DECIMAL(10,2)) extra, - CAST( 0 AS DECIMAL(10,2)) maxSalary - FROM ticket t - LEFT JOIN route r ON t.routeFk = r.id - LEFT JOIN worker w ON w.id = r.workerFk - LEFT JOIN routeConfig rc ON TRUE - LEFT JOIN (SELECT rw.routeFk, COUNT(rw.workerFk) loadWorker - FROM routeLoadWorker rw - JOIN routeLoadWorker rw2 ON rw.routeFk = rw2.routeFk AND rw2.workerFk = vWorkerFk - GROUP BY rw2.routeFk - ) sub ON sub.routeFk=r.id - WHERE r.created BETWEEN vDateFrom AND vDateTo AND w.id = vWorkerFk - GROUP BY r.id; - - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk, - dated, - id, - packages, - km, - m3Load, - amountLoad) - SELECT w.id , - r.created , - r.id, - SUM(t.packages) , - r.kmEnd-r.kmStart , - CAST(r.m3/loadWorker AS DECIMAL(10,2)) , - CASE loadWorker - WHEN 1 THEN CAST(r.m3/ loadWorker*rc.load1m3 AS DECIMAL(10,2)) - WHEN 2 THEN CAST(r.m3/ loadWorker*rc.load2m3 AS DECIMAL(10,2)) - WHEN 3 THEN CAST(r.m3/ loadWorker*rc.load3m3 AS DECIMAL(10,2)) - WHEN 4 THEN CAST(r.m3/ loadWorker*rc.load4m3 AS DECIMAL(10,2)) - WHEN 5 THEN CAST(r.m3/ loadWorker*rc.load5m3 AS DECIMAL(10,2)) - ELSE CAST(r.m3/ loadWorker*rc.load6m3 AS DECIMAL(10,2)) - END - FROM (SELECT rw.routeFk, COUNT(rw.workerFk) loadWorker - FROM routeLoadWorker rw - JOIN routeLoadWorker rw2 ON rw.routeFk = rw2.routeFk AND rw2.workerFk = vWorkerFk - GROUP BY rw2.routeFk) sub - LEFT JOIN route r ON sub.routeFk = r.id - LEFT JOIN ticket t ON t.routeFk = r.id - LEFT JOIN worker w ON w.id = r.workerFk - LEFT JOIN routeConfig rc ON TRUE - WHERE r.created BETWEEN vDateFrom AND vDateTo AND w.id <> vWorkerFk - GROUP BY r.id; - - INSERT INTO tmp.workerSalaryRoleDelivery(workerFk, - dated, - description, - extra) - SELECT workerFk, - dated, - GROUP_CONCAT(ra.name) , - CAST(SUM(rc.price) AS DECIMAL(9,2)) - FROM routeComplement rc - JOIN routeAction ra ON rc.routeActionFk=ra.id - WHERE dated BETWEEN vDateFrom AND vDateTo AND workerFk=vWorkerFk - GROUP BY dated; - - CALL timeBusiness_calculateByWorker(vWorkerFk, vDateFrom, vDateTo); - - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk, - dated, - description, - extra) - SELECT w.id, - tb.dated, - tb.type COLLATE utf8_general_ci, - CASE - WHEN tb.type = 'Vacaciones 1/2 día' OR tb.type = 'Permiso retribuido 1/2 día' - 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 - JOIN postgresql.business_labour_payroll blp ON blp.business_id = tb.businessFk - 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', 'Maternidad/Paternidad') - GROUP BY tb.dated; - - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk, - dated, - m3Delivery, - amountLoad, - description) - SELECT wdc.workerFk , - r.created, - SUM(r.m3) , - CASE - WHEN wdc.category = 1 - THEN CAST(SUM(r.m3) * rc.distributionM3Category1 AS DECIMAL (10,2)) - WHEN wdc.category = 2 - THEN CAST(SUM(r.m3) * rc.distributionM3Category2 AS DECIMAL (10,2)) - END amountLoad, - 'Gestión de la distribución' description - FROM route r - JOIN agencyMode am ON am.id= r.agencyModeFk - JOIN agency a ON a.id = am.agencyFk - JOIN workerDistributionCategory wdc ON wdc.workerFk = vWorkerFk - JOIN workerLabour wl ON r.created BETWEEN wl.started AND IFNULL(wl.ended, CURDATE()) AND wl.workerFk = wdc.workerFk AND a.workCenterFk = wl.workCenterFk - JOIN department v ON v.id = departmentFk - JOIN routeConfig rc - WHERE r.m3>0 AND created BETWEEN vDateFrom AND vDateTo AND - am.name NOT LIKE "REC_%" AND - v.name= "REPARTO" - GROUP BY r.created; - - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk, - dated, - m3Delivery, - amountLoad, - description) - SELECT sub.workerFk, - r.created, - SUM(r.m3), - CAST( (SUM(r.m3)*sub.percentage /100) * rc.m3Palletization AS DECIMAL (10,2) ), - 'Gestión de paletizado' - FROM route r - JOIN agencyMode am ON am.id= r.agencyModeFk - JOIN agency a ON a.id = am.agencyFk - JOIN (SELECT percentage,workerFk ,dated - FROM routeUserPercentage ru - WHERE workerFk = vWorkerFk AND ru.dated <= vDateTo - ORDER BY dated DESC LIMIT 1 - ) sub - JOIN routeConfig rc - JOIN workerLabour wl ON r.created BETWEEN wl.started AND IFNULL(wl.ended, CURDATE()) AND - wl.workerFk = sub.workerFk - JOIN department v ON v.id = departmentFk - WHERE r.m3>0 AND - r.created BETWEEN vDateFrom AND vDateTo AND - am.name NOT LIKE "REC_%" AND - v.name= "PALETIZADO" - GROUP BY r.created; - - DROP TEMPORARY TABLE IF EXISTS tmp.daysToRateHoliday; - CREATE TEMPORARY TABLE tmp.daysToRateHoliday - SELECT * - FROM tmp.workerSalaryRoleDelivery tb - WHERE (tb.description IN ('Festivo') OR dayofweek(tb.dated)=1) AND tb.extra = 0 ; - - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk,dated,id,packages,hours,km,m3Delivery,m3Load,amountDelivery,amountLoad,AmountKm,description, extra) - SELECT workerFk, - dated, - d.id, - packages, - hours, - km, - m3Delivery, - m3Load, - amountDelivery * r.rateHoliday, - amountLoad * r.rateHoliday, - AmountKm * r.rateHoliday, - CONCAT('Plus festivo: ',description), - extra - FROM tmp.daysToRateHoliday d - LEFT JOIN routeConfig r ON TRUE; - - DROP TEMPORARY TABLE IF EXISTS tmp.daysToDelete; - CREATE TEMPORARY TABLE tmp.daysToDelete - SELECT dated - FROM tmp.workerSalaryRoleDelivery d - 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', 'Maternidad/Paternidad'); - - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk,dated,id,packages,hours,km,m3Delivery,m3Load,amountDelivery,amountLoad,AmountKm,description, extra) - SELECT workerFk, - dated, - d.id, - packages, - hours, - km, - m3Delivery, - m3Load, - amountDelivery * r.rateHoliday, - amountLoad * r.rateHoliday, - AmountKm * r.rateHoliday, - CONCAT('Plus festivo: ', description), - extra - FROM tmp.daysToRateHoliday d - LEFT JOIN routeConfig r ON TRUE; - - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk, - dated, - description, - extra, - maxSalary) - SELECT wdc.workerFk , - CONCAT(YEAR(t.dated),'-', MONTH(t.dated),'-01') , - CASE - WHEN wdc.category = 1 - THEN rc.plusCategory1Concept - WHEN wdc.category = 2 - THEN rc.plusCategory2Concept - END, - CASE - WHEN wdc.category = 1 - THEN CAST(rc.plusCategory1 AS DECIMAL (10,2)) - WHEN wdc.category = 2 - THEN CAST(rc.plusCategory2 AS DECIMAL (10,2)) - END, - CASE - WHEN wdc.category = 1 - THEN CAST(rc.maxSalaryCategory1 AS DECIMAL (10,2)) - WHEN wdc.category = 2 - THEN CAST(rc.maxSalaryCategory2 AS DECIMAL (10,2)) - END - FROM worker w - JOIN workerDistributionCategory wdc ON wdc.workerFk = w.id - JOIN routeConfig rc - JOIN time t on t.dated BETWEEN vDateFrom AND vDateTo - WHERE w.id = vWorkerFk - GROUP BY MONTH(t.dated), YEAR(t.dated); - - DROP TEMPORARY TABLE tmp.daysToRateHoliday; - DROP TEMPORARY TABLE tmp.daysToDelete; - DROP TEMPORARY TABLE 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 `worker_getHierarchy` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -83335,7 +84281,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 `worker_getProductionerrors` */; +/*!50003 DROP PROCEDURE IF EXISTS `worker_getProductionErrors` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -83345,7 +84291,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `worker_getProductionerrors`(vAction VARCHAR(25), vDepartment VARCHAR(25), vStateCode VARCHAR(25) CHARSET utf8, vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE DEFINER=`root`@`%` PROCEDURE `worker_getProductionErrors`(vAction VARCHAR(25), vDepartment VARCHAR(25), vStateCode VARCHAR(25) CHARSET utf8, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.total; @@ -83371,9 +84317,9 @@ BEGIN GROUP BY st.workerFk; END IF; - SELECT sub1.id, sub1.firstName, sub1.lastName, CAST(sub1.totalTickets AS DECIMAL(10,0)) AS totalTickets, CAST(IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0) AS DECIMAL(10,0)) AS errors + SELECT sub1.id, sub1.firstName, sub1.lastName, CAST(sub1.totalTickets AS DECIMAL(10,0)) AS totalTickets, CAST(IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0) AS DECIMAL(10,0)) AS errors, (IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0))/sub1.totalTickets AS ratio, IF(vDepartment = 'Revisadores', NULL, volume) AS volume FROM( - SELECT w.id, w.code, w.firstName, w.lastName, t.ticketCount AS totalTickets, sub.errors + SELECT w.id, w.code, w.firstName, w.lastName, t.ticketCount AS totalTickets, sub.errors, sub2.volume FROM tmp.total AS t JOIN worker w ON w.id = t.workerFk LEFT JOIN ( @@ -83385,6 +84331,12 @@ BEGIN WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND cr.description = vDepartment GROUP BY cd.workerFk )sub ON t.workerFk = sub.workerFk + LEFT JOIN ( -- Añadir volume + SELECT SUM(w.volume) AS volume, w.workerFk + FROM bs.workerProductivity w + INNER JOIN vn.`role` r ON r.id=w.roleFk + WHERE IF(vDepartment = 'Encajadores', r.name='packager', r.name='itemPicker') AND w.dated BETWEEN vDatedFrom AND vDatedTo + GROUP BY w.workerFk) sub2 ON w.id = sub2.workerFk GROUP BY w.code) sub1 LEFT JOIN( SELECT sub1.workerFk, COUNT(id) AS errors @@ -84219,9 +85171,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 ;; @@ -84229,12 +85181,13 @@ CREATE DEFINER=`root`@`%` PROCEDURE `zone_getCollisions`() BEGIN /** * Calcula si para un mismo codigo postal y dia - * hay mas de una zona configurada + * hay mas de una zona configurada y manda correo * */ DECLARE vGeoFk INT DEFAULT NULL; DECLARE vZoneFk INT; DECLARE vIsDone INT DEFAULT FALSE; + DECLARE vTableCollisions TEXT; DECLARE cur1 CURSOR FOR SELECT zoneFk from tmp.zoneOption; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE; @@ -84257,7 +85210,8 @@ BEGIN sons INT, isChecked BOOL DEFAULT 0, zoneFk INT, - PRIMARY KEY zoneFkk (zoneFk, geoFk)) + PRIMARY KEY zoneFkk (zoneFk, geoFk), + INDEX(geoFk)) ENGINE = MEMORY; OPEN cur1; @@ -84294,25 +85248,53 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS geoCollision; CREATE TEMPORARY TABLE geoCollision - SELECT z.agencyModeFk, zn.geoFk + SELECT z.agencyModeFk, zn.geoFk, zw.warehouseFk FROM tmp.zoneNodes zn JOIN zone z ON z.id = zn.zoneFk - GROUP BY z.agencyModeFk, zn.geoFk + JOIN zoneWarehouse zw ON z.id = zw.zoneFk + GROUP BY z.agencyModeFk, zn.geoFk, zw.warehouseFk HAVING count(*) > 1; - SELECT zn.name postalCode, - zoneFk, - z.price, - z.name, - CONCAT('https://salix.verdnatura.es/#!/zone/', - zoneFk, - '/location?q=%7B%22search%22:%22', - zn.name, - '%22%7D') salix - FROM tmp.zoneNodes zn - JOIN zone z ON z.id = zn.zoneFk - JOIN geoCollision gc ON gc.agencyModeFk = z.agencyModeFk AND zn.geoFk = gc.geoFk; - + SELECT ' + + + + + + + + ' INTO vTableCollisions; + + INSERT INTO mail (receiver,replyTo,subject,body) + SELECT 'pepe@verdnatura.es' receiver, + 'noreply@verdnatura.es' replyTo, + CONCAT('Colisiones en zonas ', CURDATE()) subject, + CONCAT(vTableCollisions, + GROUP_CONCAT(sub.td SEPARATOR ''), + '
C.PostalNúmero de zonaPrecioZonaAlmacénSalix
') body + FROM(SELECT + CONCAT(' + ', zn.name, ' + ', zoneFk,' + ', z.price,' + ', z.name,' + ', w.name, ' + ', CONCAT('' + 'https://salix.verdnatura.es/#!/zone/', + zoneFk, + '/location?q=%7B%22search%22:%22', + zn.name, + '%22%7D'),' + ') td + FROM tmp.zoneNodes zn + JOIN zone z ON z.id = zn.zoneFk + JOIN geoCollision gc ON gc.agencyModeFk = z.agencyModeFk AND zn.geoFk = gc.geoFk + JOIN warehouse w ON w.id = gc.warehouseFk) sub; + DROP TEMPORARY TABLE geoCollision, tmp.zone, @@ -84614,9 +85596,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 ;; @@ -84663,11 +85645,13 @@ BEGIN IF vParentFk IS NULL THEN DROP TEMPORARY TABLE IF EXISTS tChilds; CREATE TEMPORARY TABLE tChilds + (INDEX(id)) ENGINE = MEMORY SELECT id FROM tNodes; DROP TEMPORARY TABLE IF EXISTS tParents; CREATE TEMPORARY TABLE tParents + (INDEX(id)) ENGINE = MEMORY SELECT id FROM zoneGeo LIMIT 0; @@ -84841,7 +85825,7 @@ BEGIN /** * Gets computed options for the passed zones and delivery date. * - * @table tmp.zones(id) The zones ids + * @table tmp.zone(id) The zones ids * @param vLanded The delivery date * @return tmp.zoneOption The computed options */ @@ -85115,7 +86099,7 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `zone_getShipped`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vShowExpiredZones BOOLEAN) BEGIN /** - * Devuelve la mínima fecha de envío para cada warehouse + * Devuelve la mínima fecha de envío para cada warehouse * * @param vLanded La fecha de recepcion * @param vAddressFk Id del consignatario @@ -85152,17 +86136,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 `zone_getShippedWarehouse` */; +/*!50003 DROP PROCEDURE IF EXISTS `zone_getShippedWarehouse__` */; /*!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 `zone_getShippedWarehouse`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getShippedWarehouse__`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) BEGIN /** * Devuelve la mínima fecha de envío para cada warehouse @@ -85696,22 +86680,22 @@ USE `bs`; /*!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 `lastIndicators` AS select `i`.`updated` AS `updated`,`i`.`lastYearSales` AS `lastYearSales`,(`i`.`lastYearSales` - `yi`.`lastYearSales`) AS `incLastYearSales`,`i`.`totalGreuge` AS `totalGreuge`,(`i`.`totalGreuge` - `yi`.`totalGreuge`) AS `incTotalGreuge`,`i`.`latePaymentRate` AS `latePaymentRate`,(`i`.`latePaymentRate` - `yi`.`latePaymentRate`) AS `incLatePaymentRate`,`i`.`countEmployee` AS `countEmployee`,(`i`.`countEmployee` - `yi`.`countEmployee`) AS `incCountEmployee`,`i`.`averageMana` AS `averageMana`,(`i`.`averageMana` - `yi`.`averageMana`) AS `incAverageMana`,`i`.`bankingPool` AS `bankingPool`,(`i`.`bankingPool` - `yi`.`bankingPool`) AS `incbankingPool`,`i`.`lastMonthActiveClients` AS `lastMonthActiveClients`,(`i`.`lastMonthActiveClients` - `yi`.`lastMonthActiveClients`) AS `incLastMonthActiveClients`,`i`.`lastMonthLostClients` AS `lastMonthLostClients`,(`i`.`lastMonthLostClients` - `yi`.`lastMonthLostClients`) AS `incLastMonthLostClients`,`i`.`lastMonthNewClients` AS `lastMonthNewClients`,(`i`.`lastMonthNewClients` - `yi`.`lastMonthNewClients`) AS `incLastMonthNewClients`,`i`.`lastMonthWebBuyingRate` AS `lastMonthWebBuyingRate`,(`i`.`lastMonthWebBuyingRate` - `yi`.`lastMonthWebBuyingRate`) AS `incLastMonthWebBuyingRate`,`i`.`productionHours` AS `productionHours`,`i`.`dailyWorkersCost` AS `dailyWorkersCost`,`i`.`volumeM3` AS `volumeM3`,`i`.`salesValue` AS `salesValue`,`i`.`valueM3` AS `valueM3`,`i`.`hoursM3` AS `hoursM3`,`i`.`workerCostM3` AS `workerCostM3`,`i`.`salesWorkersCostRate` AS `salesWorkersCostRate`,`i`.`thisWeekSales` AS `thisWeekSales`,`i`.`lastYearWeekSales` AS `lastYearWeekSales` from (`indicators` `i` join `indicators` `yi` on((`yi`.`updated` = (select (max(`indicators`.`updated`) + interval -(1) day) from `indicators`)))) where (`i`.`updated` = (select max(`indicators`.`updated`) from `indicators`)) */; +/*!50001 VIEW `lastIndicators` AS select `i`.`updated` AS `updated`,`i`.`lastYearSales` AS `lastYearSales`,(`i`.`lastYearSales` - `yi`.`lastYearSales`) AS `incLastYearSales`,`i`.`totalGreuge` AS `totalGreuge`,(`i`.`totalGreuge` - `yi`.`totalGreuge`) AS `incTotalGreuge`,`i`.`latePaymentRate` AS `latePaymentRate`,(`i`.`latePaymentRate` - `yi`.`latePaymentRate`) AS `incLatePaymentRate`,`i`.`countEmployee` AS `countEmployee`,(`i`.`countEmployee` - `yi`.`countEmployee`) AS `incCountEmployee`,`i`.`averageMana` AS `averageMana`,(`i`.`averageMana` - `yi`.`averageMana`) AS `incAverageMana`,`i`.`bankingPool` AS `bankingPool`,(`i`.`bankingPool` - `yi`.`bankingPool`) AS `incbankingPool`,`i`.`lastMonthActiveClients` AS `lastMonthActiveClients`,(`i`.`lastMonthActiveClients` - `yi`.`lastMonthActiveClients`) AS `incLastMonthActiveClients`,`i`.`lastMonthLostClients` AS `lastMonthLostClients`,(`i`.`lastMonthLostClients` - `yi`.`lastMonthLostClients`) AS `incLastMonthLostClients`,`i`.`lastMonthNewClients` AS `lastMonthNewClients`,(`i`.`lastMonthNewClients` - `yi`.`lastMonthNewClients`) AS `incLastMonthNewClients`,`i`.`lastMonthWebBuyingRate` AS `lastMonthWebBuyingRate`,(`i`.`lastMonthWebBuyingRate` - `yi`.`lastMonthWebBuyingRate`) AS `incLastMonthWebBuyingRate`,`i`.`productionHours__` AS `productionHours__`,`i`.`dailyWorkersCost__` AS `dailyWorkersCost__`,`i`.`volumeM3__` AS `volumeM3__`,`i`.`salesValue__` AS `salesValue__`,`i`.`valueM3__` AS `valueM3__`,`i`.`hoursM3__` AS `hoursM3__`,`i`.`workerCostM3__` AS `workerCostM3__`,`i`.`salesWorkersCostRate__` AS `salesWorkersCostRate__`,`i`.`thisWeekSales` AS `thisWeekSales`,`i`.`lastYearWeekSales` AS `lastYearWeekSales` from (`indicators` `i` join `indicators` `yi` on((`yi`.`updated` = (select (max(`indicators`.`updated`) + interval -(1) day) from `indicators`)))) where (`i`.`updated` = (select max(`indicators`.`updated`) from `indicators`)) */; /*!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 `m3Silla` +-- Final view structure for view `m3Silla__` -- -/*!50001 DROP TABLE IF EXISTS `m3Silla`*/; -/*!50001 DROP VIEW IF EXISTS `m3Silla`*/; +/*!50001 DROP TABLE IF EXISTS `m3Silla__`*/; +/*!50001 DROP VIEW IF EXISTS `m3Silla__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -85720,26 +86704,7 @@ USE `bs`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `m3Silla` AS select `m3`.`fecha` AS `fecha`,`m3`.`year` AS `year`,`m3`.`month` AS `month`,`m3`.`week` AS `week`,`m3`.`day` AS `day`,`m3`.`dayName` AS `dayName`,cast(sum(`m3`.`m3`) as decimal(10,0)) AS `Volumen`,cast(sum(`m3`.`euros`) as decimal(10,0)) AS `Euros` from `m3` where (`m3`.`warehouseFk` in (1,44)) group by `m3`.`fecha` */; -/*!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 `m3analisis` --- - -/*!50001 DROP TABLE IF EXISTS `m3analisis`*/; -/*!50001 DROP VIEW IF EXISTS `m3analisis`*/; -/*!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 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `m3analisis` AS select `m`.`fecha` AS `fecha`,`m`.`year` AS `year`,`m`.`month` AS `month`,`m`.`week` AS `week`,`m`.`day` AS `day`,`m`.`dayName` AS `dayName`,`m`.`Volumen` AS `Volumen`,`m`.`Euros` AS `Euros`,`h`.`Departamento` AS `Departamento`,`h`.`Horas` AS `Horas`,`h`.`Salarios` AS `Salarios`,(`h`.`Horas` / `m`.`Volumen`) AS `tiempoM3`,(`m`.`Euros` / `m`.`Volumen`) AS `valorM3`,(`h`.`Salarios` / `m`.`Volumen`) AS `costeLaboralM3`,(`h`.`Salarios` / `m`.`Euros`) AS `costeEuros`,(`h`.`Salarios` / `h`.`Horas`) AS `precioHora` from (`bs`.`m3Silla` `m` join `bs`.`horasSilla` `h` on((`h`.`Fecha` = `m`.`fecha`))) */; +/*!50001 VIEW `m3Silla__` AS select `m3`.`fecha` AS `fecha`,`m3`.`year` AS `year`,`m3`.`month` AS `month`,`m3`.`week` AS `week`,`m3`.`day` AS `day`,`m3`.`dayName` AS `dayName`,cast(sum(`m3`.`m3`) as decimal(10,0)) AS `Volumen`,cast(sum(`m3`.`euros`) as decimal(10,0)) AS `Euros` from `m3` where (`m3`.`warehouseFk` in (1,44)) group by `m3`.`fecha` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -85820,25 +86785,6 @@ USE `bs`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `mermas__` --- - -/*!50001 DROP TABLE IF EXISTS `mermas__`*/; -/*!50001 DROP VIEW IF EXISTS `mermas__`*/; -/*!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 `mermas__` AS select `w`.`code` AS `Comprador`,`it`.`name` AS `Familia`,`i`.`id` AS `Referencia`,`i`.`name` AS `Item`,`s`.`quantity` AS `Cantidad`,(((`b`.`buyingValue` + `b`.`freightValue`) + `b`.`comissionValue`) + `b`.`packageValue`) AS `Coste_Unitario`,(`s`.`quantity` * (((`b`.`buyingValue` + `b`.`freightValue`) + `b`.`comissionValue`) + `b`.`packageValue`)) AS `Importe`,`c`.`name` AS `Cliente`,`s`.`ticketFk` AS `ticketFk`,`t`.`shipped` AS `Fecha` from (((((((`vn`.`worker` `w` join `vn`.`itemType` `it` on((`it`.`workerFk` = `w`.`id`))) join `vn`.`item` `i` on((`i`.`typeFk` = `it`.`id`))) join `vn`.`sale` `s` on((`s`.`itemFk` = `i`.`id`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`client` `c` on((`c`.`id` = `t`.`clientFk`))) left join `bi`.`Last_buy_id__` `lb` on(((`lb`.`Id_Article` = `s`.`itemFk`) and (`lb`.`warehouse_id` = `t`.`warehouseFk`)))) left join `vn`.`buy` `b` on((`b`.`id` = `lb`.`Id_Compra`))) where ((`t`.`shipped` > '2018-01-01') and (`c`.`isRelevant` or (`c`.`id` in (200,400)))) */; -/*!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 `packingSpeed` -- @@ -85858,6 +86804,44 @@ USE `bs`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `s1_ticketDetail` +-- + +/*!50001 DROP TABLE IF EXISTS `s1_ticketDetail`*/; +/*!50001 DROP VIEW IF EXISTS `s1_ticketDetail`*/; +/*!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 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `s1_ticketDetail` AS select `s`.`ticketFk` AS `ticketFk`,cast(sum((`s`.`price` * `s`.`quantity`)) as decimal(10,2)) AS `ticketAmount`,count(`s`.`id`) AS `ticketLines`,cast(sum(`sv`.`volume`) as decimal(10,2)) AS `ticketM3`,cast(`t`.`shipped` as date) AS `shipped` from ((`vn`.`ticket` `t` join `vn`.`sale` `s` on((`s`.`ticketFk` = `t`.`id`))) join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where (`t`.`shipped` between '2021-09-01' and '2021-10-31 23:59') group by `s`.`ticketFk` */; +/*!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 `s21_saleDetail` +-- + +/*!50001 DROP TABLE IF EXISTS `s21_saleDetail`*/; +/*!50001 DROP VIEW IF EXISTS `s21_saleDetail`*/; +/*!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 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `s21_saleDetail` AS select dayofmonth(`t`.`shipped`) AS `dia`,year(`t`.`shipped`) AS `año`,month(`t`.`shipped`) AS `mes`,`s`.`concept` AS `concepto`,`s`.`quantity` AS `unidades`,`s`.`price` AS `precio`,(`s`.`quantity` * `s`.`price`) AS `venta`,`it`.`name` AS `familia`,`w`.`code` AS `comprador`,`s`.`itemFk` AS `itemFk`,`s`.`ticketFk` AS `ticketFk`,`sv`.`volume` AS `volume` from ((((((`vn`.`sale` `s` join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemType` `it` on((`it`.`id` = `i`.`typeFk`))) join `vn`.`worker` `w` on((`w`.`id` = `it`.`workerFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`client` `c` on((`c`.`id` = `t`.`clientFk`))) join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where (((`t`.`shipped` between '2020-10-21' and '2020-10-28') or (`t`.`shipped` between '2019-10-21' and '2019-10-28') or (`t`.`shipped` between '2021-09-1' and '2021-10-28')) and (`t`.`warehouseFk` in (1,60)) and `c`.`isRelevant` and (`s`.`quantity` > 0)) */; +/*!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 `v_ventas__` -- @@ -86452,6 +87436,25 @@ USE `postgresql`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `person` +-- + +/*!50001 DROP TABLE IF EXISTS `person`*/; +/*!50001 DROP VIEW IF EXISTS `person`*/; +/*!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 `person` AS select `p`.`id` AS `person_id`,`p`.`surnames` AS `name`,`p`.`nickname` AS `nickname`,`p`.`fi` AS `nif`,`p`.`birth` AS `birth`,`p`.`firstname` AS `firstname`,`p`.`p2` AS `p2`,`p`.`readerId` AS `nis`,`p`.`workerFk` AS `id_trabajador`,`p`.`isDisable` AS `isDisable`,`p`.`isFreelance` AS `isFreelance`,`p`.`isSsDiscounted` AS `isSsDiscounted`,`p`.`sex` AS `sex` from `vn`.`person` `p` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Current Database: `sage` -- @@ -86610,7 +87613,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `absenceType` AS select `cs`.`calendar_state_id` AS `id`,`cs`.`type` AS `name`,`cs`.`rgb` AS `rgb`,`cs`.`code` AS `code`,`cs`.`holidayEntitlementRate` AS `holidayEntitlementRate` from `postgresql`.`calendar_state` `cs` */; +/*!50001 VIEW `absenceType` AS select `cs`.`calendar_state_id` AS `id`,`cs`.`type` AS `name`,`cs`.`rgb` AS `rgb`,`cs`.`code` AS `code`,`cs`.`holidayEntitlementRate` AS `holidayEntitlementRate`,`cs`.`discountRate` AS `discountRate` from `postgresql`.`calendar_state` `cs` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86824,6 +87827,25 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `clientPhoneBook` +-- + +/*!50001 DROP TABLE IF EXISTS `clientPhoneBook`*/; +/*!50001 DROP VIEW IF EXISTS `clientPhoneBook`*/; +/*!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 `clientPhoneBook` AS select `c`.`id` AS `clientFk`,trim(`c`.`phone`) AS `phone` from `client` `c` where (`c`.`phone` and `c`.`isActive`) union select `c`.`id` AS `clientFk`,trim(`c`.`mobile`) AS `phone` from `client` `c` where (`c`.`mobile` and `c`.`isActive`) union select `a`.`clientFk` AS `clientFk`,trim(`a`.`phone`) AS `phone` from (`address` `a` join `client` `c` on((`c`.`id` = `a`.`clientFk`))) where (`a`.`phone` and `c`.`isActive`) union select `a`.`clientFk` AS `clientFk`,trim(`a`.`mobile`) AS `phone` from (`address` `a` join `client` `c` on((`c`.`id` = `a`.`clientFk`))) where (`a`.`mobile` and `c`.`isActive`) union select `cc`.`clientFk` AS `clientFk`,trim(`cc`.`phone`) AS `phone` from (`clientContact` `cc` left join `client` `c` on((`c`.`id` = `cc`.`clientFk`))) where (`c`.`phone` and `c`.`isActive`) */; +/*!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 `clientRisk__` -- @@ -87275,7 +88297,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionSticker` AS select `e`.`id` AS `expeditionFk`,`e`.`ticketFk` AS `ticketFk`,`t`.`addressFk` AS `addressFk`,`t`.`clientFk` AS `clientFk`,`a`.`street` AS `street`,`a`.`postalCode` AS `postalCode`,`a`.`city` AS `city`,`a`.`nickname` AS `nickname`,concat('R(',convert(right(`t`.`routeFk`,4) using utf8mb4),')') AS `routeFk`,`rm`.`beachFk` AS `beachFk`,if(`t`.`routeFk`,replace(`am`.`name`,'ZONA ','Z'),`z`.`name`) AS `zona`,`p`.`name` AS `province`,ifnull(`c`.`mobile`,ifnull(`a`.`mobile`,ifnull(`c`.`phone`,`a`.`phone`))) AS `phone` from (((((((((`expedition` `e` join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) join `address` `a` on((`a`.`id` = `t`.`addressFk`))) join `province` `p` on((`p`.`id` = `a`.`provinceFk`))) left join `routesMonitor` `rm` on((`rm`.`routeFk` = `t`.`routeFk`))) left join `beach` `b` on((`b`.`id` = `rm`.`beachFk`))) left join `zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `route` `r` on((`r`.`id` = `t`.`routeFk`))) left join `agencyMode` `am` on((`am`.`id` = `r`.`agencyModeFk`))) join `client` `c` on((`c`.`id` = `a`.`clientFk`))) */; +/*!50001 VIEW `expeditionSticker` AS select `e`.`id` AS `expeditionFk`,`e`.`ticketFk` AS `ticketFk`,`t`.`addressFk` AS `addressFk`,`t`.`clientFk` AS `clientFk`,`a`.`street` AS `street`,`a`.`postalCode` AS `postalCode`,`a`.`city` AS `city`,`a`.`nickname` AS `nickname`,concat('R(',convert(right(`t`.`routeFk`,3) using utf8mb4),')') AS `routeFk`,`rm`.`beachFk` AS `beachFk`,if(`t`.`routeFk`,replace(`am`.`name`,'ZONA ','Z'),`z`.`name`) AS `zona`,`p`.`name` AS `province`,ifnull(`c`.`mobile`,ifnull(`a`.`mobile`,ifnull(`c`.`phone`,`a`.`phone`))) AS `phone`,`w`.`code` AS `workerCode` from ((((((((((`expedition` `e` join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) join `address` `a` on((`a`.`id` = `t`.`addressFk`))) join `province` `p` on((`p`.`id` = `a`.`provinceFk`))) left join `routesMonitor` `rm` on((`rm`.`routeFk` = `t`.`routeFk`))) left join `beach` `b` on((`b`.`id` = `rm`.`beachFk`))) left join `zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `route` `r` on((`r`.`id` = `t`.`routeFk`))) left join `agencyMode` `am` on((`am`.`id` = `r`.`agencyModeFk`))) join `client` `c` on((`c`.`id` = `a`.`clientFk`))) join `worker` `w` on((`w`.`id` = `e`.`workerFk`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87299,6 +88321,25 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `expeditionTicket_NoBoxes` +-- + +/*!50001 DROP TABLE IF EXISTS `expeditionTicket_NoBoxes`*/; +/*!50001 DROP VIEW IF EXISTS `expeditionTicket_NoBoxes`*/; +/*!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 `expeditionTicket_NoBoxes` AS select `t`.`id` AS `ticketFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`routeFk` AS `routeFk`,`et`.`description` AS `description` from (((`ticket` `t` left join `expedition` `e` on((`e`.`ticketFk` = `t`.`id`))) join `routesMonitor` `rm` on((`rm`.`routeFk` = `t`.`routeFk`))) join `expeditionTruck` `et` on((`et`.`id` = `rm`.`expeditionTruckFk`))) where (isnull(`e`.`id`) and (`et`.`ETD` > curdate())) */; +/*!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 `expeditionTimeExpended` -- @@ -87565,25 +88606,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `invoiceInEntry__` --- - -/*!50001 DROP TABLE IF EXISTS `invoiceInEntry__`*/; -/*!50001 DROP VIEW IF EXISTS `invoiceInEntry__`*/; -/*!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 `invoiceInEntry__` AS select `i`.`recibida_entrada_id` AS `id`,`i`.`recibida_id` AS `invoiceInFk`,`i`.`Id_Entrada` AS `entryFk`,`i`.`percentage` AS `percentage`,`i`.`awb_recibida` AS `invoiceInAwbFk`,`i`.`Contabilizado` AS `isBooked` from `vn2008`.`recibida_entrada__` `i` */; -/*!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 `invoiceInIntrastat__` -- @@ -87636,7 +88658,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemBotanicalWithGenus` AS select `ib`.`itemFk` AS `itemFk`,ifnull(`ib`.`botanical`,concat(`g`.`latinGenusName`,' ',ifnull(`s`.`latinSpeciesName`,''))) AS `ediBotanic` from ((`vn`.`itemBotanical` `ib` left join `vn`.`ediGenus` `g` on((`g`.`id` = `ib`.`genusFk`))) left join `vn`.`ediSpecie` `s` on((`s`.`id` = `ib`.`specieFk`))) */; +/*!50001 VIEW `itemBotanicalWithGenus` AS select `ib`.`itemFk` AS `itemFk`,concat(`g`.`name`,' ',ifnull(`s`.`name`,'')) AS `ediBotanic` from ((`itemBotanical` `ib` left join `specie` `s` on((`s`.`id` = `ib`.`specieFk`))) left join `genus` `g` on((`g`.`id` = `ib`.`genusFk`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87897,12 +88919,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 `itemShelvingStock` AS select `ish`.`itemFk` AS `itemFk`,sum(`ish`.`visible`) AS `visible`,min(`ish`.`packing`) AS `packing`,min(`ish`.`grouping`) AS `grouping`,`s`.`description` AS `sector`,sum(`ish`.`visible`) AS `visibleOriginal`,sum(`issr`.`removed`) AS `removed`,`p`.`sectorFk` AS `sectorFk`,`s`.`warehouseFk` AS `warehouseFk`,`ish`.`shelvingFk` AS `shelvingFk`,`p`.`code` AS `parkingCode`,`sh`.`parkingFk` AS `parkingFk`,`ish`.`id` AS `itemShelvingFk`,`ish`.`created` AS `created` from ((((`itemShelving` `ish` left join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) left join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) left join `itemShelvingStockRemoved` `issr` on((`issr`.`itemShelvingFk` = `ish`.`id`))) where ((`ish`.`visible` <> 0) and `p`.`sectorFk`) group by `ish`.`itemFk`,`p`.`sectorFk` */; +/*!50001 VIEW `itemShelvingStock` AS select `ish`.`itemFk` AS `itemFk`,sum(`ish`.`visible`) AS `visible`,min(`ish`.`packing`) AS `packing`,min(`ish`.`grouping`) AS `grouping`,`s`.`description` AS `sector`,sum(`ish`.`visible`) AS `visibleOriginal`,0 AS `removed`,`p`.`sectorFk` AS `sectorFk`,`s`.`warehouseFk` AS `warehouseFk`,`ish`.`shelvingFk` AS `shelvingFk`,`p`.`code` AS `parkingCode`,`sh`.`parkingFk` AS `parkingFk`,`ish`.`id` AS `itemShelvingFk`,`ish`.`created` AS `created` from (((`itemShelving` `ish` left join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) left join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) where ((`ish`.`visible` <> 0) and `p`.`sectorFk`) group by `ish`.`itemFk`,`p`.`sectorFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87935,12 +88957,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 `itemShelvingStockRemoved` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,(sum(ifnull(`iss`.`quantity`,0)) + sum(ifnull(`isps`.`quantity`,0))) AS `removed` from ((`itemShelving` `ish` left join `itemShelvingSale` `iss` on((`iss`.`itemShelvingFk` = `ish`.`id`))) left join `itemShelvingPlacementSupply` `isps` on((`isps`.`itemShelvingFk` = `ish`.`id`))) group by `ish`.`id` */; +/*!50001 VIEW `itemShelvingStockRemoved` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,0 AS `removed` from ((`itemShelving` `ish` left join `itemShelvingSale` `iss` on((`iss`.`itemShelvingFk` = `ish`.`id`))) left join `itemShelvingPlacementSupply` `isps` on((`isps`.`itemShelvingFk` = `ish`.`id`))) group by `ish`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88087,12 +89109,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 `lastPurchases` AS select `tr`.`landed` AS `landed`,`w`.`id` AS `warehouseFk`,`w`.`name` AS `warehouse`,`i`.`longName` AS `longName`,`i`.`subName` AS `subName`,`e`.`id` AS `entryFk`,`b`.`stickers` AS `stickers`,`b`.`packing` AS `packing`,`e`.`ref` AS `ref`,`b`.`itemFk` AS `itemFk` from ((((`buy` `b` join `entry` `e` on((`e`.`id` = `b`.`entryFk`))) join `item` `i` on((`i`.`id` = `b`.`itemFk`))) join `travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) join `warehouse` `w` on((`w`.`id` = `tr`.`warehouseInFk`))) where ((`tr`.`landed` between `util`.`yesterday`() and `util`.`tomorrow`()) and (`e`.`isRaid` = 0) and (`b`.`stickers` > 0)) */; +/*!50001 VIEW `lastPurchases` AS select `tr`.`landed` AS `landed`,`w`.`id` AS `warehouseFk`,`w`.`name` AS `warehouse`,`i`.`longName` AS `longName`,`i`.`subName` AS `subName`,`e`.`id` AS `entryFk`,`b`.`stickers` AS `stickers`,`b`.`packing` AS `packing`,`e`.`ref` AS `ref`,`b`.`itemFk` AS `itemFk`,`ek`.`pro` AS `pro`,`ek`.`ref` AS `ektRef`,`ek`.`agj` AS `agj` from (((((`vn`.`buy` `b` join `vn`.`entry` `e` on((`e`.`id` = `b`.`entryFk`))) join `vn`.`item` `i` on((`i`.`id` = `b`.`itemFk`))) join `vn`.`travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) join `vn`.`warehouse` `w` on((`w`.`id` = `tr`.`warehouseInFk`))) left join `edi`.`ekt` `ek` on((`ek`.`id` = `b`.`ektFk`))) where ((`tr`.`landed` between `util`.`yesterday`() and `util`.`tomorrow`()) and (`e`.`isRaid` = 0) and (`b`.`stickers` > 0)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88401,25 +89423,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `saleFreight__` --- - -/*!50001 DROP TABLE IF EXISTS `saleFreight__`*/; -/*!50001 DROP VIEW IF EXISTS `saleFreight__`*/; -/*!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 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleFreight__` AS select `s`.`ticketFk` AS `ticketFk`,`t`.`clientFk` AS `clientFk`,`t`.`routeFk` AS `routeFk`,`s`.`id` AS `saleFk`,`t`.`zoneFk` AS `zoneFk`,`t`.`companyFk` AS `companyFk`,`t`.`shipped` AS `shipped`,`t`.`zonePrice` AS `price`,((((`s`.`quantity` * `r`.`cm3`) * `t`.`zonePrice`) * `i`.`compression`) / `cb`.`volume`) AS `freight` from ((((`vn`.`sale` `s` join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`packaging` `cb` on((`cb`.`id` = '94'))) join `bi`.`rotacion` `r` on(((`r`.`Id_Article` = `s`.`itemFk`) and (`r`.`warehouse_id` = `t`.`warehouseFk`)))) */; -/*!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 `saleMistakeList` -- @@ -88648,25 +89651,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `ticketGetVolume__` --- - -/*!50001 DROP TABLE IF EXISTS `ticketGetVolume__`*/; -/*!50001 DROP VIEW IF EXISTS `ticketGetVolume__`*/; -/*!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 `ticketGetVolume__` AS select `s`.`ticketFk` AS `ticketFk`,`t`.`routeFk` AS `routeFk`,`s`.`id` AS `saleFk`,`t`.`shipped` AS `shipped`,(((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) / 1000000) AS `volume` from (((`vn`.`sale` `s` join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `bi`.`rotacion` `r` on(((`r`.`Id_Article` = `s`.`itemFk`) and (`r`.`warehouse_id` = `t`.`warehouseFk`)))) */; -/*!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 `ticketLabel_Source` -- @@ -88681,7 +89665,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketLabel_Source` AS select concat(`tc`.`collectionFk`,' ',`tc`.`wagon`,'-',`tc`.`level`) AS `level`,`t`.`id` AS `Id_Ticket`,(case when (`t`.`routeFk` is not null) then if(`agr`.`showAgencyName`,concat(right(left(`agr`.`name`,(locate(' ',`agr`.`name`) - 1)),2),'- R',right(`t`.`routeFk`,3)),`agr`.`name`) else if((`am`.`deliveryMethodFk` = 2),`zo`.`name`,`am`.`name`) end) AS `Agencia`,`t`.`clientFk` AS `Id_Cliente`,`t`.`notes` AS `Notas`,'CDT' AS `Sacador`,1 AS `ncarro`,if(hour(`t`.`shipped`),date_format(`t`.`shipped`,'%H:%i'),date_format(`zo`.`hour`,'%H:%i')) AS `horaagencia`,`t`.`shipped` AS `fecha`,if(((now() + interval 1 hour) > `ze`.`etc`),'!!!','') AS `urgente` from (((((((`vn`.`ticket` `t` join `vn`.`agencyMode` `am` on((`t`.`agencyModeFk` = `am`.`id`))) left join `vn`.`address` `a` on((`a`.`id` = `t`.`addressFk`))) left join `vn`.`route` `r` on((`t`.`routeFk` = `r`.`id`))) left join `vn`.`zone_ETD` `ze` on((`ze`.`zoneFk` = `t`.`zoneFk`))) left join `vn`.`ticketCollection` `tc` on((`tc`.`ticketFk` = `t`.`id`))) left join `vn`.`agencyMode` `agr` on((`r`.`agencyModeFk` = `agr`.`id`))) left join `vn`.`zone` `zo` on((`t`.`zoneFk` = `zo`.`id`))) where (`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) */; +/*!50001 VIEW `ticketLabel_Source` AS select concat(`tc`.`collectionFk`,' ',`tc`.`wagon`,'-',`tc`.`level`) AS `level`,`t`.`id` AS `Id_Ticket`,(case when (`t`.`routeFk` is not null) then if(`agr`.`showAgencyName`,concat(right(left(`agr`.`name`,(locate(' ',`agr`.`name`) - 1)),2),'- R',right(`t`.`routeFk`,3)),`agr`.`name`) else if((`am`.`deliveryMethodFk` = 2),`zo`.`name`,`am`.`name`) end) AS `Agencia`,`t`.`clientFk` AS `Id_Cliente`,`t`.`notes` AS `Notas`,'CDT' AS `Sacador`,1 AS `ncarro`,if(hour(`t`.`shipped`),date_format(`t`.`shipped`,'%H:%i'),date_format(`zo`.`hour`,'%H:%i')) AS `horaagencia`,`t`.`shipped` AS `fecha`,if(((now() + interval 1 hour) > `ze`.`etc`),'!!!','') AS `urgente` from (((((((`vn`.`ticket` `t` join `vn`.`agencyMode` `am` on((`t`.`agencyModeFk` = `am`.`id`))) left join `vn`.`address` `a` on((`a`.`id` = `t`.`addressFk`))) left join `vn`.`route` `r` on((`t`.`routeFk` = `r`.`id`))) left join `vn`.`zoneEstimatedDelivery` `ze` on((`ze`.`zoneFk` = `t`.`zoneFk`))) left join `vn`.`ticketCollection` `tc` on((`tc`.`ticketFk` = `t`.`id`))) left join `vn`.`agencyMode` `agr` on((`r`.`agencyModeFk` = `agr`.`id`))) left join `vn`.`zone` `zo` on((`t`.`zoneFk` = `zo`.`id`))) where (`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88757,7 +89741,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketMRW` AS select `Tickets`.`Id_Agencia` AS `id_Agencia`,`Tickets`.`empresa_id` AS `empresa_id`,`Consignatarios`.`consignatario` AS `Consignatario`,`Consignatarios`.`domicilio` AS `DOMICILIO`,`Consignatarios`.`poblacion` AS `POBLACION`,`Consignatarios`.`codPostal` AS `CODPOSTAL`,`Consignatarios`.`telefono` AS `telefono`,`Consignatarios`.`movil` AS `movil`,`Clientes`.`if` AS `IF`,`Tickets`.`Id_Ticket` AS `Id_Ticket`,`Tickets`.`warehouse_id` AS `warehouse_id`,`Consignatarios`.`id_consigna` AS `Id_Consigna`,`Paises`.`Codigo` AS `CodigoPais`,`Tickets`.`Fecha` AS `Fecha`,`province`.`province_id` AS `province_id`,`Tickets`.`landing` AS `landing` from ((((`vn2008`.`Clientes` join `vn2008`.`Consignatarios` on((`Clientes`.`id_cliente` = `Consignatarios`.`Id_cliente`))) join `vn2008`.`Tickets` on((`Consignatarios`.`id_consigna` = `Tickets`.`Id_Consigna`))) join `vn2008`.`province` on((`Consignatarios`.`province_id` = `province`.`province_id`))) join `vn2008`.`Paises` on((`province`.`Paises_Id` = `Paises`.`Id`))) */; +/*!50001 VIEW `ticketMRW` AS select `Tickets`.`Id_Agencia` AS `id_Agencia`,`Tickets`.`empresa_id` AS `empresa_id`,`Consignatarios`.`consignatario` AS `Consignatario`,`Consignatarios`.`domicilio` AS `DOMICILIO`,`Consignatarios`.`poblacion` AS `POBLACION`,`Consignatarios`.`codPostal` AS `CODPOSTAL`,`Consignatarios`.`telefono` AS `telefono`,ifnull(ifnull(ifnull(ifnull(`Consignatarios`.`movil`,`Clientes`.`movil`),`Consignatarios`.`telefono`),`Clientes`.`telefono`),0) AS `movil`,`Clientes`.`if` AS `IF`,`Tickets`.`Id_Ticket` AS `Id_Ticket`,`Tickets`.`warehouse_id` AS `warehouse_id`,`Consignatarios`.`id_consigna` AS `Id_Consigna`,`Paises`.`Codigo` AS `CodigoPais`,`Tickets`.`Fecha` AS `Fecha`,`province`.`province_id` AS `province_id`,`Tickets`.`landing` AS `landing` from ((((`vn2008`.`Clientes` join `vn2008`.`Consignatarios` on((`Clientes`.`id_cliente` = `Consignatarios`.`Id_cliente`))) join `vn2008`.`Tickets` on((`Consignatarios`.`id_consigna` = `Tickets`.`Id_Consigna`))) join `vn2008`.`province` on((`Consignatarios`.`province_id` = `province`.`province_id`))) join `vn2008`.`Paises` on((`province`.`Paises_Id` = `Paises`.`Id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89276,11 +90260,11 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `zone_ETD` +-- Final view structure for view `zone_ETD__` -- -/*!50001 DROP TABLE IF EXISTS `zone_ETD`*/; -/*!50001 DROP VIEW IF EXISTS `zone_ETD`*/; +/*!50001 DROP TABLE IF EXISTS `zone_ETD__`*/; +/*!50001 DROP VIEW IF EXISTS `zone_ETD__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -89289,7 +90273,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `zone_ETD` AS select `zed`.`zoneFk` AS `zoneFk`,`zed`.`hourTheoretical` AS `HoraTeórica`,`zed`.`totalVolume` AS `volumenTotal`,`zed`.`remainingVolume` AS `volumenPendiente`,`zed`.`speed` AS `velocidad`,`zed`.`hourEffective` AS `HoraPráctica`,`zed`.`minutesLess` AS `minutesLess`,`zed`.`etc` AS `etc` from `vn`.`zoneEstimatedDelivery` `zed` */; +/*!50001 VIEW `zone_ETD__` AS select `zed`.`zoneFk` AS `zoneFk`,`zed`.`hourTheoretical` AS `HoraTeórica`,`zed`.`totalVolume` AS `volumenTotal`,`zed`.`remainingVolume` AS `volumenPendiente`,`zed`.`speed` AS `velocidad`,`zed`.`hourEffective` AS `HoraPráctica`,`zed`.`minutesLess` AS `minutesLess`,`zed`.`etc` AS `etc` from `vn`.`zoneEstimatedDelivery` `zed` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89309,4 +90293,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:41:28 +-- Dump completed on 2021-10-20 8:37:55 diff --git a/loopback/common/methods/vn-model/specs/getEnumValues.spec.js b/loopback/common/methods/vn-model/specs/getEnumValues.spec.js index b49a952e4..c010c6d0a 100644 --- a/loopback/common/methods/vn-model/specs/getEnumValues.spec.js +++ b/loopback/common/methods/vn-model/specs/getEnumValues.spec.js @@ -8,11 +8,12 @@ describe('Model getEnumValues()', () => { }); it('should return an array of enum values from a given column', async() => { - let result = await app.models.TravelThermograph.getSetValues('temperature'); + let result = await app.models.TpvTransaction.getSetValues('status'); - expect(result.length).toEqual(3); + expect(result.length).toEqual(4); expect(result[0].value).toEqual('enum'); - expect(result[1].value).toEqual('COOL'); - expect(result[2].value).toEqual('WARM'); + expect(result[1].value).toEqual('started'); + expect(result[2].value).toEqual('ok'); + expect(result[3].value).toEqual('ko'); }); });