diff --git a/back/methods/collection/spec/getCollection.spec.js b/back/methods/collection/spec/getCollection.spec.js index 5ea042f9d..e87efb4a0 100644 --- a/back/methods/collection/spec/getCollection.spec.js +++ b/back/methods/collection/spec/getCollection.spec.js @@ -2,10 +2,10 @@ const models = require('vn-loopback/server/server').models; describe('ticket getCollection()', () => { it('should return a list of collections', async() => { - let ctx = {req: {accessToken: {userId: 1106}}}; + let ctx = {req: {accessToken: {userId: 1107}}}; let response = await models.Collection.getCollection(ctx); expect(response.length).toBeGreaterThan(0); - expect(response[0].collectionFk).toEqual(1); + expect(response[0].collectionFk).toEqual(3); }); }); diff --git a/back/methods/dms/deleteTrashFiles.js b/back/methods/dms/deleteTrashFiles.js index 9da508285..e8b342ccc 100644 --- a/back/methods/dms/deleteTrashFiles.js +++ b/back/methods/dms/deleteTrashFiles.js @@ -53,8 +53,12 @@ module.exports = Self => { const pathHash = DmsContainer.getHash(dms.id); const dmsContainer = await DmsContainer.container(pathHash); const dstFile = path.join(dmsContainer.client.root, pathHash, dms.file); + try { + await fs.unlink(dstFile); + } catch (err) { + continue; + } const dstFolder = path.join(dmsContainer.client.root, pathHash); - await fs.unlink(dstFile); try { await fs.rmdir(dstFolder); await dms.destroy(myOptions); diff --git a/back/methods/osticket/closeTicket.js b/back/methods/osticket/closeTicket.js new file mode 100644 index 000000000..87d54d3b8 --- /dev/null +++ b/back/methods/osticket/closeTicket.js @@ -0,0 +1,118 @@ +const jsdom = require('jsdom'); +const mysql = require('mysql'); + +module.exports = Self => { + Self.remoteMethodCtx('closeTicket', { + description: 'Close tickets without response from the user', + accessType: 'READ', + returns: { + type: 'Object', + root: true + }, + http: { + path: `/closeTicket`, + verb: 'POST' + } + }); + + Self.closeTicket = async ctx => { + const models = Self.app.models; + const config = await models.OsTicketConfig.findOne(); + const ostUri = `${config.host}/login.php`; + + if (!config.user || !config.password || !config.userDb || !config.passwordDb) + return false; + + const con = mysql.createConnection({ + host: `${config.hostDb}`, + user: `${config.userDb}`, + password: `${config.passwordDb}`, + port: `${config.portDb}` + }); + + const sql = `SELECT ot.ticket_id, ot.number + FROM osticket.ost_ticket ot + JOIN osticket.ost_ticket_status ots ON ots.id = ot.status_id + JOIN osticket.ost_thread ot2 ON ot2.object_id = ot.ticket_id AND ot2.object_type = 'T' + JOIN ( + SELECT ote.thread_id, MAX(ote.created) created, MAX(ote.updated) updated + FROM osticket.ost_thread_entry ote + WHERE ote.staff_id != 0 AND ote.type = 'R' + GROUP BY ote.thread_id + ) sub ON sub.thread_id = ot2.id + WHERE ot.isanswered = 1 + AND ots.state = '${config.oldStatus}' + AND IF(sub.updated > sub.created, sub.updated, sub.created) < DATE_SUB(CURDATE(), INTERVAL ${config.day} DAY)`; + + let ticketsId = []; + con.connect(err => { + if (err) throw err; + con.query(sql, (err, results) => { + if (err) throw err; + for (const result of results) + ticketsId.push(result.ticket_id); + }); + }); + + await requestToken(); + + async function requestToken() { + const response = await fetch(ostUri); + + const result = response.headers.get('set-cookie'); + const [firtHeader] = result.split(' '); + const firtCookie = firtHeader.substring(0, firtHeader.length - 1); + const body = await response.text(); + const dom = new jsdom.JSDOM(body); + const token = dom.window.document.querySelector('[name="__CSRFToken__"]').value; + + await login(token, firtCookie); + } + + async function login(token, firtCookie) { + const data = { + __CSRFToken__: token, + do: 'scplogin', + userid: config.user, + passwd: config.password, + ajax: 1 + }; + const params = { + method: 'POST', + body: new URLSearchParams(data), + headers: { + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', + 'Cookie': firtCookie + } + }; + const response = await fetch(ostUri, params); + const result = response.headers.get('set-cookie'); + const [firtHeader] = result.split(' '); + const secondCookie = firtHeader.substring(0, firtHeader.length - 1); + + await close(token, secondCookie); + } + + async function close(token, secondCookie) { + for (const ticketId of ticketsId) { + const ostUri = `${config.host}/ajax.php/tickets/${ticketId}/status`; + const data = { + status_id: config.newStatusId, + comments: config.comment, + undefined: config.action + }; + const params = { + method: 'POST', + body: new URLSearchParams(data), + headers: { + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', + 'X-CSRFToken': token, + 'Cookie': secondCookie + } + }; + + return fetch(ostUri, params); + } + } + }; +}; diff --git a/back/model-config.json b/back/model-config.json index 3297d84e5..830a78fd4 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -116,6 +116,9 @@ "OsTicket": { "dataSource": "osticket" }, + "OsTicketConfig": { + "dataSource": "vn" + }, "Edi": { "dataSource": "vn" }, diff --git a/back/models/osticket-config.json b/back/models/osticket-config.json new file mode 100644 index 000000000..d42632c6a --- /dev/null +++ b/back/models/osticket-config.json @@ -0,0 +1,52 @@ +{ + "name": "OsTicketConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "osTicketConfig" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "host": { + "type": "string" + }, + "user": { + "type": "string" + }, + "password": { + "type": "string" + }, + "oldStatus": { + "type": "string" + }, + "newStatusId": { + "type": "number" + }, + "action": { + "type": "string" + }, + "day": { + "type": "number" + }, + "comment": { + "type": "string" + }, + "hostDb": { + "type": "string" + }, + "userDb": { + "type": "string" + }, + "passwordDb": { + "type": "string" + }, + "portDb": { + "type": "number" + } + } +} \ No newline at end of file diff --git a/back/models/osticket.js b/back/models/osticket.js index 9b13110bb..50e429160 100644 --- a/back/models/osticket.js +++ b/back/models/osticket.js @@ -1,3 +1,4 @@ module.exports = Self => { require('../methods/osticket/osTicketReportEmail')(Self); + require('../methods/osticket/closeTicket')(Self); }; diff --git a/db/changes/10481-june/00-aclOsTicket.sql b/db/changes/10481-june/00-aclOsTicket.sql new file mode 100644 index 000000000..ae2a121f5 --- /dev/null +++ b/db/changes/10481-june/00-aclOsTicket.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('OsTicket', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10481-june/00-aclOsTicketConfig.sql b/db/changes/10481-june/00-aclOsTicketConfig.sql new file mode 100644 index 000000000..ad53ea6ae --- /dev/null +++ b/db/changes/10481-june/00-aclOsTicketConfig.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('OsTicketConfig', '*', '*', 'ALLOW', 'ROLE', 'it'); \ No newline at end of file diff --git a/db/changes/10481-june/00-osTicketConfig.sql b/db/changes/10481-june/00-osTicketConfig.sql new file mode 100644 index 000000000..ad6662715 --- /dev/null +++ b/db/changes/10481-june/00-osTicketConfig.sql @@ -0,0 +1,20 @@ +CREATE TABLE `vn`.`osTicketConfig` ( + `id` int(11) NOT NULL, + `host` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `user` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `password` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `oldStatus` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `newStatusId` int(11) DEFAULT NULL, + `action` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `day` int(11) DEFAULT NULL, + `comment` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `hostDb` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `userDb` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `passwordDb` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `portDb` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT INTO `vn`.`osTicketConfig`(`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `action`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`) + VALUES + (0, 'https://cau.verdnatura.es/scp', NULL, NULL, 'open', 3, 'Cerrar', 60, 'Este CAU se ha cerrado automáticamente', NULL, NULL, NULL, NULL); \ No newline at end of file diff --git a/db/changes/10490-august/00-ACL.sql b/db/changes/10490-august/00-ACL.sql index d1b7f087c..29277e8bb 100644 --- a/db/changes/10490-august/00-ACL.sql +++ b/db/changes/10490-august/00-ACL.sql @@ -28,4 +28,9 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp ('Travel', 'extraCommunityEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Entry', 'entryOrderPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), ('OsTicket', 'osTicketReportEmail', 'WRITE', 'ALLOW', 'ROLE', 'system'), - ('Item', 'buyerWasteEmail', 'WRITE', 'ALLOW', 'ROLE', 'system'); \ No newline at end of file + ('Item', 'buyerWasteEmail', 'WRITE', 'ALLOW', 'ROLE', 'system'); + +INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) + VALUES ('Sector','*','READ','ALLOW','ROLE','employee'); +INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) + VALUES ('Sector','*','WRITE','ALLOW','ROLE','employee'); diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index f9cdc61b8..c9c265ae7 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -1,15 +1,15 @@ USE `util`; --- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64) +-- MySQL dump 10.19 Distrib 10.3.34-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: util -- ------------------------------------------------------ --- Server version 5.6.25-4-log +-- Server version 10.7.4-MariaDB-1:10.7.4+maria~bullseye-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; +/*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; @@ -22,7 +22,7 @@ USE `util`; LOCK TABLES `config` WRITE; /*!40000 ALTER TABLE `config` DISABLE KEYS */; -INSERT INTO `config` VALUES (1,'10472',0,'production',NULL); +INSERT INTO `config` VALUES (1,'10480',0,'production',NULL); /*!40000 ALTER TABLE `config` ENABLE KEYS */; UNLOCK TABLES; @@ -32,7 +32,7 @@ UNLOCK TABLES; LOCK TABLES `version` WRITE; /*!40000 ALTER TABLE `version` DISABLE KEYS */; -INSERT INTO `version` VALUES ('salix','10230','53f69ae8e526a4a5d827c237a5b076d38507b392','2020-11-09 11:06:43',NULL),('vn-database','10278','ee7db3309fd590c03b520c808040c9dbef8a70a1','2022-08-02 10:00:00','10281'); +INSERT INTO `version` VALUES ('salix','10230','53f69ae8e526a4a5d827c237a5b076d38507b392','2020-11-09 11:06:43',NULL),('vn-database','10322','4e88fb5d53bd852a3fe96e00cf96bf77540fabc4','2022-09-15 09:48:41','10337'); /*!40000 ALTER TABLE `version` ENABLE KEYS */; UNLOCK TABLES; @@ -42,7 +42,7 @@ UNLOCK TABLES; LOCK TABLES `versionLog` WRITE; /*!40000 ALTER TABLE `versionLog` DISABLE KEYS */; -INSERT INTO `versionLog` VALUES ('vn-database','00001','00-test.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','00003','00-sage.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','10008','00-alterRoleConfig.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','10014','00-rolePrefix.sql','jenkins@10.0.2.68','2022-02-11 00:13:25',NULL,NULL),('vn-database','10017','01-firstScript.sql','jenkins@10.0.2.70','2022-03-09 11:36:54',NULL,NULL),('vn-database','10021','00-bankAccount.sql','jenkins@10.0.2.69','2022-03-16 14:11:22',NULL,NULL),('vn-database','10023','00-firstScript.sql','jenkins@10.0.2.69','2022-03-16 15:05:29',NULL,NULL),('vn-database','10026','00-invoiceInIntrastat.sql','jenkins@10.0.2.69','2022-03-21 15:10:53',NULL,NULL),('vn-database','10027','00-Clientes_cedidos.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10028','00-item_last_buy_.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10029','00-bankToViewAccountingToTable.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10030','00-KkejarNiche.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10036','00-updateBuyConfig.sql','jenkins@10.0.2.69','2022-03-29 12:36:54',NULL,NULL),('vn-database','10037','00-firstScript.sql','jenkins@10.0.2.69','2022-03-28 11:14:26',NULL,NULL),('vn-database','10038','00-printServerQueue.sql','jenkins@10.0.2.69','2022-03-29 08:13:24',NULL,NULL),('vn-database','10048','00-firstScript.sql','jenkins@10.0.2.69','2022-03-30 12:29:06',NULL,NULL),('vn-database','10058','00-vehicleAddFields.sql','jenkins@10.0.2.69','2022-04-06 08:48:34',NULL,NULL),('vn-database','10060','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:11',NULL,NULL),('vn-database','10062','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 10:51:45',NULL,NULL),('vn-database','10064','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 13:57:11',NULL,NULL),('vn-database','10066','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:12',NULL,NULL),('vn-database','10067','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 10:18:20',NULL,NULL),('vn-database','10071','00-packingSiteLog.sql','jenkins@10.0.2.69','2022-04-08 09:37:30',NULL,NULL),('vn-database','10072','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 11:01:46',NULL,NULL),('vn-database','10073','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 13:40:56',NULL,NULL),('vn-database','10074','00-firstScript.sql','jenkins@10.0.2.69','2022-04-10 13:15:05',NULL,NULL),('vn-database','10077','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 08:07:15',NULL,NULL),('vn-database','10078','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 07:44:21',NULL,NULL),('vn-database','10079','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 12:01:37',NULL,NULL),('vn-database','10086','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 08:58:34',NULL,NULL),('vn-database','10087','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 09:39:49',NULL,NULL),('vn-database','10088','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 15:05:12',NULL,NULL),('vn-database','10089','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:12:52',NULL,NULL),('vn-database','10090','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:34:46',NULL,NULL),('vn-database','10092','00-firstScript.sql','jenkins@10.0.2.69','2022-04-19 14:45:46',NULL,NULL),('vn-database','10093','00-autoradioConfig.sql','jenkins@10.0.2.69','2022-05-03 09:16:47',NULL,NULL),('vn-database','10094','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 10:57:30',NULL,NULL),('vn-database','10097','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL),('vn-database','10099','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL),('vn-database','10100','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL),('vn-database','10101','00-firstScript.sql','jenkins@10.0.2.69','2022-04-21 14:59:31',NULL,NULL),('vn-database','10103','00-awbVolume.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL),('vn-database','10104','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL),('vn-database','10105','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL),('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL),('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL),('vn-database','10113','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL),('vn-database','10114','00-updateConfig.sql','jenkins@10.0.2.69','2022-04-27 13:37:25',NULL,NULL),('vn-database','10116','00-firstScript.sql','jenkins@10.0.2.69','2022-04-28 11:10:14',NULL,NULL),('vn-database','10118','00-firstScript.sql','jenkins@10.0.2.69','2022-04-29 08:10:15',NULL,NULL),('vn-database','10119','00-AfegirFKPart1.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL),('vn-database','10119','01-AfegirFkPart2.sql','jenkins@10.0.2.69','2022-05-05 10:22:25',NULL,NULL),('vn-database','10125','00-firstScript.sql','jenkins@10.0.2.68','2022-05-18 18:44:30',NULL,NULL),('vn-database','10127','00-firstScript.sql','jenkins@10.0.2.69','2022-05-02 11:04:46',NULL,NULL),('vn-database','10128','00-firstScript.sql','jenkins@10.0.2.69','2022-05-02 13:04:31',NULL,NULL),('vn-database','10129','00-firstScript.sql','jenkins@10.0.2.69','2022-05-03 08:21:01',NULL,NULL),('vn-database','10132','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:22:25',NULL,NULL),('vn-database','10133','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 14:32:30',NULL,NULL),('vn-database','10134','00-firstScript.sql','jenkins@10.0.2.69','2022-05-06 07:45:25',NULL,NULL),('vn-database','10135','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 08:46:17',NULL,NULL),('vn-database','10136','00-workerTimeControl.sql','jenkins@10.0.2.69','2022-05-09 13:51:12',NULL,NULL),('vn-database','10138','00-firstScript.sql','jenkins@10.0.2.69','2022-05-10 13:58:05',NULL,NULL),('vn-database','10139','00-firstScript.sql','jenkins@10.0.2.68','2022-05-16 14:32:37',NULL,NULL),('vn-database','10139','01-secondScript.sql','jenkins@10.0.2.68','2022-05-17 12:16:13',NULL,NULL),('vn-database','10141','00-firstScript.sql','jenkins@10.0.2.70','2022-05-12 08:27:31',NULL,NULL),('vn-database','10142','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:20:31',NULL,NULL),('vn-database','10143','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:20:31',NULL,NULL),('vn-database','10144','00-AfegirFKPArt1.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL),('vn-database','10144','00-firstScript.sql','jenkins@10.0.2.68','2022-05-13 09:44:25',NULL,NULL),('vn-database','10147','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL),('vn-database','10149','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL),('vn-database','10150','00-firstScript.sql','jenkins@10.0.2.68','2022-05-17 09:57:16',NULL,NULL),('vn-database','10152','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:34',NULL,NULL),('vn-database','10153','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:34',NULL,NULL),('vn-database','10154','00-compressionKk.sql','jenkins@10.0.2.68','2022-05-20 09:22:34',NULL,NULL),('vn-database','10157','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:35',NULL,NULL),('vn-database','10158','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:21',NULL,NULL),('vn-database','10160','00-firstScript.sql','jenkins@10.0.2.69','2022-06-30 09:30:50',NULL,NULL),('vn-database','10163','00-firstScript.sql','jenkins@10.0.2.68','2022-05-23 08:17:14',NULL,NULL),('vn-database','10164','00-borrarSectorsDesus.sql','jenkins@10.0.2.68','2022-06-02 12:47:21',NULL,NULL),('vn-database','10165','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10166','00-firstScript.sql','jenkins@10.0.2.68','2022-05-24 16:11:21',NULL,NULL),('vn-database','10167','00-renameVnActiveContrat.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10168','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10169','00-createTableBankEntityConfig.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10169','02-addNotNullToBankEntityBic.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10172','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10174','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 08:46:17',NULL,NULL),('vn-database','10175','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10177','00-crearTablaSpecialLabels.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10178','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:24',NULL,NULL),('vn-database','10179','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:24',NULL,NULL),('vn-database','10183','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:24',NULL,NULL),('vn-database','10184','00-firstScript.sql','jenkins@10.0.2.68','2022-06-03 08:05:34',NULL,NULL),('vn-database','10185','00-firstScript.sql','jenkins@10.0.2.68','2022-06-06 09:07:45',NULL,NULL),('vn-database','10186','00-desactivar_trigger.sql','jenkins@10.0.2.68','2022-06-07 09:31:23',NULL,NULL),('vn-database','10186','01-alter_Table_buy.sql','jenkins@10.0.2.68','2022-06-07 09:34:47',NULL,NULL),('vn-database','10186','02-alter_table_entryConfig.sql','jenkins@10.0.2.68','2022-06-07 09:34:47',NULL,NULL),('vn-database','10186','04-regularizar_Sticker_Inventario.sql','jenkins@10.0.2.68','2022-06-07 09:34:51',NULL,NULL),('vn-database','10186','09-reactivar_trigger.sql','jenkins@10.0.2.68','2022-06-07 09:34:51',NULL,NULL),('vn-database','10187','00-firstScript.sql','jenkins@10.0.2.68','2022-06-06 12:37:31',NULL,NULL),('vn-database','10188','00-firstScript.sql','jenkins@10.0.2.68','2022-06-06 14:03:36',NULL,NULL),('vn-database','10189','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10191','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10194','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10195','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10200','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:00',NULL,NULL),('vn-database','10201','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:00',NULL,NULL),('vn-database','10202','00-Remove_FK_to_ediGenus.sql','jenkins@10.0.2.69','2022-06-17 09:04:00',NULL,NULL),('vn-database','10203','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:01',NULL,NULL),('vn-database','10204','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:01',NULL,NULL),('vn-database','10205','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:21',NULL,NULL),('vn-database','10207','00-Alter_table_entry.sql','jenkins@10.0.2.69','2022-06-16 07:22:50',NULL,NULL),('vn-database','10207','01-Update_invoiceAmount.sql','jenkins@10.0.2.69','2022-06-16 07:23:00',NULL,NULL),('vn-database','10208','00-firstScript.sql','jenkins@10.0.2.69','2022-06-30 09:31:26',NULL,NULL),('vn-database','10209','00-firstScript.sql','jenkins@10.0.2.69','2022-06-16 08:47:40',NULL,NULL),('vn-database','10210','00-firstScript.sql','jenkins@10.0.2.69','2022-06-16 17:39:17',1046,'Base de datos no seleccionada'),('vn-database','10211','01-firstScript.sql','jenkins@10.0.2.69','2022-06-17 07:11:27',NULL,NULL),('vn-database','10215','00-renameIsInventory.sql','jenkins@10.0.2.69','2022-06-30 09:31:26',NULL,NULL),('vn-database','10216','00-firstScript.sql','jenkins@10.0.2.69','2022-06-23 11:15:28',NULL,NULL),('vn-database','10216','01-batchIndex.sql','jenkins@10.0.2.70','2022-06-27 18:10:55',NULL,NULL),('vn-database','10219','00-AddCollectionFkOnPackingSite.sql','jenkins@10.0.2.70','2022-06-29 09:23:42',NULL,NULL),('vn-database','10219','01-AddFkToCollectionFk.sql','jenkins@10.0.2.70','2022-06-29 09:23:43',NULL,NULL),('vn-database','10220','00-createPersonalProtectionEquipment.sql','jenkins@10.0.2.69','2022-06-30 09:31:26',NULL,NULL),('vn-database','10222','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:12:40',NULL,NULL),('vn-database','10223','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:13:52',NULL,NULL),('vn-database','10224','00-cosetes.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-21 12:03:45',NULL,NULL),('vn-database','10229','00-firstScript.sql','jenkins@10.0.2.69','2022-07-01 11:59:34',NULL,NULL),('vn-database','10233','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:13:53',NULL,NULL),('vn-database','10235','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:13:53',NULL,NULL),('vn-database','10236','00-firstScript.sql','jenkins@10.0.2.69','2022-07-05 12:11:40',NULL,NULL),('vn-database','10237','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:13:53',NULL,NULL),('vn-database','10238','00-worker_mobileExtension.sql','jenkins@10.0.2.69','2022-07-14 09:14:09',NULL,NULL),('vn-database','10239','00-firstScript.sql','jenkins@10.0.2.69','2022-07-07 21:51:58',NULL,NULL),('vn-database','10241','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-29 08:14:01',NULL,NULL),('vn-database','10242','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:14:32',NULL,NULL),('vn-database','10243','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:14:32',NULL,NULL),('vn-database','10245','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:34:51',NULL,NULL),('vn-database','10247','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:34:51',NULL,NULL),('vn-database','10248','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-20 17:27:51',NULL,NULL),('vn-database','10250','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:36:40',NULL,NULL),('vn-database','10253','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:36:57',NULL,NULL),('vn-database','10254','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:38:48',NULL,NULL),('vn-database','10256','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:38:48',NULL,NULL),('vn-database','10259','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-02 08:54:56',NULL,NULL),('vn-database','10261','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-22 08:42:20',NULL,NULL),('vn-database','10263','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:38:48',NULL,NULL),('vn-database','10265','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:38:48',NULL,NULL),('vn-database','10275','00-improvedGeneralLog.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-01 09:55:56',NULL,NULL),('vn-database','10278','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-01 17:51:41',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','00001','00-test.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','00003','00-sage.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','10008','00-alterRoleConfig.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','10014','00-rolePrefix.sql','jenkins@10.0.2.68','2022-02-11 00:13:25',NULL,NULL),('vn-database','10017','01-firstScript.sql','jenkins@10.0.2.70','2022-03-09 11:36:54',NULL,NULL),('vn-database','10021','00-bankAccount.sql','jenkins@10.0.2.69','2022-03-16 14:11:22',NULL,NULL),('vn-database','10023','00-firstScript.sql','jenkins@10.0.2.69','2022-03-16 15:05:29',NULL,NULL),('vn-database','10026','00-invoiceInIntrastat.sql','jenkins@10.0.2.69','2022-03-21 15:10:53',NULL,NULL),('vn-database','10027','00-Clientes_cedidos.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10028','00-item_last_buy_.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10029','00-bankToViewAccountingToTable.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10030','00-KkejarNiche.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10036','00-updateBuyConfig.sql','jenkins@10.0.2.69','2022-03-29 12:36:54',NULL,NULL),('vn-database','10037','00-firstScript.sql','jenkins@10.0.2.69','2022-03-28 11:14:26',NULL,NULL),('vn-database','10038','00-printServerQueue.sql','jenkins@10.0.2.69','2022-03-29 08:13:24',NULL,NULL),('vn-database','10048','00-firstScript.sql','jenkins@10.0.2.69','2022-03-30 12:29:06',NULL,NULL),('vn-database','10058','00-vehicleAddFields.sql','jenkins@10.0.2.69','2022-04-06 08:48:34',NULL,NULL),('vn-database','10060','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:11',NULL,NULL),('vn-database','10062','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 10:51:45',NULL,NULL),('vn-database','10064','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 13:57:11',NULL,NULL),('vn-database','10066','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:12',NULL,NULL),('vn-database','10067','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 10:18:20',NULL,NULL),('vn-database','10071','00-packingSiteLog.sql','jenkins@10.0.2.69','2022-04-08 09:37:30',NULL,NULL),('vn-database','10072','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 11:01:46',NULL,NULL),('vn-database','10073','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 13:40:56',NULL,NULL),('vn-database','10074','00-firstScript.sql','jenkins@10.0.2.69','2022-04-10 13:15:05',NULL,NULL),('vn-database','10077','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 08:07:15',NULL,NULL),('vn-database','10078','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 07:44:21',NULL,NULL),('vn-database','10079','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 12:01:37',NULL,NULL),('vn-database','10086','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 08:58:34',NULL,NULL),('vn-database','10087','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 09:39:49',NULL,NULL),('vn-database','10088','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 15:05:12',NULL,NULL),('vn-database','10089','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:12:52',NULL,NULL),('vn-database','10090','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:34:46',NULL,NULL),('vn-database','10092','00-firstScript.sql','jenkins@10.0.2.69','2022-04-19 14:45:46',NULL,NULL),('vn-database','10093','00-autoradioConfig.sql','jenkins@10.0.2.69','2022-05-03 09:16:47',NULL,NULL),('vn-database','10094','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 10:57:30',NULL,NULL),('vn-database','10097','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL),('vn-database','10099','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL),('vn-database','10100','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL),('vn-database','10101','00-firstScript.sql','jenkins@10.0.2.69','2022-04-21 14:59:31',NULL,NULL),('vn-database','10103','00-awbVolume.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL),('vn-database','10104','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:12:59',NULL,NULL),('vn-database','10105','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL),('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL),('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL),('vn-database','10113','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL),('vn-database','10114','00-updateConfig.sql','jenkins@10.0.2.69','2022-04-27 13:37:25',NULL,NULL),('vn-database','10116','00-firstScript.sql','jenkins@10.0.2.69','2022-04-28 11:10:14',NULL,NULL),('vn-database','10118','00-firstScript.sql','jenkins@10.0.2.69','2022-04-29 08:10:15',NULL,NULL),('vn-database','10119','00-AfegirFKPart1.sql','jenkins@10.0.2.69','2022-05-05 10:13:00',NULL,NULL),('vn-database','10119','01-AfegirFkPart2.sql','jenkins@10.0.2.69','2022-05-05 10:22:25',NULL,NULL),('vn-database','10125','00-firstScript.sql','jenkins@10.0.2.68','2022-05-18 18:44:30',NULL,NULL),('vn-database','10127','00-firstScript.sql','jenkins@10.0.2.69','2022-05-02 11:04:46',NULL,NULL),('vn-database','10128','00-firstScript.sql','jenkins@10.0.2.69','2022-05-02 13:04:31',NULL,NULL),('vn-database','10129','00-firstScript.sql','jenkins@10.0.2.69','2022-05-03 08:21:01',NULL,NULL),('vn-database','10132','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 10:22:25',NULL,NULL),('vn-database','10133','00-firstScript.sql','jenkins@10.0.2.69','2022-05-05 14:32:30',NULL,NULL),('vn-database','10134','00-firstScript.sql','jenkins@10.0.2.69','2022-05-06 07:45:25',NULL,NULL),('vn-database','10135','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 08:46:17',NULL,NULL),('vn-database','10136','00-workerTimeControl.sql','jenkins@10.0.2.69','2022-05-09 13:51:12',NULL,NULL),('vn-database','10138','00-firstScript.sql','jenkins@10.0.2.69','2022-05-10 13:58:05',NULL,NULL),('vn-database','10139','00-firstScript.sql','jenkins@10.0.2.68','2022-05-16 14:32:37',NULL,NULL),('vn-database','10139','01-secondScript.sql','jenkins@10.0.2.68','2022-05-17 12:16:13',NULL,NULL),('vn-database','10141','00-firstScript.sql','jenkins@10.0.2.70','2022-05-12 08:27:31',NULL,NULL),('vn-database','10142','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:20:31',NULL,NULL),('vn-database','10143','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:20:31',NULL,NULL),('vn-database','10144','00-AfegirFKPArt1.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL),('vn-database','10144','00-firstScript.sql','jenkins@10.0.2.68','2022-05-13 09:44:25',NULL,NULL),('vn-database','10147','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL),('vn-database','10149','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:33',NULL,NULL),('vn-database','10150','00-firstScript.sql','jenkins@10.0.2.68','2022-05-17 09:57:16',NULL,NULL),('vn-database','10152','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:34',NULL,NULL),('vn-database','10153','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:34',NULL,NULL),('vn-database','10154','00-compressionKk.sql','jenkins@10.0.2.68','2022-05-20 09:22:34',NULL,NULL),('vn-database','10157','00-firstScript.sql','jenkins@10.0.2.68','2022-05-20 09:22:35',NULL,NULL),('vn-database','10158','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:21',NULL,NULL),('vn-database','10160','00-firstScript.sql','jenkins@10.0.2.69','2022-06-30 09:30:50',NULL,NULL),('vn-database','10163','00-firstScript.sql','jenkins@10.0.2.68','2022-05-23 08:17:14',NULL,NULL),('vn-database','10164','00-borrarSectorsDesus.sql','jenkins@10.0.2.68','2022-06-02 12:47:21',NULL,NULL),('vn-database','10165','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10166','00-firstScript.sql','jenkins@10.0.2.68','2022-05-24 16:11:21',NULL,NULL),('vn-database','10167','00-renameVnActiveContrat.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10168','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10169','00-createTableBankEntityConfig.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10169','02-addNotNullToBankEntityBic.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10171','00-volumeConfig.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-18 14:11:11',NULL,NULL),('vn-database','10171','01-itemWeight.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-18 16:01:34',NULL,NULL),('vn-database','10171','02-agencymode.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-18 16:01:34',NULL,NULL),('vn-database','10172','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10174','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 08:46:17',NULL,NULL),('vn-database','10175','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10177','00-crearTablaSpecialLabels.sql','jenkins@10.0.2.68','2022-06-02 12:47:22',NULL,NULL),('vn-database','10178','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:24',NULL,NULL),('vn-database','10179','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:24',NULL,NULL),('vn-database','10183','00-firstScript.sql','jenkins@10.0.2.68','2022-06-02 12:47:24',NULL,NULL),('vn-database','10184','00-firstScript.sql','jenkins@10.0.2.68','2022-06-03 08:05:34',NULL,NULL),('vn-database','10185','00-firstScript.sql','jenkins@10.0.2.68','2022-06-06 09:07:45',NULL,NULL),('vn-database','10186','00-desactivar_trigger.sql','jenkins@10.0.2.68','2022-06-07 09:31:23',NULL,NULL),('vn-database','10186','01-alter_Table_buy.sql','jenkins@10.0.2.68','2022-06-07 09:34:47',NULL,NULL),('vn-database','10186','02-alter_table_entryConfig.sql','jenkins@10.0.2.68','2022-06-07 09:34:47',NULL,NULL),('vn-database','10186','04-regularizar_Sticker_Inventario.sql','jenkins@10.0.2.68','2022-06-07 09:34:51',NULL,NULL),('vn-database','10186','09-reactivar_trigger.sql','jenkins@10.0.2.68','2022-06-07 09:34:51',NULL,NULL),('vn-database','10187','00-firstScript.sql','jenkins@10.0.2.68','2022-06-06 12:37:31',NULL,NULL),('vn-database','10188','00-firstScript.sql','jenkins@10.0.2.68','2022-06-06 14:03:36',NULL,NULL),('vn-database','10189','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10191','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10194','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10195','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:03:41',NULL,NULL),('vn-database','10200','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:00',NULL,NULL),('vn-database','10201','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:00',NULL,NULL),('vn-database','10202','00-Remove_FK_to_ediGenus.sql','jenkins@10.0.2.69','2022-06-17 09:04:00',NULL,NULL),('vn-database','10203','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:01',NULL,NULL),('vn-database','10204','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:01',NULL,NULL),('vn-database','10205','00-firstScript.sql','jenkins@10.0.2.69','2022-06-17 09:04:21',NULL,NULL),('vn-database','10207','00-Alter_table_entry.sql','jenkins@10.0.2.69','2022-06-16 07:22:50',NULL,NULL),('vn-database','10207','01-Update_invoiceAmount.sql','jenkins@10.0.2.69','2022-06-16 07:23:00',NULL,NULL),('vn-database','10208','00-firstScript.sql','jenkins@10.0.2.69','2022-06-30 09:31:26',NULL,NULL),('vn-database','10209','00-firstScript.sql','jenkins@10.0.2.69','2022-06-16 08:47:40',NULL,NULL),('vn-database','10210','00-firstScript.sql','jenkins@10.0.2.69','2022-06-16 17:39:17',1046,'Base de datos no seleccionada'),('vn-database','10211','01-firstScript.sql','jenkins@10.0.2.69','2022-06-17 07:11:27',NULL,NULL),('vn-database','10215','00-renameIsInventory.sql','jenkins@10.0.2.69','2022-06-30 09:31:26',NULL,NULL),('vn-database','10216','00-firstScript.sql','jenkins@10.0.2.69','2022-06-23 11:15:28',NULL,NULL),('vn-database','10216','01-batchIndex.sql','jenkins@10.0.2.70','2022-06-27 18:10:55',NULL,NULL),('vn-database','10219','00-AddCollectionFkOnPackingSite.sql','jenkins@10.0.2.70','2022-06-29 09:23:42',NULL,NULL),('vn-database','10219','01-AddFkToCollectionFk.sql','jenkins@10.0.2.70','2022-06-29 09:23:43',NULL,NULL),('vn-database','10220','00-createPersonalProtectionEquipment.sql','jenkins@10.0.2.69','2022-06-30 09:31:26',NULL,NULL),('vn-database','10222','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:12:40',NULL,NULL),('vn-database','10223','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:13:52',NULL,NULL),('vn-database','10224','00-cosetes.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-21 12:03:45',NULL,NULL),('vn-database','10229','00-firstScript.sql','jenkins@10.0.2.69','2022-07-01 11:59:34',NULL,NULL),('vn-database','10231','01-tablaEktConfig.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:25:39',NULL,NULL),('vn-database','10233','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:13:53',NULL,NULL),('vn-database','10235','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:13:53',NULL,NULL),('vn-database','10236','00-firstScript.sql','jenkins@10.0.2.69','2022-07-05 12:11:40',NULL,NULL),('vn-database','10237','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:13:53',NULL,NULL),('vn-database','10238','00-worker_mobileExtension.sql','jenkins@10.0.2.69','2022-07-14 09:14:09',NULL,NULL),('vn-database','10239','00-firstScript.sql','jenkins@10.0.2.69','2022-07-07 21:51:58',NULL,NULL),('vn-database','10241','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-29 08:14:01',NULL,NULL),('vn-database','10242','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:14:32',NULL,NULL),('vn-database','10243','00-firstScript.sql','jenkins@10.0.2.69','2022-07-14 09:14:32',NULL,NULL),('vn-database','10245','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:34:51',NULL,NULL),('vn-database','10247','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:34:51',NULL,NULL),('vn-database','10248','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-20 17:27:51',NULL,NULL),('vn-database','10250','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:36:40',NULL,NULL),('vn-database','10253','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:36:57',NULL,NULL),('vn-database','10254','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:38:48',NULL,NULL),('vn-database','10256','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:38:48',NULL,NULL),('vn-database','10259','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-02 08:54:56',NULL,NULL),('vn-database','10261','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-22 08:42:20',NULL,NULL),('vn-database','10262','00-createTablepackagingWithFreight.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:13',NULL,NULL),('vn-database','10262','01-alterTablePackagingConfig.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:13',NULL,NULL),('vn-database','10262','02-insertsInicials.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:13',NULL,NULL),('vn-database','10262','03-createTablepackingWithoutFreight.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:14',NULL,NULL),('vn-database','10263','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:38:48',NULL,NULL),('vn-database','10265','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-07-28 08:38:48',NULL,NULL),('vn-database','10267','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:17',NULL,NULL),('vn-database','10267','01-fixMerge.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:17',NULL,NULL),('vn-database','10275','00-improvedGeneralLog.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-01 09:55:56',NULL,NULL),('vn-database','10277','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:26:32',NULL,NULL),('vn-database','10278','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-01 17:51:41',NULL,NULL),('vn-database','10279','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:17',NULL,NULL),('vn-database','10281','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:18',NULL,NULL),('vn-database','10282','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:18',NULL,NULL),('vn-database','10283','00-alterTable.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:34:18',NULL,NULL),('vn-database','10284','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-04 16:59:08',NULL,NULL),('vn-database','10285','00-firstScript.sql','jenkins@swarm-worker3.static.verdnatura.es','2022-08-05 09:19:33',NULL,NULL),('vn-database','10287','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:35:24',NULL,NULL),('vn-database','10288','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-11 09:35:24',NULL,NULL),('vn-database','10291','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-10 14:19:34',NULL,NULL),('vn-database','10293','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:26:32',NULL,NULL),('vn-database','10297','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-16 12:43:36',NULL,NULL),('vn-database','10298','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-08-13 21:04:13',NULL,NULL),('vn-database','10299','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:14',NULL,NULL),('vn-database','10301','00-productionConfig.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:14',NULL,NULL),('vn-database','10301','01-drop.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:14',NULL,NULL),('vn-database','10301','02-collection.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:15',NULL,NULL),('vn-database','10302','00-CreateTableEntryType.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:15',NULL,NULL),('vn-database','10302','01-insertDataEntryType.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:15',NULL,NULL),('vn-database','10302','02-alterTableEntry.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:22',NULL,NULL),('vn-database','10303','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:22:23',NULL,NULL),('vn-database','10304','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:23:48',NULL,NULL),('vn-database','10304','01-altertableticket.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:23:51',NULL,NULL),('vn-database','10305','00-ektAssign.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:24:52',NULL,NULL),('vn-database','10306','00-deliveryInformation.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:25:25',NULL,NULL),('vn-database','10307','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:25:26',NULL,NULL),('vn-database','10308','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-02 17:26:43',NULL,NULL),('vn-database','10309','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-06 11:37:54',NULL,NULL),('vn-database','10310','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:26:33',NULL,NULL),('vn-database','10311','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-06 11:37:55',NULL,NULL),('vn-database','10312','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:26:33',NULL,NULL),('vn-database','10313','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:27:21',NULL,NULL),('vn-database','10315','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:31:43',NULL,NULL),('vn-database','10317','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:31:43',NULL,NULL),('vn-database','10318','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 10:31:43',NULL,NULL),('vn-database','10321','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-08 11:11:12',NULL,NULL),('vn-database','10322','00-firstScript.sql','jenkins@swarm-worker2.static.verdnatura.es','2022-09-09 09:19:05',NULL,NULL); /*!40000 ALTER TABLE `versionLog` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -54,18 +54,18 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-08-03 9:40:36 +-- Dump completed on 2022-09-16 7:03:04 USE `account`; --- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64) +-- MySQL dump 10.19 Distrib 10.3.34-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: account -- ------------------------------------------------------ --- Server version 5.6.25-4-log +-- Server version 10.7.4-MariaDB-1:10.7.4+maria~bullseye-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; +/*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; @@ -88,7 +88,7 @@ UNLOCK TABLES; LOCK TABLES `roleInherit` WRITE; /*!40000 ALTER TABLE `roleInherit` DISABLE KEYS */; -INSERT INTO `roleInherit` VALUES (1,1,2),(2,1,3),(3,1,70),(4,2,11),(5,3,11),(6,5,1),(7,5,21),(8,5,33),(124,5,76),(167,9,103),(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),(242,20,9),(22,20,13),(23,20,16),(24,20,65),(134,20,76),(25,21,13),(26,21,18),(27,21,53),(241,21,72),(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),(245,57,33),(83,57,56),(138,57,76),(84,58,1),(85,59,13),(109,59,50),(87,60,5),(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),(168,66,9),(237,66,103),(97,67,5),(98,67,37),(99,69,35),(152,69,47),(101,70,11),(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),(248,102,13),(246,102,35),(173,103,1),(194,103,2),(181,103,3),(179,103,5),(201,103,6),(176,103,11),(231,103,13),(212,103,15),(213,103,16),(178,103,17),(230,103,18),(229,103,19),(238,103,20),(228,103,21),(232,103,22),(199,103,30),(200,103,31),(197,103,32),(207,103,33),(182,103,34),(186,103,35),(225,103,36),(204,103,37),(205,103,38),(177,103,39),(202,103,40),(203,103,41),(183,103,42),(184,103,43),(174,103,44),(175,103,45),(191,103,47),(193,103,48),(222,103,49),(224,103,50),(215,103,51),(216,103,52),(206,103,53),(210,103,54),(211,103,55),(195,103,56),(196,103,57),(219,103,58),(220,103,59),(223,103,60),(226,103,61),(185,103,64),(218,103,65),(180,103,67),(192,103,69),(233,103,70),(189,103,71),(190,103,72),(198,103,73),(234,103,74),(188,103,75),(172,103,76),(187,103,101),(221,103,102),(171,104,9),(170,104,66),(169,104,100),(166,104,103),(239,106,11),(240,107,60),(247,108,1),(250,109,13),(249,109,18); +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),(167,9,103),(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),(242,20,9),(22,20,13),(23,20,16),(24,20,65),(134,20,76),(25,21,13),(26,21,18),(27,21,53),(241,21,72),(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),(251,51,21),(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),(245,57,33),(83,57,56),(138,57,76),(84,58,1),(85,59,13),(109,59,50),(87,60,5),(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),(168,66,9),(237,66,103),(97,67,5),(98,67,37),(99,69,35),(152,69,47),(101,70,11),(102,71,1),(103,71,58),(105,72,18),(106,73,5),(108,73,19),(107,73,64),(148,101,13),(147,101,35),(154,102,1),(248,102,13),(246,102,35),(173,103,1),(194,103,2),(181,103,3),(179,103,5),(201,103,6),(176,103,11),(231,103,13),(212,103,15),(213,103,16),(178,103,17),(230,103,18),(229,103,19),(238,103,20),(228,103,21),(232,103,22),(199,103,30),(200,103,31),(197,103,32),(207,103,33),(182,103,34),(186,103,35),(225,103,36),(204,103,37),(205,103,38),(177,103,39),(202,103,40),(203,103,41),(183,103,42),(184,103,43),(174,103,44),(175,103,45),(191,103,47),(193,103,48),(222,103,49),(224,103,50),(215,103,51),(216,103,52),(206,103,53),(210,103,54),(211,103,55),(195,103,56),(196,103,57),(219,103,58),(220,103,59),(223,103,60),(226,103,61),(185,103,64),(218,103,65),(180,103,67),(192,103,69),(233,103,70),(189,103,71),(190,103,72),(198,103,73),(234,103,74),(188,103,75),(172,103,76),(187,103,101),(221,103,102),(171,104,9),(170,104,66),(169,104,100),(166,104,103),(239,106,11),(240,107,60),(247,108,1),(250,109,13),(249,109,18); /*!40000 ALTER TABLE `roleInherit` ENABLE KEYS */; UNLOCK TABLES; @@ -98,7 +98,7 @@ UNLOCK TABLES; LOCK TABLES `roleRole` WRITE; /*!40000 ALTER TABLE `roleRole` DISABLE KEYS */; -INSERT INTO `roleRole` VALUES (93925,1,1),(93926,1,2),(93927,1,3),(93930,1,6),(93929,1,11),(93928,1,70),(93843,2,2),(93845,2,6),(93844,2,11),(93728,3,3),(93730,3,6),(93729,3,11),(93698,5,1),(93705,5,2),(93704,5,3),(93697,5,5),(93710,5,6),(93709,5,11),(93702,5,13),(93706,5,18),(93699,5,21),(93700,5,33),(93707,5,53),(93703,5,70),(93708,5,72),(93701,5,76),(94027,6,6),(93866,9,1),(93867,9,2),(93868,9,3),(93869,9,5),(93870,9,6),(93864,9,9),(93871,9,11),(93872,9,13),(93873,9,15),(93874,9,16),(93875,9,17),(93876,9,18),(93877,9,19),(93878,9,20),(93879,9,21),(93880,9,22),(93881,9,30),(93882,9,31),(93883,9,32),(93884,9,33),(93885,9,34),(93886,9,35),(93887,9,36),(93888,9,37),(93889,9,38),(93890,9,39),(93891,9,40),(93892,9,41),(93893,9,42),(93894,9,43),(93895,9,44),(93896,9,45),(93897,9,47),(93898,9,48),(93899,9,49),(93900,9,50),(93901,9,51),(93902,9,52),(93903,9,53),(93904,9,54),(93905,9,55),(93906,9,56),(93907,9,57),(93908,9,58),(93909,9,59),(93910,9,60),(93911,9,61),(93912,9,64),(93913,9,65),(93914,9,67),(93915,9,69),(93916,9,70),(93917,9,71),(93918,9,72),(93919,9,73),(93920,9,74),(93921,9,75),(93922,9,76),(93923,9,101),(93924,9,102),(93865,9,103),(93618,11,6),(93617,11,11),(94715,13,1),(94716,13,2),(94717,13,3),(94720,13,6),(94719,13,11),(94714,13,13),(94718,13,70),(94241,15,1),(94245,15,2),(94244,15,3),(94248,15,6),(94247,15,11),(94233,15,15),(94234,15,35),(94239,15,36),(94242,15,44),(94246,15,47),(94235,15,49),(94236,15,56),(94238,15,58),(94243,15,70),(94240,15,75),(94237,15,76),(94255,16,1),(94260,16,2),(94259,16,3),(94266,16,6),(94265,16,11),(94250,16,13),(94251,16,15),(94249,16,16),(94254,16,35),(94261,16,36),(94264,16,44),(94263,16,47),(94253,16,49),(94256,16,56),(94262,16,58),(94258,16,70),(94257,16,75),(94252,16,76),(93644,17,1),(93655,17,2),(93654,17,3),(93649,17,5),(93677,17,6),(93648,17,9),(93676,17,11),(93647,17,13),(93659,17,15),(93646,17,16),(93636,17,17),(93661,17,18),(93658,17,19),(93637,17,20),(93650,17,21),(93675,17,22),(93674,17,30),(93673,17,31),(93672,17,32),(93652,17,33),(93671,17,34),(93657,17,35),(93670,17,36),(93638,17,37),(93669,17,38),(93639,17,39),(93668,17,40),(93667,17,41),(93666,17,42),(93665,17,43),(93678,17,44),(93679,17,45),(93680,17,47),(93681,17,48),(93682,17,49),(93656,17,50),(93683,17,51),(93684,17,52),(93662,17,53),(93685,17,54),(93686,17,55),(93664,17,56),(93651,17,57),(93687,17,58),(93688,17,59),(93689,17,60),(93690,17,61),(93640,17,64),(93645,17,65),(93641,17,67),(93691,17,69),(93653,17,70),(93692,17,71),(93663,17,72),(93693,17,73),(93643,17,74),(93694,17,75),(93642,17,76),(93695,17,101),(93696,17,102),(93660,17,103),(94628,18,1),(94631,18,2),(94630,18,3),(94634,18,6),(94633,18,11),(94627,18,18),(94632,18,70),(94629,18,76),(94621,19,1),(94624,19,2),(94623,19,3),(94626,19,6),(94625,19,11),(94616,19,13),(94617,19,18),(94614,19,19),(94615,19,21),(94618,19,53),(94622,19,70),(94619,19,72),(94620,19,76),(94276,20,1),(94284,20,2),(94283,20,3),(94282,20,5),(94281,20,6),(94268,20,9),(94280,20,11),(94269,20,13),(94275,20,15),(94270,20,16),(94279,20,17),(94285,20,18),(94274,20,19),(94267,20,20),(94286,20,21),(94287,20,22),(94288,20,30),(94289,20,31),(94290,20,32),(94291,20,33),(94292,20,34),(94273,20,35),(94293,20,36),(94294,20,37),(94295,20,38),(94296,20,39),(94297,20,40),(94298,20,41),(94299,20,42),(94300,20,43),(94301,20,44),(94302,20,45),(94303,20,47),(94304,20,48),(94305,20,49),(94278,20,50),(94306,20,51),(94307,20,52),(94308,20,53),(94309,20,54),(94310,20,55),(94311,20,56),(94312,20,57),(94313,20,58),(94314,20,59),(94315,20,60),(94316,20,61),(94317,20,64),(94271,20,65),(94318,20,67),(94319,20,69),(94320,20,70),(94321,20,71),(94322,20,72),(94323,20,73),(94324,20,74),(94325,20,75),(94272,20,76),(94326,20,101),(94327,20,102),(94277,20,103),(94608,21,1),(94611,21,2),(94610,21,3),(94613,21,6),(94612,21,11),(94603,21,13),(94604,21,18),(94602,21,21),(94605,21,53),(94609,21,70),(94606,21,72),(94607,21,76),(94725,22,1),(94731,22,2),(94730,22,3),(94733,22,6),(94732,22,11),(94722,22,13),(94724,22,18),(94723,22,21),(94721,22,22),(94726,22,53),(94729,22,70),(94727,22,72),(94728,22,76),(93970,30,1),(93978,30,2),(93977,30,3),(93959,30,5),(93990,30,6),(93967,30,9),(93991,30,11),(93966,30,13),(93972,30,15),(93965,30,16),(93989,30,17),(93975,30,18),(93979,30,19),(93960,30,20),(93969,30,21),(93961,30,22),(93958,30,30),(93988,30,31),(93987,30,32),(93968,30,33),(93986,30,34),(93980,30,35),(93985,30,36),(93984,30,37),(93983,30,38),(93982,30,39),(93992,30,40),(93993,30,41),(93994,30,42),(93995,30,43),(93996,30,44),(93997,30,45),(93998,30,47),(93999,30,48),(94000,30,49),(93981,30,50),(94001,30,51),(94002,30,52),(93962,30,53),(94003,30,54),(94004,30,55),(94005,30,56),(94006,30,57),(94007,30,58),(94008,30,59),(94009,30,60),(94010,30,61),(93963,30,64),(93971,30,65),(94011,30,67),(94012,30,69),(93976,30,70),(94013,30,71),(93974,30,72),(94014,30,73),(94015,30,74),(94016,30,75),(93964,30,76),(94017,30,101),(94018,30,102),(93973,30,103),(94020,31,1),(94021,31,2),(94022,31,3),(94025,31,6),(94024,31,11),(94019,31,31),(94023,31,70),(93932,32,1),(93933,32,2),(93934,32,3),(93937,32,6),(93936,32,11),(93931,32,32),(93935,32,70),(94085,33,33),(93732,34,1),(93737,34,2),(93736,34,3),(93739,34,6),(93738,34,11),(93733,34,13),(93734,34,33),(93731,34,34),(93735,34,70),(93774,35,1),(93779,35,2),(93778,35,3),(93781,35,6),(93780,35,11),(93773,35,35),(93777,35,70),(93775,35,75),(93776,35,76),(94515,36,1),(94517,36,2),(94516,36,3),(94520,36,6),(94519,36,11),(94512,36,36),(94513,36,44),(94514,36,47),(94518,36,70),(94058,37,1),(94063,37,2),(94062,37,3),(94065,37,6),(94064,37,11),(94057,37,37),(94061,37,70),(94059,37,74),(94060,37,76),(94072,38,1),(94075,38,2),(94074,38,3),(94077,38,6),(94076,38,11),(94067,38,13),(94068,38,37),(94066,38,38),(94069,38,64),(94073,38,70),(94071,38,74),(94070,38,76),(93627,39,1),(93633,39,2),(93632,39,3),(93620,39,5),(93635,39,6),(93634,39,11),(93625,39,13),(93624,39,18),(93621,39,21),(93626,39,33),(93619,39,39),(93628,39,53),(93630,39,56),(93622,39,57),(93631,39,70),(93629,39,72),(93623,39,76),(94029,40,1),(94032,40,2),(94031,40,3),(94039,40,6),(94038,40,11),(94034,40,36),(94028,40,40),(94037,40,44),(94036,40,47),(94030,40,49),(94035,40,58),(94033,40,70),(94047,41,1),(94051,41,2),(94050,41,3),(94056,41,6),(94055,41,11),(94041,41,13),(94042,41,35),(94048,41,36),(94043,41,40),(94040,41,41),(94054,41,44),(94053,41,47),(94045,41,49),(94052,41,58),(94049,41,70),(94046,41,75),(94044,41,76),(93746,42,1),(93751,42,2),(93750,42,3),(93754,42,6),(93753,42,11),(93741,42,35),(93744,42,36),(93740,42,42),(93748,42,44),(93752,42,47),(93742,42,49),(93747,42,58),(93749,42,70),(93745,42,75),(93743,42,76),(93759,43,1),(93765,43,2),(93764,43,3),(93771,43,6),(93770,43,11),(93756,43,13),(93758,43,35),(93766,43,36),(93757,43,42),(93755,43,43),(93769,43,44),(93768,43,47),(93760,43,49),(93767,43,58),(93763,43,70),(93762,43,75),(93761,43,76),(93602,44,1),(93603,44,2),(93604,44,3),(93607,44,6),(93606,44,11),(93601,44,44),(93605,44,70),(93611,45,1),(93613,45,2),(93612,45,3),(93616,45,6),(93615,45,11),(93609,45,13),(93610,45,44),(93608,45,45),(93614,45,70),(93814,47,1),(93815,47,2),(93816,47,3),(93819,47,6),(93818,47,11),(93813,47,47),(93817,47,70),(93837,48,1),(93840,48,2),(93839,48,3),(93842,48,6),(93841,48,11),(93832,48,13),(93833,48,35),(93834,48,47),(93831,48,48),(93838,48,70),(93836,48,75),(93835,48,76),(94429,49,1),(94432,49,2),(94431,49,3),(94434,49,6),(94433,49,11),(94425,49,36),(94428,49,44),(94427,49,47),(94424,49,49),(94426,49,58),(94430,49,70),(94475,50,1),(94482,50,2),(94481,50,3),(94484,50,6),(94483,50,11),(94462,50,13),(94474,50,18),(94463,50,21),(94476,50,33),(94464,50,35),(94470,50,36),(94479,50,44),(94478,50,47),(94465,50,49),(94461,50,50),(94473,50,53),(94477,50,56),(94466,50,57),(94469,50,58),(94467,50,59),(94480,50,70),(94472,50,72),(94471,50,75),(94468,50,76),(94329,51,1),(94334,51,2),(94333,51,3),(94336,51,6),(94335,51,11),(94328,51,51),(94332,51,70),(94330,51,74),(94331,51,75),(94346,52,1),(94351,52,2),(94350,52,3),(94354,52,6),(94353,52,11),(94338,52,13),(94348,52,18),(94339,52,19),(94345,52,21),(94340,52,35),(94341,52,51),(94337,52,52),(94347,52,53),(94349,52,70),(94352,52,72),(94343,52,74),(94344,52,75),(94342,52,76),(94079,53,1),(94080,53,2),(94081,53,3),(94084,53,6),(94083,53,11),(94078,53,53),(94082,53,70),(94218,54,1),(94219,54,2),(94220,54,3),(94223,54,6),(94222,54,11),(94217,54,54),(94221,54,70),(94227,55,1),(94229,55,2),(94228,55,3),(94232,55,6),(94231,55,11),(94225,55,13),(94226,55,54),(94224,55,55),(94230,55,70),(93847,56,1),(93848,56,2),(93849,56,3),(93852,56,6),(93851,56,11),(93846,56,56),(93850,56,70),(93858,57,1),(93861,57,2),(93860,57,3),(93863,57,6),(93862,57,11),(93854,57,13),(93855,57,33),(93856,57,56),(93853,57,57),(93859,57,70),(93857,57,76),(94383,58,1),(94384,58,2),(94385,58,3),(94388,58,6),(94387,58,11),(94382,58,58),(94386,58,70),(94393,59,1),(94403,59,2),(94402,59,3),(94412,59,6),(94411,59,11),(94390,59,13),(94400,59,18),(94392,59,21),(94407,59,33),(94394,59,35),(94405,59,36),(94410,59,44),(94409,59,47),(94395,59,49),(94391,59,50),(94399,59,53),(94408,59,56),(94396,59,57),(94406,59,58),(94389,59,59),(94401,59,70),(94398,59,72),(94404,59,75),(94397,59,76),(94443,60,1),(94455,60,2),(94454,60,3),(94436,60,5),(94460,60,6),(94459,60,11),(94440,60,13),(94452,60,18),(94442,60,21),(94441,60,33),(94444,60,35),(94448,60,36),(94458,60,44),(94457,60,47),(94445,60,49),(94437,60,50),(94451,60,53),(94447,60,56),(94438,60,57),(94456,60,58),(94446,60,59),(94435,60,60),(94453,60,70),(94450,60,72),(94449,60,75),(94439,60,76),(94525,61,1),(94529,61,2),(94528,61,3),(94531,61,6),(94530,61,11),(94522,61,13),(94523,61,36),(94524,61,44),(94526,61,47),(94521,61,61),(94527,61,70),(94355,62,62),(93772,64,64),(94363,65,1),(94371,65,2),(94370,65,3),(94381,65,6),(94380,65,11),(94361,65,13),(94374,65,18),(94357,65,19),(94364,65,21),(94376,65,33),(94358,65,35),(94368,65,36),(94379,65,44),(94378,65,47),(94365,65,49),(94359,65,50),(94373,65,53),(94377,65,56),(94366,65,57),(94375,65,58),(94367,65,59),(94356,65,65),(94369,65,70),(94372,65,72),(94362,65,75),(94360,65,76),(94649,66,1),(94648,66,2),(94650,66,3),(94651,66,5),(94652,66,6),(94646,66,9),(94653,66,11),(94654,66,13),(94655,66,15),(94656,66,16),(94657,66,17),(94658,66,18),(94659,66,19),(94660,66,20),(94661,66,21),(94662,66,22),(94663,66,30),(94664,66,31),(94665,66,32),(94666,66,33),(94667,66,34),(94668,66,35),(94669,66,36),(94670,66,37),(94671,66,38),(94672,66,39),(94673,66,40),(94674,66,41),(94675,66,42),(94676,66,43),(94677,66,44),(94678,66,45),(94679,66,47),(94680,66,48),(94681,66,49),(94682,66,50),(94683,66,51),(94684,66,52),(94685,66,53),(94686,66,54),(94687,66,55),(94688,66,56),(94689,66,57),(94690,66,58),(94691,66,59),(94692,66,60),(94693,66,61),(94694,66,64),(94695,66,65),(94645,66,66),(94696,66,67),(94697,66,69),(94698,66,70),(94699,66,71),(94700,66,72),(94701,66,73),(94702,66,74),(94703,66,75),(94704,66,76),(94705,66,101),(94706,66,102),(94647,66,103),(93715,67,1),(93723,67,2),(93722,67,3),(93712,67,5),(93727,67,6),(93726,67,11),(93720,67,13),(93719,67,18),(93714,67,21),(93716,67,33),(93713,67,37),(93724,67,53),(93711,67,67),(93721,67,70),(93725,67,72),(93718,67,74),(93717,67,76),(93824,69,1),(93828,69,2),(93827,69,3),(93830,69,6),(93829,69,11),(93821,69,35),(93822,69,47),(93820,69,69),(93826,69,70),(93823,69,75),(93825,69,76),(94736,70,6),(94735,70,11),(94734,70,70),(93796,71,1),(93799,71,2),(93798,71,3),(93802,71,6),(93801,71,11),(93797,71,58),(93800,71,70),(93795,71,71),(93807,72,1),(93809,72,2),(93808,72,3),(93812,72,6),(93811,72,11),(93804,72,13),(93805,72,18),(93810,72,70),(93803,72,72),(93806,72,76),(93947,73,1),(93952,73,2),(93951,73,3),(93942,73,5),(93957,73,6),(93956,73,11),(93949,73,13),(93953,73,18),(93943,73,19),(93946,73,21),(93945,73,33),(93954,73,53),(93944,73,64),(93950,73,70),(93955,73,72),(93941,73,73),(93948,73,76),(94737,74,74),(93793,75,75),(93794,76,76),(94558,100,1),(94554,100,2),(94540,100,3),(94538,100,5),(94565,100,6),(94557,100,9),(94535,100,11),(94598,100,13),(94576,100,15),(94577,100,16),(94537,100,17),(94594,100,18),(94593,100,19),(94578,100,20),(94592,100,21),(94599,100,22),(94562,100,30),(94563,100,31),(94559,100,32),(94571,100,33),(94541,100,34),(94545,100,35),(94590,100,36),(94568,100,37),(94569,100,38),(94536,100,39),(94566,100,40),(94567,100,41),(94542,100,42),(94543,100,43),(94533,100,44),(94534,100,45),(94551,100,47),(94553,100,48),(94586,100,49),(94588,100,50),(94579,100,51),(94580,100,52),(94570,100,53),(94574,100,54),(94575,100,55),(94555,100,56),(94556,100,57),(94583,100,58),(94584,100,59),(94587,100,60),(94591,100,61),(94581,100,62),(94544,100,64),(94582,100,65),(94596,100,66),(94539,100,67),(94552,100,69),(94600,100,70),(94549,100,71),(94550,100,72),(94561,100,73),(94601,100,74),(94547,100,75),(94548,100,76),(94532,100,100),(94546,100,101),(94585,100,102),(94572,100,103),(94573,100,104),(94564,100,105),(94560,100,106),(94589,100,107),(94597,100,108),(94595,100,109),(93786,101,1),(93790,101,2),(93789,101,3),(93792,101,6),(93791,101,11),(93783,101,13),(93784,101,35),(93788,101,70),(93785,101,75),(93787,101,76),(93782,101,101),(94414,102,1),(94419,102,2),(94418,102,3),(94423,102,6),(94422,102,11),(94415,102,13),(94416,102,35),(94417,102,70),(94420,102,75),(94421,102,76),(94413,102,102),(94087,103,1),(94088,103,2),(94089,103,3),(94090,103,5),(94091,103,6),(94146,103,9),(94092,103,11),(94093,103,13),(94094,103,15),(94095,103,16),(94096,103,17),(94097,103,18),(94098,103,19),(94099,103,20),(94100,103,21),(94101,103,22),(94102,103,30),(94103,103,31),(94104,103,32),(94105,103,33),(94106,103,34),(94107,103,35),(94108,103,36),(94109,103,37),(94110,103,38),(94111,103,39),(94112,103,40),(94113,103,41),(94114,103,42),(94115,103,43),(94116,103,44),(94117,103,45),(94118,103,47),(94119,103,48),(94120,103,49),(94121,103,50),(94122,103,51),(94123,103,52),(94124,103,53),(94125,103,54),(94126,103,55),(94127,103,56),(94128,103,57),(94129,103,58),(94130,103,59),(94131,103,60),(94132,103,61),(94133,103,64),(94134,103,65),(94135,103,67),(94136,103,69),(94137,103,70),(94138,103,71),(94139,103,72),(94140,103,73),(94141,103,74),(94142,103,75),(94143,103,76),(94144,103,101),(94145,103,102),(94086,103,103),(94155,104,1),(94154,104,2),(94153,104,3),(94152,104,5),(94156,104,6),(94148,104,9),(94157,104,11),(94158,104,13),(94159,104,15),(94160,104,16),(94161,104,17),(94162,104,18),(94163,104,19),(94164,104,20),(94165,104,21),(94166,104,22),(94167,104,30),(94168,104,31),(94169,104,32),(94170,104,33),(94171,104,34),(94172,104,35),(94173,104,36),(94174,104,37),(94175,104,38),(94176,104,39),(94177,104,40),(94178,104,41),(94179,104,42),(94180,104,43),(94181,104,44),(94182,104,45),(94183,104,47),(94184,104,48),(94185,104,49),(94186,104,50),(94187,104,51),(94188,104,52),(94189,104,53),(94190,104,54),(94191,104,55),(94192,104,56),(94193,104,57),(94194,104,58),(94195,104,59),(94196,104,60),(94197,104,61),(94213,104,62),(94198,104,64),(94199,104,65),(94149,104,66),(94200,104,67),(94201,104,69),(94202,104,70),(94203,104,71),(94204,104,72),(94205,104,73),(94206,104,74),(94207,104,75),(94208,104,76),(94150,104,100),(94209,104,101),(94210,104,102),(94151,104,103),(94147,104,104),(94212,104,105),(94211,104,106),(94214,104,107),(94216,104,108),(94215,104,109),(94026,105,105),(93940,106,6),(93939,106,11),(93938,106,106),(94494,107,1),(94506,107,2),(94505,107,3),(94487,107,5),(94511,107,6),(94510,107,11),(94491,107,13),(94503,107,18),(94493,107,21),(94492,107,33),(94495,107,35),(94499,107,36),(94509,107,44),(94508,107,47),(94496,107,49),(94488,107,50),(94502,107,53),(94498,107,56),(94489,107,57),(94507,107,58),(94497,107,59),(94486,107,60),(94504,107,70),(94501,107,72),(94500,107,75),(94490,107,76),(94485,107,107),(94708,108,1),(94709,108,2),(94710,108,3),(94713,108,6),(94712,108,11),(94711,108,70),(94707,108,108),(94639,109,1),(94641,109,2),(94640,109,3),(94644,109,6),(94643,109,11),(94636,109,13),(94637,109,18),(94642,109,70),(94638,109,76),(94635,109,109); +INSERT INTO `roleRole` VALUES (106016,1,1),(106017,1,2),(106018,1,3),(106021,1,6),(106020,1,11),(106019,1,70),(105934,2,2),(105936,2,6),(105935,2,11),(105820,3,3),(105822,3,6),(105821,3,11),(105790,5,1),(105797,5,2),(105796,5,3),(105789,5,5),(105802,5,6),(105801,5,11),(105794,5,13),(105798,5,18),(105791,5,21),(105792,5,33),(105799,5,53),(105795,5,70),(105800,5,72),(105793,5,76),(106118,6,6),(105957,9,1),(105958,9,2),(105959,9,3),(105960,9,5),(105961,9,6),(105955,9,9),(105962,9,11),(105963,9,13),(105964,9,15),(105965,9,16),(105966,9,17),(105967,9,18),(105968,9,19),(105969,9,20),(105970,9,21),(105971,9,22),(105972,9,30),(105973,9,31),(105974,9,32),(105975,9,33),(105976,9,34),(105977,9,35),(105978,9,36),(105979,9,37),(105980,9,38),(105981,9,39),(105982,9,40),(105983,9,41),(105984,9,42),(105985,9,43),(105986,9,44),(105987,9,45),(105988,9,47),(105989,9,48),(105990,9,49),(105991,9,50),(105992,9,51),(105993,9,52),(105994,9,53),(105995,9,54),(105996,9,55),(105997,9,56),(105998,9,57),(105999,9,58),(106000,9,59),(106001,9,60),(106002,9,61),(106003,9,64),(106004,9,65),(106005,9,67),(106006,9,69),(106007,9,70),(106008,9,71),(106009,9,72),(106010,9,73),(106011,9,74),(106012,9,75),(106013,9,76),(106014,9,101),(106015,9,102),(105956,9,103),(105710,11,6),(105709,11,11),(106812,13,1),(106813,13,2),(106814,13,3),(106817,13,6),(106816,13,11),(106811,13,13),(106815,13,70),(106332,15,1),(106336,15,2),(106335,15,3),(106339,15,6),(106338,15,11),(106324,15,15),(106325,15,35),(106330,15,36),(106333,15,44),(106337,15,47),(106326,15,49),(106327,15,56),(106329,15,58),(106334,15,70),(106331,15,75),(106328,15,76),(106346,16,1),(106351,16,2),(106350,16,3),(106357,16,6),(106356,16,11),(106341,16,13),(106342,16,15),(106340,16,16),(106345,16,35),(106352,16,36),(106355,16,44),(106354,16,47),(106344,16,49),(106347,16,56),(106353,16,58),(106349,16,70),(106348,16,75),(106343,16,76),(105736,17,1),(105747,17,2),(105746,17,3),(105741,17,5),(105769,17,6),(105740,17,9),(105768,17,11),(105739,17,13),(105751,17,15),(105738,17,16),(105728,17,17),(105753,17,18),(105750,17,19),(105729,17,20),(105742,17,21),(105767,17,22),(105766,17,30),(105765,17,31),(105764,17,32),(105744,17,33),(105763,17,34),(105749,17,35),(105762,17,36),(105730,17,37),(105761,17,38),(105731,17,39),(105760,17,40),(105759,17,41),(105758,17,42),(105757,17,43),(105770,17,44),(105771,17,45),(105772,17,47),(105773,17,48),(105774,17,49),(105748,17,50),(105775,17,51),(105776,17,52),(105754,17,53),(105777,17,54),(105778,17,55),(105756,17,56),(105743,17,57),(105779,17,58),(105780,17,59),(105781,17,60),(105782,17,61),(105732,17,64),(105737,17,65),(105733,17,67),(105783,17,69),(105745,17,70),(105784,17,71),(105755,17,72),(105785,17,73),(105735,17,74),(105786,17,75),(105734,17,76),(105787,17,101),(105788,17,102),(105752,17,103),(106725,18,1),(106728,18,2),(106727,18,3),(106731,18,6),(106730,18,11),(106724,18,18),(106729,18,70),(106726,18,76),(106718,19,1),(106721,19,2),(106720,19,3),(106723,19,6),(106722,19,11),(106713,19,13),(106714,19,18),(106711,19,19),(106712,19,21),(106715,19,53),(106719,19,70),(106716,19,72),(106717,19,76),(106367,20,1),(106375,20,2),(106374,20,3),(106373,20,5),(106372,20,6),(106359,20,9),(106371,20,11),(106360,20,13),(106366,20,15),(106361,20,16),(106370,20,17),(106376,20,18),(106365,20,19),(106358,20,20),(106377,20,21),(106378,20,22),(106379,20,30),(106380,20,31),(106381,20,32),(106382,20,33),(106383,20,34),(106364,20,35),(106384,20,36),(106385,20,37),(106386,20,38),(106387,20,39),(106388,20,40),(106389,20,41),(106390,20,42),(106391,20,43),(106392,20,44),(106393,20,45),(106394,20,47),(106395,20,48),(106396,20,49),(106369,20,50),(106397,20,51),(106398,20,52),(106399,20,53),(106400,20,54),(106401,20,55),(106402,20,56),(106403,20,57),(106404,20,58),(106405,20,59),(106406,20,60),(106407,20,61),(106408,20,64),(106362,20,65),(106409,20,67),(106410,20,69),(106411,20,70),(106412,20,71),(106413,20,72),(106414,20,73),(106415,20,74),(106416,20,75),(106363,20,76),(106417,20,101),(106418,20,102),(106368,20,103),(106705,21,1),(106708,21,2),(106707,21,3),(106710,21,6),(106709,21,11),(106700,21,13),(106701,21,18),(106699,21,21),(106702,21,53),(106706,21,70),(106703,21,72),(106704,21,76),(106822,22,1),(106828,22,2),(106827,22,3),(106830,22,6),(106829,22,11),(106819,22,13),(106821,22,18),(106820,22,21),(106818,22,22),(106823,22,53),(106826,22,70),(106824,22,72),(106825,22,76),(106061,30,1),(106069,30,2),(106068,30,3),(106050,30,5),(106081,30,6),(106058,30,9),(106082,30,11),(106057,30,13),(106063,30,15),(106056,30,16),(106080,30,17),(106066,30,18),(106070,30,19),(106051,30,20),(106060,30,21),(106052,30,22),(106049,30,30),(106079,30,31),(106078,30,32),(106059,30,33),(106077,30,34),(106071,30,35),(106076,30,36),(106075,30,37),(106074,30,38),(106073,30,39),(106083,30,40),(106084,30,41),(106085,30,42),(106086,30,43),(106087,30,44),(106088,30,45),(106089,30,47),(106090,30,48),(106091,30,49),(106072,30,50),(106092,30,51),(106093,30,52),(106053,30,53),(106094,30,54),(106095,30,55),(106096,30,56),(106097,30,57),(106098,30,58),(106099,30,59),(106100,30,60),(106101,30,61),(106054,30,64),(106062,30,65),(106102,30,67),(106103,30,69),(106067,30,70),(106104,30,71),(106065,30,72),(106105,30,73),(106106,30,74),(106107,30,75),(106055,30,76),(106108,30,101),(106109,30,102),(106064,30,103),(106111,31,1),(106112,31,2),(106113,31,3),(106116,31,6),(106115,31,11),(106110,31,31),(106114,31,70),(106023,32,1),(106024,32,2),(106025,32,3),(106028,32,6),(106027,32,11),(106022,32,32),(106026,32,70),(106176,33,33),(105824,34,1),(105829,34,2),(105828,34,3),(105831,34,6),(105830,34,11),(105825,34,13),(105826,34,33),(105823,34,34),(105827,34,70),(105866,35,1),(105871,35,2),(105870,35,3),(105873,35,6),(105872,35,11),(105865,35,35),(105869,35,70),(105867,35,75),(105868,35,76),(106612,36,1),(106614,36,2),(106613,36,3),(106617,36,6),(106616,36,11),(106609,36,36),(106610,36,44),(106611,36,47),(106615,36,70),(106149,37,1),(106154,37,2),(106153,37,3),(106156,37,6),(106155,37,11),(106148,37,37),(106152,37,70),(106150,37,74),(106151,37,76),(106163,38,1),(106166,38,2),(106165,38,3),(106168,38,6),(106167,38,11),(106158,38,13),(106159,38,37),(106157,38,38),(106160,38,64),(106164,38,70),(106162,38,74),(106161,38,76),(105719,39,1),(105725,39,2),(105724,39,3),(105712,39,5),(105727,39,6),(105726,39,11),(105717,39,13),(105716,39,18),(105713,39,21),(105718,39,33),(105711,39,39),(105720,39,53),(105722,39,56),(105714,39,57),(105723,39,70),(105721,39,72),(105715,39,76),(106120,40,1),(106123,40,2),(106122,40,3),(106130,40,6),(106129,40,11),(106125,40,36),(106119,40,40),(106128,40,44),(106127,40,47),(106121,40,49),(106126,40,58),(106124,40,70),(106138,41,1),(106142,41,2),(106141,41,3),(106147,41,6),(106146,41,11),(106132,41,13),(106133,41,35),(106139,41,36),(106134,41,40),(106131,41,41),(106145,41,44),(106144,41,47),(106136,41,49),(106143,41,58),(106140,41,70),(106137,41,75),(106135,41,76),(105838,42,1),(105843,42,2),(105842,42,3),(105846,42,6),(105845,42,11),(105833,42,35),(105836,42,36),(105832,42,42),(105840,42,44),(105844,42,47),(105834,42,49),(105839,42,58),(105841,42,70),(105837,42,75),(105835,42,76),(105851,43,1),(105857,43,2),(105856,43,3),(105863,43,6),(105862,43,11),(105848,43,13),(105850,43,35),(105858,43,36),(105849,43,42),(105847,43,43),(105861,43,44),(105860,43,47),(105852,43,49),(105859,43,58),(105855,43,70),(105854,43,75),(105853,43,76),(105694,44,1),(105695,44,2),(105696,44,3),(105699,44,6),(105698,44,11),(105693,44,44),(105697,44,70),(105703,45,1),(105705,45,2),(105704,45,3),(105708,45,6),(105707,45,11),(105701,45,13),(105702,45,44),(105700,45,45),(105706,45,70),(105905,47,1),(105906,47,2),(105907,47,3),(105910,47,6),(105909,47,11),(105904,47,47),(105908,47,70),(105928,48,1),(105931,48,2),(105930,48,3),(105933,48,6),(105932,48,11),(105923,48,13),(105924,48,35),(105925,48,47),(105922,48,48),(105929,48,70),(105927,48,75),(105926,48,76),(106526,49,1),(106529,49,2),(106528,49,3),(106531,49,6),(106530,49,11),(106522,49,36),(106525,49,44),(106524,49,47),(106521,49,49),(106523,49,58),(106527,49,70),(106572,50,1),(106579,50,2),(106578,50,3),(106581,50,6),(106580,50,11),(106559,50,13),(106571,50,18),(106560,50,21),(106573,50,33),(106561,50,35),(106567,50,36),(106576,50,44),(106575,50,47),(106562,50,49),(106558,50,50),(106570,50,53),(106574,50,56),(106563,50,57),(106566,50,58),(106564,50,59),(106577,50,70),(106569,50,72),(106568,50,75),(106565,50,76),(106420,51,1),(106427,51,2),(106426,51,3),(106433,51,6),(106432,51,11),(106424,51,13),(106428,51,18),(106421,51,21),(106419,51,51),(106429,51,53),(106425,51,70),(106430,51,72),(106422,51,74),(106423,51,75),(106431,51,76),(106443,52,1),(106448,52,2),(106447,52,3),(106451,52,6),(106450,52,11),(106435,52,13),(106445,52,18),(106436,52,19),(106442,52,21),(106437,52,35),(106438,52,51),(106434,52,52),(106444,52,53),(106446,52,70),(106449,52,72),(106440,52,74),(106441,52,75),(106439,52,76),(106170,53,1),(106171,53,2),(106172,53,3),(106175,53,6),(106174,53,11),(106169,53,53),(106173,53,70),(106309,54,1),(106310,54,2),(106311,54,3),(106314,54,6),(106313,54,11),(106308,54,54),(106312,54,70),(106318,55,1),(106320,55,2),(106319,55,3),(106323,55,6),(106322,55,11),(106316,55,13),(106317,55,54),(106315,55,55),(106321,55,70),(105938,56,1),(105939,56,2),(105940,56,3),(105943,56,6),(105942,56,11),(105937,56,56),(105941,56,70),(105949,57,1),(105952,57,2),(105951,57,3),(105954,57,6),(105953,57,11),(105945,57,13),(105946,57,33),(105947,57,56),(105944,57,57),(105950,57,70),(105948,57,76),(106480,58,1),(106481,58,2),(106482,58,3),(106485,58,6),(106484,58,11),(106479,58,58),(106483,58,70),(106490,59,1),(106500,59,2),(106499,59,3),(106509,59,6),(106508,59,11),(106487,59,13),(106497,59,18),(106489,59,21),(106504,59,33),(106491,59,35),(106502,59,36),(106507,59,44),(106506,59,47),(106492,59,49),(106488,59,50),(106496,59,53),(106505,59,56),(106493,59,57),(106503,59,58),(106486,59,59),(106498,59,70),(106495,59,72),(106501,59,75),(106494,59,76),(106540,60,1),(106552,60,2),(106551,60,3),(106533,60,5),(106557,60,6),(106556,60,11),(106537,60,13),(106549,60,18),(106539,60,21),(106538,60,33),(106541,60,35),(106545,60,36),(106555,60,44),(106554,60,47),(106542,60,49),(106534,60,50),(106548,60,53),(106544,60,56),(106535,60,57),(106553,60,58),(106543,60,59),(106532,60,60),(106550,60,70),(106547,60,72),(106546,60,75),(106536,60,76),(106622,61,1),(106626,61,2),(106625,61,3),(106628,61,6),(106627,61,11),(106619,61,13),(106620,61,36),(106621,61,44),(106623,61,47),(106618,61,61),(106624,61,70),(106452,62,62),(105864,64,64),(106460,65,1),(106468,65,2),(106467,65,3),(106478,65,6),(106477,65,11),(106458,65,13),(106471,65,18),(106454,65,19),(106461,65,21),(106473,65,33),(106455,65,35),(106465,65,36),(106476,65,44),(106475,65,47),(106462,65,49),(106456,65,50),(106470,65,53),(106474,65,56),(106463,65,57),(106472,65,58),(106464,65,59),(106453,65,65),(106466,65,70),(106469,65,72),(106459,65,75),(106457,65,76),(106746,66,1),(106745,66,2),(106747,66,3),(106748,66,5),(106749,66,6),(106743,66,9),(106750,66,11),(106751,66,13),(106752,66,15),(106753,66,16),(106754,66,17),(106755,66,18),(106756,66,19),(106757,66,20),(106758,66,21),(106759,66,22),(106760,66,30),(106761,66,31),(106762,66,32),(106763,66,33),(106764,66,34),(106765,66,35),(106766,66,36),(106767,66,37),(106768,66,38),(106769,66,39),(106770,66,40),(106771,66,41),(106772,66,42),(106773,66,43),(106774,66,44),(106775,66,45),(106776,66,47),(106777,66,48),(106778,66,49),(106779,66,50),(106780,66,51),(106781,66,52),(106782,66,53),(106783,66,54),(106784,66,55),(106785,66,56),(106786,66,57),(106787,66,58),(106788,66,59),(106789,66,60),(106790,66,61),(106791,66,64),(106792,66,65),(106742,66,66),(106793,66,67),(106794,66,69),(106795,66,70),(106796,66,71),(106797,66,72),(106798,66,73),(106799,66,74),(106800,66,75),(106801,66,76),(106802,66,101),(106803,66,102),(106744,66,103),(105807,67,1),(105815,67,2),(105814,67,3),(105804,67,5),(105819,67,6),(105818,67,11),(105812,67,13),(105811,67,18),(105806,67,21),(105808,67,33),(105805,67,37),(105816,67,53),(105803,67,67),(105813,67,70),(105817,67,72),(105810,67,74),(105809,67,76),(105915,69,1),(105919,69,2),(105918,69,3),(105921,69,6),(105920,69,11),(105912,69,35),(105913,69,47),(105911,69,69),(105917,69,70),(105914,69,75),(105916,69,76),(106833,70,6),(106832,70,11),(106831,70,70),(105888,71,1),(105891,71,2),(105890,71,3),(105894,71,6),(105893,71,11),(105889,71,58),(105892,71,70),(105887,71,71),(105897,72,1),(105900,72,2),(105899,72,3),(105903,72,6),(105902,72,11),(105896,72,18),(105901,72,70),(105895,72,72),(105898,72,76),(106038,73,1),(106043,73,2),(106042,73,3),(106033,73,5),(106048,73,6),(106047,73,11),(106040,73,13),(106044,73,18),(106034,73,19),(106037,73,21),(106036,73,33),(106045,73,53),(106035,73,64),(106041,73,70),(106046,73,72),(106032,73,73),(106039,73,76),(106834,74,74),(105885,75,75),(105886,76,76),(106655,100,1),(106651,100,2),(106637,100,3),(106635,100,5),(106662,100,6),(106654,100,9),(106632,100,11),(106695,100,13),(106673,100,15),(106674,100,16),(106634,100,17),(106691,100,18),(106690,100,19),(106675,100,20),(106689,100,21),(106696,100,22),(106659,100,30),(106660,100,31),(106656,100,32),(106668,100,33),(106638,100,34),(106642,100,35),(106687,100,36),(106665,100,37),(106666,100,38),(106633,100,39),(106663,100,40),(106664,100,41),(106639,100,42),(106640,100,43),(106630,100,44),(106631,100,45),(106648,100,47),(106650,100,48),(106683,100,49),(106685,100,50),(106676,100,51),(106677,100,52),(106667,100,53),(106671,100,54),(106672,100,55),(106652,100,56),(106653,100,57),(106680,100,58),(106681,100,59),(106684,100,60),(106688,100,61),(106678,100,62),(106641,100,64),(106679,100,65),(106693,100,66),(106636,100,67),(106649,100,69),(106697,100,70),(106646,100,71),(106647,100,72),(106658,100,73),(106698,100,74),(106644,100,75),(106645,100,76),(106629,100,100),(106643,100,101),(106682,100,102),(106669,100,103),(106670,100,104),(106661,100,105),(106657,100,106),(106686,100,107),(106694,100,108),(106692,100,109),(105878,101,1),(105882,101,2),(105881,101,3),(105884,101,6),(105883,101,11),(105875,101,13),(105876,101,35),(105880,101,70),(105877,101,75),(105879,101,76),(105874,101,101),(106511,102,1),(106516,102,2),(106515,102,3),(106520,102,6),(106519,102,11),(106512,102,13),(106513,102,35),(106514,102,70),(106517,102,75),(106518,102,76),(106510,102,102),(106178,103,1),(106179,103,2),(106180,103,3),(106181,103,5),(106182,103,6),(106237,103,9),(106183,103,11),(106184,103,13),(106185,103,15),(106186,103,16),(106187,103,17),(106188,103,18),(106189,103,19),(106190,103,20),(106191,103,21),(106192,103,22),(106193,103,30),(106194,103,31),(106195,103,32),(106196,103,33),(106197,103,34),(106198,103,35),(106199,103,36),(106200,103,37),(106201,103,38),(106202,103,39),(106203,103,40),(106204,103,41),(106205,103,42),(106206,103,43),(106207,103,44),(106208,103,45),(106209,103,47),(106210,103,48),(106211,103,49),(106212,103,50),(106213,103,51),(106214,103,52),(106215,103,53),(106216,103,54),(106217,103,55),(106218,103,56),(106219,103,57),(106220,103,58),(106221,103,59),(106222,103,60),(106223,103,61),(106224,103,64),(106225,103,65),(106226,103,67),(106227,103,69),(106228,103,70),(106229,103,71),(106230,103,72),(106231,103,73),(106232,103,74),(106233,103,75),(106234,103,76),(106235,103,101),(106236,103,102),(106177,103,103),(106246,104,1),(106245,104,2),(106244,104,3),(106243,104,5),(106247,104,6),(106239,104,9),(106248,104,11),(106249,104,13),(106250,104,15),(106251,104,16),(106252,104,17),(106253,104,18),(106254,104,19),(106255,104,20),(106256,104,21),(106257,104,22),(106258,104,30),(106259,104,31),(106260,104,32),(106261,104,33),(106262,104,34),(106263,104,35),(106264,104,36),(106265,104,37),(106266,104,38),(106267,104,39),(106268,104,40),(106269,104,41),(106270,104,42),(106271,104,43),(106272,104,44),(106273,104,45),(106274,104,47),(106275,104,48),(106276,104,49),(106277,104,50),(106278,104,51),(106279,104,52),(106280,104,53),(106281,104,54),(106282,104,55),(106283,104,56),(106284,104,57),(106285,104,58),(106286,104,59),(106287,104,60),(106288,104,61),(106304,104,62),(106289,104,64),(106290,104,65),(106240,104,66),(106291,104,67),(106292,104,69),(106293,104,70),(106294,104,71),(106295,104,72),(106296,104,73),(106297,104,74),(106298,104,75),(106299,104,76),(106241,104,100),(106300,104,101),(106301,104,102),(106242,104,103),(106238,104,104),(106303,104,105),(106302,104,106),(106305,104,107),(106307,104,108),(106306,104,109),(106117,105,105),(106031,106,6),(106030,106,11),(106029,106,106),(106591,107,1),(106603,107,2),(106602,107,3),(106584,107,5),(106608,107,6),(106607,107,11),(106588,107,13),(106600,107,18),(106590,107,21),(106589,107,33),(106592,107,35),(106596,107,36),(106606,107,44),(106605,107,47),(106593,107,49),(106585,107,50),(106599,107,53),(106595,107,56),(106586,107,57),(106604,107,58),(106594,107,59),(106583,107,60),(106601,107,70),(106598,107,72),(106597,107,75),(106587,107,76),(106582,107,107),(106805,108,1),(106806,108,2),(106807,108,3),(106810,108,6),(106809,108,11),(106808,108,70),(106804,108,108),(106736,109,1),(106738,109,2),(106737,109,3),(106741,109,6),(106740,109,11),(106733,109,13),(106734,109,18),(106739,109,70),(106735,109,76),(106732,109,109); /*!40000 ALTER TABLE `roleRole` ENABLE KEYS */; UNLOCK TABLES; @@ -108,7 +108,7 @@ UNLOCK TABLES; LOCK TABLES `userPassword` WRITE; /*!40000 ALTER TABLE `userPassword` DISABLE KEYS */; -INSERT INTO `userPassword` VALUES (1,7,1,0,1,1); +INSERT INTO `userPassword` VALUES (1,7,1,0,2,1); /*!40000 ALTER TABLE `userPassword` ENABLE KEYS */; UNLOCK TABLES; @@ -140,18 +140,18 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-08-03 9:40:36 +-- Dump completed on 2022-09-16 7:03:07 USE `salix`; --- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64) +-- MySQL dump 10.19 Distrib 10.3.34-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: salix -- ------------------------------------------------------ --- Server version 5.6.25-4-log +-- Server version 10.7.4-MariaDB-1:10.7.4+maria~bullseye-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; +/*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; @@ -164,7 +164,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'),(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'),(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'),(277,'Role','*','*','ALLOW','ROLE','it'),(278,'RoleInherit','*','WRITE','ALLOW','ROLE','grant'),(279,'MailAlias','*','*','ALLOW','ROLE','marketing'),(282,'UserAccount','*','WRITE','ALLOW','ROLE','it'),(283,'EntryObservation','*','*','ALLOW','ROLE','buyer'),(284,'LdapConfig','*','*','ALLOW','ROLE','sysadmin'),(285,'SambaConfig','*','*','ALLOW','ROLE','sysadmin'),(286,'ACL','*','*','ALLOW','ROLE','developer'),(287,'AccessToken','*','*','ALLOW','ROLE','developer'),(288,'MailAliasAccount','*','*','ALLOW','ROLE','marketing'),(289,'MailAliasAccount','*','*','ALLOW','ROLE','hr'),(290,'MailAlias','*','*','ALLOW','ROLE','hr'),(291,'MailForward','*','*','ALLOW','ROLE','marketing'),(292,'MailForward','*','*','ALLOW','ROLE','hr'),(293,'RoleInherit','*','*','ALLOW','ROLE','it'),(294,'RoleRole','*','*','ALLOW','ROLE','it'),(295,'AccountConfig','*','*','ALLOW','ROLE','sysadmin'),(296,'Collection','*','READ','ALLOW','ROLE','employee'),(297,'Sale','refund','WRITE','ALLOW','ROLE','employee'),(298,'InvoiceInDueDay','*','*','ALLOW','ROLE','administrative'),(299,'Collection','setSaleQuantity','*','ALLOW','ROLE','employee'),(300,'Docuware','*','*','ALLOW','ROLE','employee'),(301,'Agency','*','READ','ALLOW','ROLE','employee'),(302,'AgencyTerm','*','*','ALLOW','ROLE','administrative'),(303,'ClaimLog','*','READ','ALLOW','ROLE','claimManager'),(304,'Edi','updateData','WRITE','ALLOW','ROLE','employee'),(305,'EducationLevel','*','*','ALLOW','ROLE','employee'),(306,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'),(307,'SupplierAgencyTerm','*','*','ALLOW','ROLE','administrative'),(308,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'),(309,'Zone','getZoneClosing','*','ALLOW','ROLE','employee'),(310,'ExpeditionState','*','READ','ALLOW','ROLE','employee'),(311,'Expense','*','READ','ALLOW','ROLE','employee'),(312,'Expense','*','WRITE','ALLOW','ROLE','administrative'),(313,'Sale','refundAll','WRITE','ALLOW','ROLE','employee'),(314,'SupplierActivity','*','READ','ALLOW','ROLE','employee'),(315,'SupplierActivity','*','WRITE','ALLOW','ROLE','administrative'),(316,'Dms','deleteTrashFiles','WRITE','ALLOW','ROLE','employee'),(317,'ClientUnpaid','*','*','ALLOW','ROLE','administrative'),(318,'MdbVersion','*','*','ALLOW','ROLE','developer'),(319,'ItemType','*','READ','ALLOW','ROLE','employee'),(320,'ItemType','*','WRITE','ALLOW','ROLE','buyer'); +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'),(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'),(277,'Role','*','*','ALLOW','ROLE','it'),(278,'RoleInherit','*','WRITE','ALLOW','ROLE','grant'),(279,'MailAlias','*','*','ALLOW','ROLE','marketing'),(282,'UserAccount','*','WRITE','ALLOW','ROLE','it'),(283,'EntryObservation','*','*','ALLOW','ROLE','buyer'),(284,'LdapConfig','*','*','ALLOW','ROLE','sysadmin'),(285,'SambaConfig','*','*','ALLOW','ROLE','sysadmin'),(286,'ACL','*','*','ALLOW','ROLE','developer'),(287,'AccessToken','*','*','ALLOW','ROLE','developer'),(288,'MailAliasAccount','*','*','ALLOW','ROLE','marketing'),(289,'MailAliasAccount','*','*','ALLOW','ROLE','hr'),(290,'MailAlias','*','*','ALLOW','ROLE','hr'),(291,'MailForward','*','*','ALLOW','ROLE','marketing'),(292,'MailForward','*','*','ALLOW','ROLE','hr'),(293,'RoleInherit','*','*','ALLOW','ROLE','it'),(294,'RoleRole','*','*','ALLOW','ROLE','it'),(295,'AccountConfig','*','*','ALLOW','ROLE','sysadmin'),(296,'Collection','*','READ','ALLOW','ROLE','employee'),(297,'Sale','refund','WRITE','ALLOW','ROLE','invoicing'),(298,'InvoiceInDueDay','*','*','ALLOW','ROLE','administrative'),(299,'Collection','setSaleQuantity','*','ALLOW','ROLE','employee'),(300,'Docuware','*','*','ALLOW','ROLE','employee'),(301,'Agency','*','READ','ALLOW','ROLE','employee'),(302,'AgencyTerm','*','*','ALLOW','ROLE','administrative'),(303,'ClaimLog','*','READ','ALLOW','ROLE','claimManager'),(304,'Edi','updateData','WRITE','ALLOW','ROLE','employee'),(305,'EducationLevel','*','*','ALLOW','ROLE','employee'),(306,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'),(307,'SupplierAgencyTerm','*','*','ALLOW','ROLE','administrative'),(308,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'),(309,'Zone','getZoneClosing','*','ALLOW','ROLE','employee'),(310,'ExpeditionState','*','READ','ALLOW','ROLE','employee'),(311,'Expense','*','READ','ALLOW','ROLE','employee'),(312,'Expense','*','WRITE','ALLOW','ROLE','administrative'),(314,'SupplierActivity','*','READ','ALLOW','ROLE','employee'),(315,'SupplierActivity','*','WRITE','ALLOW','ROLE','administrative'),(316,'Dms','deleteTrashFiles','WRITE','ALLOW','ROLE','employee'),(317,'ClientUnpaid','*','*','ALLOW','ROLE','administrative'),(318,'MdbVersion','*','*','ALLOW','ROLE','developer'),(319,'ItemType','*','READ','ALLOW','ROLE','employee'),(320,'ItemType','*','WRITE','ALLOW','ROLE','buyer'),(321,'InvoiceOut','refund','WRITE','ALLOW','ROLE','invoicing'),(322,'InvoiceOut','refund','WRITE','ALLOW','ROLE','salesAssistant'),(323,'InvoiceOut','refund','WRITE','ALLOW','ROLE','claimManager'),(324,'Ticket','refund','WRITE','ALLOW','ROLE','invoicing'),(325,'Ticket','refund','WRITE','ALLOW','ROLE','salesAssistant'),(326,'Ticket','refund','WRITE','ALLOW','ROLE','claimManager'),(327,'Sale','refund','WRITE','ALLOW','ROLE','salesAssistant'),(328,'Sale','refund','WRITE','ALLOW','ROLE','claimManager'),(329,'TicketRefund','*','WRITE','ALLOW','ROLE','invoicing'),(330,'ClaimObservation','*','WRITE','ALLOW','ROLE','salesPerson'),(331,'ClaimObservation','*','READ','ALLOW','ROLE','salesPerson'),(332,'Client','setPassword','WRITE','ALLOW','ROLE','salesPerson'),(333,'Client','updateUser','WRITE','ALLOW','ROLE','salesPerson'),(334,'ShelvingLog','*','READ','ALLOW','ROLE','employee'),(335,'ZoneExclusionGeo','*','READ','ALLOW','ROLE','employee'),(336,'ZoneExclusionGeo','*','WRITE','ALLOW','ROLE','deliveryBoss'),(337,'Parking','*','*','ALLOW','ROLE','employee'),(338,'Shelving','*','*','ALLOW','ROLE','employee'); /*!40000 ALTER TABLE `ACL` ENABLE KEYS */; UNLOCK TABLES; @@ -206,18 +206,18 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-08-03 9:40:36 +-- Dump completed on 2022-09-16 7:03:09 USE `vn`; --- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64) +-- MySQL dump 10.19 Distrib 10.3.34-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: vn -- ------------------------------------------------------ --- Server version 5.6.25-4-log +-- Server version 10.7.4-MariaDB-1:10.7.4+maria~bullseye-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; +/*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; @@ -250,7 +250,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'),('gardenCentre','Vivero'),('gardening','Jardinería'),('mortuary','Funeraria'),('officialOrganism','Organismo oficial'),('others','Otros'),('restoration','Restauración'),('wholesaler','Mayorista'); +INSERT INTO `businessType` VALUES ('decoration','Decoración'),('events','Eventos'),('florist','Floristería'),('gardenCentre','Vivero'),('gardening','Jardinería'),('individual','Particular'),('mortuary','Funeraria'),('officialOrganism','Organismo oficial'),('others','Otros'),('otherSector','Profesional de otro sector'),('restoration','Restauración'),('wholesaler','Mayorista'); /*!40000 ALTER TABLE `businessType` ENABLE KEYS */; UNLOCK TABLES; @@ -340,7 +340,7 @@ UNLOCK TABLES; LOCK TABLES `claimRedelivery` WRITE; /*!40000 ALTER TABLE `claimRedelivery` DISABLE KEYS */; -INSERT INTO `claimRedelivery` VALUES (1,'Cliente'),(2,'No dev./No especif.'),(3,'Reparto'),(4,'Agencia'),(5,'Tour'); +INSERT INTO `claimRedelivery` VALUES (1,'Cliente'),(2,'No dev./No especif.'),(3,'Reparto'),(4,'Agencia'),(5,'Tour'),(6,'Fuera Peninsula'); /*!40000 ALTER TABLE `claimRedelivery` ENABLE KEYS */; UNLOCK TABLES; @@ -360,7 +360,7 @@ UNLOCK TABLES; LOCK TABLES `component` WRITE; /*!40000 ALTER TABLE `component` DISABLE KEYS */; -INSERT INTO `component` VALUES (10,'Precios Especiales',4,NULL,NULL,1,'specialPrices',0),(14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay',0),(15,'reparto',6,NULL,NULL,1,'delivery',1),(17,'recobro',5,NULL,NULL,1,'debtCollection',0),(21,'ajuste',11,NULL,NULL,1,'adjustment',0),(22,'venta por paquete',9,1,NULL,0,'salePerPackage',0),(23,'venta por caja',9,2,NULL,0,'salePerBox',0),(28,'valor de compra',1,NULL,NULL,1,'purchaseValue',1),(29,'margen',4,NULL,NULL,1,'margin',1),(32,'descuento ultimas unidades',9,3,-0.05,0,'lastUnitsDiscount',0),(33,'venta por caja',9,1,NULL,0,'salePerBox',0),(34,'descuento comprador',4,NULL,NULL,1,'buyerDiscount',0),(35,'cartera comprador',10,NULL,NULL,1,NULL,0),(36,'descuadre',12,NULL,NULL,1,'imbalance',0),(37,'maná',7,4,NULL,0,'mana',0),(38,'embolsado',9,NULL,NULL,1,'bagged',0),(39,'maná auto',7,NULL,NULL,1,'autoMana',0),(40,'cambios Santos 2016',4,NULL,NULL,1,NULL,0),(41,'bonificacion porte',6,NULL,NULL,1,'freightCharge',0),(42,'promocion Francia',4,NULL,NULL,1,'frenchOffer',0),(43,'promocion Floramondo',4,NULL,NULL,1,'floramondoPromo',0),(44,'rappel cadena',2,NULL,NULL,1,'rappel',0),(45,'maná reclamacion',7,4,NULL,0,'manaClaim',0); +INSERT INTO `component` VALUES (10,'Precios Especiales',4,NULL,NULL,1,'specialPrices',0),(14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay',0),(15,'reparto',6,NULL,NULL,1,'delivery',1),(17,'recobro',5,NULL,NULL,1,'debtCollection',0),(21,'ajuste',11,NULL,NULL,1,'adjustment',0),(22,'venta por paquete',9,1,NULL,0,'salePerPackage',0),(23,'venta por caja',9,2,NULL,0,'salePerBox',0),(28,'valor de compra',1,NULL,NULL,1,'purchaseValue',1),(29,'margen',4,NULL,NULL,1,'margin',1),(32,'descuento ultimas unidades',9,3,-0.05,0,'lastUnitsDiscount',0),(33,'venta por caja',9,1,NULL,0,'salePerBox',0),(34,'descuento comprador',4,NULL,NULL,1,'buyerDiscount',0),(35,'cartera comprador',10,NULL,NULL,1,NULL,0),(36,'descuadre',12,NULL,NULL,1,'imbalance',0),(37,'maná',7,4,NULL,0,'mana',0),(38,'embolsado',9,NULL,NULL,1,'bagged',0),(39,'maná auto',7,NULL,NULL,1,'autoMana',0),(40,'cambios Santos 2016',4,NULL,NULL,1,NULL,0),(41,'bonificacion porte',6,NULL,NULL,1,'freightCharge',0),(42,'promocion Francia',4,NULL,NULL,1,'frenchOffer',0),(43,'promocion Floramondo',4,NULL,NULL,1,'floramondoPromo',0),(44,'rappel cadena',2,NULL,NULL,1,'rappel',0),(45,'maná reclamacion',7,4,NULL,0,'manaClaim',0),(46,'recargo a particular',2,NULL,0.25,0,'individual',0); /*!40000 ALTER TABLE `component` ENABLE KEYS */; UNLOCK TABLES; @@ -420,7 +420,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,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); +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),(20,'incoterms-authorization','Autorización de incoterms',1,1,1,0); /*!40000 ALTER TABLE `sample` ENABLE KEYS */; UNLOCK TABLES; @@ -430,7 +430,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,'alert'),(2,'Libre',2,0,'FREE',NULL,2,1,0,0,0,1,0,4,1,'notice'),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0,'success'),(4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0,'success'),(5,'Preparación',6,1,'ON_PREPARATION',7,5,0,0,0,2,0,0,2,0,'warning'),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0,'warning'),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1,'alert'),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0,'warning'),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0,NULL),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0,NULL),(11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0,NULL),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1,'alert'),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0,NULL),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0,'warning'),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0,NULL),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL),(20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0,'success'),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0,'success'),(22,'Pte. Ampliar',2,0,'EXPANDABLE',NULL,22,0,0,0,0,0,0,4,1,'alert'),(23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1,'success'),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1,'success'),(25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0,'alert'),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,28,0,0,0,1,0,0,2,0,'warning'),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0,'success'),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,1,0,0,1,1,1,3,0,'warning'),(29,'Previa Impreso',4,0,'PRINTED PREVIOUS',2,29,1,0,1,0,0,1,2,0,'success'),(30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0,'success'),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,2,0,'success'),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0,'warning'),(33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0,'success'),(34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1,'alert'),(35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0,NULL),(36,'Previa Revisando',3,1,'PREVIOUS_CONTROL',1,29,0,1,0,4,0,1,3,0,'warning'),(37,'Previa Revisado',3,1,'PREVIOUS_CONTROLLED',1,29,0,1,0,4,0,1,3,0,'warning'); +INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1,'alert'),(2,'Libre',2,0,'FREE',NULL,2,1,0,0,0,1,0,4,1,'notice'),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0,'success'),(4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0,'success'),(5,'Preparación',6,1,'ON_PREPARATION',7,5,0,0,0,2,0,0,2,0,'warning'),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0,'warning'),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1,'alert'),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0,'warning'),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0,NULL),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0,NULL),(11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0,NULL),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1,'alert'),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0,NULL),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0,'warning'),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0,NULL),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL),(20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0,'success'),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0,'success'),(22,'Pte. Ampliar',2,0,'EXPANDABLE',NULL,22,0,0,0,0,0,0,4,1,'alert'),(23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1,'success'),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1,'success'),(25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0,'alert'),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,28,0,0,0,1,0,0,2,0,'warning'),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0,'success'),(28,'Previa OK',3,0,'OK PREVIOUS',3,28,1,0,0,1,1,1,3,0,'warning'),(29,'Previa Impreso',4,0,'PRINTED PREVIOUS',2,29,1,0,1,0,0,1,2,0,'success'),(30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0,'success'),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,2,0,'success'),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0,'warning'),(33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0,'success'),(34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1,'alert'),(35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0,NULL),(36,'Previa Revisando',3,0,'PREVIOUS_CONTROL',2,37,1,0,0,4,0,1,2,0,'warning'),(37,'Previa Revisado',3,0,'PREVIOUS_CONTROLLED',2,29,1,0,1,0,0,1,2,0,'warning'); /*!40000 ALTER TABLE `state` ENABLE KEYS */; UNLOCK TABLES; @@ -460,7 +460,7 @@ UNLOCK TABLES; LOCK TABLES `volumeConfig` WRITE; /*!40000 ALTER TABLE `volumeConfig` DISABLE KEYS */; -INSERT INTO `volumeConfig` VALUES (2.67,1.60,0.8,150,0.30,120,57,2.0,150,200,50); +INSERT INTO `volumeConfig` VALUES (2.67,1.60,0.8,150,0.30,120,57,2.0,5,200,5,167.0); /*!40000 ALTER TABLE `volumeConfig` ENABLE KEYS */; UNLOCK TABLES; @@ -482,18 +482,18 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-08-03 9:40:36 +-- Dump completed on 2022-09-16 7:03:16 USE `cache`; --- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64) +-- MySQL dump 10.19 Distrib 10.3.34-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: cache -- ------------------------------------------------------ --- Server version 5.6.25-4-log +-- Server version 10.7.4-MariaDB-1:10.7.4+maria~bullseye-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; +/*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; @@ -518,18 +518,18 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-08-03 9:40:36 +-- Dump completed on 2022-09-16 7:03:17 USE `hedera`; --- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64) +-- MySQL dump 10.19 Distrib 10.3.34-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: hedera -- ------------------------------------------------------ --- Server version 5.6.25-4-log +-- Server version 10.7.4-MariaDB-1:10.7.4+maria~bullseye-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; +/*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; @@ -592,7 +592,7 @@ UNLOCK TABLES; LOCK TABLES `location` WRITE; /*!40000 ALTER TABLE `location` DISABLE KEYS */; -INSERT INTO `location` VALUES (2,'39.2095886','-0.4173501','Valencia','Calle Fenollar, 2','46680','Algemesi','Valencia','963 242 100','es'),(3,'40.4564969','-3.4875829','Madrid','Avenida de la Constitución, 3 - Nave E','28850','Torrejón de Ardoz','Madrid','916 774 777',NULL),(4,'41.4962045','2.3765504','Barcelona','Camí del crist, 33','08340','Vilassar de Mar','Barcelona','607 562 391','ca'),(5,'52.2612312','4.7818154','Holland','Aalsmeer Flower Auction','1430 BA','Legmeerdijk 313','Aalsmeer','Nederland','nl'),(6,'43.4375416','5.2261456','Marseille','ruben@verdnatura.es','13054','Marigname','Marseille','+33 781 533 900','fr'); +INSERT INTO `location` VALUES (2,'39.2095886','-0.4173501','Valencia','Calle Fenollar, 2','46680','Algemesi','Valencia','963 242 100','es'),(3,'40.4564969','-3.4875829','Madrid','Avenida de la Constitución, 3 - Nave E','28850','Torrejón de Ardoz','Madrid','963 242 100',NULL),(4,'41.4962045','2.3765504','Barcelona','Camí del crist, 33','08340','Vilassar de Mar','Barcelona','607 562 391','ca'),(5,'52.2612312','4.7818154','Holland','Aalsmeer Flower Auction','1430 BA','Legmeerdijk 313','Aalsmeer','Nederland','nl'),(6,'43.4375416','5.2261456','Marseille','ruben@verdnatura.es','13054','Marigname','Marseille','+33 781 533 900','fr'); /*!40000 ALTER TABLE `location` ENABLE KEYS */; UNLOCK TABLES; @@ -684,18 +684,18 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-08-03 9:40:36 +-- Dump completed on 2022-09-16 7:03:22 USE `postgresql`; --- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64) +-- MySQL dump 10.19 Distrib 10.3.34-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: postgresql -- ------------------------------------------------------ --- Server version 5.6.25-4-log +-- Server version 10.7.4-MariaDB-1:10.7.4+maria~bullseye-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; +/*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; @@ -760,18 +760,18 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-08-03 9:40:37 +-- Dump completed on 2022-09-16 7:03:24 USE `sage`; --- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64) +-- MySQL dump 10.19 Distrib 10.3.34-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: sage -- ------------------------------------------------------ --- Server version 5.6.25-4-log +-- Server version 10.7.4-MariaDB-1:10.7.4+maria~bullseye-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; +/*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; @@ -816,4 +816,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-08-03 9:40:37 +-- Dump completed on 2022-09-16 7:03:25 diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 5e4e43924..73a6ef687 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1,7 +1,7 @@ CREATE SCHEMA IF NOT EXISTS `vn2008`; CREATE SCHEMA IF NOT EXISTS `tmp`; -UPDATE `util`.`config` +UPDATE `util`.`config` SET `environment`= 'test'; ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1; @@ -9,8 +9,8 @@ ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1; -INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) - VALUES +INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) + VALUES ('DEFAULT_TOKEN', '1209600', util.VN_CURDATE(), 66); INSERT INTO `salix`.`printConfig` (`id`, `itRecipient`, `incidencesEmail`) @@ -26,11 +26,11 @@ INSERT INTO `vn`.`bionicConfig` (`generalInflationCoeficient`, `minimumDensityVo (1.30, 167.00, 138000, 71); INSERT INTO `vn`.`chatConfig` (`host`, `api`) - VALUES + VALUES ('https://chat.verdnatura.es', 'https://chat.verdnatura.es/api/v1'); -INSERT IGNORE INTO `vn`.`greugeConfig`(`id`, `freightPickUpPrice`) - VALUES +INSERT IGNORE INTO `vn`.`greugeConfig`(`id`, `freightPickUpPrice`) + VALUES ('1', '11'); INSERT INTO `vn`.`packagingConfig`(`upperGap`) @@ -56,11 +56,11 @@ INSERT INTO `account`.`account`(`id`) INSERT INTO `vn`.`educationLevel` (`id`, `name`) VALUES (1, 'ESTUDIOS PRIMARIOS COMPLETOS'), - (2, 'ENSEÑANZAS DE BACHILLERATO'); + (2, 'ENSEÑANZAS DE BACHILLERATO'); INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`) SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9 - FROM `vn`.`user`; + FROM `vn`.`user`; UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20; UPDATE `vn`.`worker` SET bossFk = 20 WHERE id = 1 OR id = 9; @@ -73,7 +73,7 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType` (1, 978, 1, 0, 2000, 9, 0); INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`, `image`) - VALUES + VALUES (1101, 'BruceWayne', 'Bruce Wayne', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'), (1102, 'PetterParker', 'Petter Parker', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), (1103, 'ClarkKent', 'Clark Kent', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'ClarkKent@mydomain.com', 'fr', 'e7723f0b24ff05b32ed09d95196f2f29'), @@ -117,7 +117,7 @@ INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossF (1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107, NULL, 1), (1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108, 1, NULL), (1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109, 1, 2), - (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110, 2, 1); + (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110, 2, 1); INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`) VALUES @@ -127,7 +127,7 @@ INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`) (4, 'JPY', 'Yen Japones', 1); INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`, `politicalCountryFk`) - VALUES + VALUES (1, 'España', 1, 'ES', 1, 24, 4, 0, 1, 1), (2, 'Italia', 1, 'IT', 1, 27, 4, 0, 1, 2), (3, 'Alemania', 1, 'DE', 1, 22, 4, 0, 1, 3), @@ -155,12 +155,12 @@ INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`) - VALUES + VALUES (1, 'First sector', 1, 1, 'FIRST'), (2, 'Second sector', 2, 0, 'SECOND'); -INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`) - VALUES +INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`) + VALUES ('1', 700, '01', 1, '700-01', 70001), ('2', 700, '02', 2, '700-02', 70002), ('3', 100, '01', 1, '100-01', 1), @@ -169,8 +169,8 @@ INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingO (34965, 200, '02', 2, 'L-08-4', 21800), (39096, 200, '03', 2, 'LR-02-3', 99999); -INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `userFk`, `isRecyclable`) - VALUES +INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `userFk`, `isRecyclable`) + VALUES ('AA6', 34965, 1, 0, NULL, 0), ('AA7', 34965, 1, 0, NULL, 0), ('AA8', 34965, 1, 0, NULL, 0), @@ -186,7 +186,7 @@ INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `user ('UXN', 1, 0, 1, 1106, 1); INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`, `daysInFuture`) - VALUES + VALUES (1, 'CC and credit policies', 'Transfers', 'wireTransfer', NULL, 1), (2, 'Cash', 'Cash', 'cash', 1000, 0), (3, 'Credit card', 'Credit Card', 'creditCard', NULL, 0), @@ -201,8 +201,8 @@ INSERT INTO `vn`.`bankEntity`(`id`, `countryFk`, `name`, `bic`) (128, 1, 'The Best Bank', 'BBKKESMMMMMM'), (2100, 1, 'Caixa Bank', 'CAIXESBB'); -INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`) - VALUES +INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`) + VALUES (1, 'Pay on receipt', '5720000001', 3, 128, 1, 1), (2, 'Cash', '5700000001', 2, 128, 1, 1), (3, 'Compensation', '4000000000', 8, 128, 1, 1), @@ -256,7 +256,7 @@ UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com' UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23; INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `isIbanRequiredForClients`, `isIbanRequiredForSuppliers`, `hasVerified`) - VALUES + VALUES (1, NULL, 'PayMethod one', 0, 001, 0, 0, 0), (2, NULL, 'PayMethod two', 10, 001, 0, 0, 1), (3, 'compensation', 'PayMethod three', 0, 001, 0, 0, 0), @@ -265,7 +265,7 @@ INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt (8,'wireTransfer', 'WireTransfer', 5, 001, 1, 1, 0); INSERT INTO `vn`.`payDem`(`id`, `payDem`) - VALUES + VALUES (1, 10), (2, 20); @@ -294,7 +294,7 @@ INSERT INTO `vn`.`town`(`id`, `name`, `provinceFk`) (5, 'Quito', 5); INSERT INTO `vn`.`postCode`(`code`, `townFk`, `geoFk`) - VALUES + VALUES ('46000', 1, 6), ('46460', 2, 6), ('46680', 3, 6), @@ -535,7 +535,7 @@ INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, (442 , 'VNL', 241, 30, 2 , 1, NULL, 2, 'VNL Company - Plant passport'), (567 , 'VNH', NULL, 30, NULL, 4, NULL, 1, 'VNH Company - Plant passport'), (791 , 'FTH', NULL, 30, NULL, 3, '2015-11-30', 1, NULL), - (1381, 'ORN', NULL, 30, NULL, 7, NULL, 1, 'ORN Company - Plant passport'); + (1381, 'ORN', NULL, 30, NULL, 7, NULL, 1, 'ORN Company - Plant passport'); INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`) VALUES @@ -556,7 +556,7 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`) VALUES (1, 'T', 1014.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), - (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), + (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), (3, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), (4, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), (5, 'A', 8.88, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 0); @@ -568,7 +568,7 @@ UPDATE `vn`.`invoiceOut` SET ref = 'T4444444' WHERE id = 4; UPDATE `vn`.`invoiceOut` SET ref = 'A1111111' WHERE id = 5; INSERT INTO `vn`.`invoiceOutTax` (`invoiceOutFk`, `taxableBase`, `vat`, `pgcFk`) - VALUES + VALUES (1, 895.76, 89.58, 4722000010), (1, 33.80, 7.10, 4722000021), (2, 110.33, 11.03, 4770000010), @@ -587,7 +587,7 @@ INSERT INTO `vn`.`expence`(`id`, `name`, `isWithheld`) (7001000000, 'Mercaderia', 0), (7050000000, 'Prestacion de servicios', 1); - + INSERT INTO `vn`.`invoiceOutExpence`(`id`, `invoiceOutFk`, `amount`, `expenceFk`, `created`) VALUES (1, 1, 813.06, 2000000000, util.VN_CURDATE()), @@ -599,7 +599,7 @@ INSERT INTO `vn`.`invoiceOutExpence`(`id`, `invoiceOutFk`, `amount`, `expenceFk` (7, 5, 8.07, 2000000000, util.VN_CURDATE()); INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, `price`, `bonus`, `itemMaxSize`) - VALUES + VALUES (1, 'Zone pickup A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), (2, 'Zone pickup B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), (3, 'Zone 247 A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100), @@ -615,7 +615,7 @@ INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, (13, 'Zone quantum break', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 5, 0, 0, 0, 100); INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`) - VALUES + VALUES (1, 1, 1), (2, 2, 2), (3, 3, 1), @@ -631,7 +631,7 @@ INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`) (13, 13, 5); INSERT INTO `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`) - VALUES + VALUES (1, util.VN_CURDATE(), '23:59'), (2, util.VN_CURDATE(), '23:59'), (3, util.VN_CURDATE(), '23:59'), @@ -703,7 +703,7 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des (11, 24, 4, 'Reclama ticket: 7'), (12, 11, 3, 'Delivery after 10am'); --- FIX for state hours on local, inter_afterInsert +-- FIX for state hours on local, inter_afterInsert UPDATE vncontrol.inter SET odbc_date = DATE_ADD(util.VN_CURDATE(), INTERVAL -10 SECOND); INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`) @@ -799,7 +799,7 @@ INSERT INTO `vn`.`itemCategory`(`id`, `name`, `display`, `color`, `icon`, `code` INSERT INTO `vn`.`temperature`(`code`, `name`, `description`) VALUES ('warm', 'Warm', 'Warm'), - ('cool', 'Cool', 'Cool'); + ('cool', 'Cool', 'Cool'); INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `life`, `workerFk`, `isPackaging`, `temperatureFk`) VALUES @@ -853,7 +853,7 @@ INSERT INTO `vn`.`taxClassCode`(`taxClassFk`, `effectived`, `taxCodeFk`) (1, util.VN_CURDATE(), 1), (1, util.VN_CURDATE(), 21), (2, util.VN_CURDATE(), 2); - + INSERT INTO `vn`.`intrastat`(`id`, `description`, `taxClassFk`, `taxCodeFk`) VALUES (05080000, 'Coral y materiales similares', 2, 2), @@ -865,26 +865,26 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`) ('SER', 'Services'), ('VT', 'Sales'); -INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`, - `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`) +INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`, + `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`, `weightByPiece`) VALUES - (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0, 15), - (2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0, 10), - (3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, 5), - (4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL), - (5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL), - (6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL), - (7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL), - (8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, NULL), - (9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL), - (10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL), - (11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL), - (12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL), - (13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 2, 'VT', 1, NULL, NULL, 1, NULL), - (14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL), - (15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL), - (16, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL), - (71, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT', 0, NULL, NULL, 0, NULL); + (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0, 15,3), + (2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0, 10,2), + (3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, 5,5), + (4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL), + (5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL), + (6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL), + (7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL), + (8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, NULL,NULL), + (9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL,NULL), + (10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL), + (11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL), + (12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL), + (13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 2, 'VT', 1, NULL, NULL, 1, NULL,NULL), + (14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL,NULL), + (15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL), + (16, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL), + (71, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL); -- Update the taxClass after insert of the items UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2 @@ -1004,7 +1004,7 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (3, 39, 0.994), (4, 28, 1.25), (4, 29, 0.42), - (4, 39, 0.017), + (4, 39, 0.017), (5, 17, 9.94), (5, 28, 50), (5, 29, 49.4), @@ -1026,8 +1026,8 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (9, 15, 3.0949), (9, 21, 0.001), (9, 28, 53), - (9, 29, 46.4), - (9, 39, 0.994), + (9, 29, 46.4), + (9, 39, 0.994), (10, 15, 0.0199), (10, 28, 7), (10, 29, 0), @@ -1126,14 +1126,14 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (32, 36, -92.324), (32, 39, 0.994); -INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `shelve`, `visible`, `grouping`, `packing`, `userFk`) - VALUES +INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `shelve`, `visible`, `grouping`, `packing`, `userFk`) + VALUES (2, 'GVC', 'A', 1, 1, 1, 1106), (4, 'HEJ', 'A', 1, 1, 1, 1106), (1, 'UXN', 'A', 2, 12, 12, 1106); -INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`) - VALUES +INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`) + VALUES ('1', '1', '1', '', '1106'), ('2', '2', '5', '', '1106'), ('1', '7', '1', '', '1106'), @@ -1326,7 +1326,7 @@ INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`) CALL `vn`.`itemRefreshTags`(NULL); INSERT INTO `vn`.`itemLog` (`id`, `originFk`, `userFk`, `action`, `description`) - VALUES + VALUES ('1', '1', '1', 'insert', 'We made a change!'); INSERT INTO `vn`.`recovery`(`id`, `clientFk`, `started`, `finished`, `amount`, `period`) @@ -1502,8 +1502,8 @@ INSERT INTO `hedera`.`orderRowComponent`(`rowFk`, `componentFk`, `price`) (4, 21, -0.001), (4, 28, 20.72), (4, 29, -19.72), - (4, 37, 2), - (4, 39, 0.01), + (4, 37, 2), + (4, 39, 0.01), (5, 15, 0.58), (5, 23, 6.5), (5, 28, 20.72), @@ -1722,7 +1722,7 @@ INSERT INTO `vn`.`workerManaExcluded`(`workerFk`) La otra manera es poner el calculo con los 2 trabajadores que utilizamos ahora mismo para los tickets */ -call vn.manaSpellersRequery(19); +call vn.manaSpellersRequery(19); call vn.manaSpellersRequery(18); INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk`, `userFk`, `companyFk`) @@ -1795,8 +1795,8 @@ INSERT INTO `hedera`.`tpvMerchant`(`id`, `description`, `companyFk`, `bankFk`, ` (1, 'Arkham Bank', 442, 1, 'h12387193H10238'), (2, 'NewYork Bank', 442, 1, '7981ugsgd1hsdad'); -INSERT INTO `hedera`.`tpvTransaction`(`id`,`merchantFk`, `clientFk`,`receiptFk`, `amount`, `response`, `errorCode`, `status`, `created`) - VALUES +INSERT INTO `hedera`.`tpvTransaction`(`id`,`merchantFk`, `clientFk`,`receiptFk`, `amount`, `response`, `errorCode`, `status`, `created`) + VALUES (1, 1, 1101, NULL, 2000, NULL, 'SIS0042', 'ok', util.VN_CURDATE()), (2, 1, 1101, NULL, 1000, NULL, 'SIS0051', 'started', util.VN_CURDATE()), (3, 2, 1101, NULL, 7268, NULL, NULL, 'ok', util.VN_CURDATE()), @@ -1810,32 +1810,32 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`) (2, 2), (3, 3), (4, 4), - (5, 5), - (6, 6), - (7, 7), - (8, 8), - (9, 9), - (10, 10), - (11, 11), - (12, 12), - (13, 13), - (14, 14), + (5, 5), + (6, 6), + (7, 7), + (8, 8), + (9, 9), + (10, 10), + (11, 11), + (12, 12), + (13, 13), + (14, 14), (15, 15), (16, 16), (17, 17), (18, 18), (19, 19), - (20, 20), - (21, 21), + (20, 20), + (21, 21), (22, 22); -INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`) +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`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate`) VALUES (1, 'Cobro web', 100.50, util.VN_CURDATE(), 9, 1, 1101, util.VN_CURDATE(), 442, 1), @@ -1884,59 +1884,47 @@ INSERT INTO `pbx`.`sip`(`user_id`, `extension`) (5, 1102), (9, 1201); -INSERT INTO `postgresql`.`profile`(`profile_id`, `workerFk`, `profile_type_id`) - SELECT w.id, w.id, 1 - FROM `vn`.`worker` `w`; +DROP TEMPORARY TABLE IF EXISTS tmp.worker; +CREATE TEMPORARY TABLE tmp.worker + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT w.id, w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL +1 YEAR)), '-12-25'), CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk` + FROM `vn`.`worker` `w`; -INSERT INTO `postgresql`.`business`(`business_id`, `client_id`, `companyCodeFk`, `date_start`, `date_end`, `workerBusiness`, `reasonEndFk`) - SELECT p.profile_id, p.profile_id, 'VNL', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL +1 YEAR)), '-01-25'), CONCAT('E-46-',RPAD(CONCAT(p.profile_id,9),8,p.profile_id)), NULL - FROM `postgresql`.`profile` `p`; +INSERT INTO `vn`.`business`(`id`, `workerFk`, `companyCodeFk`, `started`, `ended`, `workerBusiness`, `reasonEndFk`, `notes`, `departmentFk`, `workerBusinessProfessionalCategoryFk`, `calendarTypeFk`, `isHourlyLabor`, `workerBusinessAgreementFk`, `workcenterFk`) + SELECT * FROM tmp.worker; -INSERT INTO `postgresql`.`business_labour`(`business_id`, `notes`, `department_id`, `professional_category_id`, `incentivo`, `calendar_labour_type_id`, `porhoras`, `labour_agreement_id`, `workcenter_id`) - SELECT b.business_id, NULL, 23, 1, 0, 1, 1, 1, 1 - FROM `postgresql`.`business` `b`; +DROP TEMPORARY TABLE IF EXISTS tmp.worker; +CREATE TEMPORARY TABLE tmp.worker + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT '1111' as 'id', w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-24'), CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk` + FROM `vn`.`worker` `w` + WHERE `w`.`id` = 1109; -INSERT INTO `postgresql`.`business` (`client_id`, `companyCodeFk`, `date_start`, `date_end`, `workerBusiness`, `reasonEndFk`) - SELECT p.profile_id, 'VNL', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-24'), CONCAT('E-46-',RPAD(CONCAT(p.profile_id,9),8,p.profile_id)), NULL - FROM `postgresql`.`profile` `p` - WHERE `p`.`profile_id` = 1109; +INSERT INTO `vn`.`business` (`id`, `workerFk`, `companyCodeFk`, `started`, `ended`, `workerBusiness`, `reasonEndFk`, `notes`, `departmentFk`, `workerBusinessProfessionalCategoryFk`, `calendarTypeFk`, `isHourlyLabor`, `workerBusinessAgreementFk`, `workcenterFk`) + SELECT * FROM tmp.worker; -UPDATE `postgresql`.`business` +DROP TEMPORARY TABLE IF EXISTS tmp.worker; + +UPDATE `vn`.`business` SET `payedHolidays`= 8 - WHERE `business_id`= 1106; + WHERE `id`= 1106; -INSERT INTO `postgresql`.`business_labour` (`business_id`, `notes`, `department_id`, `professional_category_id`, `incentivo`, `calendar_labour_type_id`, `porhoras`, `labour_agreement_id`, `workcenter_id`) - VALUES - (1111, NULL, 23, 1, 0.0, 1, 1, 1, 1); - -UPDATE `postgresql`.`business_labour` bl - JOIN `postgresql`.`business` b ON b.business_id = bl.business_id - JOIN `postgresql`.`profile` pr ON pr.profile_id = b.client_id - SET bl.`professional_category_id` = 31 - WHERE pr.`workerFk` = 1110; - -UPDATE `postgresql`.`business_labour` bl - SET bl.`department_id` = 43 -WHERE business_id IN(18, 19); +UPDATE `vn`.`business` b + SET b.`workerBusinessProfessionalCategoryFk` = 31 + WHERE b.`workerFk` = 1110; -INSERT INTO `postgresql`.`media`(`media_id`, `media_type_id`, `value`, `sort`) - VALUES - (1, 10, 600123321, 0), - (2, 10, 700987987, 0); - -INSERT INTO `postgresql`.`profile_media`(`profile_media_id`, `profile_id`, `media_id`) - VALUES - (1, 1106, 1), - (2, 1107, 2); +UPDATE `vn`.`business` b + SET b.`departmentFk` = 43 + WHERE b.id IN(18, 19); INSERT INTO `vn`.`workCenterHoliday` (`workCenterFk`, `days`, `year`) - VALUES - ('1', '27.5', YEAR(util.VN_CURDATE())), - ('5', '22', YEAR(util.VN_CURDATE())), - ('1', '24.5', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))), - ('5', '23', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))); - -ALTER TABLE `postgresql`.`business_labour_payroll` DROP FOREIGN KEY `business_labour_payroll_cod_categoria`; + VALUES + ('1', '27.5', YEAR(util.VN_CURDATE())), + ('5', '22', YEAR(util.VN_CURDATE())), + ('1', '24.5', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))), + ('5', '23', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))); INSERT INTO `vn`.`workerBusinessType` (`id`, `name`, `isFullTime`, `isPermanent`, `hasHolidayEntitlement`) VALUES @@ -1944,24 +1932,45 @@ INSERT INTO `vn`.`workerBusinessType` (`id`, `name`, `isFullTime`, `isPermanent` (100, 'INDEFINIDO A TIEMPO COMPLETO', 1, 1, 1), (109, 'CONVERSION DE TEMPORAL EN INDEFINIDO T.COMPLETO', 1, 1, 1); -INSERT INTO `postgresql`.`business_labour_payroll` (`business_id`, `cod_tarifa`, `cod_categoria`, `cod_contrato`, `importepactado`) - VALUES - (1, 7, 12, 100, 900.50), - (1106, 7, 12, 100, 1263.03), - (1107, 7, 12, 100, 2000), - (1108, 7, 12, 100, 1500); +UPDATE `vn`.`business` b + SET `rate` = 7, + `workerBusinessCategoryFk` = 12, + `workerBusinessTypeFk` = 100, + `amount` = 900.50 + WHERE b.id = 1; + +UPDATE `vn`.`business` b + SET `rate` = 7, + `workerBusinessCategoryFk` = 12, + `workerBusinessTypeFk` = 100, + `amount` = 1263.03 + WHERE b.id = 1106; + +UPDATE `vn`.`business` b + SET `rate` = 7, + `workerBusinessCategoryFk` = 12, + `workerBusinessTypeFk` = 100, + `amount` = 2000 + WHERE b.id = 1107; + +UPDATE `vn`.`business` b + SET `rate` = 7, + `workerBusinessCategoryFk` = 12, + `workerBusinessTypeFk` = 100, + `amount` = 1500 + WHERE b.id = 1108; INSERT INTO `vn`.`absenceType` (`id`, `name`, `rgb`, `code`, `holidayEntitlementRate`, `discountRate`) VALUES (1, 'Holidays', '#FF4444', 'holiday', 0, 0), (2, 'Leave of absence', '#C71585', 'absence', 0, 1), (6, 'Half holiday', '#E65F00', 'halfHoliday', 0, 0.5), - (15, 'Half Paid Leave', '#5151c0', 'halfPaidLeave', 0, 1), + (15, 'Half Paid Leave', '#5151c0', 'halfPaidLeave', 0, 1), (20, 'Furlough', '#97B92F', 'furlough', 1, 1), (21, 'Furlough half day', '#778899', 'halfFurlough', 0.5, 1); -INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`, `date`) - VALUES +INSERT INTO `postgresql`.`calendar_employee` (`businessFk`, `calendar_state_id`, `date`) + VALUES (1, 6, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))), (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))), (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -11 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 11 DAY))), @@ -1979,8 +1988,8 @@ INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id` (1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 7 DAY))), (1107, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL - 16 DAY)); -INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`) - VALUES +INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`) + VALUES ('1', 'https://api.gateway360.com/api/3.0/sms/send', 'Verdnatura', '5715476da95b46d686a5a255e6459523'); INSERT INTO `vn`.`sharingClient`(`id`, `workerFk`, `started`, `ended`, `clientFk`) @@ -1996,37 +2005,37 @@ CALL `vn`.zoneGeo_calcTree(); -- this is an auto calculate for table vn.zoneGeo, INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`) VALUES - (1, 3, 0), - (1, 4, 0), - (1, 5, 0), + (1, 3, 0), + (1, 4, 0), + (1, 5, 0), (1, 1, 1), - (2, 3, 0), - (2, 4, 0), - (2, 5, 0), + (2, 3, 0), + (2, 4, 0), + (2, 5, 0), (2, 1, 1), - (3, 3, 0), - (3, 4, 0), - (3, 5, 0), + (3, 3, 0), + (3, 4, 0), + (3, 5, 0), (3, 1, 1), - (4, 3, 0), - (4, 4, 0), - (4, 5, 0), + (4, 3, 0), + (4, 4, 0), + (4, 5, 0), (4, 1, 1), - (5, 3, 1), - (5, 4, 0), - (5, 5, 1), + (5, 3, 1), + (5, 4, 0), + (5, 5, 1), (5, 1, 1), - (6, 3, 1), - (6, 4, 0), - (6, 5, 1), + (6, 3, 1), + (6, 4, 0), + (6, 5, 1), (6, 1, 1), - (7, 3, 0), - (7, 4, 0), - (7, 5, 0), + (7, 3, 0), + (7, 4, 0), + (7, 5, 0), (7, 1, 1), - (8, 3, 0), - (8, 4, 0), - (8, 5, 0), + (8, 3, 0), + (8, 4, 0), + (8, 5, 0), (8, 1, 1), (10, 14, 1); @@ -2239,12 +2248,12 @@ INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `dated`) (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)); INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `weekDays`) - VALUES + VALUES (8, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun'), (10, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun'); INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `started`, `ended`) - VALUES + VALUES (9, 'range', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR)); INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`) @@ -2307,8 +2316,8 @@ INSERT INTO `vn`.`workerDocument`(`id`, `worker`, `document`,`isReadableByWorker (1, 1106, 4, TRUE), (2, 1107, 3, FALSE); -INSERT INTO `vn`.`device` (`sn`, `model`, `userFk`) - VALUES +INSERT INTO `vn`.`device` (`sn`, `model`, `userFk`) + VALUES ('aaa', 'android', '9'); INSERT INTO `vn`.`queuePriority`(`id`, `priority`) @@ -2322,7 +2331,7 @@ INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `week (1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000); INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11'); - + INSERT INTO `vn`.`thermograph`(`id`, `model`) VALUES ('TMM190901395', 'TEMPMATE'), @@ -2340,21 +2349,21 @@ INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, ('138350-0', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', NULL, 5), ('138350-0', util.VN_CURDATE(), 1, NULL, 'COOL', NULL, NULL); -REPLACE INTO `vn`.`incoterms`(`code`, `name`) - VALUES +REPLACE INTO `vn`.`incoterms`(`code`, `name`) + VALUES ('FAS', 'Free Alongside Ship'); -REPLACE INTO `vn`.`customsAgent`(`id`, `fiscalName`, `street`, `nif`, `phone`, `email`) - VALUES +REPLACE INTO `vn`.`customsAgent`(`id`, `fiscalName`, `street`, `nif`, `phone`, `email`) + VALUES (1, 'Agent one', '1007 Mountain Drive, Gotham', 'N1111111111', '111111111', 'agentone@gotham.com'), (2, 'Agent two', '1007 Mountain Drive, Gotham', 'N2222222222', '222222222', 'agenttwo@gotham.com'); -INSERT INTO `vn`.`tablet`(`uuid`, `name`, `place`, `macwifi`) - VALUES +INSERT INTO `vn`.`tablet`(`uuid`, `name`, `place`, `macwifi`) + VALUES ('1', 'TEST', 'ON THE FIXTURES', '0'), ('2', 'DEV', 'OTHER TABLET', '0'); -INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`) +INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`) VALUES (1, 23), (2, 1); @@ -2387,8 +2396,8 @@ INSERT INTO `vn`.`rate`(`dated`, `warehouseFk`, `rate0`, `rate1`, `rate2`, `rate (DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), 1, 10, 15, 20, 25), (util.VN_CURDATE(), 1, 12, 17, 22, 27); -INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk) - VALUES +INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk) + VALUES (1, '07546501420', 67, 671, util.VN_CURDATE(), 1761, 1, 1), (2, '07546491421', 252, 2769, util.VN_CURDATE(), 5231, 1, 1), (3, '07546500823', 102, 1495, util.VN_CURDATE(), 3221, 1, 1), @@ -2400,8 +2409,8 @@ INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk (9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1), (10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1); -INSERT INTO `vn`.`dua` (id, code, awbFk, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk) - VALUES +INSERT INTO `vn`.`dua` (id, code, awbFk, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk) + VALUES (1, '19ES0028013A481523', 1, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 11276.95, 442), (2, '21ES00280136115760', 2, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1376.20, 442), (3, '19ES00280131956004', 3, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 3, 14268.50, 442), @@ -2448,25 +2457,25 @@ INSERT INTO `vn`.`duaInvoiceIn`(`id`, `duaFk`, `invoiceInFk`) (4, 4, 4), (5, 5, 5), (6, 6, 6), - (7, 7, 7), - (8, 8, 8), + (7, 7, 7), + (8, 8, 8), (9, 9, 9), (10, 10, 10); INSERT INTO `vn`.`invoiceInTax` (`invoiceInFk`, `taxableBase`, `expenceFk`, `foreignValue`, `taxTypeSageFk`, `transactionTypeSageFk`) VALUES - (1, 99.99, '2000000000', null, null, null), - (2, 999.99, '2000000000', null, null, null), - (3, 1000.50, '2000000000', null, null, null), - (4, 0.50, '2000000000', null, null, null), - (5, 150.50, '2000000000', null, null, null), - (1, 252.25, '4751000000', NULL, 7, 61), - (2, 223.17, '6210000567', NULL, 8, 20), - (3, 95.60, '7001000000', NULL, 8, 35), - (4, 446.63, '7001000000', NULL, 6, 61), - (5, 64.23, '6210000567', NULL, 8, 20), - (6, 29.95, '7001000000', NULL, 7, 20), - (7, 58.64, '6210000567', NULL, 8, 20); + (1, 99.99, '2000000000', NULL, NULL, NULL), + (2, 999.99, '2000000000', NULL, NULL, NULL), + (3, 1000.50, '2000000000', NULL, NULL, NULL), + (4, 0.50, '2000000000', NULL, NULL, NULL), + (5, 150.50, '2000000000', NULL, NULL, NULL), + (1, 252.25, '4751000000', NULL, 7, 61), + (2, 223.17, '6210000567', NULL, 8, 20), + (3, 95.60, '7001000000', NULL, 8, 35), + (4, 446.63, '7001000000', NULL, 6, 61), + (5, 64.23, '6210000567', NULL, 8, 20), + (6, 29.95, '7001000000', NULL, 7, 20), + (7, 58.64, '6210000567', NULL, 8, 20); INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amount`, `stems`, `countryFk`) VALUES @@ -2474,7 +2483,7 @@ INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amo (1, 10, 6021010, 20.00, 205, 5), (2, 13.20, 5080000, 15.00, 580, 5), (2, 16.10, 6021010, 25.00, 80, 5); - + INSERT INTO `vn`.`ticketRecalc`(`ticketFk`) SELECT t.id FROM vn.ticket t @@ -2491,7 +2500,7 @@ INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`) (4, 7, 1); INSERT INTO `vn`.`expeditionTruck` (`id`, `ETD`, `description`) - VALUES + VALUES (1, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +3 YEAR))), 'Best truck in fleet'); INSERT INTO `vn`.`expeditionPallet` (`id`, `truckFk`, `built`, `position`, `isPrint`) @@ -2499,7 +2508,7 @@ INSERT INTO `vn`.`expeditionPallet` (`id`, `truckFk`, `built`, `position`, `isPr (1, 1, util.VN_CURDATE(), 1, 1); INSERT INTO `vn`.`expeditionScan` (`id`, `expeditionFk`, `scanned`, `palletFk`) - VALUES + VALUES (1, 1, util.VN_CURDATE(), 1), (2, 2, util.VN_CURDATE(), 1), (3, 3, util.VN_CURDATE(), 1), @@ -2534,7 +2543,7 @@ UPDATE `vn`.`route` INSERT INTO `bs`.`salesPerson` (`workerFk`, `year`, `month`, `portfolioWeight`) VALUES (18, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 807.23), - (19, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 34.40); + (19, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 34.40); INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`) VALUES @@ -2563,14 +2572,14 @@ INSERT INTO `vn`.`calendarHolidaysType` (`id`, `name`, `hexColour`) INSERT INTO `vn`.`calendarHolidays` (`id`, `calendarHolidaysTypeFk`, `dated`, `calendarHolidaysNameFk`, `workCenterFk`) VALUES (1, 1, CONCAT(YEAR(util.VN_CURDATE()), '-12-09'), 1, 1); - + INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackages`, `kmPrice`, `packagePrice`, `routePrice`, `minimumKm`, `minimumM3`, `m3Price`) VALUES (1, 1, 0, 0.00, 0.00, NULL, 0, 0.00, 23), (2, 1, 60, 0.00, 0.00, NULL, 0, 5.00, 33), (3, 2, 0, 15.00, 0.00, NULL, 0, 0.00, 0), (4, 2, 0, 20.00, 0.00, NULL, 0, 0.00, 0), - (5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0); + (5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0); INSERT INTO `vn`.`chat` (`senderFk`, `recipient`, `dated`, `checkUserStatus`, `message`, `status`, `attempts`) VALUES @@ -2596,7 +2605,7 @@ INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed` (1106, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)); INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`) -VALUES +VALUES (1, 1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=7, 7, 14) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100), (2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=8, 8, 15) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100); @@ -2634,11 +2643,23 @@ INSERT INTO `vn`.`sectorCollection` (`userFk`, `sectorFk`) INSERT INTO `vn`.`sectorCollectionSaleGroup` (`sectorCollectionFk`, `saleGroupFk`) VALUES (1, 1); - + INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`) VALUES (1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13); INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) - VALUES + VALUES (1, 9); + +INSERT INTO `vn`.`productionConfig` (`isPreviousPreparationRequired`, `ticketPrintedMax`, `ticketTrolleyMax`, `rookieDays`, `notBuyingMonths`, `id`, `isZoneClosedByExpeditionActivated`, `maxNotReadyCollections`, `minTicketsToCloseZone`, `movingTicketDelRoute`, `defaultZone`, `defautlAgencyMode`, `hasUniqueCollectionTime`, `maxCollectionWithoutUser`, `pendingCollectionsOrder`, `pendingCollectionsAge`) + VALUES + (0, 8, 80, 0, 0, 1, 0, 15, 25, -1, 697, 1328, 0, 1, 8, 6); + +INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPackingTypeFk`, `saleTotalCount`, `salePickedCount`, `trainFk`, `sectorFk`, `wagons`) + VALUES + (3, util.VN_NOW(), 1107, 5, NULL, 0, 0, 1, NULL, NULL); + +INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters`) + VALUES + (9, 3, util.VN_NOW(), NULL, 0, NULL, NULL, NULL, NULL); diff --git a/db/dump/structure.sql b/db/dump/structure.sql index b81630eab..402c8e695 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -1,8 +1,8 @@ --- MariaDB dump 10.19 Distrib 10.6.8-MariaDB, for debian-linux-gnu (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.12-MariaDB, for debian-linux-gnu (x86_64) -- --- Host: db.verdnatura.es Database: account +-- Host: 127.0.0.1 Database: account -- ------------------------------------------------------ --- Server version 5.6.25-4-log +-- Server version 10.7.3-MariaDB-1:10.7.3+maria~focal /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -19,7 +19,7 @@ -- Current Database: `account` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `account` /*!40100 DEFAULT CHARACTER SET utf8 */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `account` /*!40100 DEFAULT CHARACTER SET utf8mb3 */; USE `account`; @@ -34,7 +34,7 @@ CREATE TABLE `account` ( `id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), CONSTRAINT `account_ibfk_3` FOREIGN KEY (`id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Users allowed to have an account'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Users allowed to have an account'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -88,15 +88,15 @@ DROP TABLE IF EXISTS `accountConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `accountConfig` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `homedir` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'The base folder for users home directory', - `shell` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'The default shell', + `homedir` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'The base folder for users home directory', + `shell` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'The default shell', `idBase` int(11) NOT NULL COMMENT 'Base id for Posix users and groups', `min` smallint(6) NOT NULL, `max` smallint(6) NOT NULL COMMENT 'Maximum password age (seconds)', `warn` smallint(6) NOT NULL COMMENT 'Warn to change password when elapsed (seconds)', `inact` smallint(6) NOT NULL COMMENT 'Maximum inactivity time (seconds)', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global configuration parameters for accounts'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Global configuration parameters for accounts'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -122,14 +122,14 @@ DROP TABLE IF EXISTS `accountLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `accountLog` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `msg` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `pid` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `user` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `host` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `rhost` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `time` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `msg` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `pid` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `user` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `host` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `rhost` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `time` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -155,13 +155,13 @@ DROP TABLE IF EXISTS `ldapConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ldapConfig` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `server` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'The LDAP server access url', - `rdn` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'The LDAP user', - `password` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'The LDAP password', - `userDn` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The base DN for users', - `groupDn` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The base DN for groups', + `server` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'The LDAP server access url', + `rdn` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'The LDAP user', + `password` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'The LDAP password', + `userDn` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'The base DN for users', + `groupDn` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'The base DN for groups', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='LDAP server configuration parameters'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='LDAP server configuration parameters'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -173,12 +173,12 @@ DROP TABLE IF EXISTS `mailAlias`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mailAlias` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `alias` varchar(50) CHARACTER SET utf8 NOT NULL, - `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `isPublic` tinyint(4) NOT NULL DEFAULT '1', + `alias` varchar(50) CHARACTER SET utf8mb3 NOT NULL, + `description` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isPublic` tinyint(4) NOT NULL DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `alias` (`alias`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Mail aliases'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Mail aliases'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -197,7 +197,7 @@ CREATE TABLE `mailAliasAccount` ( KEY `account` (`account`), CONSTRAINT `account` FOREIGN KEY (`account`) REFERENCES `account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `mailAlias` FOREIGN KEY (`mailAlias`) REFERENCES `mailAlias` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Mail alias that is assigned to each account'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Mail alias that is assigned to each account'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -209,12 +209,12 @@ DROP TABLE IF EXISTS `mailClientAccess`; /*!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', - `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `client` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL, + `action` set('OK','REJECT') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'REJECT', + `description` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `mailFrom` (`client`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -228,7 +228,7 @@ CREATE TABLE `mailConfig` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `domain` varchar(255) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -240,10 +240,10 @@ DROP TABLE IF EXISTS `mailForward`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mailForward` ( `account` int(10) unsigned NOT NULL, - `forwardTo` varchar(250) CHARACTER SET utf8 NOT NULL, + `forwardTo` varchar(250) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`account`), CONSTRAINT `mailForward_ibfk_1` FOREIGN KEY (`account`) REFERENCES `account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Mail forwarding'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Mail forwarding'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -255,12 +255,12 @@ DROP TABLE IF EXISTS `mailSenderAccess`; /*!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, + `sender` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL, `action` set('OK','REJECT') NOT NULL DEFAULT 'REJECT', - `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `description` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `mailFrom` (`sender`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -305,14 +305,14 @@ DROP TABLE IF EXISTS `role`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `role` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(14) COLLATE utf8_unicode_ci NOT NULL COMMENT 'MySQL doesn''t support more than 14 chars for proxied user names', - `description` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - `hasLogin` tinyint(3) unsigned NOT NULL DEFAULT '1', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `name` varchar(14) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'MySQL doesn''t support more than 14 chars for proxied user names', + `description` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `hasLogin` tinyint(3) unsigned NOT NULL DEFAULT 1, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Roles'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Roles'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -372,7 +372,7 @@ CREATE TABLE `roleConfig` ( `userHost` varchar(255) NOT NULL, `tplUser` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COMMENT='Role configuration parameters'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COMMENT='Role configuration parameters'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -391,7 +391,7 @@ CREATE TABLE `roleInherit` ( KEY `owner_id` (`inheritsFrom`), CONSTRAINT `roleInherit_ibfk_1` FOREIGN KEY (`role`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `roleInherit_ibfk_2` FOREIGN KEY (`inheritsFrom`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Role inheritance'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Role inheritance'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -407,7 +407,7 @@ CREATE TABLE `roleRole` ( `inheritsFrom` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `role` (`role`,`inheritsFrom`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Calculated role inheritance'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Calculated role inheritance'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -419,13 +419,13 @@ DROP TABLE IF EXISTS `sambaConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sambaConfig` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `adDomain` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Active directory domain', - `adController` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'The hosname of domain controller', - `adUser` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Active directory user', - `adPassword` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Active directory password', - `verifyCert` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT 'Whether to verify server certificate', + `adDomain` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'Active directory domain', + `adController` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'The hosname of domain controller', + `adUser` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'Active directory user', + `adPassword` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'Active directory password', + `verifyCert` tinyint(3) unsigned NOT NULL DEFAULT 1 COMMENT 'Whether to verify server certificate', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global configuration parameters for accounts'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Global configuration parameters for accounts'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -437,23 +437,23 @@ DROP TABLE IF EXISTS `user`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `user` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `realm` varchar(512) CHARACTER SET utf8 DEFAULT NULL, - `name` varchar(30) CHARACTER SET utf8 NOT NULL, - `nickname` varchar(127) COLLATE utf8_unicode_ci NOT NULL, - `bcryptPassword` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL, - `role` int(10) unsigned NOT NULL DEFAULT '2', - `active` tinyint(1) NOT NULL DEFAULT '1', - `email` varchar(255) CHARACTER SET utf8 DEFAULT NULL, + `realm` varchar(512) CHARACTER SET utf8mb3 DEFAULT NULL, + `name` varchar(30) CHARACTER SET utf8mb3 NOT NULL, + `nickname` varchar(127) COLLATE utf8mb3_unicode_ci NOT NULL, + `bcryptPassword` varchar(512) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `role` int(10) unsigned NOT NULL DEFAULT 2, + `active` tinyint(1) NOT NULL DEFAULT 1, + `email` varchar(255) CHARACTER SET utf8mb3 DEFAULT NULL, `emailVerified` tinyint(1) DEFAULT NULL, - `verificationToken` varchar(512) CHARACTER SET utf8 DEFAULT NULL, - `lang` char(2) CHARACTER SET utf8 DEFAULT NULL, + `verificationToken` varchar(512) CHARACTER SET utf8mb3 DEFAULT NULL, + `lang` char(2) CHARACTER SET utf8mb3 DEFAULT NULL, `lastPassChange` datetime DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `image` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `password` char(64) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Deprecated', - `recoverPass` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT 'Deprecated', - `sync` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Deprecated', + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `image` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `password` char(64) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'Deprecated', + `recoverPass` tinyint(3) unsigned NOT NULL DEFAULT 1 COMMENT 'Deprecated', + `sync` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Deprecated', PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`), UNIQUE KEY `mail` (`email`), @@ -462,7 +462,7 @@ CREATE TABLE `user` ( KEY `nickname` (`nickname`), KEY `lang` (`lang`), CONSTRAINT `user_ibfk_2` FOREIGN KEY (`role`) REFERENCES `role` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global users'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Global users'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -502,7 +502,7 @@ DELIMITER ;; FOR EACH ROW BEGIN CALL hedera.image_ref('user', NEW.image); - + INSERT IGNORE INTO userSync SET `name` = NEW.`name`; END */;; DELIMITER ; @@ -529,7 +529,7 @@ BEGIN IF !(NEW.`password` <=> OLD.`password`) THEN SET NEW.bcryptPassword = NULL; - SET NEW.lastPassChange = NOW(); + SET NEW.lastPassChange = util.VN_NOW(); END IF; END */;; DELIMITER ; @@ -567,7 +567,7 @@ BEGIN 'jgallego@verdnatura.es', 'Rol modificado', CONCAT( - myUser_getName(), + myUser_getName(), ' ha modificado el rol del usuario ', NEW.`name`, ' de ', OLD.role, ' a ', NEW.role) ); @@ -612,7 +612,7 @@ CREATE TABLE `userConfig` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `loginKey` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -630,7 +630,7 @@ CREATE TABLE `userPassword` ( `nDigits` tinyint(3) unsigned NOT NULL COMMENT 'Minimum of digits', `nPunct` tinyint(3) unsigned NOT NULL COMMENT 'Minimum of symbols', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Restrictions on user passwords'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Restrictions on user passwords'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -643,7 +643,7 @@ DROP TABLE IF EXISTS `userSync`; CREATE TABLE `userSync` ( `name` varchar(30) NOT NULL COMMENT 'The user name', PRIMARY KEY (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Users pending to be synchronized'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='Users pending to be synchronized'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -653,102 +653,6 @@ CREATE TABLE `userSync` ( -- -- Dumping routines for database 'account' -- -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP FUNCTION IF EXISTS `myUserGetId` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `myUserGetId`() RETURNS int(11) - READS SQL DATA - DETERMINISTIC -BEGIN -/** - * @deprecated Use myUser_getId() - */ - RETURN myUser_getId(); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP FUNCTION IF EXISTS `myUserGetName` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `myUserGetName`() RETURNS varchar(30) CHARSET utf8 - NO SQL - DETERMINISTIC -BEGIN -/** - * @deprecated Use myUser_getName() - */ - RETURN myUser_getName(); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP FUNCTION IF EXISTS `myUserHasRole` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `myUserHasRole`(vRoleName VARCHAR(255)) RETURNS tinyint(1) - DETERMINISTIC -BEGIN -/** - * @deprecated Use myUser_hasRole() - */ - RETURN myUser_hasRole(vRoleName); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP FUNCTION IF EXISTS `myUserHasRoleId` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `myUserHasRoleId`(vRoleId INT) RETURNS tinyint(1) - DETERMINISTIC -BEGIN -/** - * @deprecated Use myUser_hasRoleId() - */ - RETURN myUser_hasRoleId(vRoleId); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `myUser_checkLogin` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -756,6 +660,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `myUser_checkLogin`() RETURNS tinyint(1) READS SQL DATA @@ -777,7 +683,7 @@ BEGIN SET vSignature = util.hmacSha2(256, CONCAT_WS('/', @userId, @userName), vKey); RETURN vSignature = @userSignature; END IF; - + RETURN FALSE; END ;; @@ -786,8 +692,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `myUser_getId` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -795,6 +699,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `myUser_getId`() RETURNS int(11) READS SQL DATA @@ -806,7 +712,7 @@ BEGIN * @return The user id */ DECLARE vUser INT DEFAULT NULL; - + IF myUser_checkLogin() THEN SET vUser = @userId; @@ -814,7 +720,7 @@ BEGIN SELECT id INTO vUser FROM user WHERE name = LEFT(USER(), INSTR(USER(), '@') - 1); END IF; - + RETURN vUser; END ;; DELIMITER ; @@ -822,8 +728,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `myUser_getName` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -831,8 +735,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `myUser_getName`() RETURNS varchar(30) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `myUser_getName`() RETURNS varchar(30) CHARSET utf8mb3 NO SQL DETERMINISTIC BEGIN @@ -849,7 +755,7 @@ BEGIN ELSE SET vUser = LEFT(USER(), INSTR(USER(), '@') - 1); END IF; - + RETURN vUser; END ;; DELIMITER ; @@ -857,8 +763,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `myUser_hasRole` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -866,6 +770,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `myUser_hasRole`(vRoleName VARCHAR(255)) RETURNS tinyint(1) DETERMINISTIC @@ -883,8 +789,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `myUser_hasRoleId` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -892,6 +796,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `myUser_hasRoleId`(vRoleId INT) RETURNS tinyint(1) DETERMINISTIC @@ -909,8 +815,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `passwordGenerate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -918,8 +822,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `passwordGenerate`() RETURNS text CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `passwordGenerate`() RETURNS text CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci READS SQL DATA BEGIN /** @@ -944,10 +850,10 @@ BEGIN DECLARE vDigitChars TEXT DEFAULT '1234567890'; DECLARE vPunctChars TEXT DEFAULT '!$%&()=.'; - SELECT length, nAlpha, nUpper, nDigits, nPunct + SELECT length, nAlpha, nUpper, nDigits, nPunct INTO vMinLength, vMinAlpha, vMinUpper, vMinDigits, vMinPunct FROM userPassword; - WHILE LENGTH(vPwd) < vMinLength OR vAlpha < vMinAlpha + WHILE LENGTH(vPwd) < vMinLength OR vAlpha < vMinAlpha OR vUpper < vMinUpper OR vDigits < vMinDigits OR vPunct < vMinPunct DO SET vRandIndex = FLOOR((RAND() * 4) + 1); @@ -973,8 +879,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `toUnixDays` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -982,6 +886,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `toUnixDays`(vDate DATE) RETURNS int(11) DETERMINISTIC @@ -999,102 +905,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP FUNCTION IF EXISTS `userGetId` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `userGetId`() RETURNS int(11) - READS SQL DATA - DETERMINISTIC -BEGIN -/** - * @deprecated Use myUser_getId() - */ - RETURN myUser_getId(); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP FUNCTION IF EXISTS `userGetName` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `userGetName`() RETURNS varchar(30) CHARSET utf8 - NO SQL - DETERMINISTIC -BEGIN -/** - * @deprecated Use myUser_getName() - */ - RETURN myUser_getName(); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP FUNCTION IF EXISTS `userHasRole` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `userHasRole`(vUserName VARCHAR(255), vRoleName VARCHAR(255)) RETURNS tinyint(1) - DETERMINISTIC -BEGIN -/** - * @deprecated Use user_hasRole() - */ - RETURN user_hasRole(vUserName, vRoleName); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP FUNCTION IF EXISTS `userHasRoleId` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `userHasRoleId`(vUser VARCHAR(255), vRoleId INT) RETURNS tinyint(1) - DETERMINISTIC -BEGIN -/** - * @deprecated Use user_hasRoleId() - */ - RETURN user_hasRoleId(vUser, vRoleId); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `user_getMysqlRole` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -1102,8 +912,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `user_getMysqlRole`(vUserName VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `user_getMysqlRole`(vUserName VARCHAR(255)) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN /** @@ -1116,7 +928,7 @@ BEGIN DECLARE vRole VARCHAR(255); SELECT CONCAT(IF(r.hasLogin, c.rolePrefix, ''), r.name) INTO vRole - FROM role r + FROM role r JOIN user u ON u.role = r.id JOIN roleConfig c WHERE u.name = vUserName; @@ -1128,8 +940,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `user_getNameFromId` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -1137,22 +947,24 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `user_getNameFromId`(vSelf INT) RETURNS varchar(30) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `user_getNameFromId`(vSelf INT) RETURNS varchar(30) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN /** * Gets user name from it's id. - * + * * @param vSelf The user id * @return The user name */ DECLARE vName VARCHAR(30); - - SELECT `name` INTO vName - FROM user + + SELECT `name` INTO vName + FROM user WHERE id = vSelf; - + RETURN vName; END ;; DELIMITER ; @@ -1160,8 +972,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `user_hasRole` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -1169,6 +979,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `user_hasRole`(vUserName VARCHAR(255), vRoleName VARCHAR(255)) RETURNS tinyint(1) DETERMINISTIC @@ -1196,8 +1008,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `user_hasRoleId` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -1205,6 +1015,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `user_hasRoleId`(vUser VARCHAR(255), vRoleId INT) RETURNS tinyint(1) DETERMINISTIC @@ -1224,7 +1036,7 @@ BEGIN JOIN role r ON r.id = rr.inheritsFrom WHERE u.`name` = vUser AND r.id = vRoleId; - + RETURN vHasRole; END ;; DELIMITER ; @@ -1232,30 +1044,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `myUserLogout` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `myUserLogout`() -BEGIN -/** - * @deprecated Use myUser_Logout() - */ - CALL myUser_logout; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myUser_changePassword` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -1263,6 +1051,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myUser_changePassword`(vOldPassword VARCHAR(255), vPassword VARCHAR(255)) BEGIN @@ -1279,8 +1069,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myUser_login` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -1288,6 +1076,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myUser_login`(vUserName VARCHAR(255), vPassword VARCHAR(255)) READS SQL DATA @@ -1305,7 +1095,7 @@ BEGIN AND password = MD5(vPassword) AND active; - IF vAuthIsOk + IF vAuthIsOk THEN CALL myUser_loginWithName (vUserName); ELSE @@ -1317,8 +1107,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myUser_loginWithKey` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -1326,6 +1114,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myUser_loginWithKey`(vUserName VARCHAR(255), vKey VARCHAR(255)) READS SQL DATA @@ -1351,8 +1141,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myUser_loginWithName` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -1360,13 +1148,15 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myUser_loginWithName`(vUserName VARCHAR(255)) READS SQL DATA BEGIN /** * Logs in using only the user name. This procedure is intended to be executed - * by users with a high level of privileges so that normal users should not have + * by users with a high level of privileges so that normal users should not have * execute permissions on it. * * @param vUserName The user name @@ -1388,8 +1178,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myUser_logout` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -1397,12 +1185,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myUser_logout`() BEGIN /** * Logouts the user. - */ + */ SET @userId = NULL; SET @userName = NULL; SET @userSignature = NULL; @@ -1412,8 +1202,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myUser_restorePassword` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -1421,6 +1209,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myUser_restorePassword`(vVerificationToken VARCHAR(255), vPassword VARCHAR(255)) BEGIN @@ -1437,8 +1227,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `role_checkName` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -1446,6 +1234,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `role_checkName`(vRoleName VARCHAR(255)) BEGIN @@ -1466,8 +1256,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `role_getDescendents` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -1475,6 +1263,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `role_getDescendents`(vSelf INT) BEGIN @@ -1525,9 +1315,9 @@ BEGIN SELECT COUNT(*) > 0 INTO vIsRoot FROM tmp.role t - JOIN role r ON r.id = t.id + JOIN role r ON r.id = t.id WHERE r.`name` = 'root'; - + IF vIsRoot THEN INSERT IGNORE INTO tmp.role (id) SELECT id FROM role; @@ -1543,8 +1333,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `role_sync` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -1552,6 +1340,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `role_sync`() BEGIN @@ -1607,57 +1397,52 @@ 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `role_syncPrivileges` */; /*!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 character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `role_syncPrivileges`() BEGIN /** * Synchronizes permissions of MySQL role users based on role hierarchy. - * The computed role users of permission mix will be named according to - * pattern [vRolePrefix][roleName]. + * The computed role users of permission mix will be named according to + * pattern [vGenRolePrefix][roleName]. * - * If [vTplUser]@[vTplHost] user exists, it will be taken as a template for + * If [vTplUser]@[vRoleHost] user exists, it will be taken as a template for * basic attributes. * * Warning! This procedure should only be called when MySQL privileges * are modified. If role hierarchy is modified, you must call the role_sync() * procedure wich calls this internally. */ - DECLARE vIsMysql BOOL DEFAULT VERSION() NOT LIKE '%MariaDB%'; + DECLARE vIsMariaDb BOOL DEFAULT VERSION() LIKE '%MariaDB%'; DECLARE vVersion INT DEFAULT SUBSTRING_INDEX(VERSION(), '.', 1); DECLARE vTplUser VARCHAR(255); - DECLARE vTplHost VARCHAR(255); + DECLARE vRoleHost VARCHAR(255); DECLARE vUserPrefix VARCHAR(2); DECLARE vUserHost VARCHAR(255); - DECLARE vRolePrefix VARCHAR(2); - DECLARE vRoleHost VARCHAR(255); + DECLARE vGenRolePrefix VARCHAR(2); + DECLARE vGenRoleHost VARCHAR(255); DECLARE vPrefixedLike VARCHAR(255); DECLARE vPassword VARCHAR(255) DEFAULT ''; SELECT rolePrefix, userPrefix, userHost, tplUser - INTO vRolePrefix, vUserPrefix, vUserHost, vTplUser + INTO vGenRolePrefix, vUserPrefix, vUserHost, vTplUser FROM roleConfig; -- Deletes computed role users - SET vPrefixedLike = CONCAT(vRolePrefix, '%'); - SET vRoleHost = vUserHost; + SET vPrefixedLike = CONCAT(vGenRolePrefix, '%'); + SET vGenRoleHost = vUserHost; - IF vIsMysql THEN - SET vTplHost = 'localhost'; - - DELETE FROM mysql.user - WHERE `User` LIKE vPrefixedLike; - ELSE - SET vTplHost = ''; + IF vIsMariaDb THEN + SET vRoleHost = ''; DELETE FROM mysql.global_priv WHERE `User` LIKE vPrefixedLike; @@ -1668,6 +1453,11 @@ BEGIN `Role` LIKE vPrefixedLike AND (`User`, `Host`) = ('root', 'localhost') ); + ELSE + SET vRoleHost = 'localhost'; + + DELETE FROM mysql.user + WHERE `User` LIKE vPrefixedLike; END IF; DELETE FROM mysql.db @@ -1694,7 +1484,7 @@ BEGIN SELECT id, `name` `role`, - CONCAT(vRolePrefix, `name`) prefixedRole + CONCAT(vGenRolePrefix, `name`) prefixedRole FROM `role` WHERE hasLogin; @@ -1711,16 +1501,102 @@ BEGIN JOIN `roleRole` rr ON rr.role = r.id JOIN `role` ri ON ri.id = rr.inheritsFrom JOIN mysql.`user` u - ON u.`User` = ri.`name` AND u.`Host` = vTplHost; + ON u.`User` = ri.`name` AND u.`Host` = vRoleHost; -- Recreate role users - IF vIsMysql THEN + IF vIsMariaDb THEN + -- Roles + + INSERT INTO mysql.global_priv (`Host`, `User`, `Priv`) + SELECT vRoleHost, prefixedRole, + JSON_OBJECT( + 'is_role', TRUE, + 'access', 0 + ) + FROM tRole r + UNION + SELECT vRoleHost, CONCAT(vGenRolePrefix, 'root'), + JSON_OBJECT( + 'is_role', TRUE, + 'access', 0 + ); + + INSERT INTO mysql.roles_mapping (`Host`, `User`, `Role`, `Admin_option`) + SELECT vRoleHost, prefixedRole, inheritsFrom, 'N' + FROM tRoleInherit + UNION + SELECT vRoleHost, CONCAT(vGenRolePrefix, 'root'), prefixedRole, 'Y' + FROM tRole; + + INSERT INTO mysql.roles_mapping (`Host`, `User`, `Role`, `Admin_option`) + SELECT 'localhost', 'root', prefixedRole, 'Y' + FROM tRole + UNION + SELECT 'localhost', 'root', CONCAT(vGenRolePrefix, 'root'), 'Y'; + + -- Role users + + INSERT INTO mysql.global_priv ( + `User`, + `Host`, + `Priv` + ) + SELECT + r.prefixedRole, + vGenRoleHost, + JSON_MERGE_PATCH( + IFNULL(t.`Priv`, '{}'), + IFNULL(u.`Priv`, '{}'), + JSON_OBJECT( + 'mysql_old_password', JSON_VALUE(t.`Priv`, '$.mysql_old_password'), + 'mysql_native_password', JSON_VALUE(t.`Priv`, '$.mysql_native_password'), + 'authentication_string', JSON_VALUE(t.`Priv`, '$.authentication_string'), + 'ssl_type', JSON_VALUE(t.`Priv`, '$.ssl_type'), + 'default_role', r.prefixedRole, + 'access', 0, + 'is_role', FALSE + ) + ) + FROM tRole r + LEFT JOIN mysql.global_priv t + ON (t.`User`, t.Host) = (vTplUser, vRoleHost) + LEFT JOIN mysql.global_priv u + ON (u.`User`, u.Host) = (r.`role`, vRoleHost); + + INSERT INTO mysql.roles_mapping (`Host`, `User`, `Role`, `Admin_option`) + SELECT vGenRoleHost, prefixedRole, prefixedRole, 'N' + FROM tRole; + + -- Accounts + + DROP TEMPORARY TABLE IF EXISTS tAccounts; + CREATE TEMPORARY TABLE tAccounts + (INDEX (`name`)) + ENGINE = MEMORY + SELECT p.`User` `name`, r.prefixedRole + FROM mysql.global_priv p + JOIN `user` u ON u.`name` = p.`User` + JOIN tRole r ON r.`id` = u.`role` + WHERE JSON_EXTRACT(p.`Priv`, '$.autogenerated') = 'true'; + + UPDATE mysql.global_priv p + JOIN tAccounts c ON c.`name` = p.`User` + SET p.`Priv` = JSON_SET(p.`Priv`, '$.default_role', c.prefixedRole) + WHERE p.`Host` = vUserHost; + + UPDATE IGNORE mysql.roles_mapping m + JOIN tAccounts c ON c.`name` = m.`User` + SET m.`Role` = c.prefixedRole + WHERE m.`Host` = vUserHost; + + DROP TEMPORARY TABLE tAccounts; + ELSE DROP TEMPORARY TABLE IF EXISTS tUser; CREATE TEMPORARY TABLE tUser SELECT r.prefixedRole `User`, - vRoleHost `Host`, + vGenRoleHost `Host`, IFNULL(t.`authentication_string`, '') `authentication_string`, IFNULL(t.`plugin`, @@ -1752,16 +1628,16 @@ BEGIN FROM tRole r LEFT JOIN mysql.user t ON t.`User` = vTplUser - AND t.`Host` = vTplHost + AND t.`Host` = vRoleHost LEFT JOIN mysql.user u ON u.`User` = r.role - AND u.`Host` = vTplHost; + AND u.`Host` = vRoleHost; IF vVersion <= 5 THEN SELECT `Password` INTO vPassword FROM mysql.user WHERE `User` = vTplUser - AND `Host` = vTplHost; + AND `Host` = vRoleHost; INSERT INTO mysql.user ( `User`, @@ -1839,8 +1715,8 @@ BEGIN '', vUserHost, prefixedRole, - vRoleHost, - CONCAT(prefixedRole, '@', vRoleHost) + vGenRoleHost, + CONCAT(prefixedRole, '@', vGenRoleHost) FROM tRole; -- Global privileges @@ -1883,13 +1759,13 @@ BEGIN FROM tRoleInherit r JOIN mysql.user u ON u.`User` = r.inheritsFrom - AND u.`Host`= vTplHost + AND u.`Host`= vRoleHost GROUP BY r.prefixedRole; - + UPDATE mysql.user u JOIN tUserPriv t ON u.`User` = t.prefixedRole - AND u.`Host` = vRoleHost + AND u.`Host` = vGenRoleHost SET u.`Select_priv` = t.`Select_priv`, @@ -1980,7 +1856,7 @@ BEGIN ) SELECT r.prefixedRole, - vRoleHost, + vGenRoleHost, t.`Db`, MAX(t.`Select_priv`), MAX(t.`Insert_priv`), @@ -2004,7 +1880,7 @@ BEGIN FROM tRoleInherit r JOIN mysql.db t ON t.`User` = r.inheritsFrom - AND t.`Host`= vTplHost + AND t.`Host`= vRoleHost GROUP BY r.prefixedRole, t.`Db`; -- Table level privileges @@ -2021,7 +1897,7 @@ BEGIN ) SELECT r.prefixedRole, - vRoleHost, + vGenRoleHost, t.`Db`, t.`Table_name`, t.`Grantor`, @@ -2031,7 +1907,7 @@ BEGIN FROM tRoleInherit r JOIN mysql.tables_priv t ON t.`User` = r.inheritsFrom - AND t.`Host`= vTplHost + AND t.`Host`= vRoleHost GROUP BY r.prefixedRole, t.`Db`, t.`Table_name`; -- Column level privileges @@ -2047,7 +1923,7 @@ BEGIN ) SELECT r.prefixedRole, - vRoleHost, + vGenRoleHost, t.`Db`, t.`Table_name`, t.`Column_name`, @@ -2056,7 +1932,7 @@ BEGIN FROM tRoleInherit r JOIN mysql.columns_priv t ON t.`User` = r.inheritsFrom - AND t.`Host`= vTplHost + AND t.`Host`= vRoleHost GROUP BY r.prefixedRole, t.`Db`, t.`Table_name`, t.`Column_name`; -- Routine privileges @@ -2073,7 +1949,7 @@ BEGIN ) SELECT r.prefixedRole, - vRoleHost, + vGenRoleHost, t.`Db`, t.`Routine_name`, t.`Routine_type`, @@ -2083,94 +1959,7 @@ BEGIN FROM tRoleInherit r JOIN mysql.procs_priv t ON t.`User` = r.inheritsFrom - AND t.`Host`= vTplHost; - ELSE - -- Roles - - INSERT INTO mysql.global_priv (`Host`, `User`, `Priv`) - SELECT vTplHost, prefixedRole, - JSON_OBJECT( - 'is_role', TRUE, - 'access', 0 - ) - FROM tRole r - UNION - SELECT vTplHost, CONCAT(vRolePrefix, 'root'), - JSON_OBJECT( - 'is_role', TRUE, - 'access', 0 - ); - - INSERT INTO mysql.roles_mapping (`Host`, `User`, `Role`, `Admin_option`) - SELECT vTplHost, prefixedRole, inheritsFrom, 'N' - FROM tRoleInherit - UNION - SELECT vTplHost, CONCAT(vRolePrefix, 'root'), `User`, 'Y' - FROM mysql.global_priv - WHERE `User` LIKE vPrefixedLike AND `Host` = vTplHost; - - INSERT INTO mysql.roles_mapping (`Host`, `User`, `Role`, `Admin_option`) - SELECT 'localhost', 'root', prefixedRole, 'Y' - FROM tRole - UNION - SELECT 'localhost', 'root', CONCAT(vRolePrefix, 'root'), 'Y'; - - -- Role users - - INSERT INTO mysql.global_priv ( - `User`, - `Host`, - `Priv` - ) - SELECT - r.prefixedRole, - vRoleHost, - JSON_MERGE_PATCH( - IFNULL(t.`Priv`, '{}'), - IFNULL(u.`Priv`, '{}'), - JSON_OBJECT( - 'mysql_old_password', JSON_VALUE(t.`Priv`, '$.mysql_old_password'), - 'mysql_native_password', JSON_VALUE(t.`Priv`, '$.mysql_native_password'), - 'authentication_string', JSON_VALUE(t.`Priv`, '$.authentication_string'), - 'ssl_type', JSON_VALUE(t.`Priv`, '$.ssl_type'), - 'default_role', r.prefixedRole, - 'access', 0, - 'is_role', FALSE - ) - ) - FROM tRole r - LEFT JOIN mysql.global_priv t - ON (t.`User`, t.Host) = (vTplUser, vTplHost) - LEFT JOIN mysql.global_priv u - ON (u.`User`, u.Host) = (r.`role`, vTplHost); - - INSERT INTO mysql.roles_mapping (`Host`, `User`, `Role`, `Admin_option`) - SELECT vRoleHost, prefixedRole, prefixedRole, 'N' - FROM tRole; - - -- Accounts - - DROP TEMPORARY TABLE IF EXISTS tAccounts; - CREATE TEMPORARY TABLE tAccounts - (INDEX (`name`)) - ENGINE = MEMORY - SELECT p.`User` `name`, r.prefixedRole - FROM mysql.global_priv p - JOIN `user` u ON u.`name` = p.`User` - JOIN tRole r ON r.`id` = u.`role` - WHERE JSON_EXTRACT(p.`Priv`, '$.autogenerated') = 'true'; - - UPDATE mysql.global_priv p - JOIN tAccounts c ON c.`name` = p.`User` - SET p.`Priv` = JSON_SET(p.`Priv`, '$.default_role', c.prefixedRole) - WHERE p.`Host` = vUserHost; - - UPDATE IGNORE mysql.roles_mapping m - JOIN tAccounts c ON c.`name` = m.`User` - SET m.`Role` = c.prefixedRole - WHERE m.`Host` = vUserHost; - - DROP TEMPORARY TABLE tAccounts; + AND t.`Host`= vRoleHost; END IF; -- Cleanup @@ -2186,104 +1975,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `userLogin` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `userLogin`(vUserName VARCHAR(255), vPassword VARCHAR(255)) - READS SQL DATA -BEGIN -/** - * @deprecated Use myUser_login() - */ - CALL myUser_login(vUserName, vPassword); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `userLoginWithKey` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `userLoginWithKey`(vUserName VARCHAR(255), vKey VARCHAR(255)) - READS SQL DATA -BEGIN -/** - * @deprecated Use myUser_loginWithKey() - */ - CALL myUser_loginWithKey(vUserName, vKey); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `userLoginWithName` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `userLoginWithName`(vUserName VARCHAR(255)) - READS SQL DATA -BEGIN -/** - * @deprecated Use myUser_loginWithName() - */ - CALL myUser_loginWithName(vUserName); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `userSetPassword` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `userSetPassword`(vUserName VARCHAR(255), vPassword VARCHAR(255)) -BEGIN -/** - * @deprecated Use user_setPassword() - */ - DECLARE vUserId INT; - - SELECT id INTO vUserId - FROM user WHERE `name` = vUserName; - - CALL user_setPassword(vUserId, vPassword); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `user_changePassword` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2291,6 +1982,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `user_changePassword`(vSelf INT, vOldPassword VARCHAR(255), vPassword VARCHAR(255)) BEGIN @@ -2307,7 +2000,7 @@ BEGIN SELECT `password` = MD5(vOldPassword), `name` INTO vPasswordOk, vUserName FROM user WHERE id = vSelf; - + IF NOT vPasswordOk THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Invalid password'; @@ -2320,8 +2013,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `user_checkName` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2329,6 +2020,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `user_checkName`(vUserName VARCHAR(255)) BEGIN @@ -2348,8 +2041,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `user_checkPassword` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2357,6 +2048,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `user_checkPassword`(vPassword VARCHAR(255)) BEGIN @@ -2381,7 +2074,7 @@ BEGIN IF vChr REGEXP '[[:alpha:]]' THEN SET vNAlpha = vNAlpha+1; - + IF vChr REGEXP '[A-Z]' THEN SET vNUpper = vNUpper+1; @@ -2416,8 +2109,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `user_restorePassword` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2425,6 +2116,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `user_restorePassword`(vSelf INT, vVerificationToken VARCHAR(255), vPassword VARCHAR(255)) BEGIN @@ -2441,7 +2134,7 @@ BEGIN SELECT verificationToken = vVerificationToken, `name` INTO vTokenVerified, vUserName FROM user WHERE id = vSelf; - + IF NOT vTokenVerified THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Invalid verification token'; @@ -2454,8 +2147,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `user_setPassword` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2463,6 +2154,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `user_setPassword`(vSelf INT, vPassword VARCHAR(255)) BEGIN @@ -2491,7 +2184,7 @@ DELIMITER ; -- Current Database: `bs` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `bs` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `bs` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `bs`; @@ -2506,7 +2199,7 @@ SET character_set_client = utf8; /*!50001 CREATE TABLE `bajasLaborales` ( `firstname` tinyint NOT NULL, `name` tinyint NOT NULL, - `business_id` tinyint NOT NULL, + `businessFk` tinyint NOT NULL, `lastDate` tinyint NOT NULL, `endContract` tinyint NOT NULL, `type` tinyint NOT NULL, @@ -2525,16 +2218,16 @@ DROP TABLE IF EXISTS `bancos_evolution`; CREATE TABLE `bancos_evolution` ( `Fecha` date NOT NULL, `Id_Banco` int(11) NOT NULL, - `saldo` decimal(10,2) NOT NULL DEFAULT '0.00', - `quilla` decimal(10,2) NOT NULL DEFAULT '0.00', - `deuda` decimal(10,2) NOT NULL DEFAULT '0.00', - `liquidez` decimal(10,2) NOT NULL DEFAULT '0.00', - `disponibilidad ajena` decimal(10,2) NOT NULL DEFAULT '0.00', - `saldo_aux` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'Saldo auxiliar para el calculo de lo dispuesto en las polizas', + `saldo` decimal(10,2) NOT NULL DEFAULT 0.00, + `quilla` decimal(10,2) NOT NULL DEFAULT 0.00, + `deuda` decimal(10,2) NOT NULL DEFAULT 0.00, + `liquidez` decimal(10,2) NOT NULL DEFAULT 0.00, + `disponibilidad ajena` decimal(10,2) NOT NULL DEFAULT 0.00, + `saldo_aux` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT 'Saldo auxiliar para el calculo de lo dispuesto en las polizas', PRIMARY KEY (`Fecha`,`Id_Banco`), KEY `fk_banco_evolution_idx` (`Id_Banco`), CONSTRAINT `fk_banco_evolution` FOREIGN KEY (`Id_Banco`) REFERENCES `vn`.`accounting` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los saldos bancarios'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Almacena los saldos bancarios'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2550,7 +2243,7 @@ CREATE TABLE `carteras` ( `Mes` int(11) NOT NULL, `Peso` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`CodigoTrabajador`,`Año`,`Mes`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2565,7 +2258,7 @@ CREATE TABLE `clientAnnualConsumption` ( `invoiced` double(17,0) DEFAULT NULL, PRIMARY KEY (`clientFk`), CONSTRAINT `fmaId_Cliente` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2576,14 +2269,14 @@ DROP TABLE IF EXISTS `clientDied`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `clientDied` ( - `id` int(11) NOT NULL DEFAULT '0', - `clientName` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + `id` int(11) NOT NULL DEFAULT 0, + `clientName` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, `lastInvoiced` date DEFAULT NULL, - `workerCode` varchar(3) COLLATE utf8_unicode_ci NOT NULL, - `Boss` varchar(3) COLLATE utf8_unicode_ci NOT NULL, - `Aviso` varchar(13) CHARACTER SET utf8 DEFAULT NULL, + `workerCode` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, + `Boss` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, + `Aviso` varchar(13) CHARACTER SET utf8mb3 DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Clientes que no han comprado en los ultimos 3 meses, se actualiza con proceso nocturno el 3 de cada mes'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Clientes que no han comprado en los ultimos 3 meses, se actualiza con proceso nocturno el 3 de cada mes'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2597,11 +2290,11 @@ CREATE TABLE `clientNewBorn` ( `clientFk` int(11) NOT NULL, `firstShipped` date NOT NULL COMMENT 'Primer pedido o de la relacion comercial, o después de un año de inactividad', `lastShipped` date NOT NULL COMMENT 'último pedido del cliente', - `isModified` tinyint(4) DEFAULT '0', - `isRookie` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'define un cliente que ha de ser cuidado por ser nuevo o recuperado', + `isModified` tinyint(4) DEFAULT 0, + `isRookie` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'define un cliente que ha de ser cuidado por ser nuevo o recuperado', PRIMARY KEY (`clientFk`), CONSTRAINT `clientNewBorn_fk1` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Listado de clientes que se consideran nuevos a efectos de cobrar la comision adicional del comercial'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Listado de clientes que se consideran nuevos a efectos de cobrar la comision adicional del comercial'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2638,7 +2331,7 @@ CREATE TABLE `clientNewBorn__` ( `clientFk` int(11) NOT NULL, `shipped` date NOT NULL, PRIMARY KEY (`clientFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Listado de clientes que se consideran nuevos a efectos de cobrar la comision adicional del comercial'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Listado de clientes que se consideran nuevos a efectos de cobrar la comision adicional del comercial'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2656,7 +2349,7 @@ CREATE TABLE `compradores` ( `comision` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`Id_Trabajador`,`año`,`semana`), CONSTRAINT `comprador_trabajador` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn`.`worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2672,7 +2365,7 @@ CREATE TABLE `compradores_evolution` ( `importe` decimal(10,0) DEFAULT NULL, PRIMARY KEY (`Id_Trabajador`,`fecha`), CONSTRAINT `evo_trabajador` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn`.`worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2686,7 +2379,7 @@ CREATE TABLE `customerEvolution` ( `dated` date NOT NULL, `quantity` int(11) NOT NULL, PRIMARY KEY (`dated`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2699,14 +2392,14 @@ DROP TABLE IF EXISTS `defaulter`; CREATE TABLE `defaulter` ( `clientFk` int(11) NOT NULL, `created` date NOT NULL, - `amount` double NOT NULL DEFAULT '0', + `amount` double NOT NULL DEFAULT 0, `defaulterSinced` date DEFAULT NULL, `hasChanged` tinyint(1) DEFAULT NULL, `frozened` date DEFAULT NULL, PRIMARY KEY (`clientFk`,`created`), KEY `client` (`clientFk`), KEY `date` (`created`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2718,9 +2411,9 @@ DROP TABLE IF EXISTS `experienceIberflora2016`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `experienceIberflora2016` ( `Id_Cliente` int(11) NOT NULL, - `isVisitor` tinyint(4) NOT NULL DEFAULT '0', + `isVisitor` tinyint(4) NOT NULL DEFAULT 0, PRIMARY KEY (`Id_Cliente`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de clientes que participan en el estudio sobre la mejora del consumo tras la visita a las instalaciones de Silla'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Lista de clientes que participan en el estudio sobre la mejora del consumo tras la visita a las instalaciones de Silla'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2739,7 +2432,7 @@ CREATE TABLE `fondo_maniobra` ( `proveedores_pagos` double DEFAULT NULL, `fondo_medio` double DEFAULT NULL, PRIMARY KEY (`fecha`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2772,7 +2465,7 @@ CREATE TABLE `indicators` ( `thisWeekSales` decimal(10,2) DEFAULT NULL, `lastYearWeekSales` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`updated`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los valores actuales para una consulta diaria rápida por los directivos.'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Almacena los valores actuales para una consulta diaria rápida por los directivos.'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2784,17 +2477,17 @@ DROP TABLE IF EXISTS `inspeccionSS_2021`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `inspeccionSS_2021` ( `business_id` int(11) DEFAULT NULL, - `id` int(11) NOT NULL DEFAULT '0', - `firstName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `lastName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `id` int(11) NOT NULL DEFAULT 0, + `firstName` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `lastName` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `timed` datetime NOT NULL, `hours_week` smallint(6) DEFAULT NULL, `year` int(4) NOT NULL, `week` int(2) NOT NULL, `dated` date NOT NULL, `orden` int(11) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='bs.inspeccionSS_2021_add()'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='bs.inspeccionSS_2021_add()'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2851,16 +2544,16 @@ CREATE TABLE `m3` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fecha` date NOT NULL, `provinceFk` smallint(5) unsigned DEFAULT NULL, - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '0', + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 0, `m3` decimal(10,2) DEFAULT NULL, `year` int(11) DEFAULT NULL, `month` int(11) DEFAULT NULL, `week` int(11) DEFAULT NULL, `day` int(11) DEFAULT NULL, - `dayName` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, - `euros` decimal(10,2) DEFAULT '0.00', + `dayName` varchar(12) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `euros` decimal(10,2) DEFAULT 0.00, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2871,13 +2564,13 @@ DROP TABLE IF EXISTS `mermasCache__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mermasCache__` ( - `Comprador` varchar(3) COLLATE utf8_unicode_ci NOT NULL, + `Comprador` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, `año` int(4) NOT NULL, `Valor_Compra` decimal(10,0) DEFAULT NULL, `Faltas` decimal(10,0) DEFAULT NULL, `Basura` decimal(10,0) DEFAULT NULL, PRIMARY KEY (`Comprador`,`año`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2893,12 +2586,12 @@ CREATE TABLE `nightTask` ( `finished` datetime DEFAULT NULL, `lastFinished` datetime DEFAULT NULL, `order` int(11) DEFAULT NULL, - `schema` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `procedure` varchar(100) COLLATE utf8_unicode_ci NOT NULL, - `error` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `errorCode` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `schema` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `procedure` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, + `error` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `errorCode` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -2917,7 +2610,7 @@ BEGIN IF NOT (NEW.`schema`REGEXP '^[0-9a-zA-Z_]+$') OR NOT (NEW.`procedure`REGEXP '^[0-9a-zA-Z_]+$') THEN CALL util.throw('ONLY_ALPHANUMERICS_ALLOWED'); - + END IF; END */;; @@ -2943,7 +2636,7 @@ BEGIN IF NOT (NEW.`schema`REGEXP '^[0-9a-zA-Z_]+$') OR NOT (NEW.`procedure`REGEXP '^[0-9a-zA-Z_]+$') THEN CALL util.throw('ONLY_ALPHANUMERICS_ALLOWED'); - + END IF; END */;; @@ -2962,9 +2655,9 @@ DROP TABLE IF EXISTS `nightTaskConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `nightTaskConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `logMail` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `logMail` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2994,15 +2687,15 @@ DROP TABLE IF EXISTS `payMethodClient`; CREATE TABLE `payMethodClient` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dated` date NOT NULL, - `payMethodFk` tinyint(3) unsigned NOT NULL DEFAULT '0', - `clientFk` int(11) NOT NULL DEFAULT '0', + `payMethodFk` tinyint(3) unsigned NOT NULL DEFAULT 0, + `clientFk` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `FkPayMethod_idx` (`payMethodFk`), KEY `FkClientPayMethod_idx` (`clientFk`), KEY `FkDateClientPayMethod` (`dated`,`clientFk`), CONSTRAINT `FkClientPayMethod` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `FkPayMethodClient` FOREIGN KEY (`payMethodFk`) REFERENCES `vn`.`payMethod` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_bin; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3015,12 +2708,12 @@ DROP TABLE IF EXISTS `payMethodClientEvolution`; CREATE TABLE `payMethodClientEvolution` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dated` date NOT NULL, - `payMethodName` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `payMethodName` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `amountClient` int(11) NOT NULL, `amount` decimal(10,2) NOT NULL, `equalizationTax` decimal(10,2) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3032,11 +2725,11 @@ DROP TABLE IF EXISTS `produccion__`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `produccion__` ( `dated` date NOT NULL, - `m3` int(11) NOT NULL DEFAULT '0', - `cost` int(11) NOT NULL DEFAULT '0', - `eurosM3` decimal(10,2) NOT NULL DEFAULT '0.00', + `m3` int(11) NOT NULL DEFAULT 0, + `cost` int(11) NOT NULL DEFAULT 0, + `eurosM3` decimal(10,2) NOT NULL DEFAULT 0.00, PRIMARY KEY (`dated`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3089,13 +2782,13 @@ DROP TABLE IF EXISTS `sale`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sale` ( `saleFk` int(11) NOT NULL, - `amount` decimal(10,3) NOT NULL DEFAULT '0.000', - `surcharge` decimal(10,3) NOT NULL DEFAULT '0.000', + `amount` decimal(10,3) NOT NULL DEFAULT 0.000, + `surcharge` decimal(10,3) NOT NULL DEFAULT 0.000, `dated` date NOT NULL, `typeFk` smallint(5) unsigned NOT NULL, - `clientFk` int(11) NOT NULL DEFAULT '1', - `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', - `margin` decimal(10,3) NOT NULL DEFAULT '0.000', + `clientFk` int(11) NOT NULL DEFAULT 1, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, + `margin` decimal(10,3) NOT NULL DEFAULT 0.000, PRIMARY KEY (`saleFk`), KEY `tip_to_tip_idx` (`typeFk`), KEY `clientes_bs_ventas_idx` (`clientFk`), @@ -3105,7 +2798,7 @@ CREATE TABLE `sale` ( CONSTRAINT `sale_FK_1` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `sale_FK_2` FOREIGN KEY (`companyFk`) REFERENCES `vn`.`company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `sale_FK_3` FOREIGN KEY (`typeFk`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3117,11 +2810,11 @@ DROP TABLE IF EXISTS `salePersonEvolution__`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `salePersonEvolution__` ( `dated` date NOT NULL DEFAULT '0000-00-00', - `amount` decimal(10,2) NOT NULL DEFAULT '0.00', - `equalizationTax` decimal(10,2) NOT NULL DEFAULT '0.00', - `salesPersonFk` int(11) NOT NULL DEFAULT '0', + `amount` decimal(10,2) NOT NULL DEFAULT 0.00, + `equalizationTax` decimal(10,2) NOT NULL DEFAULT 0.00, + `salesPersonFk` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`dated`,`salesPersonFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3135,24 +2828,24 @@ CREATE TABLE `salesByItemTypeDay` ( `itemTypeFk` smallint(5) unsigned NOT NULL, `itemCategoryFk` int(10) unsigned NOT NULL, `dated` date NOT NULL, - `netSale` int(11) NOT NULL DEFAULT '0', - `stems` int(11) NOT NULL DEFAULT '0', - `references` int(11) NOT NULL DEFAULT '0', - `trash` int(11) NOT NULL DEFAULT '0', - `faults` int(11) NOT NULL DEFAULT '0', - `claimed` decimal(10,2) NOT NULL DEFAULT '0.00', - `accepted` decimal(10,2) NOT NULL DEFAULT '0.00', - `sale` decimal(10,2) NOT NULL DEFAULT '0.00', - `buy` decimal(10,2) NOT NULL DEFAULT '0.00', - `saleComponent` decimal(10,2) NOT NULL DEFAULT '0.00', - `costComponent` decimal(10,2) NOT NULL DEFAULT '0.00', - `marginComponent` decimal(10,2) NOT NULL DEFAULT '0.00', + `netSale` int(11) NOT NULL DEFAULT 0, + `stems` int(11) NOT NULL DEFAULT 0, + `references` int(11) NOT NULL DEFAULT 0, + `trash` int(11) NOT NULL DEFAULT 0, + `faults` int(11) NOT NULL DEFAULT 0, + `claimed` decimal(10,2) NOT NULL DEFAULT 0.00, + `accepted` decimal(10,2) NOT NULL DEFAULT 0.00, + `sale` decimal(10,2) NOT NULL DEFAULT 0.00, + `buy` decimal(10,2) NOT NULL DEFAULT 0.00, + `saleComponent` decimal(10,2) NOT NULL DEFAULT 0.00, + `costComponent` decimal(10,2) NOT NULL DEFAULT 0.00, + `marginComponent` decimal(10,2) NOT NULL DEFAULT 0.00, PRIMARY KEY (`itemTypeFk`,`dated`), KEY `itemTypeSalesByweek_itemCategoryFk_idx` (`itemCategoryFk`), KEY `itemTypeSalesByweek_period_idx` (`dated`), CONSTRAINT `itemTypeSalesByweek_itemCategoryFk` FOREIGN KEY (`itemCategoryFk`) REFERENCES `vn`.`itemCategory` (`id`) ON UPDATE CASCADE, CONSTRAINT `itemTypeSalesByweek_itemTypeFk` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn`.`itemType` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Ventas diarias agrupadas por reino y familia'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Ventas diarias agrupadas por reino y familia'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3167,7 +2860,7 @@ CREATE TABLE `salesByWeek` ( `year` int(11) NOT NULL, `sales` double DEFAULT NULL, UNIQUE KEY `week` (`week`,`year`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3181,16 +2874,16 @@ CREATE TABLE `salesByclientSalesPerson` ( `dated` date NOT NULL DEFAULT '0000-00-00', `salesPersonFk` int(10) unsigned DEFAULT NULL, `clientFk` int(11) NOT NULL, - `amount` decimal(10,3) NOT NULL DEFAULT '0.000', - `equalizationTax` decimal(10,3) NOT NULL DEFAULT '0.000', - `amountNewBorn` decimal(10,3) NOT NULL DEFAULT '0.000', + `amount` decimal(10,3) NOT NULL DEFAULT 0.000, + `equalizationTax` decimal(10,3) NOT NULL DEFAULT 0.000, + `amountNewBorn` decimal(10,3) NOT NULL DEFAULT 0.000, PRIMARY KEY (`dated`,`clientFk`), KEY `clientSalePersonEvolution_clientFk` (`clientFk`), KEY `salesByclientSalesPerson_salesPerson` (`salesPersonFk`), KEY `salesByclientSalesPerson_dated` (`dated`,`clientFk`,`amount`), CONSTRAINT `clientSalePersonEvolution_clientFk` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE, CONSTRAINT `salesByclientSalesPerson_salesPerson` FOREIGN KEY (`salesPersonFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Ventas diarias por cliente y comercial'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Ventas diarias por cliente y comercial'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3202,8 +2895,8 @@ DROP TABLE IF EXISTS `salesMonthlySnapshot`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `salesMonthlySnapshot` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `salesPersonName` varchar(100) COLLATE utf8_unicode_ci DEFAULT '', - `teamName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `salesPersonName` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT '', + `teamName` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `year` int(11) DEFAULT NULL, `month` int(11) DEFAULT NULL, `currentSale` decimal(10,3) DEFAULT NULL, @@ -3215,7 +2908,7 @@ CREATE TABLE `salesMonthlySnapshot` ( `newClientScore` decimal(10,3) DEFAULT NULL, `teamBossPlus` decimal(10,3) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3231,7 +2924,7 @@ CREATE TABLE `salesMonthlySnapshot__` ( `year` int(4) NOT NULL, `month` int(2) NOT NULL, `departmentFk` int(11) NOT NULL, - `ownSalesAmount` decimal(10,2) DEFAULT '0.00', + `ownSalesAmount` decimal(10,2) DEFAULT 0.00, `ownSalesPosition` int(11) DEFAULT NULL, `ownSalesBonus` int(11) DEFAULT NULL, `ownSalesScore` int(11) DEFAULT NULL, @@ -3245,7 +2938,7 @@ CREATE TABLE `salesMonthlySnapshot__` ( `teamSalesScore` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `workerFk_UNIQUE` (`workerFk`,`year`,`month`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='cada mes se guardan aqui los datos de forma estática, para consulta en grafana.'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='cada mes se guardan aqui los datos de forma estática, para consulta en grafana.'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3267,10 +2960,10 @@ CREATE TABLE `salesPerson` ( `leasedReplacement` decimal(10,2) DEFAULT NULL, `itemTypeBorrowed` decimal(10,2) DEFAULT NULL, `portfolioWeight` decimal(10,2) DEFAULT NULL COMMENT 'Pero de la cartera del comercial a fecha vendedores.updated', - `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), PRIMARY KEY (`workerFk`,`year`,`month`), CONSTRAINT `salesPerson_FK` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3293,7 +2986,7 @@ CREATE TABLE `salesPersonClient__` ( `substitutionBorrowed` decimal(10,2) DEFAULT NULL, `itemTypeBorrowed` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`salesPersonFk`,`clientFk`,`year`,`month`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Ventas por comercial por cliente'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Ventas por comercial por cliente'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3307,13 +3000,13 @@ CREATE TABLE `salesPersonEvolution` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dated` date NOT NULL DEFAULT '0000-00-00', `salesPersonFk` int(10) unsigned DEFAULT NULL, - `amount` decimal(10,3) NOT NULL DEFAULT '0.000', - `equalizationTax` decimal(10,3) NOT NULL DEFAULT '0.000', - `amountNewBorn` decimal(10,3) NOT NULL DEFAULT '0.000', + `amount` decimal(10,3) NOT NULL DEFAULT 0.000, + `equalizationTax` decimal(10,3) NOT NULL DEFAULT 0.000, + `amountNewBorn` decimal(10,3) NOT NULL DEFAULT 0.000, PRIMARY KEY (`id`), KEY `salesPersonEvolution_salesPerson` (`salesPersonFk`), CONSTRAINT `salesPersonEvolution_salesPerson` FOREIGN KEY (`salesPersonFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Evolución Comerciales'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Evolución Comerciales'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3354,7 +3047,7 @@ CREATE TABLE `vendedores_evolution` ( `month` int(11) NOT NULL, PRIMARY KEY (`workerFk`,`year`,`month`), CONSTRAINT `evo_vendedor_trabajador` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3394,7 +3087,7 @@ CREATE TABLE `ventas_contables` ( `empresa_id` int(4) NOT NULL, `gasto` varchar(10) CHARACTER SET latin1 NOT NULL, PRIMARY KEY (`year`,`month`,`grupo`,`reino_id`,`tipo_id`,`empresa_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3405,11 +3098,11 @@ DROP TABLE IF EXISTS `waste`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `waste` ( - `buyer` varchar(30) CHARACTER SET utf8 NOT NULL, + `buyer` varchar(30) CHARACTER SET utf8mb3 NOT NULL, `year` int(4) NOT NULL, `week` int(2) NOT NULL, - `family` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `itemFk` int(11) NOT NULL DEFAULT '0', + `family` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL, + `itemFk` int(11) NOT NULL DEFAULT 0, `itemTypeFk` smallint(5) unsigned DEFAULT NULL, `saleTotal` decimal(16,0) DEFAULT NULL, `saleWaste` decimal(16,0) DEFAULT NULL, @@ -3419,7 +3112,7 @@ CREATE TABLE `waste` ( KEY `waste_item_id` (`itemFk`), CONSTRAINT `waste_itemType_id` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn`.`itemType` (`id`) ON UPDATE CASCADE, CONSTRAINT `waste_item_id` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3431,14 +3124,14 @@ DROP TABLE IF EXISTS `workerLabourDataByMonth`; /*!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, + `code` varchar(25) COLLATE utf8mb3_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; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3463,7 +3156,7 @@ CREATE TABLE `workerProductivity` ( CONSTRAINT `workerProductivity_FK` FOREIGN KEY (`actionFk`) REFERENCES `vncontrol`.`accion` (`accion_id`) ON UPDATE CASCADE, CONSTRAINT `workerProductivity_warehouseFk` FOREIGN KEY (`warehouseFk`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `workerProductivity_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3478,7 +3171,7 @@ CREATE TABLE `workerProductivityConfig` ( `minSeconsPackager` int(11) DEFAULT NULL, `minSeconsItemPicker` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3489,14 +3182,14 @@ DROP TABLE IF EXISTS `workerSpeed__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerSpeed__` ( - `workerCode` varchar(3) COLLATE utf8_unicode_ci NOT NULL, - `accion` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', + `workerCode` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, + `accion` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL, + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 1, `LitrosMinuto` decimal(10,1) DEFAULT NULL, `LitrosMinutoLastHour` decimal(10,1) DEFAULT NULL, `lastUpdated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`workerCode`,`warehouseFk`,`accion`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3510,25 +3203,10 @@ CREATE TABLE `zone_ETD__` ( `zoneFk` int(11) DEFAULT NULL, `totalVolume` decimal(5,1) DEFAULT NULL, `remainingVolume` decimal(5,1) DEFAULT NULL, - `speed` decimal(10,2) NOT NULL DEFAULT '0.00', + `speed` decimal(10,2) NOT NULL DEFAULT 0.00, `hourTheoretical` time DEFAULT NULL, - `hourPractical` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '' -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `zone_ETD_byTime` --- - -DROP TABLE IF EXISTS `zone_ETD_byTime`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `zone_ETD_byTime` ( - `theorical` time NOT NULL, - `practical` time NOT NULL DEFAULT '00:00:00', - `m3` decimal(10,1) NOT NULL DEFAULT '0.0', - PRIMARY KEY (`theorical`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + `hourPractical` varchar(10) CHARACTER SET utf8mb3 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3553,51 +3231,33 @@ DELIMITER ;; /*!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 `zone_ETD_byTime_Refresh` */;; -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_unicode_ci */ ;; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ;; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; -/*!50003 SET @saved_time_zone = @@time_zone */ ;; -/*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `zone_ETD_byTime_Refresh` ON SCHEDULE EVERY 5 MINUTE STARTS '2022-01-28 09:52:45' ON COMPLETION NOT PRESERVE ENABLE DO CALL bs.zone_ETD_byTime() */ ;; -/*!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 'bs' -- -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `tramo` */; /*!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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `tramo`(vDateTime DATETIME) RETURNS varchar(20) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `tramo`(vDateTime DATETIME) RETURNS varchar(20) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci NO SQL BEGIN DECLARE vTramo VARCHAR(20); DECLARE vHour INT; - + SET vHour = HOUR(vDateTime) ; - + SET vTramo = - CASE + CASE WHEN vHour BETWEEN 0 AND 14 THEN 'Mañana' WHEN vHour BETWEEN 15 AND 24 THEN 'Tarde' END ; @@ -3609,8 +3269,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `bancos_evolution_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -3618,6 +3276,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `bancos_evolution_add`(vStartingDate DATE) BEGIN @@ -3625,10 +3285,10 @@ BEGIN * Inserta en la tabla bancos_evolution los saldos acumulados de cada banco * * @param vStartingDate Fecha desde la cual se recalculan la tabla bs.bancos_evolution - */ + */ DECLARE vCurrentDate DATE; - DECLARE vMaxDate DATE DEFAULT TIMESTAMPADD(MONTH, 7, CURDATE()); - IF IFNULL(vStartingDate,0) < TIMESTAMPADD(YEAR, -5, CURDATE()) THEN + DECLARE vMaxDate DATE DEFAULT TIMESTAMPADD(MONTH, 7, util.VN_CURDATE()); + IF IFNULL(vStartingDate,0) < TIMESTAMPADD(YEAR, -5, util.VN_CURDATE()) THEN CALL util.throw('invalid date'); END IF; DELETE FROM bs.bancos_evolution WHERE Fecha >= vStartingDate; @@ -3639,72 +3299,72 @@ BEGIN SELECT vCurrentDate, Id_Banco, deuda FROM bs.bancos_evolution WHERE Fecha = TIMESTAMPADD(DAY,-1,vCurrentDate); - + WHILE vCurrentDate < vMaxDate DO -- insertar solo el dia de ayer INSERT INTO bs.bancos_evolution(Fecha ,Id_Banco, saldo) - SELECT vCurrentDate, Id_Banco, SUM(saldo) + SELECT vCurrentDate, Id_Banco, SUM(saldo) FROM ( SELECT Id_Banco ,saldo FROM bs.bancos_evolution WHERE Fecha = TIMESTAMPADD(DAY,-1,vCurrentDate) -- los saldos acumulados del dia anterior UNION ALL - + SELECT c.Id_Banco, IFNULL(SUM(Entrada),0) - IFNULL(SUM(Salida),0) as saldo FROM vn2008.Cajas c JOIN vn2008.Bancos b using(Id_Banco) -- saldos de las cajas - JOIN vn.accountingType at2 ON at2.id = b.cash + JOIN vn.accountingType at2 ON at2.id = b.cash WHERE at2.code IN ('wireTransfer','fundingLine') AND Cajafecha = vCurrentDate AND (Serie = 'MB' OR at2.code = 'fundingLine') GROUP BY Id_Banco - )sub + )sub GROUP BY Id_Banco ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo); - + SET vCurrentDate = TIMESTAMPADD(DAY,1,vCurrentDate); END WHILE; - -- Ahora actualizamos la quilla + -- Ahora actualizamos la quilla UPDATE bs.bancos_evolution be JOIN ( SELECT bp.Id_Banco, - sum(bp.importe) as quilla, t.dated - FROM vn.time t + FROM vn.time t JOIN vn2008.Bancos_poliza bp ON t.dated between apertura AND IFNULL(cierre, t.dated) WHERE t.dated BETWEEN vStartingDate AND vMaxDate GROUP BY Id_Banco, t.dated ) sub ON be.Id_Banco = sub.Id_Banco AND sub.dated = be.Fecha - SET be.quilla = sub.quilla; + SET be.quilla = sub.quilla; -- pagos futuros no concilidados INSERT INTO bs.bancos_evolution(Fecha, Id_Banco, saldo) SELECT t.dated, p.id_banco, - importe - FROM vn.time t + FROM vn.time t join vn2008.pago p ON p.fecha <= t.dated - WHERE t.dated BETWEEN CURDATE() AND vMaxDate - AND p.fecha BETWEEN CURDATE() AND vMaxDate + WHERE t.dated BETWEEN util.VN_CURDATE() AND vMaxDate + AND p.fecha BETWEEN util.VN_CURDATE() AND vMaxDate AND NOT conciliado ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo); -- cobros futuros INSERT INTO bs.bancos_evolution(Fecha, Id_Banco, saldo) SELECT t.dated, r.Id_Banco, SUM(Entregado) - FROM vn.time t + FROM vn.time t JOIN vn2008.Recibos r ON r.Fechacobro <= t.dated - WHERE r.Fechacobro > CURDATE() AND r.Fechacobro <= vMaxDate - AND t.dated BETWEEN CURDATE() AND vMaxDate + WHERE r.Fechacobro > util.VN_CURDATE() AND r.Fechacobro <= vMaxDate + AND t.dated BETWEEN util.VN_CURDATE() AND vMaxDate GROUP BY t.dated, r.Id_Banco ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo); -- saldos de la tabla prevision INSERT INTO bs.bancos_evolution(Fecha, Id_Banco, saldo) SELECT t.dated, sp.Id_Banco, SUM(Importe) - FROM vn.time t + FROM vn.time t JOIN vn2008.Saldos_Prevision sp ON sp.Fecha <= t.dated JOIN vn2008.Bancos b ON sp.Id_Banco = b.Id_Banco - JOIN vn.accountingType at2 ON at2.id = b.cash + JOIN vn.accountingType at2 ON at2.id = b.cash WHERE at2.code IN ('wireTransfer','fundingLine') AND t.dated BETWEEN vStartingDate AND vMaxDate GROUP BY t.dated, sp.Id_Banco @@ -3718,12 +3378,12 @@ BEGIN -- Deuda UPDATE bs.bancos_evolution be JOIN vn2008.Bancos b using(Id_Banco) - JOIN vn.accountingType at2 ON at2.id = b.cash + JOIN vn.accountingType at2 ON at2.id = b.cash SET be.deuda = IF(at2.code = 'fundingLine', be.saldo_aux, 0) , be.saldo = IF(at2.code = 'fundingLine', 0, be.saldo_aux) WHERE Fecha >= vStartingDate; - -- Liquidez + -- Liquidez update bs.bancos_evolution set liquidez = saldo - quilla + deuda WHERE Fecha >= vStartingDate; -- Disponibilidad update bs.bancos_evolution set `disponibilidad ajena` = - quilla + deuda WHERE Fecha >= vStartingDate; @@ -3734,8 +3394,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `campaignComparative` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -3743,17 +3401,19 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `campaignComparative`(vDateFrom DATE, vDateTo DATE) BEGIN - SELECT - workerName, - id, - name, - CAST(SUM(previousAmmount) AS DECIMAL(10, 0)) AS previousAmmount, - CAST(SUM(currentAmmount) AS DECIMAL(10, 0)) AS currentAmmount + SELECT + workerName, + id, + name, + CAST(SUM(previousAmmount) AS DECIMAL(10, 0)) AS previousAmmount, + CAST(SUM(currentAmmount) AS DECIMAL(10, 0)) AS currentAmmount FROM ( - (SELECT + (SELECT CONCAT(w.firstname, ' ', w.lastName) AS workerName, c.id, c.name, @@ -3762,11 +3422,11 @@ BEGIN FROM bs.ventas v INNER JOIN vn.`client` c ON v.Id_Cliente = c.id INNER JOIN vn.worker w ON c.salesPersonFk = w.id - WHERE v.fecha BETWEEN DATE_ADD(vDateFrom, INTERVAL - 1 YEAR) + WHERE v.fecha BETWEEN DATE_ADD(vDateFrom, INTERVAL - 1 YEAR) AND DATE_ADD(vDateTo, INTERVAL - 1 YEAR) GROUP BY w.id, v.Id_Cliente) UNION ALL - (SELECT + (SELECT CONCAT(w.firstname, ' ', w.lastName) AS workerName, c.id, c.name, @@ -3789,8 +3449,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `carteras_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -3798,6 +3456,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `carteras_add`() BEGIN @@ -3805,15 +3465,15 @@ BEGIN * Inserta en @bs.carteras. */ DELETE FROM bs.carteras - WHERE Año >= YEAR(CURDATE()) - 1; + WHERE Año >= YEAR(util.VN_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 + JOIN vn.worker w ON w.id = c.salesPersonFk + WHERE t.year >= YEAR(util.VN_CURDATE()) - 1 GROUP BY w.code, t.year , t.month; END ;; DELIMITER ; @@ -3821,8 +3481,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -3830,6 +3488,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`() BEGIN @@ -3839,39 +3499,37 @@ BEGIN DECLARE vThreeYearAgo DATETIME; - SET vOneYearAgo = TIMESTAMPADD(YEAR, -1,CURDATE()); - SET vTwoYearAgo = TIMESTAMPADD(YEAR, -2,CURDATE()); - SET vThreeYearAgo = TIMESTAMPADD(YEAR, -3,CURDATE()); - SET vFourYearsAgo = TIMESTAMPADD(YEAR, -4,CURDATE()); + SET vOneYearAgo = TIMESTAMPADD(YEAR, -1,util.VN_CURDATE()); + SET vTwoYearAgo = TIMESTAMPADD(YEAR, -2,util.VN_CURDATE()); + SET vThreeYearAgo = TIMESTAMPADD(YEAR, -3,util.VN_CURDATE()); + SET vFourYearsAgo = TIMESTAMPADD(YEAR, -4,util.VN_CURDATE()); DELETE FROM bs.clientNewBorn WHERE lastShipped < vOneYearAgo; - + DELETE FROM ventas WHERE fecha < vFourYearsAgo; - + DELETE FROM payMethodClient WHERE dated < vOneYearAgo; DELETE FROM payMethodClientEvolution WHERE dated < vFourYearsAgo; - DELETE FROM bs.salesByclientSalesPerson + DELETE FROM bs.salesByclientSalesPerson WHERE dated < vFourYearsAgo; - - DELETE FROM bs.m3 + + DELETE FROM bs.m3 WHERE fecha < vTwoYearAgo; DELETE FROM salesByItemTypeDay - WHERE dated < vThreeYearAgo; + WHERE dated < vThreeYearAgo; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientDied_recalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -3879,12 +3537,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clientDied_recalc`() BEGIN - SET @primerAviso := TIMESTAMPADD(MONTH,-1,CURDATE()); - SET @segundoAviso := TIMESTAMPADD(MONTH,-2,CURDATE()); - SET @tercerAviso := TIMESTAMPADD(MONTH,-3,CURDATE()); + SET @primerAviso := TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()); + SET @segundoAviso := TIMESTAMPADD(MONTH,-2,util.VN_CURDATE()); + SET @tercerAviso := TIMESTAMPADD(MONTH,-3,util.VN_CURDATE()); TRUNCATE TABLE bs.clientDied; @@ -3910,15 +3570,13 @@ BEGIN DELETE cd.* FROM bs.clientDied cd JOIN vn.ticket t ON t.clientFk = cd.id WHERE t.refFk IS NULL - AND t.shipped >=TIMESTAMPADD(MONTH,-1,CURDATE()); + AND t.shipped >=TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientNewBorn_recalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -3926,21 +3584,23 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clientNewBorn_recalc`() BLOCK1: BEGIN DECLARE vClientFk INT; - DECLARE vShipped DATE; + DECLARE vShipped DATE; DECLARE vPreviousShipped DATE; - DECLARE vDone boolean; - DECLARE cur cursor for - - SELECT clientFk, firstShipped - FROM bs.clientNewBorn; - - DECLARE continue HANDLER FOR NOT FOUND SET vDone = TRUE; - SET vDone := FALSE; + DECLARE vDone boolean; + DECLARE cur cursor for + + SELECT clientFk, firstShipped + FROM bs.clientNewBorn; + + DECLARE continue HANDLER FOR NOT FOUND SET vDone = TRUE; + SET vDone := FALSE; DELETE FROM bs.clientNewBorn WHERE isModified = FALSE; @@ -3949,10 +3609,10 @@ BLOCK1: BEGIN FROM vn.client c JOIN vn.ticket t on t.clientFk = c.id LEFT JOIN clientNewBorn cb on cb.clientFk = c.id - WHERE t.shipped BETWEEN TIMESTAMPADD(YEAR, -1, CURDATE()) AND CURDATE() AND cb.isModified is null + WHERE t.shipped BETWEEN TIMESTAMPADD(YEAR, -1, util.VN_CURDATE()) AND util.VN_CURDATE() AND cb.isModified is null GROUP BY c.id; OPEN cur; - + LOOP1: LOOP SET vDone := FALSE; FETCH cur INTO vClientFk, vShipped; @@ -3963,37 +3623,37 @@ BLOCK1: BEGIN END IF; BLOCK2: BEGIN - DECLARE vCurrentShipped DATE; - DECLARE vDone2 boolean; + DECLARE vCurrentShipped DATE; + DECLARE vDone2 boolean; DECLARE cur2 CURSOR FOR - SELECT shipped - FROM vn.ticket - WHERE clientFk = vClientFk AND shipped <= CURDATE() + SELECT shipped + FROM vn.ticket + WHERE clientFk = vClientFk AND shipped <= util.VN_CURDATE() ORDER BY shipped DESC; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone2 = TRUE; SET vDone2 := FALSE; OPEN cur2; - + SET vPreviousShipped := vShipped; LOOP2: LOOP SET vDone2 := FALSE; FETCH cur2 INTO vCurrentShipped; - + IF DATEDIFF(vPreviousShipped,vCurrentShipped) > 365 THEN - UPDATE bs.clientNewBorn - SET firstShipped = vPreviousShipped + UPDATE bs.clientNewBorn + SET firstShipped = vPreviousShipped WHERE clientFk= vClientFk; - + CLOSE cur2; - LEAVE LOOP2; + LEAVE LOOP2; END IF; - + SET vPreviousShipped := vCurrentShipped; IF vDone2 THEN - UPDATE bs.clientNewBorn - SET firstShipped = vCurrentShipped + UPDATE bs.clientNewBorn + SET firstShipped = vCurrentShipped WHERE clientFk= vClientFk; CLOSE cur2; LEAVE LOOP2; @@ -4003,22 +3663,20 @@ BLOCK1: BEGIN END BLOCK2; END LOOP LOOP1; - UPDATE bs.clientNewBorn cnb + UPDATE bs.clientNewBorn cnb LEFT JOIN (SELECT DISTINCT t.clientFk FROM vn.ticket t JOIN vn.productionConfig pc - WHERE t.shipped BETWEEN curdate() + INTERVAL -(`notBuyingMonths`) MONTH - AND curdate() + INTERVAL -(`pc`.`rookieDays`) DAY) notRookie ON notRookie.clientFk = cnb.clientFk - SET cnd.isRookie = ISNULL(notRookie.clientFk); - + WHERE t.shipped BETWEEN util.VN_CURDATE() + INTERVAL -(`notBuyingMonths`) MONTH + AND util.VN_CURDATE() + INTERVAL -(`pc`.`rookieDays`) DAY) notRookie ON notRookie.clientFk = cnb.clientFk + SET cnd.isRookie = ISNULL(notRookie.clientFk); + END BLOCK1 ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `comercialesCompleto` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4026,21 +3684,23 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `comercialesCompleto`(IN vWorker INT, vDate DATE) BEGIN DECLARE vAYearAgoStarted DATE DEFAULT DATE_FORMAT(TIMESTAMPADD(YEAR, - 1, vDate), '%Y-%m-01'); DECLARE vAYearAgoEnded DATE DEFAULT TIMESTAMPADD(YEAR, - 1, LAST_DAY(vDate)); - + CALL vn.worker_GetHierarchy(vWorker); - + INSERT IGNORE INTO tmp.workerHierarchyList (workerFk) SELECT wd2.workerFk FROM vn.workerDepartment wd2 WHERE wd2.workerFk = vWorker; - + -- Falta que en algunos casos solo tenga en cuenta los tipos afectados. - SELECT + SELECT c.Id_Cliente id_cliente, c.calidad, c.Cliente cliente, @@ -4066,7 +3726,7 @@ BEGIN FROM vn2008.Clientes c LEFT JOIN - (SELECT g.Id_Cliente, CAST( SUM(Importe) as DECIMAL(12,2)) AS Greuge + (SELECT g.Id_Cliente, CAST( SUM(Importe) as DECIMAL(12,2)) AS Greuge FROM vn2008.Greuges g JOIN vn.`client` c ON c.id = g.Id_Cliente LEFT JOIN vn.worker w ON c.salesPersonFk = w.id @@ -4088,14 +3748,14 @@ BEGIN WHERE v.fecha BETWEEN TIMESTAMPADD(YEAR, - 1, vDate) AND vDate GROUP BY v.Id_Cliente) c365 ON c365.Id_Cliente = c.Id_Cliente LEFT JOIN - (SELECT + (SELECT Id_Cliente, SUM(importe) consumo FROM bs.ventas v INNER JOIN vn2008.Clientes c USING (Id_Cliente) LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador WHERE - (c.Id_Trabajador = vWorker OR tr.boss = vWorker) + (c.Id_Trabajador = vWorker OR tr.boss = vWorker) AND (v.fecha BETWEEN TIMESTAMPADD(DAY, - DAY(vDate) + 1, vDate) AND TIMESTAMPADD(DAY, - 1, vDate)) GROUP BY Id_Cliente) mes_actual ON mes_actual.Id_Cliente = c.Id_Cliente LEFT JOIN @@ -4142,8 +3802,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `compradores_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4151,22 +3809,24 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `compradores_add`(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 hasta */ REPLACE bs.compradores - SELECT it.workerFk AS Id_Trabajador, vYear AS año, tm.week AS semana, SUM(importe) AS importe, 0 AS comision + 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 + 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; @@ -4176,8 +3836,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `compradores_add_launcher` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4185,6 +3843,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `compradores_add_launcher`() BEGIN @@ -4192,22 +3852,22 @@ BEGIN DECLARE vYear INT; DECLARE vWeek INT; DECLARE done BOOL DEFAULT FALSE; - + DECLARE rs CURSOR FOR SELECT year, week FROM vn.time - WHERE dated <= curdate() - AND year = vYear + WHERE dated <= util.VN_CURDATE() + AND year = vYear AND week >= vWeek; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - - SELECT MAX(año) INTO vYear + + SELECT MAX(año) INTO vYear FROM compradores; - + SELECT MAX(semana) INTO vWeek - FROM compradores - WHERE año = vYear; + FROM compradores + WHERE año = vYear; OPEN rs; @@ -4216,7 +3876,7 @@ BEGIN WHILE NOT done DO CALL compradores_add(vYear, vWeek, vWeek); - + FETCH rs INTO vYear, vWeek; END WHILE; @@ -4224,15 +3884,13 @@ BEGIN CLOSE rs; CALL compradores_evolution_add; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `compradores_evolution_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4240,6 +3898,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `compradores_evolution_add`() BEGIN @@ -4256,10 +3916,10 @@ DECLARE i INT DEFAULT 1; SELECT TIMESTAMPADD(DAY,1,MAX(fecha)) INTO datFEC FROM bs.compradores_evolution; IF ISNULL(datFEC) THEN - - SELECT min(fecha) INTO datFEC + + SELECT min(fecha) INTO datFEC FROM bs.ventas; - + INSERT INTO bs.compradores_evolution( Id_Trabajador , fecha , importe) @@ -4268,19 +3928,19 @@ SELECT TIMESTAMPADD(DAY,1,MAX(fecha)) INTO datFEC FROM bs.compradores_evolution; JOIN vn2008.Tipos tp using(tipo_id) WHERE fecha = datFEC GROUP BY Id_Trabajador; - + SET datFEC = TIMESTAMPADD(DAY, 1, datFEC); - + END IF; - WHILE datFEC < CURDATE() DO - - IF i mod 150 = 0 THEN + WHILE datFEC < util.VN_CURDATE() DO + + IF i mod 150 = 0 THEN SELECT datFEC; END IF; - + SET i = i + 1; - + REPLACE bs.compradores_evolution( Id_Trabajador , fecha , importe) @@ -4288,7 +3948,7 @@ SELECT TIMESTAMPADD(DAY,1,MAX(fecha)) INTO datFEC FROM bs.compradores_evolution; SELECT Id_Trabajador , datFEC as fecha , sum(importe) as importe - + FROM ( @@ -4296,17 +3956,17 @@ SELECT TIMESTAMPADD(DAY,1,MAX(fecha)) INTO datFEC FROM bs.compradores_evolution; , importe FROM bs.compradores_evolution WHERE fecha = TIMESTAMPADD(DAY,-1,datFEC) -- las ventas acumuladas del dia anterior - + UNION ALL - + SELECT Id_Trabajador , importe * IF(v.fecha < datFEC,-1,1) -- se restan las ventas del año anterior y se suman las del actual FROM bs.ventas v JOIN vn2008.Tipos tp using(tipo_id) WHERE fecha IN (datFEC, TIMESTAMPADD(DAY,-365,datFEC)) AND reino_id != 6 - - )sub + + )sub GROUP BY Id_Trabajador; SET datFEC = TIMESTAMPADD(DAY,1,datFEC); @@ -4320,8 +3980,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `fondo_evolution_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4329,6 +3987,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `fondo_evolution_add`() BEGIN @@ -4336,49 +3996,49 @@ 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 + + SELECT TIMESTAMPADD(DAY,1,MAX(fecha)) + INTO datFEC FROM bs.fondo_maniobra; - - WHILE datFEC < CURDATE() DO - + + WHILE datFEC < util.VN_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 + JOIN vn.client c ON io.clientFk = c.id WHERE c.isRelevant - AND io.companyFk <> 1381 + 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 + 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 + 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 + 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 @@ -4386,7 +4046,7 @@ BEGIN WHERE fecha <= datFEC ) sub SET fondo_medio = media WHERE fecha = datFEC; - + SET datFEC = TIMESTAMPADD(DAY,1,datFEC); END WHILE; @@ -4398,8 +4058,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `fruitsEvolution` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4407,10 +4065,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `fruitsEvolution`() BEGIN -select Id_Cliente, +select Id_Cliente, Cliente, count(semana) as semanas, (w.code IS NOT NULL) isWorker from ( select distinct v.Id_Cliente, c.name as Cliente, week(fecha, 3) as semana @@ -4428,8 +4088,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `indicatorsUpdate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4437,6 +4095,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `indicatorsUpdate`(vDated DATE) BEGIN @@ -4451,45 +4111,44 @@ BEGIN -- Ventas totales del ultimo año UPDATE indicators - SET lastYearSales = + SET lastYearSales = (SELECT SUM(importe + recargo) FROM ventas v JOIN vn2008.empresa e ON e.id = v.empresa_id JOIN vn2008.empresa_grupo eg ON eg.empresa_grupo_id = e.empresa_grupo WHERE fecha BETWEEN oneYearBefore AND vDated AND eg.grupo = 'Verdnatura' - ) + ) WHERE updated = vDated; - + -- Greuge total acumulado UPDATE indicators - SET totalGreuge = + SET totalGreuge = (SELECT SUM(amount) FROM vn.greuge WHERE shipped <= vDated - ) + ) WHERE updated = vDated; -- Tasa de morosidad con respecto a las ventas del último mes UPDATE indicators - SET latePaymentRate = - (SELECT SUM(amount) - FROM bi.defaulters + SET latePaymentRate = + (SELECT SUM(amount) + FROM bi.defaulters WHERE date = vDated AND amount > 0) / - (SELECT SUM(importe + recargo) - FROM ventas + (SELECT SUM(importe + recargo) + FROM ventas WHERE fecha BETWEEN oneMonthBefore AND vDated) WHERE updated = vDated; -- Número de trabajadores activos UPDATE indicators - SET countEmployee = + SET countEmployee = (SELECT CAST(SUM(cl.hours_week) / 40 AS DECIMAL (10, 2)) - FROM postgresql.business b - JOIN postgresql.business_labour bl ON bl.business_id = b.business_id - JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = bl.calendar_labour_type_id - WHERE vDated BETWEEN b.date_start AND IFNULL(b.date_end, vDated) + FROM vn.business b + JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = b.calendarTypeFk + WHERE vDated BETWEEN b.started AND IFNULL(b.ended, vDated) AND b.companyCodeFk = 'VNL' ) WHERE updated = vDated; @@ -4504,7 +4163,7 @@ BEGIN -- Número de clientes que han comprado en los últimos 30 dias UPDATE indicators - SET lastMonthActiveClients = + SET lastMonthActiveClients = (SELECT COUNT(DISTINCT t.clientFk) FROM vn.ticket t WHERE t.shipped BETWEEN oneMonthBefore AND vDated @@ -4513,9 +4172,9 @@ BEGIN -- Número de clientes que no han comprado en los últimos 30 dias, pero compraron en los 30 anteriores UPDATE indicators - SET lastMonthLostClients = + SET lastMonthLostClients = (SELECT COUNT(lm.clientFk) - FROM + FROM (SELECT DISTINCT t.clientFk FROM vn.ticket t WHERE t.shipped BETWEEN oneMonthBefore AND vDated @@ -4532,9 +4191,9 @@ BEGIN -- Número de clientes que han comprado en los últimos 30 dias, pero no compraron en los 30 anteriores UPDATE indicators - SET lastMonthNewClients = + SET lastMonthNewClients = (SELECT COUNT(cm.clientFk) - FROM + FROM (SELECT DISTINCT t.clientFk FROM vn.ticket t WHERE t.shipped BETWEEN oneMonthBefore AND vDated @@ -4560,7 +4219,7 @@ BEGIN -- Cálculo de las ventas agrupado por semanas SELECT week INTO vWeek - FROM vn.time + FROM vn.time WHERE dated = vDated; TRUNCATE salesByWeek; @@ -4574,12 +4233,12 @@ BEGIN -- Indicador Ventas semana actual UPDATE indicators i - JOIN salesByWeek s ON s.week= vWeek + JOIN salesByWeek s ON s.week= vWeek AND s.year = YEAR(vDated) SET i.thisWeekSales = s.sales WHERE updated = vDated; - -- Indicador ventas semana actual en el año pasado + -- Indicador ventas semana actual en el año pasado UPDATE indicators i JOIN salesByWeek s ON s.week = vWeek AND s.year = YEAR(vDated)-1 @@ -4592,8 +4251,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `indicatorsUpdateLauncher` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4601,6 +4258,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `indicatorsUpdateLauncher`() BEGIN @@ -4610,15 +4269,15 @@ BEGIN SELECT IFNULL(TIMESTAMPADD(DAY,1,MAX(updated)), '2018-04-01') INTO vDated FROM bs.indicators; - - WHILE vDated < CURDATE() DO - + + WHILE vDated < util.VN_CURDATE() DO + CALL indicatorsUpdate(vDated); - + SELECT TIMESTAMPADD(DAY,1,MAX(updated)) INTO vDated FROM bs.indicators; - + END WHILE; END ;; @@ -4627,8 +4286,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `inspeccionSS_2021_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4636,6 +4293,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `inspeccionSS_2021_add`() BEGIN @@ -4643,29 +4302,30 @@ BEGIN TRUNCATE bs.inspeccionSS_2021; INSERT INTO bs.inspeccionSS_2021 - SELECT wbd.business_id , - w.id, - w.firstName, - w.lastName, - d.name , - wtc.timed , - cl.hours_week , - t.`year` , - t.week , - t.dated , - 0 AS orden - FROM vn.workerTimeControl wtc - JOIN vn.worker w ON w.id = wtc.userFk - JOIN vn.workerBusinessDated wbd ON wbd.workerFk = wtc.userFk AND wbd.dated = date(wtc.timed) - JOIN vn.time t ON t.dated = wbd.dated - JOIN postgresql.business_labour bl ON bl.business_id = wbd.business_id - JOIN postgresql.calendar_labour_type AS cl ON bl.calendar_labour_type_id = cl.calendar_labour_type_id - JOIN vn.department d ON d.id = bl.department_id - JOIN vn.department d2 ON d2.id = d.parentFk AND d2.name = 'PRODUCCION' - WHERE wtc.timed BETWEEN '2020-10-01' AND '2021-04-19' - AND d.lft BETWEEN d2.lft AND d2.rgt - AND lastName NOT LIKE 'FERRER%'; - + SELECT wbd.businessFk , + w.id, + w.firstName, + w.lastName, + d.name , + wtc.timed , + cl.hours_week , + t.`year` , + t.week , + t.dated , + 0 AS orden + FROM vn.workerTimeControl wtc + JOIN vn.worker w ON w.id = wtc.userFk + JOIN vn.workerBusinessDated wbd ON wbd.workerFk = wtc.userFk + AND wbd.dated = date(wtc.timed) + JOIN vn.time t ON t.dated = wbd.dated + JOIN vn.business b ON b.id = wbd.businessFk + JOIN postgresql.calendar_labour_type AS cl ON b.calendarTypeFk = cl.calendar_labour_type_id + JOIN vn.department d ON d.id = b.departmentFk + JOIN vn.department d2 ON d2.id = d.parentFk AND d2.name = 'PRODUCCION' + WHERE wtc.timed BETWEEN '2020-10-01' AND '2021-04-19' + AND d.lft BETWEEN d2.lft AND d2.rgt + AND lastName NOT LIKE 'FERRER%'; + SET @orden := 1; SET @id := 0; SET @day := 0; @@ -4674,15 +4334,13 @@ BEGIN SET orden = IF(id = @id AND day(timed) = @day, @orden := @orden + 1, @orden := 1), id = @id := id + (0 * @day := day(timed)) ORDER BY id, timed; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `m3Add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4690,21 +4348,23 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `m3Add`() BEGIN DECLARE datSTART DATE; DECLARE datEND DATE; - + SELECT TIMESTAMPADD(WEEK, -1,MAX(fecha)) INTO datSTART FROM bs.m3; - - SET datEND = TIMESTAMPADD(DAY,-1,CURDATE()); - - DELETE FROM bs.m3 + + SET datEND = TIMESTAMPADD(DAY,-1,util.VN_CURDATE()); + + DELETE FROM bs.m3 WHERE fecha >= datSTART; - + INSERT INTO bs.m3 (fecha, provinceFk, warehouseFk, m3, year, month, week, day, dayName, euros) SELECT v.fecha, a.provinceFk, t.warehouseFk, sum(s.quantity * ic.cm3delivery) / 1000000 AS m3, tm.year, tm.month, tm.week, tm.day, dayname(v.fecha), sum(importe) @@ -4726,8 +4386,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `manaCustomerUpdate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4735,6 +4393,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `manaCustomerUpdate`() BEGIN @@ -4747,51 +4407,51 @@ BEGIN DECLARE vManaBankId INT; DECLARE vManaGreugeTypeId INT; - SELECT id INTO vManaId + SELECT id INTO vManaId FROM vn.component WHERE code = 'mana'; - - SELECT id INTO vManaAutoId + + SELECT id INTO vManaAutoId FROM vn.component WHERE code = 'autoMana'; - + SELECT id INTO vClaimManaId FROM vn.component WHERE code = 'manaClaim'; - - SELECT id INTO vManaBankId + + SELECT id INTO vManaBankId FROM vn.bank WHERE code = 'mana'; - - SELECT id INTO vManaGreugeTypeId + + SELECT id INTO vManaGreugeTypeId FROM vn.greugeType WHERE code = 'mana'; SELECT IFNULL(MAX(dated), '2016-01-01') - INTO vFromDated + INTO vFromDated FROM vn.clientManaCache; - + DELETE FROM vn.clientManaCache WHERE dated = vFromDated; SELECT IFNULL(MAX(dated), '2016-01-01') - INTO vFromDated + INTO vFromDated FROM vn.clientManaCache; - WHILE timestampadd(DAY,30,vFromDated) < CURDATE() DO + WHILE timestampadd(DAY,30,vFromDated) < util.VN_CURDATE() DO SELECT timestampadd(DAY,30,vFromDated), - timestampadd(DAY,-90,vFromDated) - INTO + timestampadd(DAY,-90,vFromDated) + INTO vToDated, vForDeleteDated; - + DELETE FROM vn.clientManaCache WHERE dated <= vForDeleteDated; INSERT INTO vn.clientManaCache(clientFk, mana, dated) - SELECT + SELECT Id_Cliente, cast(sum(mana) as decimal(10,2)) as mana, - vToDated as dated - FROM + vToDated as dated + FROM ( SELECT cs.Id_Cliente, Cantidad * Valor as mana FROM vn2008.Tickets t @@ -4799,20 +4459,20 @@ BEGIN JOIN vn2008.Movimientos m on m.Id_Ticket = t.Id_Ticket JOIN vn2008.Movimientos_componentes mc on mc.Id_Movimiento = m.Id_Movimiento WHERE Id_Componente IN (vManaAutoId, vManaId, vClaimManaId) - AND t.Fecha > vFromDated + AND t.Fecha > vFromDated AND date(t.Fecha) <= vToDated UNION ALL SELECT r.Id_Cliente, - Entregado FROM vn2008.Recibos r WHERE Id_Banco = vManaBankId - AND Fechacobro > vFromDated + AND Fechacobro > vFromDated AND Fechacobro <= vToDated - + UNION ALL SELECT g.Id_Cliente, g.Importe FROM vn2008.Greuges g WHERE Greuges_type_id = vManaGreugeTypeId - AND Fecha > vFromDated + AND Fecha > vFromDated AND Fecha <= vToDated UNION ALL SELECT clientFk, mana @@ -4823,7 +4483,7 @@ BEGIN HAVING Id_Cliente; SET vFromDated = vToDated; - + END WHILE; END ;; @@ -4832,8 +4492,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `manaSpellers_actualize` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4841,10 +4499,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `manaSpellers_actualize`() BEGIN -/** +/** * Recalcula el valor del campo con el modificador de precio para el componente de maná automático. */ @@ -4852,19 +4512,17 @@ BEGIN JOIN (SELECT Id_Trabajador workerFk, FLOOR(SUM(importe)/12) pesoCarteraMensual FROM bs.vendedores - WHERE año * 100 + mes >= (YEAR(CURDATE()) -1) * 100 + MONTH(CURDATE()) + WHERE año * 100 + mes >= (YEAR(util.VN_CURDATE()) -1) * 100 + MONTH(util.VN_CURDATE()) GROUP BY workerFk ) lastYearSales USING(workerFk) SET pricesModifierRate = GREATEST(minRate, LEAST(maxRate, ROUND(- amount/lastYearSales.pesoCarteraMensual,3))); - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `nightTask_launchAll` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4872,6 +4530,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `nightTask_launchAll`() BEGIN @@ -4888,9 +4548,9 @@ BEGIN DECLARE vId INT; DECLARE rs CURSOR FOR - SELECT id, `schema`, `procedure` - FROM nightTask - WHERE finished <= CURDATE() + SELECT id, `schema`, `procedure` + FROM nightTask + WHERE finished <= util.VN_CURDATE() OR finished IS NULL ORDER BY `order`; @@ -4909,7 +4569,7 @@ BEGIN END IF; UPDATE nightTask - SET `started` = NOW(), + SET `started` = util.VN_NOW(), `finished` = NULL, `error` = NULL, `errorCode` = NULL @@ -4922,7 +4582,7 @@ BEGIN vError, vErrorCode ); - + IF vError IS NOT NULL THEN SET vNErrors = vNErrors + 1; @@ -4932,8 +4592,8 @@ BEGIN WHERE id = vId; ELSE UPDATE nightTask - SET finished = NOW(), - lastFinished = NOW() + SET finished = util.VN_NOW(), + lastFinished = util.VN_NOW() WHERE id = vId; END IF; END LOOP; @@ -4960,8 +4620,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `nightTask_launchTask` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4969,6 +4627,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `nightTask_launchTask`( vSchema VARCHAR(255), @@ -4992,15 +4652,13 @@ BEGIN vError = MESSAGE_TEXT, vErrorCode = RETURNED_SQLSTATE; - CALL util.exec(CONCAT('CALL `', vSchema ,'`.`', vProcedure ,'`')); + CALL util.exec(CONCAT('CALL `', vSchema ,'`.`', vProcedure ,'`')); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `payMethodClientAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5008,33 +4666,33 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `payMethodClientAdd`() BEGIN - INSERT IGNORE INTO `bs`.`payMethodClient` (dated, payMethodFk, clientFk) - SELECT CURDATE(), c.payMethodFk, c.id - FROM vn.client c + INSERT IGNORE INTO `bs`.`payMethodClient` (dated, payMethodFk, clientFk) + SELECT util.VN_CURDATE(), c.payMethodFk, c.id + FROM vn.client c JOIN vn.payMethod p ON c.payMethodFk = p.id; - + TRUNCATE `bs`.`payMethodClientEvolution` ; - + INSERT INTO `bs`.`payMethodClientEvolution` (dated, payMethodName, amountClient, amount, equalizationTax) - SELECT p.dated, pm.name, COUNT(p.clientFk), SUM(sub.importe) , SUM(sub.recargo) + SELECT p.dated, pm.name, COUNT(p.clientFk), SUM(sub.importe) , SUM(sub.recargo) FROM bs.payMethodClient p - JOIN (SELECT SUM(v.importe) AS importe, SUM(v.recargo) as recargo, v.fecha, v.Id_cliente + JOIN (SELECT SUM(v.importe) AS importe, SUM(v.recargo) as recargo, v.fecha, v.Id_cliente FROM bs.ventas v WHERE v.fecha>= (SELECT MIN(dated) FROM bs. payMethodClient) GROUP BY v.Id_cliente, v.fecha) sub ON sub.fecha = p.dated AND sub.Id_cliente = p.ClientFk JOIN vn.payMethod pm ON p.payMethodFk = pm.id - GROUP BY dated,payMethodFk; + GROUP BY dated,payMethodFk; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `saleGraphic` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5042,21 +4700,23 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `saleGraphic`(IN vItemFk INT, IN vTypeFk INT, IN vCategoryFk INT, IN vFromDate DATE, IN vToDate DATE, IN vProducerFk INT) BEGIN - + DECLARE vFromDateLastYear DATE; DECLARE vToDateLastYear DATE; DECLARE vFromDateTwoYearsAgo DATE; DECLARE vToDateTwoYearsAgo DATE; - + SET vItemFk = IFNULL(vItemFk,0); SET vTypeFk = IFNULL(vTypeFk, 0); SET vCategoryFk = IFNULL(vCategoryFk,0); - SET vFromDate = IFNULL(vFromDate,CURDATE()); - SET vToDate = IFNULL(vToDate,CURDATE()); + SET vFromDate = IFNULL(vFromDate,util.VN_CURDATE()); + SET vToDate = IFNULL(vToDate,util.VN_CURDATE()); SET vProducerFk = IFNULL(vProducerFk,0); SET vFromDateLastYear = TIMESTAMPADD(YEAR,-1,vFromDate); @@ -5066,27 +4726,25 @@ BEGIN SELECT s.quantity, CAST(v.importe AS DECIMAL(10,0)) importe, v.fecha FROM bs.ventas v - JOIN vn.sale s ON s.id = v.Id_Movimiento - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.sale s ON s.id = v.Id_Movimiento + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk WHERE vItemFk IN (i.id, 0) AND vTypeFk IN (i.typeFk, 0) AND vCategoryFk IN (it.categoryFk, 0) AND vProducerFk IN (i.producerFk, 0) AND (v.fecha BETWEEN vFromDate AND vToDate OR v.fecha BETWEEN vFromDateLastYear AND vToDateLastYear - OR v.fecha BETWEEN vFromDateTwoYearsAgo AND vToDateTwoYearsAgo + OR v.fecha BETWEEN vFromDateTwoYearsAgo AND vToDateTwoYearsAgo ); - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `salePersonEvolutionAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5094,32 +4752,32 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `salePersonEvolutionAdd`(IN vDateStart DATETIME) BEGIN - DELETE FROM bs.salePersonEvolution - WHERE dated <= DATE_SUB(CURDATE(), INTERVAL 1 YEAR); - - + DELETE FROM bs.salePersonEvolution + WHERE dated <= DATE_SUB(util.VN_CURDATE(), INTERVAL 1 YEAR); + + INSERT INTO bs.salePersonEvolution (dated, amount, equalizationTax, salesPersonFk) - SELECT fecha dated, - CAST(SUM(importe) AS DECIMAL(10,2) ) amount, + SELECT fecha dated, + CAST(SUM(importe) AS DECIMAL(10,2) ) amount, CAST(SUM(recargo) AS DECIMAL(10,2) ) equalizationTax , IFNULL(salesPersonFk,0) salesPersonFk FROM bs.ventas v - JOIN vn.client c ON v.Id_Cliente = c.id + JOIN vn.client c ON v.Id_Cliente = c.id JOIN vn.company co ON co.id = v.empresa_id WHERE co.code = "VNL" AND fecha >= vDateStart GROUP BY v.fecha,c.salesPersonFk - ORDER BY salesPersonFk,dated ASC; + ORDER BY salesPersonFk,dated ASC; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `salesByclientSalesPerson_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5127,14 +4785,16 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `salesByclientSalesPerson_add`(vDatedFrom DATE) BEGIN IF vDatedFrom IS NULL THEN - SELECT CURDATE() - INTERVAL DAY(CURDATE())-1 DAY - INTERVAL 1 MONTH INTO vDatedFrom; + SELECT util.VN_CURDATE() - INTERVAL DAY(util.VN_CURDATE())-1 DAY - INTERVAL 1 MONTH INTO vDatedFrom; END IF; - + INSERT INTO salesByclientSalesPerson( dated, salesPersonFk, clientFk, amount, equalizationTax) SELECT v.fecha, c.salesPersonFk, @@ -5146,21 +4806,19 @@ BEGIN WHERE v.fecha >= vDatedFrom GROUP BY v.fecha,c.salesPersonFk,v.Id_Cliente ON DUPLICATE KEY UPDATE amount= VALUES(amount), equalizationTax= VALUES(equalizationTax); - + UPDATE salesByclientSalesPerson s JOIN vn.newBornSales n ON n.dated = s.dated AND n.clientFk = s.clientFk SET s.amountNewBorn = n.amount - WHERE n.dated >= vDatedFrom; - + WHERE n.dated >= vDatedFrom; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `salesByItemTypeDay_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5168,169 +4826,171 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `salesByItemTypeDay_add`(vDateStart DATE, vDateEnd DATE) BEGIN /** * Almacena datos relativos a las ventas de artículos agrupados por reino y familia * - * @param vDateStart - * @param vDateEnd + * @param vDateStart + * @param vDateEnd */ - - DELETE FROM bs.salesByItemTypeDay + + DELETE FROM bs.salesByItemTypeDay WHERE dated BETWEEN vDateStart AND vDateEnd; - + INSERT INTO bs.salesByItemTypeDay (itemTypeFk, itemCategoryFk, dated) - SELECT id, categoryFk, dated + SELECT id, categoryFk, dated FROM vn.itemType JOIN vn.`time` WHERE dated BETWEEN vDateStart AND vDateEnd; - + UPDATE bs.salesByItemTypeDay it - JOIN (SELECT ic.id itemCategoryFk, + JOIN (SELECT ic.id itemCategoryFk, it.id itemTypeFk, bs.dated, SUM(bs.amount) netSale FROM bs.sale bs JOIN vn.itemType it ON it.id = bs.typeFk - JOIN vn .itemCategory ic ON ic.id = it.categoryFk + JOIN vn .itemCategory ic ON ic.id = it.categoryFk JOIN vn.client c on c.id = bs.clientFk JOIN vn.sale s ON s.id = bs.saleFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.ticket t ON t.id = s.ticketFk JOIN vn.`time` ti ON ti.dated = bs.dated - WHERE ic.merchandise + WHERE ic.merchandise AND bs.dated BETWEEN vDateStart AND vDateEnd GROUP BY ic.id, it.id, bs.dated) sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk SET it.netSale = sub.netSale; - - + + UPDATE bs.salesByItemTypeDay it - JOIN (SELECT ic.id AS itemCategoryFk, + JOIN (SELECT ic.id AS itemCategoryFk, it.id AS itemTypeFk, bs.dated, SUM(i.stems * s.quantity) stems FROM bs.sale bs JOIN vn.itemType it ON it.id = bs.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk JOIN vn.sale s ON s.id = bs.saleFk - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.item i ON i.id = s.itemFk + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.item i ON i.id = s.itemFk JOIN vn.`time` tm ON tm.dated = bs.dated - WHERE ic.merchandise + WHERE ic.merchandise AND bs.dated BETWEEN vDateStart AND vDateEnd - GROUP BY ic.id, it.id, bs.dated) sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk + GROUP BY ic.id, it.id, bs.dated) sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk SET it.stems = sub.stems; - - + + UPDATE bs.salesByItemTypeDay it - JOIN (SELECT ic.id AS itemCategoryFk, + JOIN (SELECT ic.id AS itemCategoryFk, it.id AS itemTypeFk, DATE(t.shipped) dated, COUNT(DISTINCT(i.id)) `references` FROM vn.ticket t - 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 - JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.merchandise + 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 + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + WHERE ic.merchandise AND t.shipped BETWEEN vDateStart AND util.dayEnd(vDateEnd) GROUP BY ic.id, it.id, dated) sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk SET it.`references` = sub.`references`; - + UPDATE bs.salesByItemTypeDay it - JOIN (SELECT ic.id AS itemCategoryFk, + JOIN (SELECT ic.id AS itemCategoryFk, it.id AS itemTypeFk, DATE(t.shipped) dated, SUM(i.stems*s.quantity) AS trash FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk - JOIN vn.client c ON c.id = t.clientFk - WHERE c.name = 'BASURA' + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.client c ON c.id = t.clientFk + WHERE c.name = 'BASURA' AND t.shipped BETWEEN vDateStart AND util.dayEnd(vDateEnd) GROUP BY ic.id, it.id, dated) sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk - SET it.trash = sub.trash; - + SET it.trash = sub.trash; + UPDATE bs.salesByItemTypeDay it - JOIN (SELECT ic.id AS itemCategoryFk, + JOIN (SELECT ic.id AS itemCategoryFk, it.id AS itemTypeFk, DATE(t.shipped) dated, SUM(IFNULL(i.stems, 1) * s.quantity) AS faults FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk - JOIN vn.client c ON c.id = t.clientFk - WHERE c.name = 'FALTAS' + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.client c ON c.id = t.clientFk + WHERE c.name = 'FALTAS' AND t.shipped BETWEEN vDateStart AND util.dayEnd(vDateEnd) GROUP BY ic.id, it.id, dated) sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk - SET it.`faults` = sub.`faults`; - + SET it.`faults` = sub.`faults`; + UPDATE bs.salesByItemTypeDay it - JOIN (SELECT ic.id AS itemCategoryFk, + JOIN (SELECT ic.id AS itemCategoryFk, it.id AS itemTypeFk, DATE(t.shipped) dated, - SUM((cb.quantity * s.price * (100 - s.discount) / 100) * ((cc.maxResponsibility - c.responsibility )/4 )) accepted, + SUM((cb.quantity * s.price * (100 - s.discount) / 100) * ((cc.maxResponsibility - c.responsibility )/4 )) accepted, SUM(cb.quantity * s.price * (100 - s.discount) / 100) claimed FROM vn.claim c JOIN vn.claimBeginning cb ON cb.claimFk = c.id JOIN vn.sale s ON s.id = cb.saleFk JOIN vn.ticket t ON t.id = s.ticketFk JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk JOIN vn.claimConfig cc - WHERE ic.merchandise + WHERE ic.merchandise AND t.shipped BETWEEN vDateStart AND util.dayEnd(vDateEnd) GROUP BY ic.id, it.id, dated) sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk SET it.accepted = sub.accepted, it.claimed = sub.claimed; - + UPDATE bs.salesByItemTypeDay it - JOIN(SELECT itemCategoryFk, - itemTypeFk, - dated, - CAST(SUM(sale) AS DECIMAL(10,2)) sale, + JOIN(SELECT itemCategoryFk, + itemTypeFk, + dated, + CAST(SUM(sale) AS DECIMAL(10,2)) sale, CAST(SUM(buy) AS DECIMAL(10,2))buy - FROM(SELECT ic.id itemCategoryFk, + FROM(SELECT ic.id itemCategoryFk, it.id itemTypeFk, bs.dated, SUM(bs.amount) sale, 0 buy FROM bs.sale bs JOIN vn.itemType it ON it.id = bs.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk JOIN vn.client c on c.id = bs.clientFk JOIN vn.`time` tm ON tm.dated = bs.dated JOIN vn.sale s ON s.id = bs.saleFk - JOIN vn.item i ON i.id = s.itemFk - WHERE ic.merchandise + JOIN vn.item i ON i.id = s.itemFk + WHERE ic.merchandise AND bs.dated BETWEEN vDateStart AND vDateEnd GROUP BY ic.id, it.id, bs.dated - UNION ALL - SELECT ic.id, + UNION ALL + SELECT ic.id, it.id, t.landed, 0 , SUM(b.buyingValue * b.quantity) - FROM vn.entry e - JOIN vn.travel t ON t.id = e.travelFk - JOIN vn.buy b ON b.entryFk = e.id - JOIN vn.item i ON i.id = b.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk + FROM vn.entry e + JOIN vn.travel t ON t.id = e.travelFk + JOIN vn.buy b ON b.entryFk = e.id + JOIN vn.item i ON i.id = b.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk WHERE ic.merchandise AND t.landed BETWEEN vDateStart AND vDateEnd - GROUP BY ic.id, it.id, t.landed) sub + GROUP BY ic.id, it.id, t.landed) sub GROUP BY itemCategoryFk, itemTypeFk, dated) sub2 ON sub2.dated = it.dated AND sub2.itemCategoryFk = it.itemCategoryFk AND sub2.itemTypeFk = it.itemTypeFk SET it.sale = sub2.sale, it.buy = sub2.buy; - + DROP TEMPORARY TABLE IF EXISTS tmp.`component`; CREATE TEMPORARY TABLE tmp.`component` (PRIMARY KEY (`itemTypeFk`,`dated`), @@ -5338,18 +4998,18 @@ BEGIN KEY `salesByItemTypeDay_dated_idx` (`dated`)) ENGINE = MEMORY SELECT DATE(t.shipped) dated, - ic.id itemCategoryFk, + ic.id itemCategoryFk, it.id itemTypeFk, SUM(s.quantity * IF(c.code = 'purchaseValue', sc.value,0)) costComponent, SUM(s.quantity * IF(ct.isMargin, sc.value,0)) marginComponent FROM vn.ticket t - JOIN vn.sale s ON t.id = s.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk - JOIN vn.saleComponent sc ON sc.saleFk = s.id - STRAIGHT_JOIN vn.component c ON c.id = sc.componentFk - JOIN vn.componentType ct ON ct.id = c.typeFk + JOIN vn.sale s ON t.id = s.ticketFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.saleComponent sc ON sc.saleFk = s.id + STRAIGHT_JOIN vn.component c ON c.id = sc.componentFk + JOIN vn.componentType ct ON ct.id = c.typeFk WHERE t.shipped BETWEEN vDateStart AND util.dayEnd(vDateEnd) GROUP BY ic.id, it.id, dated; @@ -5358,23 +5018,23 @@ BEGIN SET it.costComponent = c.costComponent, it.marginComponent = c.marginComponent, it.saleComponent = c.costComponent + c.marginComponent; - - DROP TEMPORARY TABLE tmp.`component`; - + + DROP TEMPORARY TABLE tmp.`component`; + /* UPDATE bs.salesByItemTypeDay it JOIN(SELECT DATE(t.shipped) dated, - ic.id itemCategoryFk, + ic.id itemCategoryFk, it.id itemTypeFk, SUM(s.quantity * IF(c.code = 'purchaseValue', sc.value,0)) costComponent, SUM(s.quantity * IF(ct.isMargin, sc.value,0)) marginComponent FROM vn.ticket t - JOIN vn.sale s ON t.id = s.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk - JOIN vn.saleComponent sc ON sc.saleFk = s.id - STRAIGHT_JOIN vn.component c ON c.id = sc.componentFk - JOIN vn.componentType ct ON ct.id = c.typeFk + JOIN vn.sale s ON t.id = s.ticketFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.saleComponent sc ON sc.saleFk = s.id + STRAIGHT_JOIN vn.component c ON c.id = sc.componentFk + JOIN vn.componentType ct ON ct.id = c.typeFk JOIN vn.`time` tm ON tm.dated = DATE(t.shipped) WHERE t.shipped BETWEEN vDateStart AND util.dayEnd(vDateEnd) GROUP BY ic.id, it.id, dated)sub ON sub.dated = it.dated AND sub.itemCategoryFk = it.itemCategoryFk AND sub.itemTypeFk = it.itemTypeFk @@ -5387,8 +5047,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `salesByItemTypeDay_addLauncher` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5396,12 +5054,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `salesByItemTypeDay_addLauncher`() BEGIN DECLARE vDateStart,vDateEnd INT; - SELECT DATE_SUB(CURDATE(), INTERVAL 30 DAY), CURDATE() INTO vDateStart,vDateEnd; + SELECT DATE_SUB(util.VN_CURDATE(), INTERVAL 30 DAY), util.VN_CURDATE() INTO vDateStart,vDateEnd; CALL bs.salesByItemTypeDay_add(vDateStart, vDateEnd); END ;; DELIMITER ; @@ -5409,8 +5069,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `salesMonthlySnapshot_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5418,6 +5076,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `salesMonthlySnapshot_add`() BEGIN @@ -5429,13 +5089,13 @@ BEGIN DECLARE vMaxWorkersWithPlusNewClient INT; DECLARE vRowCount INT DEFAULT 1; DECLARE vMaxRow INT; - DECLARE vPreviusMonth DATETIME DEFAULT CURDATE(); + DECLARE vPreviusMonth DATETIME DEFAULT util.VN_CURDATE(); SELECT executionDay, maxPlusNewClient, plusDifference, maxScoreNewClient, scoreDifference, salesPersonWithPlusNewClient INTO vExecutionDay, vPlusNewClient, vPlusDifference, vScoreNewClient, vScoreDifference, vMaxWorkersWithPlusNewClient FROM vn.commissionConfig; - IF(DAY(CURDATE()) = vExecutionDay) THEN + IF(DAY(util.VN_CURDATE()) = vExecutionDay) THEN -- COMERCIAL Y EQUIPO DROP TEMPORARY TABLE IF EXISTS tmp.salesPersons; CREATE TEMPORARY TABLE tmp.salesPersons @@ -5446,13 +5106,13 @@ BEGIN FROM vn.department d JOIN vn.workerDepartment wd ON wd.departmentFk = d.id JOIN account.user u ON u.id = wd.workerFk - JOIN vn.department d2 ON d2.id = d.parentFk + JOIN vn.department d2 ON d2.id = d.parentFk WHERE d2.code = 'VT'; -- VENTA, COMISIÓN DROP TEMPORARY TABLE IF EXISTS tmp.sale; CREATE TEMPORARY TABLE tmp.sale - ENGINE = MEMORY + ENGINE = MEMORY SELECT YEAR(s.dated) year, MONTH(s.dated) month, u.name, @@ -5462,7 +5122,7 @@ BEGIN cc.minimumSalesByQuarter/3 minimumSalesByMonth FROM bs.salesByclientSalesPerson s - JOIN vn.client c ON c.id = s.salesPersonFk + JOIN vn.client c ON c.id = s.salesPersonFk JOIN account.user u ON u.id = s.salesPersonFk JOIN vn.commissionConfig cc WHERE dated BETWEEN util.firstDayOfMonth(vPreviusMonth) AND LAST_DAY(vPreviusMonth) @@ -5487,8 +5147,8 @@ BEGIN IFNULL(v.portfolioWeight,0) AS walletWeigth FROM bs.vendedores v JOIN account.`user` u ON u.id = v.Id_Trabajador - JOIN vn.saleGoal sg ON sg.`year` = YEAR(vPreviusMonth) - AND sg.`month` = MONTH(vPreviusMonth) + JOIN vn.saleGoal sg ON sg.`year` = YEAR(vPreviusMonth) + AND sg.`month` = MONTH(vPreviusMonth) AND v.portfolioWeight BETWEEN sg.walletWeightFrom AND sg.walletWeightTo WHERE v.año = YEAR(vPreviusMonth)-1 AND v.mes = MONTH(vPreviusMonth) GROUP BY u.id @@ -5609,7 +5269,7 @@ BEGIN LEFT JOIN tmp.newClients nc ON nc.workerFk = sp.workerFk ) sub ORDER BY salesPersonName; - + DROP TEMPORARY TABLE tmp.salesPersons, tmp.sale, @@ -5623,8 +5283,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `salesPersonEvolution_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5632,47 +5290,49 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `salesPersonEvolution_add`() BEGIN DECLARE vDated DATE; DECLARE vCont INT DEFAULT 1; - SELECT TIMESTAMPADD(DAY,1,MAX(dated)) INTO vDated + SELECT TIMESTAMPADD(DAY,1,MAX(dated)) INTO vDated FROM bs.salesPersonEvolution; IF ISNULL(vDated) THEN - SELECT MIN(dated) INTO vDated + SELECT MIN(dated) INTO vDated FROM salesByclientSalesPerson; - + INSERT INTO bs.salesPersonEvolution( salesPersonFk, dated, amount, equalizationTax, amountNewBorn ) SELECT salesPersonFk, dated, amount, equalizationTax, amountNewBorn - FROM salesByclientSalesPerson + FROM salesByclientSalesPerson WHERE dated = vDated GROUP BY salesPersonFk; - + SET vDated = TIMESTAMPADD(DAY, 1, vDated); END IF; - - WHILE vDated < CURDATE() DO - + + WHILE vDated < util.VN_CURDATE() DO + SET vCont = vCont + 1; - + REPLACE bs.salesPersonEvolution( salesPersonFk, dated, amount) - SELECT salesPersonFk, vDated, SUM(amount) + SELECT salesPersonFk, vDated, SUM(amount) FROM(SELECT salesPersonFk, amount - FROM salesPersonEvolution + FROM salesPersonEvolution WHERE dated = TIMESTAMPADD(DAY,-1,vDated) -- amount acumulado día anterior UNION ALL SELECT salesPersonFk, amount * IF(dated < vDated,-1,1) -- suma amount año actual/ resta amount año anterior - FROM salesByclientSalesPerson + FROM salesByclientSalesPerson WHERE dated IN (vDated, TIMESTAMPADD(DAY,-365,vDated)) )sub GROUP BY salesPersonFk; - + SET vDated = TIMESTAMPADD(DAY,1,vDated); - + END WHILE; END ;; DELIMITER ; @@ -5680,8 +5340,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `salesPerson_updatePortfolio` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5689,19 +5347,21 @@ DELIMITER ; /*!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`@`localhost` PROCEDURE `salesPerson_updatePortfolio`() BEGIN /** * Actualiza el campo portfolioWeight que indica el peso de la cartera del comercial * - */ - DECLARE vStarted DATE DEFAULT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -17 MONTH), '%Y-%m-01'); - + */ + DECLARE vStarted DATE DEFAULT DATE_FORMAT(DATE_ADD(util.VN_CURDATE(), INTERVAL -17 MONTH), '%Y-%m-01'); + UPDATE vendedores v - JOIN vn.`time` t ON t.`year` = v.año AND t.`month` = v.mes - SET v.portfolioWeight = NULL - WHERE t.dated BETWEEN vStarted AND CURDATE(); + JOIN vn.`time` t ON t.`year` = v.año AND t.`month` = v.mes + SET v.portfolioWeight = NULL + WHERE t.dated BETWEEN vStarted AND util.VN_CURDATE(); UPDATE vendedores v JOIN ( @@ -5712,10 +5372,10 @@ BEGIN FROM vn.`time` t STRAIGHT_JOIN bs.ventas v ON t.dated = v.fecha JOIN vn.`client` c ON c.id = v.Id_Cliente - WHERE c.lastSalesPersonFk IS NOT NULL - AND v.fecha BETWEEN vStarted AND CURDATE() + WHERE c.lastSalesPersonFk IS NOT NULL + AND v.fecha BETWEEN vStarted AND util.VN_CURDATE() GROUP BY c.lastSalesPersonFk, t.`year`, t.`month` - ) sub ON sub.lastSalesPersonFk = v.Id_Trabajador AND sub.`year` = v.año AND sub.`month`= v.mes + ) sub ON sub.lastSalesPersonFk = v.Id_Trabajador AND sub.`year` = v.año AND sub.`month`= v.mes SET v.portfolioWeight = sub.importe; END ;; DELIMITER ; @@ -5723,8 +5383,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `vendedores_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5732,35 +5390,37 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `vendedores_add`(intYEAR INT, vQuarter INT) BEGIN DECLARE vCommissionRate DOUBLE; - + SELECT rate INTO vCommissionRate FROM vn.commissionConfig; - + -- vaciar tabla DELETE v.* FROM vendedores v JOIN vn.`time` t ON t.`year` = v.año AND t.`month` = v.mes WHERE t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter; - + REPLACE vendedores(Id_Trabajador, año, mes, importe, comision, portfolioWeight) SELECT c.Id_Trabajador , intYEAR , MONTH(v.fecha) intMONTH - , sum(v.importe) - , sum(v.importe) * vCommissionRate - , sum(v.importe) + , sum(v.importe) + , sum(v.importe) * vCommissionRate + , sum(v.importe) FROM ventas v JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente JOIN vn.`time` t on t.dated = v.fecha WHERE c.Id_Trabajador is not null AND t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter GROUP BY c.Id_Trabajador, t.`month`; - + -- Sustitucion cedidas - lended INSERT INTO vendedores (Id_Trabajador, mes, año, importe, comision) SELECT c.salesPersonFk @@ -5776,7 +5436,7 @@ BEGIN GROUP BY c.salesPersonFk, t.`month` ON DUPLICATE KEY UPDATE comision = comision + VALUES(comision), importe = importe + VALUES(importe); - + -- Sustitucion arrendadas - borrowed INSERT INTO vendedores (Id_Trabajador, mes, año, importe, comision) SELECT scd.substituteFk @@ -5793,15 +5453,13 @@ BEGIN ON DUPLICATE KEY UPDATE comision = comision + VALUES(comision), importe = importe + VALUES(importe); - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `vendedores_add_launcher` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5809,24 +5467,24 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `vendedores_add_launcher`() BEGIN DECLARE vDatedFrom DATE; - - CALL bs.vendedores_add(YEAR(CURDATE()),QUARTER(CURDATE())); + + CALL bs.vendedores_add(YEAR(util.VN_CURDATE()),QUARTER(util.VN_CURDATE())); CALL bs.vendedores_evolution_add; - SELECT util.firstDayOfMonth(CURDATE())- INTERVAL 1 MONTH INTO vDatedFrom; + SELECT util.firstDayOfMonth(util.VN_CURDATE())- INTERVAL 1 MONTH INTO vDatedFrom; CALL bs.salesByclientSalesPerson_add(vDatedFrom); - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `vendedores_evolution_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5834,6 +5492,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `vendedores_evolution_add`() BEGIN @@ -5846,20 +5506,20 @@ Inserta en la tabla compradores_evolution las ventas acumuladas en el ultimo mes DECLARE vDateFrom DATE; DECLARE vDateTo DATE; - SET vCurYear = year(CURDATE()); - SET vCurMonth = month(CURDATE()); + SET vCurYear = year(util.VN_CURDATE()); + SET vCurMonth = month(util.VN_CURDATE()); SELECT IFNULL(max(year),vCurYear-1), IFNULL(max(month),1) INTO vYear, vMonth FROM bs.vendedores_evolution; WHILE (vYear < vCurYear) OR (vYear = vCurYear AND vMonth < vCurMonth) DO - + SELECT max(dated), TIMESTAMPADD(DAY,-364,max(dated)) INTO vDateTo, vDateFrom FROM vn.time WHERE year = vYear AND month = vMonth; - + REPLACE bs.vendedores_evolution( workerFk , year , month @@ -5868,14 +5528,14 @@ Inserta en la tabla compradores_evolution las ventas acumuladas en el ultimo mes , vYear as year , vMonth as month , sum(v.importe) as sales - FROM bs.ventas v + FROM bs.ventas v JOIN vn.client c on c.id = v.Id_Cliente WHERE v.fecha BETWEEN vDateFrom AND vDateTo AND c.salesPersonFk is not null GROUP BY c.salesPersonFk; SET vMonth = vMonth + 1; - + IF vMonth = 13 THEN SET vMonth = 1; SET vYear = vYear + 1; @@ -5888,8 +5548,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ventas_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5897,6 +5555,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ventas_add`( IN vStarted DATETIME, @@ -5905,7 +5565,7 @@ BEGIN /** * Añade las ventas que se realizaron de hace * una semana hasta hoy -* +* * @param vStarted Fecha de inicio * @param vEnded Fecha de finalizacion * @@ -5913,8 +5573,8 @@ BEGIN DECLARE vStartingDate DATETIME; DECLARE vEndingDate DATETIME; - IF vStarted < TIMESTAMPADD(YEAR,-5,CURDATE()) - OR vEnded < TIMESTAMPADD(YEAR,-5,CURDATE()) THEN + IF vStarted < TIMESTAMPADD(YEAR,-5,util.VN_CURDATE()) + OR vEnded < TIMESTAMPADD(YEAR,-5,util.VN_CURDATE()) THEN CALL util.throw('fechaDemasiadoAntigua'); END IF; @@ -5922,8 +5582,8 @@ BEGIN SET vStartingDate = vStarted ; SET vEndingDate = vn2008.dayend(vStartingDate); - DELETE - FROM sale + DELETE + FROM sale WHERE dated BETWEEN vStartingDate AND vEnded; WHILE vEndingDate <= vEnded DO @@ -5944,28 +5604,28 @@ 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 = s.ticketFk - JOIN vn.address a ON a.id = t.addressFk + JOIN vn.address a ON a.id = t.addressFk JOIN vn.client cl ON cl.id = a.clientFk WHERE t.shipped BETWEEN vStartingDate AND vEndingDate AND s.quantity <> 0 AND s.discount <> 100 - AND ic.merchandise + AND ic.merchandise GROUP BY sc.saleFk HAVING IFNULL(importe,0) <> 0 OR IFNULL(recargo,0) <> 0; UPDATE sale s JOIN ( - SELECT s.id, + SELECT s.id, SUM(s.quantity * sc.value ) margen, s.quantity * s.price * (100 - s.discount ) / 100 pvp FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.ticket t ON t.id = s.ticketFk JOIN vn.saleComponent sc ON sc.saleFk = s.id - JOIN vn.component c ON c.id = sc.componentFk - JOIN vn.componentType ct ON ct.id = c.typeFk + JOIN vn.component c ON c.id = sc.componentFk + JOIN vn.componentType ct ON ct.id = c.typeFk WHERE t.shipped BETWEEN vStartingDate AND vEndingDate AND ct.isMargin = TRUE - GROUP BY s.id) sub ON sub.id = s.saleFk + GROUP BY s.id) sub ON sub.id = s.saleFk SET s.margin = sub.margen + s.amount + s.surcharge - sub.pvp; SET vStartingDate = TIMESTAMPADD(DAY,1, vStartingDate); @@ -5979,8 +5639,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ventas_add_launcher` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5988,17 +5646,19 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ventas_add_launcher`() BEGIN - + /** * Añade las ventas que se realizaron de hace * una semana hasta hoy * **/ - CALL bs.ventas_add(timestampadd(week,-1,curdate()),curdate()); + CALL bs.ventas_add(timestampadd(week,-1,util.VN_CURDATE()),util.VN_CURDATE()); END ;; DELIMITER ; @@ -6006,8 +5666,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ventas_contables_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6015,10 +5673,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ventas_contables_add`(IN vYear INT, IN vMonth INT) BEGIN - + /** * Reemplaza las ventas contables del último año. * Es el origen de datos para el balance de Entradas @@ -6030,8 +5690,8 @@ BEGIN DECLARE TIPO_PATRIMONIAL INT DEFAULT 188; - DELETE FROM bs.ventas_contables - WHERE year = vYear + DELETE FROM bs.ventas_contables + WHERE year = vYear AND month = vMonth; DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; @@ -6042,7 +5702,7 @@ BEGIN FROM vn2008.Tickets t JOIN vn2008.Facturas f ON f.Id_Factura = t.Factura WHERE year(f.Fecha) = vYear - AND month(f.Fecha) = vMonth; + AND month(f.Fecha) = vMonth; INSERT INTO bs.ventas_contables(year , month @@ -6052,7 +5712,7 @@ BEGIN , tipo_id , empresa_id , gasto) - + SELECT vYear , vMonth , round(sum(Cantidad * Preu * (100 - m.Descuento)/100)) @@ -6064,13 +5724,13 @@ BEGIN , tp.reino_id , a.tipo_id , t.empresa_id - , 7000000000 + , 7000000000 + IF(e.empresa_grupo = e2.empresa_grupo ,1 ,IF(e2.empresa_grupo,2,0) - ) * 1000000 + ) * 1000000 + tp.reino_id * 10000 as Gasto - FROM vn2008.Movimientos m + FROM vn2008.Movimientos m JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente @@ -6084,7 +5744,7 @@ BEGIN AND m.Descuento <> 100 AND a.tipo_id != TIPO_PATRIMONIAL GROUP BY grupo, reino_id, tipo_id, empresa_id, Gasto; - + INSERT INTO bs.ventas_contables(year , month , venta @@ -6103,17 +5763,17 @@ BEGIN ) as grupo , NULL , NULL - , t.companyFk + , t.companyFk , 7050000000 - FROM vn.ticketService ts + FROM vn.ticketService ts JOIN vn.ticket t ON ts.ticketFk = t.id - JOIN vn.address a on a.id = t.addressFk - JOIN vn.client cl on cl.id = a.clientFk + JOIN vn.address a on a.id = t.addressFk + JOIN vn.client cl on cl.id = a.clientFk JOIN tmp.ticket_list tt on tt.Id_Ticket = t.id - JOIN vn.company c on c.id = t.companyFk + JOIN vn.company c on c.id = t.companyFk LEFT JOIN vn.company c2 on c2.clientFk = cl.id - GROUP BY grupo, t.companyFk ; - + GROUP BY grupo, t.companyFk ; + DROP TEMPORARY TABLE tmp.ticket_list; END ;; DELIMITER ; @@ -6121,8 +5781,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ventas_contables_add_launcher` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6130,17 +5788,19 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ventas_contables_add_launcher`() BEGIN - + /** * Reemplaza las ventas contables del último año. * Es el origen de datos para el balance de Entradas * **/ - - CALL bs.ventas_contables_add(YEAR(TIMESTAMPADD(MONTH,-1,CURDATE())), MONTH(TIMESTAMPADD(MONTH,-1,CURDATE()))); + + CALL bs.ventas_contables_add(YEAR(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())), MONTH(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()))); END ;; DELIMITER ; @@ -6148,8 +5808,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ventas_contables_por_cliente` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6157,15 +5815,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ventas_contables_por_cliente`(IN vYear INT, IN vMonth INT) BEGIN - + /** * Muestra las ventas (€) de cada cliente * dependiendo del año */ - + DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list @@ -6174,8 +5834,8 @@ BEGIN FROM vn2008.Tickets t JOIN vn2008.Facturas f ON f.Id_Factura = t.Factura WHERE year(f.Fecha) = vYear - AND month(f.Fecha) = vMonth; - + AND month(f.Fecha) = vMonth; + SELECT vYear Año, vMonth Mes, t.Id_Cliente, @@ -6185,7 +5845,7 @@ BEGIN IF(e2.empresa_grupo,2,0)) AS grupo, t.empresa_id empresa - FROM vn2008.Movimientos m + FROM vn2008.Movimientos m JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.Id_Consigna JOIN vn2008.Clientes c ON c.Id_Cliente = cs.Id_Cliente @@ -6199,17 +5859,15 @@ BEGIN AND m.Descuento <> 100 AND a.tipo_id != 188 GROUP BY t.Id_Cliente, grupo,t.empresa_id; - + DROP TEMPORARY TABLE tmp.ticket_list; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `vivosMuertos` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6217,10 +5875,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `vivosMuertos`() BEGIN - + /** * Devuelve el número de clientes nuevos y muertos, * dependiendo de la fecha actual. @@ -6229,11 +5889,11 @@ BEGIN * @param @datEND Fecha de finalización a buscar */ - SET @datSTART = TIMESTAMPADD(YEAR,-2,CURDATE()); - SET @datEND = TIMESTAMPADD(DAY,-DAY(CURDATE()),CURDATE()); - + SET @datSTART = TIMESTAMPADD(YEAR,-2,util.VN_CURDATE()); + SET @datEND = TIMESTAMPADD(DAY,-DAY(util.VN_CURDATE()),util.VN_CURDATE()); + DROP TEMPORARY TABLE IF EXISTS tmp.VivosMuertos; - + CREATE TEMPORARY TABLE tmp.VivosMuertos SELECT c.Id_Cliente, tm.yearMonth, f.Compra, 0 as Nuevo, 0 as Muerto FROM vn2008.Clientes c @@ -6249,10 +5909,10 @@ BEGIN WHERE Fecha BETWEEN @datSTART AND @datEND) f ON f.yearMonth = tm.yearMonth AND f.Id_Cliente = c.Id_Cliente; - + UPDATE tmp.VivosMuertos vm JOIN - (SELECT MIN(tm.yearMonth) firstMonth, f.Id_Cliente + (SELECT MIN(tm.yearMonth) firstMonth, f.Id_Cliente FROM vn2008.Facturas f JOIN vn2008.time tm ON tm.date = f.Fecha WHERE Fecha BETWEEN @datSTART AND @datEND @@ -6260,9 +5920,9 @@ BEGIN AND fm.Id_Cliente = vm.Id_Cliente SET Nuevo = 1; - + SELECT max(yearMonth) INTO @lastYearMonth FROM tmp.VivosMuertos; - + UPDATE tmp.VivosMuertos vm JOIN ( SELECT MAX(tm.yearMonth) firstMonth, f.Id_Cliente @@ -6284,8 +5944,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `waste_addSales` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6293,6 +5951,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `waste_addSales`() BEGIN @@ -6302,24 +5962,24 @@ BEGIN SELECT week, year INTO vWeek, vYear FROM vn.time - WHERE dated = CURDATE(); - + WHERE dated = util.VN_CURDATE(); + REPLACE bs.waste SELECT *, 100 * mermas / total as porcentaje FROM ( - SELECT buyer, - year, + SELECT buyer, + year, week, family, itemFk, itemTypeFk, - floor(sum(value)) as total, + floor(sum(value)) as total, floor(sum(IF(clientTypeFk = 'loses', value, 0))) as mermas - FROM vn.saleValue + FROM vn.saleValue where year = vYear and week = vWeek - + GROUP BY family, itemFk - + ) sub ORDER BY mermas DESC; END ;; @@ -6328,8 +5988,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerLabour_getData` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6337,6 +5995,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerLabour_getData`() BEGIN @@ -6351,86 +6011,87 @@ BEGIN DECLARE vDateEnded DATE; DECLARE vCursor CURSOR FOR - SELECT util.firstDayOfMonth(t.dated), LAST_DAY(t.dated) + SELECT util.firstDayOfMonth(t.dated), LAST_DAY(t.dated) FROM vn.time t WHERE t.dated BETWEEN vDateStarted AND vDateEnded - GROUP BY year,month; + 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, + + IF DAY(util.VN_CURDATE()) = 21 THEN + + SELECT util.firstDayOfMonth(DATE_SUB(util.VN_CURDATE(), INTERVAL 12 MONTH)), + LAST_DAY(DATE_SUB(util.VN_CURDATE(), INTERVAL 1 MONTH)) + INTO vDateStarted, vDateEnded; - - DELETE FROM workerLabourDataByMonth + + 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(wbt.isPermanent) - FROM vn.workerLabour w - JOIN vn.workCenter wc ON wc.id = w.workCenterFk - JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk - LEFT JOIN vn.workerBusinessType wbt ON wbt.id = 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 + INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) + SELECT 'hiring', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent) + FROM vn.business b + JOIN vn.workCenter wc ON wc.id = b.workCenterFk + JOIN vn.worker w ON w.id = b.workerFk + LEFT JOIN vn.workerBusinessType wbt ON wbt.id = b.workerBusinessTypeFk + LEFT JOIN (SELECT b.id, b.workerFk + FROM vn.business b + LEFT JOIN (SELECT ended, workerFk FROM vn.business) wl + ON wl.ended = DATE_SUB(b.started, INTERVAL 1 DAY) AND wl.workerFk = b.workerFk + WHERE b.started BETWEEN vFristDay AND vLastDay AND wl.ended + )sub ON sub.workerFk = b.workerFk WHERE wc.payrollCenterFk IS NOT NULL - AND w.started BETWEEN vFristDay AND vLastDay + AND b.workCenterFk IS NOT NULL + AND b.started BETWEEN vFristDay AND vLastDay AND sub.workerFk IS NULL - AND NOT w.isFreelance; + AND NOT w.isFreelance; -- Bajas periodo - INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) - SELECT 'layoffs', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent) - FROM vn.workerLabour w - JOIN vn.workCenter wc ON wc.id = w.workCenterFk - JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk - LEFT JOIN vn.workerBusinessType wbt ON wbt.id = bl.cod_contrato - LEFT JOIN (SELECT started, workerFk FROM vn.workerLabour) wl ON wl.started >= w.ended - AND wl.workerFk = w.workerFk - WHERE wc.payrollCenterFk IS NOT NULL - AND w.ended BETWEEN vFristDay AND vLastDay + INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) + SELECT 'layoffs', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent) + FROM vn.business b + JOIN vn.worker w ON w.id = b.workerFk + JOIN vn.workCenter wc ON wc.id = b.workCenterFk + LEFT JOIN vn.workerBusinessType wbt ON wbt.id = b.workerBusinessTypeFk + LEFT JOIN (SELECT started, workerFk FROM vn.business) wl ON wl.started >= b.ended + AND wl.workerFk = b.workerFk + WHERE wc.payrollCenterFk IS NOT NULL + AND b.ended BETWEEN vFristDay AND vLastDay AND wl.started IS NULL AND NOT w.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(wbt.isPermanent) - FROM vn.workerLabour w - JOIN vn.workCenter wc ON wc.id = w.workCenterFk - JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk - LEFT JOIN vn.workerBusinessType wbt ON wbt.id = bl.cod_contrato + INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) + SELECT 'staff', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent) + FROM vn.business b + JOIN vn.worker w ON w.id = b.workerFk + JOIN vn.workCenter wc ON wc.id = b.workCenterFk + LEFT JOIN vn.workerBusinessType wbt ON wbt.id = b.workerBusinessTypeFk WHERE wc.payrollCenterFk IS NOT NULL AND vLastDay BETWEEN started AND IFNULL(ended, vLastDay) AND NOT w.isFreelance; -- Discapacidad - INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) - SELECT 'disabled', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent) - FROM vn.workerLabour w - JOIN vn.workCenter wc ON wc.id = w.workCenterFk - JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk - LEFT JOIN vn.workerBusinessType wbt ON wbt.id = bl.cod_contrato + INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) + SELECT 'disabled', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(wbt.isPermanent) + FROM vn.business b + JOIN vn.worker w ON w.id = b.workerFk + JOIN vn.workCenter wc ON wc.id = b.workCenterFk + LEFT JOIN vn.workerBusinessType wbt ON wbt.id = b.workerBusinessTypeFk WHERE wc.payrollCenterFk IS NOT NULL AND vLastDay BETWEEN started AND IFNULL(ended, vLastDay) AND w.isDisable @@ -6446,8 +6107,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerProductivity_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6455,15 +6114,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerProductivity_add`() BEGIN DECLARE vDateFrom DATE; - SELECT DATE_SUB(CURDATE(),INTERVAL 30 DAY) INTO vDateFrom; - - DELETE FROM workerProductivity + SELECT DATE_SUB(util.VN_CURDATE(),INTERVAL 30 DAY) INTO vDateFrom; + + DELETE FROM workerProductivity WHERE dated >= vDateFrom; - + -- SACADORES Y ARTIFICIAL INSERT INTO workerProductivity(dated, wareHouseFk, workerFk, volume, seconds, actionFk) SELECT sub.dated, @@ -6477,7 +6138,7 @@ BEGIN DATE(t.shipped) dated, SUM((ic.cm3delivery * s.quantity)/1000000) volume, TIME_TO_SEC(TIMEDIFF( MAX(st.created),MIN(st.created))) + w.minSeconsItemPicker seconds, - a.accion_id + a.accion_id FROM vn.saleTracking st LEFT JOIN vn.salesPreviousPreparated sp ON sp.saleFk = st.saleFk JOIN vn.sale s ON s.id = st.saleFk @@ -6487,70 +6148,70 @@ BEGIN JOIN vncontrol.accion a ON a.accion_id = st.actionFk LEFT JOIN vn.workerDepartment wd ON wd.workerFk = st.workerFk JOIN workerProductivityConfig w ON TRUE - WHERE t.shipped >= vDateFrom - AND ISNULL(sp.saleFk) + WHERE t.shipped >= vDateFrom + AND ISNULL(sp.saleFk) AND (a.accion = 'SACAR' OR a.accion = 'PRESACAR') GROUP BY t.id, t.warehouseFk, st.workerFk ) sub GROUP BY sub.warehouseFk, sub.workerFk, sub.dated; - + -- ENCAJADORES INSERT INTO workerProductivity(dated, wareHouseFk, workerFk, volume, seconds, actionFk) SELECT sub2.shipped, sub2.warehouseFk, - sub2.workerFK, - SUM(sub2.volume), + sub2.workerFK, + SUM(sub2.volume), SUM(sub2.seconds), - a.accion_id - FROM (SELECT t.warehouseFk, - SUM(s.volume) volume, - sub.workerFk, + a.accion_id + FROM (SELECT t.warehouseFk, + SUM(s.volume) volume, + sub.workerFk, DATE(t.shipped) shipped, sub.seconds + w.minSeconsPackager seconds, - s.saleFk - FROM vn.saleVolume s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN(SELECT e.workerFk, e.ticketFk,TIME_TO_SEC(TIMEDIFF( MAX(e.created), MIN(e.created))) seconds + s.saleFk + FROM vn.saleVolume s + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN(SELECT e.workerFk, e.ticketFk,TIME_TO_SEC(TIMEDIFF( MAX(e.created), MIN(e.created))) seconds FROM vn.expedition e JOIN vn.ticket t ON t.id = e.ticketFk WHERE e.workerFk IS NOT NULL AND - t.shipped >= vDateFrom + t.shipped >= vDateFrom GROUP BY e.ticketFk )sub ON sub.ticketFk = t.id JOIN workerProductivityConfig w ON TRUE - GROUP BY s.ticketFk, t.warehouseFk + GROUP BY s.ticketFk, t.warehouseFk )sub2 JOIN vncontrol.accion a ON a.accion = 'ENCAJAR' GROUP BY sub2.warehouseFk,sub2.workerFk, sub2.shipped; - + -- REVISADORES INSERT INTO workerProductivity(dated, wareHouseFk, workerFk, volume, seconds, actionFk) SELECT sub2.shipped, sub2.warehouseFk, - sub2.workerFK, - SUM(sub2.volume), + sub2.workerFK, + SUM(sub2.volume), SUM(sub2.seconds), sub2.accion_id - FROM (SELECT t.warehouseFk, - SUM(s.volume) volume, - sub.workerFk, + FROM (SELECT t.warehouseFk, + SUM(s.volume) volume, + sub.workerFk, DATE(t.shipped) shipped, sub.seconds + w.minSeconsPackager seconds, sub.accion_id - FROM vn.saleVolume s + 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, a.accion_id + JOIN(SELECT st.workerFk, t.id ticketFk,TIME_TO_SEC(TIMEDIFF( MAX(st.created), MIN(st.created))) seconds, a.accion_id FROM vn.saleTracking st JOIN vncontrol.accion a ON a.accion_id = st.actionFk JOIN vn.sale s ON s.id = st.saleFk JOIN vn.ticket t ON s.ticketFk = t.id WHERE a.accion = 'CONTROLAR' - AND t.shipped >= vDateFrom + AND t.shipped >= vDateFrom GROUP BY t.id )sub ON sub.ticketFk = t.id JOIN workerProductivityConfig w ON TRUE - GROUP BY s.ticketFk, t.warehouseFk + GROUP BY s.ticketFk, t.warehouseFk )sub2 GROUP BY sub2.warehouseFk,sub2.workerFk, sub2.shipped; END ;; @@ -6559,56 +6220,12 @@ 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `zone_ETD_byTime` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_ETD_byTime`() -BEGIN - SET @m := 0; - - SELECT MAX(hourTheoretical) INTO @h - FROM vn.zoneEstimatedDelivery ze - WHERE ze.remainingVolume ; - - DROP TEMPORARY TABLE IF EXISTS tmpZone; - CREATE TEMPORARY TABLE tmpZone - SELECT remainingVolume, - hourTheoretical, - @m := @m + minutesLess + HOUR(TIMEDIFF(@h, hourTheoretical)) * 60 + MINUTE(TIMEDIFF(@h, hourTheoretical)) totalMinutes, - @h := hourTheoretical previousHourTheoretical - FROM vn.zoneEstimatedDelivery ze - WHERE ze.remainingVolume - ORDER BY ze.hourTheoretical DESC; - - TRUNCATE bs.zone_ETD_byTime ; - - INSERT INTO bs.zone_ETD_byTime(theorical, practical, m3) - SELECT tz.hourTheoretical, - TIMESTAMPADD(MINUTE, MIN(totalMinutes), tz.hourTheoretical), - sum(tz.remainingVolume) - FROM tmpZone tz - GROUP BY tz.hourTheoretical; - - DROP TEMPORARY TABLE tmpZone; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Current Database: `cache` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `cache` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `cache` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `cache`; @@ -6620,14 +6237,14 @@ DROP TABLE IF EXISTS `addressFriendship`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `addressFriendship` ( - `addressFk1` int(11) NOT NULL DEFAULT '0', - `addressFk2` int(11) NOT NULL DEFAULT '0', - `friendship` int(11) NOT NULL DEFAULT '0', + `addressFk1` int(11) NOT NULL DEFAULT 0, + `addressFk2` int(11) NOT NULL DEFAULT 0, + `friendship` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`addressFk1`,`addressFk2`), KEY `addressFriendship_fk2_idx` (`addressFk2`), CONSTRAINT `addressFriendship_fk1` FOREIGN KEY (`addressFk1`) REFERENCES `vn`.`address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `addressFriendship_fk2` FOREIGN KEY (`addressFk2`) REFERENCES `vn`.`address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6643,7 +6260,7 @@ CREATE TABLE `available` ( `available` int(11) NOT NULL, UNIQUE KEY `calc_id` (`item_id`,`calc_id`) USING HASH, KEY `calc_id_4` (`calc_id`) USING BTREE -) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6659,7 +6276,7 @@ CREATE TABLE `availableNoRaids` ( `available` int(11) NOT NULL, UNIQUE KEY `calc_id` (`item_id`,`calc_id`), KEY `calc_id_4` (`calc_id`) USING BTREE -) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6671,11 +6288,11 @@ DROP TABLE IF EXISTS `cache`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cache` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(50) CHARACTER SET utf8 NOT NULL, + `name` varchar(50) CHARACTER SET utf8mb3 NOT NULL, `lifetime` time NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6688,18 +6305,18 @@ DROP TABLE IF EXISTS `cache_calc`; CREATE TABLE `cache_calc` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `cache_id` int(10) unsigned NOT NULL, - `cacheName` varchar(255) CHARACTER SET utf8 DEFAULT NULL, - `params` varchar(100) CHARACTER SET utf8 NOT NULL DEFAULT '', + `cacheName` varchar(255) CHARACTER SET utf8mb3 DEFAULT NULL, + `params` varchar(100) CHARACTER SET utf8mb3 NOT NULL DEFAULT '', `last_refresh` datetime DEFAULT NULL, `expires` datetime DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `connection_id` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `cache_name` (`cache_id`,`params`), KEY `cache_id` (`cache_id`), KEY `cacheName` (`cacheName`), KEY `expires` (`expires`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6713,7 +6330,7 @@ CREATE TABLE `cache_valid` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `valid` tinyint(3) unsigned NOT NULL, PRIMARY KEY (`id`) -) ENGINE=MEMORYDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6726,11 +6343,11 @@ DROP TABLE IF EXISTS `departure_limit`; CREATE TABLE `departure_limit` ( `warehouse_id` smallint(6) unsigned NOT NULL, `fecha` date NOT NULL, - `hora` int(11) NOT NULL DEFAULT '0', - `minSpeed` decimal(10,2) NOT NULL DEFAULT '0.00', + `hora` int(11) NOT NULL DEFAULT 0, + `minSpeed` decimal(10,2) NOT NULL DEFAULT 0.00, PRIMARY KEY (`warehouse_id`,`fecha`), CONSTRAINT `warehouse_departure` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6749,7 +6366,7 @@ CREATE TABLE `last_buy` ( KEY `buy_id` (`buy_id`), KEY `warehouse_id` (`warehouse_id`) USING BTREE, CONSTRAINT `last_buy_FK_1` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6761,14 +6378,14 @@ DROP TABLE IF EXISTS `prod_graphic_source`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `prod_graphic_source` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `m3` double NOT NULL DEFAULT '0', + `m3` double NOT NULL DEFAULT 0, `warehouse_id` int(11) NOT NULL, `hora` int(11) NOT NULL, - `order` int(11) NOT NULL DEFAULT '0', - `graphCategory` int(11) NOT NULL DEFAULT '0', - `Agencia` varchar(45) CHARACTER SET utf8 NOT NULL, + `order` int(11) NOT NULL DEFAULT 0, + `graphCategory` int(11) NOT NULL DEFAULT 0, + `Agencia` varchar(45) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6784,7 +6401,7 @@ CREATE TABLE `stock` ( `amount` int(11) NOT NULL, UNIQUE KEY `warehouse_id` (`warehouse_id`,`item_id`) USING HASH, KEY `warehouse_id_2` (`warehouse_id`) USING BTREE -) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6800,7 +6417,7 @@ CREATE TABLE `visible` ( `visible` int(11) NOT NULL, UNIQUE KEY `calc_id` (`calc_id`,`item_id`) USING HASH, KEY `id` (`item_id`) USING BTREE -) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6813,12 +6430,12 @@ DROP TABLE IF EXISTS `zoneAgencyFriendship`; CREATE TABLE `zoneAgencyFriendship` ( `agencyModeFk` int(11) NOT NULL, `zoneFk` int(11) NOT NULL, - `friendship` bigint(21) NOT NULL DEFAULT '0', + `friendship` bigint(21) NOT NULL DEFAULT 0, PRIMARY KEY (`agencyModeFk`,`zoneFk`), KEY `zoneAgencyFriendship_fk1_idx` (`zoneFk`), CONSTRAINT `zoneAgencyFriendship` FOREIGN KEY (`agencyModeFk`) REFERENCES `vn`.`agencyMode` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `zoneAgencyFriendship_fk1` FOREIGN KEY (`zoneFk`) REFERENCES `vn`.`zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6867,8 +6484,6 @@ DELIMITER ; -- -- Dumping routines for database 'cache' -- -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `addressFriendship_Update` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6876,27 +6491,29 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `addressFriendship_Update`() BEGIN - REPLACE cache.addressFriendship + REPLACE cache.addressFriendship SELECT addressFk1, addressFk2, count(*) friendship FROM ( SELECT t.routeFk, t.zoneFk, t.addressFk addressFk1, t2.addressFk addressFk2 FROM vn.ticket t JOIN vn.ticket t2 USING(routeFk, zoneFk) - WHERE t.shipped >= TIMESTAMPADD(MONTH,-3,CURDATE()) - AND t2.shipped >= TIMESTAMPADD(MONTH,-3,CURDATE()) + WHERE t.shipped >= TIMESTAMPADD(MONTH,-3,util.VN_CURDATE()) + AND t2.shipped >= TIMESTAMPADD(MONTH,-3,util.VN_CURDATE()) AND t.addressFk != t2.addressFk) sub GROUP BY addressFk1, addressFk2; - + REPLACE cache.zoneAgencyFriendship SELECT r.agencyModeFk, t.zoneFk, count(*) friendship FROM vn.route r JOIN vn.ticket t ON t.routeFk = r.id - WHERE t.shipped >= TIMESTAMPADD(MONTH,-3,CURDATE()) + WHERE t.shipped >= TIMESTAMPADD(MONTH,-3,util.VN_CURDATE()) AND r.agencyModeFk AND t.routeFk AND t.zoneFk @@ -6907,8 +6524,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `availableNoRaids_refresh` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6916,6 +6531,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `availableNoRaids_refresh`(OUT `vCalc` INT, IN `vRefresh` INT, IN `vWarehouse` INT, IN `vDate` DATE) proc: BEGIN @@ -6931,7 +6548,7 @@ proc: BEGIN RESIGNAL; END; - IF vDate < CURDATE() THEN + IF vDate < util.VN_CURDATE() THEN LEAVE proc; END IF; @@ -6943,7 +6560,7 @@ proc: BEGIN IF !vRefresh THEN LEAVE proc; END IF; - + -- Calcula algunos parametros necesarios SET vStartDate = TIMESTAMP(vDate, '00:00:00'); @@ -6951,7 +6568,7 @@ proc: BEGIN SELECT inventoried INTO vInventoryDate FROM vn.config; - SELECT SUBTIME(NOW(), reserveTime) INTO vReserveDate + SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vReserveDate FROM hedera.orderConfig; -- Calcula el ultimo dia de vida para cada producto @@ -6973,7 +6590,7 @@ proc: BEGIN AND t.warehouseInFk = vWarehouse AND s.name != 'INVENTARIO' AND NOT e.isRaid - GROUP BY b.itemFk + GROUP BY b.itemFk ) c JOIN vn.item i ON i.id = c.item_id JOIN vn.itemType it ON it.id = i.typeFk @@ -6983,22 +6600,22 @@ proc: BEGIN DROP TEMPORARY TABLE IF EXISTS item_range_copy1; CREATE TEMPORARY TABLE item_range_copy1 LIKE item_range; - INSERT INTO item_range_copy1 + INSERT INTO item_range_copy1 SELECT * FROM item_range; - + DROP TEMPORARY TABLE IF EXISTS item_range_copy2; CREATE TEMPORARY TABLE item_range_copy2 LIKE item_range; - INSERT INTO item_range_copy2 + INSERT INTO item_range_copy2 SELECT * FROM item_range; - + DROP TEMPORARY TABLE IF EXISTS item_range_copy3; CREATE TEMPORARY TABLE item_range_copy3 LIKE item_range; - INSERT INTO item_range_copy3 + INSERT INTO item_range_copy3 SELECT * FROM item_range; - + DROP TEMPORARY TABLE IF EXISTS item_range_copy4; CREATE TEMPORARY TABLE item_range_copy4 LIKE item_range; - INSERT INTO item_range_copy4 + INSERT INTO item_range_copy4 SELECT * FROM item_range; -- Calcula el ATP @@ -7006,10 +6623,10 @@ proc: BEGIN DELETE FROM availableNoRaids WHERE calc_id = vCalc; INSERT INTO availableNoRaids (calc_id, item_id, available) - SELECT vCalc, t.item_id, SUM(stock) amount FROM ( + SELECT vCalc, t.item_id, SUM(stock) amount FROM ( SELECT il.itemFk AS item_id, stock FROM tmp.itemList il - JOIN item_range ir ON ir.item_id = il.itemFk + JOIN item_range ir ON ir.item_id = il.itemFk UNION ALL SELECT t.item_id, minacum(dt, amount, vDate) AS available FROM ( SELECT itemFk AS item_id, DATE(dat) dt, SUM(quantity) amount FROM ( @@ -7030,8 +6647,8 @@ proc: BEGIN UNION ALL SELECT i.itemFk, i.shipped AS dat, i.quantity FROM vn.itemEntryOut i - JOIN item_range_copy3 ir ON ir.item_id = i.itemFk - WHERE i.shipped >= vStartDate + JOIN item_range_copy3 ir ON ir.item_id = i.itemFk + WHERE i.shipped >= vStartDate AND (ir.date_end IS NULL OR i.shipped <= ir.date_end) AND i.warehouseOutFk = vWarehouse UNION ALL @@ -7047,10 +6664,10 @@ proc: BEGIN ) t GROUP BY item_id, dt ) t - GROUP BY t.item_id + GROUP BY t.item_id ) t GROUP BY t.item_id; - DROP TEMPORARY TABLE IF EXISTS + DROP TEMPORARY TABLE IF EXISTS tmp.itemList ,item_range ,item_range_copy1 @@ -7065,8 +6682,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `available_clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7074,6 +6689,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `available_clean`() BEGIN @@ -7087,12 +6704,12 @@ BEGIN FROM available a LEFT JOIN tCalc c ON c.id = a.calc_id WHERE c.id IS NULL; - + DELETE a FROM availableNoRaids a LEFT JOIN tCalc c ON c.id = a.calc_id WHERE c.id IS NULL; - + DROP TEMPORARY TABLE tCalc; END ;; DELIMITER ; @@ -7100,8 +6717,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `available_refresh` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7109,6 +6724,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `available_refresh`(OUT `vCalc` INT, IN `vRefresh` INT, IN `vWarehouse` INT, IN `vDate` DATE) proc: BEGIN @@ -7124,7 +6741,7 @@ proc: BEGIN RESIGNAL; END; - IF vDate < CURDATE() THEN + IF vDate < util.VN_CURDATE() THEN LEAVE proc; END IF; @@ -7155,7 +6772,7 @@ proc: BEGIN SELECT inventoried INTO vInventoryDate FROM vn.config; - SELECT SUBTIME(NOW(), reserveTime) INTO vReserveDate + SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vReserveDate FROM hedera.orderConfig; -- Calcula el ultimo dia de vida para cada producto @@ -7175,7 +6792,7 @@ proc: BEGIN WHERE t.landed BETWEEN vInventoryDate AND vStartDate AND t.warehouseInFk = vWarehouse AND NOT e.isExcludedFromAvailable - GROUP BY b.itemFk + GROUP BY b.itemFk ) c JOIN vn.item i ON i.id = c.item_id JOIN vn.itemType it ON it.id = i.typeFk @@ -7185,22 +6802,22 @@ proc: BEGIN DROP TEMPORARY TABLE IF EXISTS item_range_copy1; CREATE TEMPORARY TABLE item_range_copy1 LIKE item_range; - INSERT INTO item_range_copy1 + INSERT INTO item_range_copy1 SELECT * FROM item_range; DROP TEMPORARY TABLE IF EXISTS item_range_copy2; CREATE TEMPORARY TABLE item_range_copy2 LIKE item_range; - INSERT INTO item_range_copy2 + INSERT INTO item_range_copy2 SELECT * FROM item_range; DROP TEMPORARY TABLE IF EXISTS item_range_copy3; CREATE TEMPORARY TABLE item_range_copy3 LIKE item_range; - INSERT INTO item_range_copy3 + INSERT INTO item_range_copy3 SELECT * FROM item_range; DROP TEMPORARY TABLE IF EXISTS item_range_copy4; CREATE TEMPORARY TABLE item_range_copy4 LIKE item_range; - INSERT INTO item_range_copy4 + INSERT INTO item_range_copy4 SELECT * FROM item_range; -- Calcula el ATP @@ -7208,14 +6825,14 @@ proc: BEGIN DELETE FROM available WHERE calc_id = vCalc; INSERT INTO available (calc_id, item_id, available) - SELECT vCalc, t.item_id, SUM(stock) amount FROM ( + SELECT vCalc, t.item_id, SUM(stock) amount FROM ( SELECT il.itemFk AS item_id, stock FROM tmp.itemList il - JOIN item_range ir ON ir.item_id = il.itemFk + JOIN item_range ir ON ir.item_id = il.itemFk UNION ALL - SELECT t.item_id, minacum(dt, amount, vDate) AS available + SELECT t.item_id, minacum(dt, amount, vDate) AS available FROM ( - SELECT itemFk AS item_id, DATE(dat) dt, SUM(quantity) amount + SELECT itemFk AS item_id, DATE(dat) dt, SUM(quantity) amount FROM ( SELECT i.itemFk, i.shipped AS dat, i.quantity FROM vn.itemTicketOut i @@ -7227,7 +6844,7 @@ proc: BEGIN SELECT i.itemFk, i.landed AS dat, i.quantity FROM vn.itemEntryIn i JOIN item_range_copy2 ir ON ir.item_id = i.itemFk - LEFT JOIN edi.warehouseFloramondo wf ON wf.entryFk = i.entryFk + LEFT JOIN edi.warehouseFloramondo wf ON wf.entryFk = i.entryFk WHERE i.landed >= vStartDate AND (ir.date_end IS NULL OR i.landed <= ir.date_end) AND i.warehouseInFk = vWarehouse @@ -7235,8 +6852,8 @@ proc: BEGIN UNION ALL SELECT i.itemFk, i.shipped AS dat, i.quantity FROM vn.itemEntryOut i - JOIN item_range_copy3 ir ON ir.item_id = i.itemFk - WHERE i.shipped >= vStartDate + JOIN item_range_copy3 ir ON ir.item_id = i.itemFk + WHERE i.shipped >= vStartDate AND (ir.date_end IS NULL OR i.shipped <= ir.date_end) AND i.warehouseOutFk = vWarehouse UNION ALL @@ -7252,10 +6869,10 @@ proc: BEGIN ) t GROUP BY item_id, dt ) t - GROUP BY t.item_id + GROUP BY t.item_id ) t GROUP BY t.item_id; - DROP TEMPORARY TABLE IF EXISTS + DROP TEMPORARY TABLE IF EXISTS tmp.itemList ,item_range ,item_range_copy1 @@ -7270,8 +6887,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `cacheCalc_clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7279,10 +6894,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `cacheCalc_clean`() BEGIN - DECLARE vCleanTime DATETIME DEFAULT TIMESTAMPADD(MINUTE, -5, NOW()); + DECLARE vCleanTime DATETIME DEFAULT TIMESTAMPADD(MINUTE, -5, util.VN_NOW()); DELETE FROM cache_calc WHERE expires < vCleanTime; END ;; DELIMITER ; @@ -7290,8 +6907,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `cache_calc_end` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7299,6 +6914,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `cache_calc_end`(IN `v_calc` INT) BEGIN @@ -7309,8 +6926,8 @@ BEGIN UPDATE cache_calc cc JOIN cache c ON c.id = cc.cache_id SET - cc.last_refresh = NOW(), - cc.expires = LEAST(ADDTIME(NOW(), c.lifetime), util.midNight()), + cc.last_refresh = util.VN_NOW(), + cc.expires = LEAST(ADDTIME(util.VN_NOW(), c.lifetime), util.midNight()), cc.connection_id = NULL WHERE cc.id = v_calc; @@ -7328,8 +6945,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `cache_calc_start` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7337,6 +6952,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `cache_calc_start`(OUT `v_calc` INT, INOUT `v_refresh` INT, IN `v_cache_name` VARCHAR(50), IN `v_params` VARCHAR(100)) proc: BEGIN @@ -7384,12 +7001,12 @@ proc: BEGIN INTO v_cache_id, v_calc, v_expires FROM cache c LEFT JOIN cache_calc ca - ON ca.cache_id = c.id AND ca.params = v_params COLLATE 'utf8_general_ci' + ON ca.cache_id = c.id AND ca.params = v_params COLLATE 'utf8_general_ci' WHERE c.name = v_cache_name COLLATE 'utf8_general_ci'; - + -- Si existe una calculo valido libera el bloqueo y devuelve su identificador. - IF !v_refresh AND NOW() < v_expires + IF !v_refresh AND util.VN_NOW() < v_expires THEN DO RELEASE_LOCK(v_lock_id); SET v_refresh = FALSE; @@ -7427,8 +7044,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `cache_calc_unlock` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7436,6 +7051,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `cache_calc_unlock`(IN `v_calc` INT) proc: BEGIN @@ -7450,7 +7067,7 @@ proc: BEGIN FROM cache c JOIN cache_calc ca ON c.id = ca.cache_id WHERE ca.id = v_calc; - + DELETE FROM cache_calc WHERE id = v_calc; IF v_cache_name IS NOT NULL THEN @@ -7462,8 +7079,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `cache_clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7471,6 +7086,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `cache_clean`() NO SQL @@ -7483,8 +7100,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7492,13 +7107,15 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`() BEGIN - - DECLARE vDateShort DATETIME; - SET vDateShort = TIMESTAMPADD(MONTH, -1, CURDATE()); + DECLARE vDateShort DATETIME; + + SET vDateShort = TIMESTAMPADD(MONTH, -1, util.VN_CURDATE()); DELETE FROM cache.departure_limit WHERE Fecha < vDateShort; END ;; @@ -7507,8 +7124,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `departure_timing` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7516,6 +7131,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `departure_timing`(vWarehouseId INT) BEGIN @@ -7535,11 +7152,11 @@ DECLARE vLoadingDelay DECIMAL(5) DEFAULT 2; DECLARE rs CURSOR FOR SELECT Departure , Sum(pb.m3)/(GREATEST(IFNULL(lhp.m3,0),IFNULL(dp.minSpeed,0))) AS Horas - , curDate()+(Departure + vLoadingDelay -(Sum(pb.m3)/(GREATEST(IFNULL(lhp.m3,0),IFNULL(minSpeed,0))))/24) AS InicioPreparacion + , util.VN_CURDATE()+(Departure + vLoadingDelay -(Sum(pb.m3)/(GREATEST(IFNULL(lhp.m3,0),IFNULL(minSpeed,0))))/24) AS InicioPreparacion FROM tmp.production_buffer pb LEFT JOIN vn.lastHourProduction lhp ON lhp.warehouseFk = pb.warehouse_id - LEFT JOIN cache.departure_limit dp ON dp.warehouse_id = pb.warehouse_id AND dp.fecha = CURDATE() - WHERE pb.Fecha = CURDATE() + LEFT JOIN cache.departure_limit dp ON dp.warehouse_id = pb.warehouse_id AND dp.fecha = util.VN_CURDATE() + WHERE pb.Fecha = util.VN_CURDATE() AND pb.graphCategory > 1 AND IFNULL(Departure,0) > 0 GROUP BY Departure @@ -7547,7 +7164,7 @@ DECLARE rs CURSOR FOR DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - SET myTime = HOUR(now()) + MINUTE(now()) / 60; + SET myTime = HOUR(util.VN_NOW()) + MINUTE(util.VN_NOW()) / 60; OPEN rs; @@ -7556,23 +7173,23 @@ DECLARE rs CURSOR FOR WHILE NOT done DO SET resto = IF(inicioProd < rsDeparture, rsDeparture - inicioProd,0); - + SET inicioProd = rsDeparture - rsHoras; - + IF inicioProd - resto < myTime THEN - + SET done = TRUE; - + ELSE - + SET departureLimit = rsDeparture; - + FETCH rs INTO rsDeparture, rsHoras , rsInicio; - + -- SELECT rsDeparture, rsHoras , rsInicio; - + END IF; - + END WHILE; SET departureLimit = IFNULL(departureLimit,24); @@ -7581,10 +7198,10 @@ DECLARE rs CURSOR FOR SELECT minSpeed INTO myMinSpeed FROM cache.departure_limit WHERE warehouse_id = vWarehouseId - AND fecha = CURDATE(); + AND fecha = util.VN_CURDATE(); REPLACE cache.departure_limit(warehouse_id, fecha, hora, minSpeed) - VALUES (vWarehouseId, CURDATE(), departureLimit, IFNULL(myMinSpeed,0)); + VALUES (vWarehouseId, util.VN_CURDATE(), departureLimit, IFNULL(myMinSpeed,0)); CLOSE rs; @@ -7594,8 +7211,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `last_buy_refresh` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7603,6 +7218,8 @@ DELIMITER ; /*!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`@`localhost` PROCEDURE `last_buy_refresh`(vRefresh BOOL) proc: BEGIN @@ -7617,7 +7234,7 @@ proc: BEGIN DECLARE started DATE; DECLARE ended DATE; DECLARE vLastRefresh DATE; - + DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN CALL cache_calc_unlock (vCalc); @@ -7633,7 +7250,7 @@ proc: BEGIN -- TODO: ¿Se puede usar la fecha del ultimo inventario? SELECT inventoried INTO started FROM vn.config LIMIT 1; - SET ended = CURDATE(); -- TIMESTAMPADD(DAY, -1, CURDATE()); + SET ended = util.VN_CURDATE(); -- TIMESTAMPADD(DAY, -1, util.VN_CURDATE()); CALL vn.buyUltimateFromInterval(NULL, started, ended); @@ -7652,8 +7269,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `prod_graphic_refresh` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7661,20 +7276,22 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `prod_graphic_refresh`(v_refresh BOOL, wh_id INT) proc: BEGIN DECLARE datEQ DATETIME; DECLARE timDIF TIME; DECLARE v_calc INT; - + CALL cache_calc_start (v_calc, v_refresh, 'prod_graphic', wh_id); - + IF !v_refresh THEN LEAVE proc; END IF; - + CALL vn2008.production_control_source(wh_id, 0); DELETE FROM prod_graphic_source; @@ -7689,11 +7306,11 @@ proc: BEGIN pb.Agencia FROM tmp.production_buffer pb JOIN vn.state st ON st.id = pb.state - WHERE Fecha = CURDATE() + WHERE Fecha = util.VN_CURDATE() GROUP BY wh_id, graphCategory ; - - + + CALL cache_calc_end (v_calc); END ;; DELIMITER ; @@ -7701,8 +7318,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `stock_refresh` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7710,11 +7325,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `stock_refresh`(v_refresh BOOL) proc: BEGIN /** - * Crea o actualiza la cache con el disponible hasta el día de + * Crea o actualiza la cache con el disponible hasta el día de * ayer. Esta cache es usada como base para otros procedimientos * como el cáculo del visible o del ATP. * @@ -7739,22 +7356,22 @@ proc: BEGIN END IF; SET v_date_inv = (SELECT inventoried FROM vn.config LIMIT 1); - SET v_curdate = CURDATE(); - + SET v_curdate = util.VN_CURDATE(); + DELETE FROM stock; - + INSERT INTO stock (item_id, warehouse_id, amount) SELECT item_id, warehouse_id, SUM(amount) amount FROM ( - SELECT itemFk AS item_id, warehouseFk AS warehouse_id, quantity AS amount + SELECT itemFk AS item_id, warehouseFk AS warehouse_id, quantity AS amount FROM vn.itemTicketOut WHERE shipped >= v_date_inv AND shipped < v_curdate UNION ALL - SELECT itemFk ASitem_id, warehouseInFk AS warehouse_id, quantity AS amount + SELECT itemFk ASitem_id, warehouseInFk AS warehouse_id, quantity AS amount FROM vn.itemEntryIn WHERE landed >= v_date_inv AND landed < v_curdate AND isVirtualStock is FALSE UNION ALL - SELECT itemFk AS item_id ,warehouseOutFk AS warehouse_id, quantity AS amount + SELECT itemFk AS item_id ,warehouseOutFk AS warehouse_id, quantity AS amount FROM vn.itemEntryOut WHERE shipped >= v_date_inv AND shipped < v_curdate ) t @@ -7767,8 +7384,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `visible_clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7776,6 +7391,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `visible_clean`() BEGIN @@ -7784,12 +7401,12 @@ BEGIN (INDEX (id)) ENGINE = MEMORY SELECT id FROM cache_calc; - + DELETE v FROM visible v LEFT JOIN tCalc c ON c.id = v.calc_id WHERE c.id IS NULL; - + DROP TEMPORARY TABLE tCalc; END ;; DELIMITER ; @@ -7797,8 +7414,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `visible_refresh` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7806,6 +7421,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `visible_refresh`(OUT v_calc INT, v_refresh BOOL, v_warehouse INT) proc: BEGIN @@ -7820,11 +7437,11 @@ proc: BEGIN IF !v_refresh THEN LEAVE proc; END IF; - + -- Calculamos el stock hasta ayer - + CALL `cache`.stock_refresh(false); - + DROP TEMPORARY TABLE IF EXISTS vn2008.tmp_item; CREATE TEMPORARY TABLE vn2008.tmp_item (PRIMARY KEY (item_id)) @@ -7833,9 +7450,9 @@ proc: BEGIN WHERE warehouse_id = v_warehouse; -- Calculamos los movimientos confirmados de hoy - CALL vn.item_GetVisible(v_warehouse, NULL); + CALL vn.item_GetVisible(v_warehouse, NULL); DELETE FROM visible WHERE calc_id = v_calc; - + INSERT INTO visible (calc_id, item_id,visible) SELECT v_calc, item_id, visible FROM vn2008.tmp_item; @@ -7853,7 +7470,7 @@ DELIMITER ; -- Current Database: `edi` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `edi` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `edi` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `edi`; @@ -7867,21 +7484,21 @@ DROP TABLE IF EXISTS `PriceDetails`; CREATE TABLE `PriceDetails` ( `ID` int(11) NOT NULL, `SuplyResponseID` int(11) NOT NULL, - `PriceType` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `Location` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `PriceType` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `Location` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `Price` decimal(10,2) DEFAULT NULL, `BasisQuantitiy` int(11) DEFAULT NULL, - `BasisQuantityType` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `BasisQuantityType` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `MinimumQuantity` int(11) DEFAULT NULL, - `MinimumQuantityType` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `MinimumQuantityType` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `MaximumQuantity Integer` int(11) DEFAULT NULL, - `MaximumQuantityType` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `MaximumQuantityType` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `LatestDeliveryDateTime` datetime DEFAULT NULL, `EarliestDespatchDateTime` datetime DEFAULT NULL, `FirstOrderDateTime` datetime DEFAULT NULL, `LatestOrderDateTime` datetime DEFAULT NULL, PRIMARY KEY (`ID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7893,31 +7510,31 @@ DROP TABLE IF EXISTS `VMPSettings`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `VMPSettings` ( `VMPID` int(11) NOT NULL, - `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `isEktSender` tinyint(4) NOT NULL DEFAULT '0', + `name` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isEktSender` tinyint(4) NOT NULL DEFAULT 0, `MessageID` int(11) NOT NULL, `dateTimeTry` timestamp NULL DEFAULT NULL, `isVmpBA` tinyint(4) DEFAULT NULL COMMENT 'Basic authentication', `vmpVersion` int(11) DEFAULT NULL, - `vmpUrl` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `loginName` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `loginPassword` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, + `vmpUrl` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `loginName` varchar(150) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `loginPassword` varchar(150) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `refreshRate` int(11) DEFAULT NULL, - `eanBuyer` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `eanSupplier` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `eanAgent` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `eanBuyer` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `eanSupplier` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `eanAgent` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `dateTimeLastSync` timestamp NULL DEFAULT NULL, `closedFrom` int(11) DEFAULT NULL, `closedTo` int(11) DEFAULT NULL, `totalRefreshHours` int(11) DEFAULT NULL COMMENT 'Numero > 4 para no saturar, no repetir para que no solapen las actualizaciones', - `UseSupplierEmbalageCode` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'vmp you want to see their embalage code', + `UseSupplierEmbalageCode` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'vmp you want to see their embalage code', `firstSupplyResponseId` int(11) DEFAULT NULL, `ApiId` int(11) DEFAULT NULL, - `ApiKey` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - `isBlocked` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'product source not allowed', - `isVNHSupplier` tinyint(1) DEFAULT '0' COMMENT 'The account belongs to VNH', + `ApiKey` varchar(100) COLLATE utf8mb3_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; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7930,7 +7547,7 @@ DROP TABLE IF EXISTS `bucket`; CREATE TABLE `bucket` ( `bucket_id` int(11) unsigned NOT NULL, `bucket_type_id` mediumint(8) unsigned NOT NULL, - `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, `x_size` mediumint(8) unsigned NOT NULL COMMENT 'mm', `y_size` mediumint(8) unsigned NOT NULL COMMENT 'mm', `z_size` mediumint(8) unsigned NOT NULL COMMENT 'mm', @@ -7940,7 +7557,7 @@ CREATE TABLE `bucket` ( PRIMARY KEY (`bucket_id`), KEY `group_id` (`y_size`), KEY `plant_id` (`x_size`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='/tmp/floricode/VBN020101/CK090916.txt'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='/tmp/floricode/VBN020101/CK090916.txt'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7952,12 +7569,12 @@ DROP TABLE IF EXISTS `bucket_type`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `bucket_type` ( `bucket_type_id` mediumint(8) unsigned NOT NULL, - `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, `entry_date` date DEFAULT NULL, `expiry_date` date DEFAULT NULL, `change_date_time` datetime DEFAULT NULL, PRIMARY KEY (`bucket_type_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='/tmp/floricode/VBN020101/FB090916.txt'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='/tmp/floricode/VBN020101/FB090916.txt'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7973,7 +7590,7 @@ CREATE TABLE `clientFHAdminNumber` ( 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; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7985,8 +7602,8 @@ DROP TABLE IF EXISTS `deliveryInformation`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `deliveryInformation` ( `ID` int(11) NOT NULL AUTO_INCREMENT, - `DeliveryType` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `Location` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `DeliveryType` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `Location` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `DeliveryPrice` decimal(10,2) DEFAULT NULL, `ChargeAmount` decimal(10,2) DEFAULT NULL, `BasisQuantitiy` int(11) DEFAULT NULL, @@ -7997,15 +7614,15 @@ CREATE TABLE `deliveryInformation` ( `FirstOrderDateTime` datetime DEFAULT NULL, `LatestOrderDateTime` datetime DEFAULT NULL, `supplyResponseID` int(11) DEFAULT NULL, - `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), PRIMARY KEY (`ID`), - UNIQUE KEY `deliveryInformation_UN` (`Location`,`LatestDeliveryDateTime`,`FirstOrderDateTime`,`LatestOrderDateTime`,`supplyResponseID`), + UNIQUE KEY `deliveryInformation_UN` (`Location`,`LatestDeliveryDateTime`,`FirstOrderDateTime`,`LatestOrderDateTime`,`supplyResponseID`,`DeliveryType`) USING HASH, KEY `fgbSupplyResponse_idx` (`supplyResponseID`), KEY `fgbSupplyResponse_idx2` (`FirstOrderDateTime`), KEY `fgbSupplyResponse_idx3` (`LatestOrderDateTime`) USING BTREE, KEY `deliveryInformation_updated_IDX` (`updated`) USING BTREE, CONSTRAINT `fgbSupplyResponse` FOREIGN KEY (`supplyResponseID`) REFERENCES `supplyResponse` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8016,15 +7633,15 @@ DROP TABLE IF EXISTS `di`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `di` ( - `ID` int(11) NOT NULL DEFAULT '0', - `Location` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `ID` int(11) NOT NULL DEFAULT 0, + `Location` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `LatestDeliveryDateTime` datetime DEFAULT NULL, `FirstOrderDateTime` datetime DEFAULT NULL, `LatestOrderDateTime` datetime DEFAULT NULL, `supplyResponseID` int(11) DEFAULT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `di_UN` (`Location`,`LatestDeliveryDateTime`,`FirstOrderDateTime`,`LatestOrderDateTime`,`supplyResponseID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8036,24 +7653,24 @@ DROP TABLE IF EXISTS `ekt`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ekt` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Id', - `barcode` char(15) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Generated auction barcode', + `barcode` char(25) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'Generated auction barcode', `entryYear` smallint(5) unsigned NOT NULL COMMENT 'Transaction year', `batchNumber` bigint(20) unsigned DEFAULT NULL COMMENT 'RFF+BT', `deliveryNumber` bigint(20) unsigned DEFAULT NULL COMMENT 'RFF+AAJ', `vendorOrderNumber` bigint(20) unsigned DEFAULT NULL COMMENT 'RFF+VN', `fec` date DEFAULT NULL COMMENT 'DTM+97', `hor` time DEFAULT NULL COMMENT 'UNB', - `now` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time', - `ptj` mediumint(8) unsigned DEFAULT NULL COMMENT 'NAD+BY', + `util.VN_NOW` timestamp NULL DEFAULT current_timestamp() COMMENT 'Creation time', + `ptj` bigint(20) unsigned DEFAULT NULL COMMENT 'NAD+BY', `ref` int(11) NOT NULL COMMENT 'LIN', - `item` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'IMD+S99', - `pac` int(11) DEFAULT '0' COMMENT 'QTY+52', + `item` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'IMD+S99', + `pac` int(11) DEFAULT 0 COMMENT 'QTY+52', `qty` int(10) NOT NULL COMMENT 'QTY+66', - `ori` varchar(3) COLLATE utf8_unicode_ci DEFAULT 'NL' COMMENT 'IMD+S62', - `cat` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'IMD+S98', + `ori` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT 'NL' COMMENT 'IMD+S62', + `cat` varchar(2) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'IMD+S98', `agj` int(11) DEFAULT NULL COMMENT 'RFF+AGJ', `kop` int(11) DEFAULT NULL COMMENT 'RFF+ADZ', - `ptd` varchar(6) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'RFF+ACE', + `ptd` varchar(6) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'RFF+ACE', `sub` mediumint(8) unsigned DEFAULT NULL COMMENT 'RFF+CTS', `pro` mediumint(8) unsigned NOT NULL COMMENT 'NAD+MF', `pri` double NOT NULL COMMENT 'PRI+INV', @@ -8064,21 +7681,20 @@ CREATE TABLE `ekt` ( `k2` smallint(5) unsigned DEFAULT NULL COMMENT 'IMD+K02', `k3` tinyint(3) unsigned DEFAULT NULL COMMENT 'IMD+P01', `k4` tinyint(3) unsigned DEFAULT NULL COMMENT 'IMD+P02', - `s1` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `s2` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `s3` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `s4` varchar(4) COLLATE utf8_unicode_ci DEFAULT NULL, - `s5` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `s6` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `ok` tinyint(4) NOT NULL DEFAULT '0', + `s1` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `s2` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `s3` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `s4` varchar(4) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `s5` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `s6` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `ok` tinyint(4) NOT NULL DEFAULT 0, `trolleyFk` int(11) DEFAULT NULL, `putOrderFk` bigint(20) unsigned DEFAULT NULL COMMENT 'RFF+ON', - `scanned` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Whether it''s been scanned', - `cps` varchar(7) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Código alfanumérico de Floriday', - `dp` int(11) DEFAULT NULL COMMENT 'NAD+DP', - `sender` int(11) DEFAULT NULL COMMENT 'NAD+SE', + `scanned` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Whether it''s been scanned', + `cps` varchar(7) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'Código alfanumérico de Floriday', + `dp` bigint(20) unsigned DEFAULT NULL COMMENT 'NAD+DP', + `sender` bigint(20) unsigned DEFAULT NULL COMMENT 'NAD+SE', PRIMARY KEY (`id`) USING BTREE, - UNIQUE KEY `barcode_year` (`barcode`,`entryYear`), UNIQUE KEY `entry_year` (`deliveryNumber`,`entryYear`) USING BTREE, KEY `ref` (`ref`), KEY `ptj` (`ptj`), @@ -8089,7 +7705,24 @@ CREATE TABLE `ekt` ( KEY `putOrderFk` (`putOrderFk`), KEY `ekt_batchNumber` (`batchNumber`) USING BTREE, KEY `ekt_vendorOrderNumber` (`vendorOrderNumber`) USING BTREE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `ektConfig` +-- + +DROP TABLE IF EXISTS `ektConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ektConfig` ( + `usefulAuctionLeftSegmentLength` int(11) NOT NULL DEFAULT 13 COMMENT 'Segmento aprovechable del codigo de barras de Floricode', + `standardBarcodeLength` int(11) NOT NULL DEFAULT 20 COMMENT 'Longitud del código de barras standard de Floricode', + `floridayBarcodeLength` int(11) NOT NULL DEFAULT 6, + `floramondoBarcodeLength` int(11) NOT NULL DEFAULT 13 COMMENT 'Longitud del código de los albaranes múltiples de Floramondo', + `defaultKlo` int(11) NOT NULL DEFAULT 99 COMMENT 'Reloj por defecto', + `ektRecentScopeDays` int(11) NOT NULL DEFAULT 7 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8109,9 +7742,69 @@ CREATE TABLE `ektEntryAssign__` ( `supplierFk` int(11) DEFAULT NULL, `entryFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='define las condiciones para asignar entradas a los ekt'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='define las condiciones para asignar entradas a los ekt'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `ektRecent` +-- + +DROP TABLE IF EXISTS `ektRecent`; +/*!50001 DROP VIEW IF EXISTS `ektRecent`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `ektRecent` ( + `id` tinyint NOT NULL, + `barcode` tinyint NOT NULL, + `entryYear` tinyint NOT NULL, + `batchNumber` tinyint NOT NULL, + `deliveryNumber` tinyint NOT NULL, + `vendorOrderNumber` tinyint NOT NULL, + `fec` tinyint NOT NULL, + `hor` tinyint NOT NULL, + `util.VN_NOW` tinyint NOT NULL, + `ptj` tinyint NOT NULL, + `ref` tinyint NOT NULL, + `item` tinyint NOT NULL, + `pac` tinyint NOT NULL, + `qty` tinyint NOT NULL, + `ori` tinyint NOT NULL, + `cat` tinyint NOT NULL, + `agj` tinyint NOT NULL, + `kop` tinyint NOT NULL, + `ptd` tinyint NOT NULL, + `sub` tinyint NOT NULL, + `pro` tinyint NOT NULL, + `pri` tinyint NOT NULL, + `package` tinyint NOT NULL, + `auction` tinyint NOT NULL, + `klo` tinyint NOT NULL, + `k1` tinyint NOT NULL, + `k2` tinyint NOT NULL, + `k3` tinyint NOT NULL, + `k4` tinyint NOT NULL, + `s1` tinyint NOT NULL, + `s2` tinyint NOT NULL, + `s3` tinyint NOT NULL, + `s4` tinyint NOT NULL, + `s5` tinyint NOT NULL, + `s6` tinyint NOT NULL, + `ok` tinyint NOT NULL, + `trolleyFk` tinyint NOT NULL, + `putOrderFk` tinyint NOT NULL, + `scanned` tinyint NOT NULL, + `cps` tinyint NOT NULL, + `dp` tinyint NOT NULL, + `sender` tinyint NOT NULL, + `usefulAuctionLeftSegmentLength` tinyint NOT NULL, + `standardBarcodeLength` tinyint NOT NULL, + `floridayBarcodeLength` tinyint NOT NULL, + `floramondoBarcodeLength` tinyint NOT NULL, + `defaultKlo` tinyint NOT NULL, + `ektRecentScopeDays` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `errorList` -- @@ -8152,7 +7845,7 @@ CREATE TABLE `exchange` ( KEY `buy_edi_id` (`ektFk`), CONSTRAINT `exchange_ibfk_1` FOREIGN KEY (`mailFk`) REFERENCES `mail` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `exchange_ibfk_2` FOREIGN KEY (`ektFk`) REFERENCES `ekt` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8164,14 +7857,14 @@ DROP TABLE IF EXISTS `exchangeConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `exchangeConfig` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `logMail` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Mail where the log information is sent', + `logMail` varchar(150) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'Mail where the log information is sent', `restrictToSenders` tinyint(4) NOT NULL COMMENT 'Whether to process mails only from known senders', `presaleFk` mediumint(8) unsigned DEFAULT NULL, `defaultKop` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `presale_id` (`presaleFk`), CONSTRAINT `exchangeConfig_ibfk_1` FOREIGN KEY (`presaleFk`) REFERENCES `exchangeType` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Configuration parameters'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Configuration parameters'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8183,9 +7876,9 @@ DROP TABLE IF EXISTS `exchangeType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `exchangeType` ( `id` mediumint(8) unsigned NOT NULL, - `description` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8197,14 +7890,14 @@ DROP TABLE IF EXISTS `feature`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `feature` ( `item_id` int(11) unsigned NOT NULL, - `feature_type_id` varchar(3) COLLATE utf8_unicode_ci NOT NULL, - `feature_value` varchar(3) COLLATE utf8_unicode_ci NOT NULL, + `feature_type_id` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, + `feature_value` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, `entry_date` date NOT NULL, `expiry_date` date NOT NULL, `change_date_time` datetime NOT NULL, PRIMARY KEY (`item_id`,`feature_type_id`), KEY `feature_ix1` (`feature_value`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='/tmp/floricode/florecompc2/FF130916.txt'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='/tmp/floricode/florecompc2/FF130916.txt'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8215,12 +7908,12 @@ DROP TABLE IF EXISTS `fileConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `fileConfig` ( - `name` varchar(25) COLLATE utf8_unicode_ci NOT NULL, - `checksum` text COLLATE utf8_unicode_ci, - `keyValue` tinyint(1) NOT NULL DEFAULT '1', + `name` varchar(25) COLLATE utf8mb3_unicode_ci NOT NULL, + `checksum` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `keyValue` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY (`name`), UNIQUE KEY `fileConfig_name_uindex` (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8231,9 +7924,9 @@ DROP TABLE IF EXISTS `floraHollandConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `floraHollandConfig` ( - `defaultAdminNumber` int(11) NOT NULL DEFAULT '66011', - `floramondoMargin` decimal(10,2) NOT NULL DEFAULT '0.17' -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + `defaultAdminNumber` int(11) NOT NULL DEFAULT 66011, + `floramondoMargin` decimal(10,2) NOT NULL DEFAULT 0.17 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8245,11 +7938,11 @@ DROP TABLE IF EXISTS `ftpConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ftpConfig` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `host` varchar(255) CHARACTER SET utf8 NOT NULL, - `user` varchar(50) CHARACTER SET utf8 NOT NULL, - `password` varchar(50) CHARACTER SET utf8 NOT NULL, + `host` varchar(255) CHARACTER SET utf8mb3 NOT NULL, + `user` varchar(50) CHARACTER SET utf8mb3 NOT NULL, + `password` varchar(50) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Configuration parameters'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Configuration parameters'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8261,13 +7954,13 @@ DROP TABLE IF EXISTS `genus`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `genus` ( `genus_id` mediumint(8) unsigned NOT NULL, - `latin_genus_name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `latin_genus_name` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, `entry_date` date DEFAULT NULL, `expiry_date` date DEFAULT NULL, `change_date_time` datetime DEFAULT NULL, - `isHazard` tinyint(1) NOT NULL DEFAULT '0', + `isHazard` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`genus_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='/tmp/floricode/florecompc2/FG130916.txt'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='/tmp/floricode/florecompc2/FG130916.txt'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8278,11 +7971,11 @@ DROP TABLE IF EXISTS `goodCharacteristic`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `goodCharacteristic` ( - `supplyResponse` varchar(26) COLLATE utf8_unicode_ci NOT NULL, - `type` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'edi.type', - `value` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'edi.value', + `supplyResponse` varchar(26) COLLATE utf8mb3_unicode_ci NOT NULL, + `type` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'edi.type', + `value` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'edi.value', PRIMARY KEY (`supplyResponse`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8294,16 +7987,16 @@ DROP TABLE IF EXISTS `imapConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `imapConfig` ( `id` tinyint(3) unsigned NOT NULL, - `environment` varchar(45) CHARACTER SET utf8 NOT NULL, - `host` varchar(150) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'localhost', - `user` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `pass` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `cleanPeriod` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'How long the old mails are preserved', - `successFolder` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `errorFolder` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, + `environment` varchar(45) CHARACTER SET utf8mb3 NOT NULL, + `host` varchar(150) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'localhost', + `user` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `pass` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `cleanPeriod` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'How long the old mails are preserved', + `successFolder` varchar(150) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `errorFolder` varchar(150) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `imapConfig_environment` (`environment`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='IMAP configuration parameters'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='IMAP configuration parameters'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8315,8 +8008,8 @@ DROP TABLE IF EXISTS `item`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `item` ( `id` int(11) unsigned NOT NULL, - `product_name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `product_name` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `name` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, `plant_id` mediumint(8) unsigned DEFAULT NULL, `group_id` int(11) unsigned DEFAULT NULL, `entry_date` date DEFAULT NULL, @@ -8325,7 +8018,7 @@ CREATE TABLE `item` ( PRIMARY KEY (`id`), KEY `group_id` (`group_id`), KEY `plant_id` (`plant_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='/tmp/floricode/florecompc2/FP130916.txt'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='/tmp/floricode/florecompc2/FP130916.txt'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8340,7 +8033,7 @@ CREATE TABLE `item_defaultType` ( `itemTypeFk` int(11) NOT NULL, `bucket_id` int(11) DEFAULT NULL, PRIMARY KEY (`item_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='guarda las excepciones de los item holandeses para asignarles nuestros cubos y nuestros tipos'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='guarda las excepciones de los item holandeses para asignarles nuestros cubos y nuestros tipos'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8353,13 +8046,13 @@ DROP TABLE IF EXISTS `item_feature`; CREATE TABLE `item_feature` ( `item_id` int(11) NOT NULL, `presentation_order` tinyint(11) unsigned NOT NULL, - `feature` varchar(3) COLLATE utf8_unicode_ci NOT NULL, + `feature` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, `regulation_type` tinyint(3) unsigned NOT NULL, `entry_date` date NOT NULL, `expiry_date` date DEFAULT NULL, `change_date_time` datetime NOT NULL, PRIMARY KEY (`item_id`,`presentation_order`,`entry_date`,`change_date_time`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='/tmp/floricode/florecompc2/FY130916.txt'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='/tmp/floricode/florecompc2/FY130916.txt'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -8395,7 +8088,7 @@ CREATE TABLE `item_free` ( `id` int(11) NOT NULL, `token` int(11) DEFAULT NULL COMMENT 'campo para asegurar que solo el usuario coge uno de los valores', PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8407,12 +8100,12 @@ DROP TABLE IF EXISTS `item_group`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `item_group` ( `group_code` int(11) unsigned NOT NULL, - `dutch_group_description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `dutch_group_description` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, `entry_date` date NOT NULL, `expiry_date` date NOT NULL, `change_date_time` datetime NOT NULL, PRIMARY KEY (`group_code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='/tmp/floricode/florecompc2/FO130916.txt'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='/tmp/floricode/florecompc2/FO130916.txt'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8426,8 +8119,8 @@ CREATE TABLE `item_groupToOffer` ( `group_code` int(11) unsigned NOT NULL, `itemTypeFk` smallint(5) unsigned NOT NULL, `intrastatFk` int(8) unsigned zerofill NOT NULL, - `originFk` tinyint(2) unsigned NOT NULL DEFAULT '17', - `expenseFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT '7001000000', + `originFk` tinyint(2) unsigned NOT NULL DEFAULT 17, + `expenseFk` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT '7001000000', PRIMARY KEY (`group_code`), KEY `item_groupToOffer_fk2_idx` (`itemTypeFk`), KEY `item_groupToOffer_fk3_idx` (`intrastatFk`), @@ -8435,7 +8128,7 @@ CREATE TABLE `item_groupToOffer` ( CONSTRAINT `item_groupToOffer_fk2` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `item_groupToOffer_fk3` FOREIGN KEY (`intrastatFk`) REFERENCES `vn`.`intrastat` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `item_groupToOffer_fk4` FOREIGN KEY (`originFk`) REFERENCES `vn`.`origin` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='se ofreceran para ser comprados'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='se ofreceran para ser comprados'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8447,22 +8140,22 @@ DROP TABLE IF EXISTS `item_track`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `item_track` ( `item_id` int(10) unsigned NOT NULL, - `s1` tinyint(3) NOT NULL DEFAULT '0', - `s2` tinyint(3) NOT NULL DEFAULT '0', - `s3` tinyint(3) NOT NULL DEFAULT '0', - `s4` tinyint(3) NOT NULL DEFAULT '0', - `pac` tinyint(3) NOT NULL DEFAULT '0', - `cat` tinyint(3) NOT NULL DEFAULT '0', - `ori` tinyint(3) NOT NULL DEFAULT '0', - `pro` tinyint(3) NOT NULL DEFAULT '0', - `package` tinyint(3) NOT NULL DEFAULT '0', - `s5` tinyint(3) NOT NULL DEFAULT '0', - `s6` tinyint(3) NOT NULL DEFAULT '0', - `kop` tinyint(3) NOT NULL DEFAULT '0', - `sub` tinyint(3) NOT NULL DEFAULT '0', - `item` tinyint(3) NOT NULL DEFAULT '0', + `s1` tinyint(3) NOT NULL DEFAULT 0, + `s2` tinyint(3) NOT NULL DEFAULT 0, + `s3` tinyint(3) NOT NULL DEFAULT 0, + `s4` tinyint(3) NOT NULL DEFAULT 0, + `pac` tinyint(3) NOT NULL DEFAULT 0, + `cat` tinyint(3) NOT NULL DEFAULT 0, + `ori` tinyint(3) NOT NULL DEFAULT 0, + `pro` tinyint(3) NOT NULL DEFAULT 0, + `package` tinyint(3) NOT NULL DEFAULT 0, + `s5` tinyint(3) NOT NULL DEFAULT 0, + `s6` tinyint(3) NOT NULL DEFAULT 0, + `kop` tinyint(3) NOT NULL DEFAULT 0, + `sub` tinyint(3) NOT NULL DEFAULT 0, + `item` tinyint(3) NOT NULL DEFAULT 0, PRIMARY KEY (`item_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8474,12 +8167,12 @@ DROP TABLE IF EXISTS `log`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `log` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `tableName` varchar(100) COLLATE utf8_unicode_ci NOT NULL, - `fieldName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - `fieldValue` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `tableName` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, + `fieldName` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `fieldValue` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8492,17 +8185,17 @@ DROP TABLE IF EXISTS `mail`; CREATE TABLE `mail` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `senderFk` int(10) unsigned DEFAULT NULL, - `sender` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `messageId` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `sender` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `messageId` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `nExchanges` int(10) unsigned NOT NULL, - `error` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `source` text COLLATE utf8_unicode_ci, + `error` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `source` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `mail_id` (`messageId`), KEY `sender_id` (`senderFk`), CONSTRAINT `mail_ibfk_2` FOREIGN KEY (`senderFk`) REFERENCES `mailSender` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8514,11 +8207,11 @@ DROP TABLE IF EXISTS `mailSender`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mailSender` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `mail` varchar(150) COLLATE utf8_unicode_ci NOT NULL, + `mail` varchar(150) COLLATE utf8mb3_unicode_ci NOT NULL, `kop` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `mail` (`mail`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='List of allowed mailers'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='List of allowed mailers'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8529,18 +8222,18 @@ DROP TABLE IF EXISTS `marketPlace`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `marketPlace` ( - `id` varchar(13) COLLATE utf8_unicode_ci NOT NULL, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `supplierFk` int(11) NOT NULL DEFAULT '1433', - `isOffered` tinyint(2) NOT NULL DEFAULT '0', + `id` varchar(13) COLLATE utf8mb3_unicode_ci NOT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `supplierFk` int(11) NOT NULL DEFAULT 1433, + `isOffered` tinyint(2) NOT NULL DEFAULT 0, `MaxLatestDeliveryHour` int(11) DEFAULT NULL COMMENT 'Maxima hora para tener en cuenta la oferta', - `isLatestOrderDateTimeRelevant` tinyint(2) DEFAULT '0' COMMENT 'Se tiene en cuenta para calcular el próximo travel posible', - `isEarlyBird` tinyint(4) NOT NULL DEFAULT '0', + `isLatestOrderDateTimeRelevant` tinyint(2) DEFAULT 0 COMMENT 'Se tiene en cuenta para calcular el próximo travel posible', + `isEarlyBird` tinyint(4) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `marketPlaceisOfferedIdx` (`isOffered`), KEY `marketPlaceMaxLatestIdx` (`MaxLatestDeliveryHour`), KEY `marketPlace_isLatestOrderDateTimeRelevant_IDX` (`isLatestOrderDateTimeRelevant`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8551,13 +8244,13 @@ DROP TABLE IF EXISTS `offerList`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `offerList` ( - `supplier` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `supplier` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, `total` int(11) DEFAULT NULL COMMENT 'Total de oferta', `filter` int(11) DEFAULT NULL COMMENT 'Total en edi.supplyOffer', `vnh` int(11) DEFAULT NULL COMMENT 'Total en la entrada de VNH', `algemesi` int(11) DEFAULT NULL COMMENT 'Total en la entrada de Algemesi', PRIMARY KEY (`supplier`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de las ofertas para mostrar en grafana'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Lista de las ofertas para mostrar en grafana'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8569,16 +8262,16 @@ DROP TABLE IF EXISTS `param`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `param` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `code` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `name` varchar(5) COLLATE utf8_unicode_ci NOT NULL, - `subname` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, - `position` tinyint(3) unsigned NOT NULL DEFAULT '1', - `type` enum('INTEGER','DOUBLE','STRING','DATE','TIME') COLLATE utf8_unicode_ci NOT NULL, - `required` tinyint(3) unsigned NOT NULL DEFAULT '1', + `code` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL, + `name` varchar(5) COLLATE utf8mb3_unicode_ci NOT NULL, + `subname` varchar(5) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `position` tinyint(3) unsigned NOT NULL DEFAULT 1, + `type` enum('INTEGER','DOUBLE','STRING','DATE','TIME') COLLATE utf8mb3_unicode_ci NOT NULL, + `required` tinyint(3) unsigned NOT NULL DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `code` (`code`), UNIQUE KEY `name` (`name`,`subname`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Parameters to capture of every exchange'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Parameters to capture of every exchange'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8596,7 +8289,7 @@ CREATE TABLE `plant` ( `expiry_date` date DEFAULT NULL, `change_date_time` datetime DEFAULT NULL, PRIMARY KEY (`plant_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='/tmp/floricode/florecompc2/FT130916.txt'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='/tmp/floricode/florecompc2/FT130916.txt'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8611,16 +8304,16 @@ CREATE TABLE `putOrder` ( `deliveryInformationID` int(11) DEFAULT NULL, `supplyResponseID` int(11) DEFAULT NULL, `orderTradelineItemID` int(11) DEFAULT NULL COMMENT 'ticketFk or EntryFk?', - `OrderTradeLineDateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'fecha de creacion en la tabla', + `OrderTradeLineDateTime` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'fecha de creacion en la tabla', `quantity` int(11) DEFAULT NULL, - `EndUserPartyID` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `EndUserPartyGLN` varchar(13) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The grower can use this reference in his EKT in the NAD (MA) segment.', - `OrderStatus` int(11) DEFAULT '0' COMMENT '1 pending\n2 confirmed\n3 canceled', + `EndUserPartyID` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `EndUserPartyGLN` varchar(13) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'The grower can use this reference in his EKT in the NAD (MA) segment.', + `OrderStatus` int(11) DEFAULT 0 COMMENT '1 pending\n2 confirmed\n3 canceled', `isOrderProcessed` tinyint(4) DEFAULT NULL, - `error` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `barcode` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `FHAdminNumber` int(11) DEFAULT '66011', + `error` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `barcode` varchar(25) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `FHAdminNumber` int(11) DEFAULT 66011, `saleFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `orderTradelineItemID_UNIQUE` (`orderTradelineItemID`), @@ -8628,7 +8321,7 @@ CREATE TABLE `putOrder` ( KEY `supplyResponseID_idx` (`supplyResponseID`), KEY `putOrder_FK` (`saleFk`), CONSTRAINT `putOrder_FK` FOREIGN KEY (`saleFk`) REFERENCES `vn`.`sale` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -8645,9 +8338,9 @@ DELIMITER ;; BEGIN DECLARE nextID INT; - + SELECT 1 + MAX(id) INTO nextID FROM putOrder ; - + SET NEW.orderTradelineItemID = nextID; END */;; @@ -8669,36 +8362,36 @@ DELIMITER ;; BEFORE UPDATE ON `putOrder` FOR EACH ROW BEGIN - + DECLARE vError VARCHAR(100) DEFAULT 'Orderregel niet meer teruggevonden op basis van de orderps'; DECLARE vVmpIdError INT DEFAULT 7; DECLARE vVmpFk INT; DECLARE vSupplyResponseNumberOfUnits INT; - - SELECT sr.vmpID INTO vVmpFk - FROM edi.supplyResponse sr + + SELECT sr.vmpID INTO vVmpFk + FROM edi.supplyResponse sr WHERE sr.id = NEW.supplyResponseID; - - IF NEW.OrderStatus = 3 - AND NOT (NEW.OrderStatus <=> OLD.OrderStatus) - AND NEW.error = vError - AND vVmpFk = vVmpIdError - - THEN - + + IF NEW.OrderStatus = 3 + AND NOT (NEW.OrderStatus <=> OLD.OrderStatus) + AND NEW.error = vError + AND vVmpFk = vVmpIdError + + THEN + SET NEW.OrderStatus = 2; - + END IF; - + -- Error de disponible menor de lo solicitado IF NEW.error LIKE 'error2602%' THEN - + SELECT NumberOfUnits INTO vSupplyResponseNumberOfUnits - FROM edi.supplyResponse sr + FROM edi.supplyResponse sr WHERE sr.ID = NEW.supplyResponseID; - + SET NEW.error = CONCAT('(',vSupplyResponseNumberOfUnits,') ', NEW.error); - + END IF; END */;; DELIMITER ; @@ -8725,24 +8418,24 @@ BEGIN DECLARE vIsEktSender BOOLEAN; IF NEW.OrderStatus = vOrderStatusDenied AND NOT (NEW.OrderStatus <=> OLD.OrderStatus) THEN - + SELECT s.id INTO vSaleFk - FROM vn.sale s + FROM vn.sale s JOIN vn.ticket t ON s.ticketFk = t.id JOIN vn.item i ON i.id = s.itemFk JOIN deliveryInformation di ON di.ID = NEW.deliveryInformationID - WHERE t.clientFk = NEW.EndUserPartyGLN AND t.shipped >= CURDATE() + WHERE t.clientFk = NEW.EndUserPartyGLN AND t.shipped >= util.VN_CURDATE() AND i.supplyResponseFk = NEW.supplyResponseID LIMIT 1; - + UPDATE vn.sale s JOIN vn.ticket t ON s.ticketFk = t.id JOIN vn.item i ON i.id = s.itemFk JOIN deliveryInformation di ON di.ID = NEW.deliveryInformationID SET s.quantity = 0 - WHERE t.clientFk = NEW.EndUserPartyGLN AND t.shipped >= CURDATE() + WHERE t.clientFk = NEW.EndUserPartyGLN AND t.shipped >= util.VN_CURDATE() AND i.supplyResponseFk = NEW.supplyResponseID; - + INSERT INTO vn.mail (sender, `subject`, body) SELECT IF(u.id IS NOT NULL AND c.email IS NOT NULL, c.email, @@ -8754,26 +8447,26 @@ BEGIN IF (u.id IS NOT NULL AND c.email IS NOT NULL , CONCAT('https://verdnatura.es/#!form=ecomerce%2Fticket&ticket=', t.id ), CONCAT('https://salix.verdnatura.es/#!/ticket/', t.id ,'/summary'))) - FROM vn.sale s + FROM vn.sale s JOIN vn.ticket t ON t.id = s.ticketFk JOIN vn.`client` c ON c.id = t.clientFk LEFT JOIN account.user u ON u.id= c.salesPersonFk AND u.name IN ('ruben', 'ismaelalcolea') WHERE s.id = vSaleFk; - + END IF; IF NEW.OrderStatus = vOrderStatusOK AND NOT (NEW.OrderStatus <=> OLD.OrderStatus) THEN - SELECT v.isEktSender INTO vIsEktSender + SELECT v.isEktSender INTO vIsEktSender FROM edi.VMPSettings v - JOIN edi.supplyResponse sr ON sr.vmpID = v.VMPID + JOIN edi.supplyResponse sr ON sr.vmpID = v.VMPID WHERE sr.id = NEW.supplyResponseID; - + IF NOT vIsEktSender THEN CALL edi.ekt_add(NEW.id); - + END IF; IF NEW.barcode THEN @@ -8782,7 +8475,7 @@ BEGIN SELECT i.id, NEW.barcode FROM vn.item i WHERE i.supplyResponseFk = NEW.supplyResponseID; - + END IF; END IF; @@ -8804,12 +8497,12 @@ DROP TABLE IF EXISTS `specie`; CREATE TABLE `specie` ( `specie_id` mediumint(8) unsigned NOT NULL, `genus_id` mediumint(8) unsigned NOT NULL, - `latin_species_name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `latin_species_name` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, `entry_date` date DEFAULT NULL, `expiry_date` date DEFAULT NULL, `change_date_time` datetime DEFAULT NULL, PRIMARY KEY (`specie_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='/tmp/floricode/florecompc2/FS130916.txt'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='/tmp/floricode/florecompc2/FS130916.txt'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8821,17 +8514,17 @@ DROP TABLE IF EXISTS `supplier`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `supplier` ( `supplier_id` int(10) unsigned NOT NULL COMMENT 'FHRegistrationNr', - `glnAddressCode` varchar(13) COLLATE utf8_unicode_ci DEFAULT NULL, - `company_name` varchar(70) COLLATE utf8_unicode_ci NOT NULL, + `glnAddressCode` varchar(13) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `company_name` varchar(70) COLLATE utf8mb3_unicode_ci NOT NULL, `entry_date` date NOT NULL, `expiry_date` date NOT NULL, `change_date_time` datetime NOT NULL, - `isAllowedDirectSales` tinyint(1) NOT NULL DEFAULT '0', - `isBanned` tinyint(1) NOT NULL DEFAULT '0', + `isAllowedDirectSales` tinyint(1) NOT NULL DEFAULT 0, + `isBanned` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`supplier_id`), UNIQUE KEY `supplier_UN` (`glnAddressCode`), KEY `glnaddressCodeidx` (`glnAddressCode`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='/tmp/floricode/FEC010104/CC090916.txt'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='/tmp/floricode/FEC010104/CC090916.txt'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8899,60 +8592,60 @@ DROP TABLE IF EXISTS `supplyResponse`; CREATE TABLE `supplyResponse` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `NumberBunchesPerCask` int(11) DEFAULT NULL, - `SupplierGLN` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `SupplierGLN` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `NewItem` tinyint(1) DEFAULT NULL, - `SendererID` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `ItemSupplierID` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `SendererID` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `ItemSupplierID` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `TransactionDate` datetime DEFAULT NULL, - `TransactionNumber` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `AuctionClockNumber` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `SupplierID` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `TransactionNumber` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `AuctionClockNumber` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `SupplierID` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `ItemDatesupplyResponsecol` datetime DEFAULT NULL, `Item_ArticleCode` int(11) DEFAULT NULL, - `VBNOmschrijving` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `ExtraRemark` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `ArtCodeType` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `VBNGroupCode` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `VBNGroupDescription` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `VBNOmschrijving` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `ExtraRemark` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `ArtCodeType` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `VBNGroupCode` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `VBNGroupDescription` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `TransactionTime` time DEFAULT NULL, - `CountryOfOrigin` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `CountryOfOrigin` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `NumberOfItemsPerCask` int(11) DEFAULT NULL, `NumberOfLayersPerTrolley` int(11) DEFAULT NULL, `NumberOfUnits` int(11) DEFAULT NULL, `MinimumNumberToOrder` int(11) DEFAULT NULL, - `MinimumOrderUnitType` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `MinimumOrderUnitType` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `Price` decimal(10,2) DEFAULT NULL, - `Quality` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `s1` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `s2` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `s3` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `s4` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `s5` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `s6` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `ExaminiationCode1` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `ExaminiationCode2` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `OrderUnitType` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `Quality` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `s1` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `s2` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `s3` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `s4` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `s5` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `s6` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `ExaminiationCode1` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `ExaminiationCode2` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `OrderUnitType` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `EmbalageCode` int(11) DEFAULT NULL, - `PictureReference` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `AgentGLN` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `PictureReference` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `AgentGLN` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `MaximumNumberToOrder` int(11) DEFAULT NULL, `MaximumOrderType` tinyint(1) DEFAULT NULL COMMENT 'Unit: 1 = piece, 2 = bunch, 3 = box, 4 = layer, 5 = load carrier/trolley', `IncrementalOrderableQuantity` int(11) DEFAULT NULL, `IncrementalOrderableQuantityType` tinyint(1) DEFAULT NULL COMMENT 'Unit: 1 = piece, 2 = bunch, 3 = box, 4 = layer, 5 = load carrier/trolley', `PackingPrice` decimal(10,2) DEFAULT NULL, - `PackingPriceType` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL, + `PackingPriceType` varchar(25) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `PackingPriceQuantity` int(11) DEFAULT NULL, `PackingPriceQuantityType` tinyint(1) DEFAULT NULL COMMENT 'Unit: 1 = piece, 2 = bunch, 3 = box, 4 = layer, 5 = load carrier/trolley', - `MarketPlaceID` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `MarketFormCode` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '"002" Standard Sales\n"005" Catalogue (optional)\n"001" Committed (optional)\n"003" Buffer (optional, Clock Pre Sales) ', - `FlowerColor` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `MarketPlaceID` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `MarketFormCode` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT '"002" Standard Sales\n"005" Catalogue (optional)\n"001" Committed (optional)\n"003" Buffer (optional, Clock Pre Sales) ', + `FlowerColor` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `vmpID` int(11) DEFAULT NULL, `widthMeasure` int(11) DEFAULT NULL COMMENT 'mm Embalage Width', `lengthMeasure` int(11) DEFAULT NULL COMMENT 'mm Embalage Length', `heightMeasure` int(11) DEFAULT NULL COMMENT 'mm Embalage Height', - `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `EmbalageCodeSupplier` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `created` datetime NOT NULL DEFAULT current_timestamp(), + `EmbalageCodeSupplier` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), PRIMARY KEY (`ID`), KEY `IX_TransNumber` (`TransactionNumber`) COMMENT 'Agregado por Ernesto 11.6.2019\nSe ejecutaba 1 consulta por segundo desde MAIL y consumia un 20% de CPU de todo el servidor !!!!!\nCPU usada es mas estable que Indice en SendererID, cpu vs espacio que ocupa?\n', KEY `supplyResponse_Ix1` (`Item_ArticleCode`), @@ -8963,7 +8656,7 @@ CREATE TABLE `supplyResponse` ( KEY `supplyResponse_updated_IDX` (`updated`) USING BTREE, CONSTRAINT `supplyResponse_fk2` FOREIGN KEY (`MarketPlaceID`) REFERENCES `marketPlace` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `supplyResponseputOrder_FK` FOREIGN KEY (`vmpID`) REFERENCES `VMPSettings` (`VMPID`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -8981,8 +8674,8 @@ BEGIN UPDATE vn.buy b JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.travel tr ON tr.id = e.travelFk - JOIN vn.agencyMode am ON am.id = tr.agencyModeFk + JOIN vn.travel tr ON tr.id = e.travelFk + JOIN vn.agencyMode am ON am.id = tr.agencyModeFk JOIN vn.item i ON i.id = b.itemFk JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID SET b.quantity = NEW.NumberOfItemsPerCask * NEW.NumberOfUnits, @@ -8990,8 +8683,8 @@ BEGIN WHERE i.supplyResponseFk = NEW.ID AND am.name = 'LOGIFLORA' AND e.isRaid - AND tr.landed >= CURDATE(); - + AND tr.landed >= util.VN_CURDATE(); + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -9009,14 +8702,14 @@ DROP TABLE IF EXISTS `supplyResponseLog`; CREATE TABLE `supplyResponseLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `supplyResponseFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `NumberOfUnitsOld` int(11) DEFAULT NULL, `NumberOfUnitsNew` int(11) DEFAULT NULL, `lastVMPUpdate` datetime DEFAULT NULL, PRIMARY KEY (`id`), KEY `supplyResponseLog_FK` (`supplyResponseFk`), CONSTRAINT `supplyResponseLog_FK` FOREIGN KEY (`supplyResponseFk`) REFERENCES `supplyResponse` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Esta tabla la utiliza la empresa LOGIFLORA. No kkear.'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Esta tabla la utiliza la empresa LOGIFLORA. No kkear.'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9027,13 +8720,13 @@ DROP TABLE IF EXISTS `tableConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tableConfig` ( - `fileName` varchar(2) COLLATE utf8_unicode_ci NOT NULL, - `toTable` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `file` varchar(30) COLLATE utf8_unicode_ci NOT NULL, + `fileName` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL, + `toTable` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL, + `file` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL, `updated` date DEFAULT NULL, PRIMARY KEY (`fileName`), UNIQUE KEY `to_table` (`toTable`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9044,14 +8737,14 @@ DROP TABLE IF EXISTS `type`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `type` ( - `type_id` varchar(3) COLLATE utf8_unicode_ci NOT NULL, + `type_id` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, `type_group_id` tinyint(3) unsigned NOT NULL, - `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, `entry_date` date NOT NULL, `expiry_date` date NOT NULL, `change_date_time` datetime NOT NULL, PRIMARY KEY (`type_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='/tmp/floricode/florecompc2/FE130916.txt'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='/tmp/floricode/florecompc2/FE130916.txt'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9062,14 +8755,14 @@ DROP TABLE IF EXISTS `value`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `value` ( - `type_id` varchar(3) COLLATE utf8_unicode_ci NOT NULL, - `type_value` varchar(3) COLLATE utf8_unicode_ci NOT NULL, - `type_description` varchar(70) COLLATE utf8_unicode_ci NOT NULL, + `type_id` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, + `type_value` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, + `type_description` varchar(70) COLLATE utf8mb3_unicode_ci NOT NULL, `entry_date` date NOT NULL, `expiry_date` date NOT NULL, `change_date_time` datetime NOT NULL, PRIMARY KEY (`type_id`,`type_value`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='/tmp/floricode/florecompc2/FV130916.txt'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='/tmp/floricode/florecompc2/FV130916.txt'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9081,15 +8774,15 @@ DROP TABLE IF EXISTS `warehouseFloramondo`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `warehouseFloramondo` ( `warehouseFk` smallint(6) unsigned NOT NULL, - `travellingDays` int(11) NOT NULL DEFAULT '1', + `travellingDays` int(11) NOT NULL DEFAULT 1, `entryFk` int(11) DEFAULT NULL, `isFV` int(11) DEFAULT NULL COMMENT 'NULL indiferente\n0 no\n1 si\n', - `dayRange` int(11) NOT NULL DEFAULT '0' COMMENT 'dias de margen a futuro', + `dayRange` int(11) NOT NULL DEFAULT 0 COMMENT 'dias de margen a futuro', PRIMARY KEY (`warehouseFk`), KEY `warehouseFloramondo_FK2_idx` (`entryFk`), CONSTRAINT `warehouseFloramondo_FK2` FOREIGN KEY (`entryFk`) REFERENCES `vn`.`entry` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `warehouseFloramondo_fk` FOREIGN KEY (`warehouseFk`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9120,8 +8813,6 @@ DELIMITER ; -- -- Dumping routines for database 'edi' -- -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `imageName` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -9129,11 +8820,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `imageName`(vPictureReference VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `imageName`(vPictureReference VARCHAR(255)) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN - + SET vPictureReference = REPLACE(vPictureReference,'.',''); SET vPictureReference = REPLACE(vPictureReference,'/',''); @@ -9145,7 +8838,7 @@ BEGIN SET vPictureReference = REPLACE(vPictureReference,'?',''); SET vPictureReference = REPLACE(vPictureReference,'=',''); - + RETURN vPictureReference; END ;; @@ -9154,8 +8847,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -9163,31 +8854,31 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`() BEGIN - DECLARE vFourYearsAgo DATE DEFAULT TIMESTAMPADD(YEAR,-4,CURDATE()); - DECLARE vOneWeekAgo DATE DEFAULT TIMESTAMPADD(WEEK,-1,CURDATE()); + DECLARE vFourYearsAgo DATE DEFAULT TIMESTAMPADD(YEAR,-4,util.VN_CURDATE()); + DECLARE vOneWeekAgo DATE DEFAULT TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); DELETE FROM ekt WHERE fec < vFourYearsAgo; - + DELETE IGNORE sr.* FROM supplyResponse sr LEFT JOIN edi.deliveryInformation di ON sr.ID = di.supplyResponseID WHERE di.LatestOrderDateTime < vOneWeekAgo OR di.ID IS NULL; - - DELETE FROM putOrder - WHERE created < TIMESTAMPADD(MONTH,-1,CURDATE()); - + + DELETE FROM putOrder + WHERE created < TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()); + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `deliveryInformation_Delete` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -9195,38 +8886,38 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `deliveryInformation_Delete`() BEGIN - + DECLARE vID INT; DECLARE vGap INT DEFAULT 100; DECLARE vTope INT; - - SELECT MIN(ID), MAX(ID) + + SELECT MIN(ID), MAX(ID) INTO vID, vTope FROM edi.deliveryInformation; - WHILE vID <= vTope DO - + WHILE vID <= vTope DO + SET vID = vID + vGap; - - DELETE - FROM edi.deliveryInformation + + DELETE + FROM edi.deliveryInformation WHERE ID < vID AND EarliestDespatchDateTime IS NULL; - + 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ekt_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -9234,18 +8925,20 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ekt_add`(vPutOrderFk INT) BEGIN - + /** * Añade ekt para las ordenes de compra de proveedores que no envian el ekt por email - * + * * @param vPutOrderFk PutOrderId de donde coger los datos **/ - - INSERT INTO edi.ekt(entryYear, - deliveryNumber, + + INSERT INTO edi.ekt(entryYear, + deliveryNumber, fec, hor, item, @@ -9265,7 +8958,7 @@ BEGIN putOrderFk, `ref`, kop) - SELECT year(curdate()) entryYear, + SELECT year(util.VN_CURDATE()) entryYear, p.id deliveryNumber , DATE(di.LatestDeliveryDateTime) fec, HOUR(di.LatestDeliveryDateTime) hor, @@ -9285,36 +8978,36 @@ BEGIN i.value10 s6, p.id putOrderFk, sr.Item_ArticleCode, - sr.vmpID + sr.vmpID FROM edi.putOrder p - JOIN edi.supplyResponse sr ON sr.ID = p.supplyResponseID - JOIN edi.deliveryInformation di ON di.id = p.deliveryInformationID - JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID - JOIN vn.item i ON i.supplyResponseFk = sr.ID - JOIN vn.origin o ON o.id = i.originFk + JOIN edi.supplyResponse sr ON sr.ID = p.supplyResponseID + JOIN edi.deliveryInformation di ON di.id = p.deliveryInformationID + JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID + JOIN vn.item i ON i.supplyResponseFk = sr.ID + JOIN vn.origin o ON o.id = i.originFk WHERE p.id = vPutOrderFk; - + CALL edi.ekt_load(LAST_INSERT_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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ekt_load` */; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ekt_load`(IN `vSelf` INT) proc:BEGIN - + DECLARE vRef INT; DECLARE vBuy INT; DECLARE vItem INT; @@ -9339,51 +9032,51 @@ proc:BEGIN FROM edi.ekt e LEFT JOIN edi.item i ON e.ref = i.id LEFT JOIN edi.putOrder po ON po.id = e.putOrderFk - LEFT JOIN vn.item i2 ON i2.supplyResponseFk = po.supplyResponseID + LEFT JOIN vn.item i2 ON i2.supplyResponseFk = po.supplyResponseID LEFT JOIN vn.ektEntryAssign eea ON eea.sub = e.sub LEFT JOIN edi.item_groupToOffer igto ON igto.group_code = i.group_id WHERE e.id = vSelf LIMIT 1; - + IF NOT vHasItemGroup THEN - + CALL vn.mail_insert('logistica@verdnatura.es', 'nocontestar@verdnatura.es', 'Nuevo grupo en Floramondo', vDescription); - + CALL vn.mail_insert('pako@verdnatura.es', 'nocontestar@verdnatura.es', CONCAT('Nuevo grupo en Floramondo: ', vDescription), vDescription); - + LEAVE proc; - + END IF; - + -- Asigna la entrada SELECT vn.ekt_getEntry(vSelf) INTO vEntryFk; - + -- Inserta el cubo si no existe IF vPackage = 800 THEN - + SET vHasToChangePackagingFk = TRUE; - + IF vItem THEN - + SELECT vn.item_getPackage(vItem) INTO vPackage ; - + ELSE - + SET vPackage = 8000 + vQty; INSERT IGNORE INTO vn.packaging(id, width, `depth`) SELECT vPackage, vc.ccLength / vQty, vc.ccWidth FROM vn.volumeConfig vc; - + END IF; - + ELSE - + INSERT IGNORE INTO vn2008.Cubos (Id_Cubo, X, Y, Z) SELECT bucket_id, ROUND(x_size/10), ROUND(y_size/10), ROUND(z_size/10) FROM bucket WHERE bucket_id = vPackage; - + IF ROW_COUNT() > 0 THEN INSERT INTO vn2008.mail SET @@ -9392,27 +9085,27 @@ proc:BEGIN `to` = 'ekt@verdnatura.es'; END IF; END IF; - + -- Si es una compra de Logiflora obtiene el articulo IF vPutOrderFk THEN - + SELECT i.id INTO vItem FROM edi.putOrder po JOIN vn.item i ON i.supplyResponseFk = po.supplyResponseID WHERE po.id = vPutOrderFk LIMIT 1; - + END IF; INSERT IGNORE INTO item_track SET item_id = vRef; - + IF IFNULL(vItem,0) = 0 THEN - + -- Intenta obtener el artículo en base a los atributos holandeses - + SELECT b.id, IFNULL(b.itemOriginalFk ,b.itemFk) INTO vBuy, vItem - FROM edi.ekt e + FROM edi.ekt e JOIN edi.item_track t ON t.item_id = e.ref LEFT JOIN edi.ekt l ON l.ref = e.ref LEFT JOIN vn.buy b ON b.ektFk = l.id @@ -9433,19 +9126,19 @@ proc:BEGIN AND IF(t.pro, l.pro = e.pro, TRUE) AND IF(t.package, l.package = e.package, TRUE) AND IF(t.item, l.item = e.item, TRUE) - AND i.isFloramondo = vIsFloramondoDirect - ORDER BY l.now DESC, b.id ASC + AND i.isFloramondo = vIsFloramondoDirect + ORDER BY l.util.VN_NOW DESC, b.id ASC LIMIT 1; END IF; - + -- Si no encuentra el articulo lo crea en el caso de las compras directas en Floramondo IF ISNULL(vItem) AND vIsFloramondoDirect THEN - + CALL edi.item_getNewByEkt(vSelf, vItem); - + END IF; - + INSERT INTO vn.buy ( entryFk @@ -9469,16 +9162,16 @@ proc:BEGIN ,e.qty stickers ,@pac := IFNULL(i.stemMultiplier, 1) * e.pac / @t packing ,IFNULL(b.`grouping`, e.pac) - ,@pac * e.qty + ,@pac * e.qty ,vForceToPacking ,s.`name` ,IF(vHasToChangePackagingFk OR ISNULL(b.packageFk), vPackage, b.packageFk) - ,i.density * (vn.item_getVolume(i.id, IFNULL(b.packageFk, e.package)) / 1000000) - FROM edi.ekt e + ,b.weight + FROM edi.ekt e LEFT JOIN vn.buy b ON b.id = vBuy LEFT JOIN vn.item i ON i.id = b.itemFk LEFT JOIN vn.supplier s ON e.pro = s.id - JOIN vn2008.config cfg + JOIN vn2008.config cfg WHERE e.id = vSelf LIMIT 1; @@ -9486,22 +9179,22 @@ proc:BEGIN CREATE TEMPORARY TABLE tmp.buyRecalc SELECT buy.id - FROM vn.buy + FROM vn.buy WHERE ektFk = vSelf; CALL vn.buy_recalcPrices(); -- Si es una compra de Logiflora hay que informar la tabla vn.saleBuy IF vPutOrderFk THEN - + REPLACE vn.saleBuy(saleFk, buyFk, workerFk) SELECT po.saleFk, b.id, account.myUser_getId() FROM edi.putOrder po JOIN vn.buy b ON b.ektFk = vSelf WHERE po.id = vPutOrderFk; - + END IF; - -- Si es una compra directa en Floramondo hay que añadirlo al ticket + -- Si es una compra directa en Floramondo hay que añadirlo al ticket IF vIsFloramondoDirect THEN @@ -9512,7 +9205,7 @@ proc:BEGIN JOIN edi.ekt e ON e.sub = eea.sub AND e.id = vSelf WHERE e.fec = t.shipped LIMIT 1; - + IF ISNULL(vTicketFk) THEN INSERT INTO vn.ticket ( @@ -9540,8 +9233,8 @@ proc:BEGIN z.id, z.price, z.bonus - FROM edi.ekt e - JOIN vn.ektEntryAssign eea ON eea.sub = e.sub + FROM edi.ekt e + JOIN vn.ektEntryAssign eea ON eea.sub = e.sub JOIN vn.address a ON a.id = eea.addressFk JOIN vn.warehouse w ON w.name = 'Floramondo' JOIN vn.company c ON c.code = 'VNL' @@ -9550,11 +9243,11 @@ proc:BEGIN LIMIT 1; SET vTicketFk = LAST_INSERT_ID(); - + INSERT INTO vn.ticketLog - SET originFk = vTicketFk, - userFk = account.myUser_getId(), - `action` = 'insert', + SET originFk = vTicketFk, + userFk = account.myUser_getId(), + `action` = 'insert', description = CONCAT('EktLoad ha creado el ticket:', ' ', vTicketFk); END IF; @@ -9564,9 +9257,9 @@ proc:BEGIN FROM edi.ekt e JOIN edi.floraHollandConfig fhc WHERE e.id = vSelf; - + SELECT LAST_INSERT_ID() INTO vSaleFk; - + REPLACE vn.saleBuy(saleFk, buyFk, workerFk) SELECT vSaleFk, b.id, account.myUser_getId() FROM vn.buy b @@ -9577,23 +9270,21 @@ proc:BEGIN FROM edi.ekt e JOIN vn.component c ON c.code = 'purchaseValue' WHERE e.id = vSelf; - + INSERT INTO vn.saleComponent(saleFk, componentFk, value) - SELECT vSaleFk, c.id, e.pri * fhc.floramondoMargin + SELECT vSaleFk, c.id, e.pri * fhc.floramondoMargin FROM edi.ekt e JOIN edi.floraHollandConfig fhc JOIN vn.component c ON c.code = 'margin' WHERE e.id = vSelf; END IF; - + DROP TEMPORARY TABLE tmp.buyRecalc; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ekt_loadNotBuy` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -9601,10 +9292,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ekt_loadNotBuy`() BEGIN - + /** * Ejecuta ekt_load para aquellos ekt de hoy que no tienen vn.buy */ @@ -9614,24 +9307,24 @@ BEGIN DECLARE cursor1 CURSOR FOR SELECT e.id - FROM edi.ekt e - LEFT JOIN vn.buy b ON b.ektFk = e.id - WHERE e.fec >= CURDATE() + FROM edi.ekt e + LEFT JOIN vn.buy b ON b.ektFk = e.id + WHERE e.fec >= util.VN_CURDATE() AND ISNULL(b.ektFk); DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; OPEN cursor1; bucle: LOOP - + FETCH cursor1 INTO vEktFk; - + IF done THEN LEAVE bucle; END IF; - + CALL edi.ekt_load(vEktFk); - + END LOOP bucle; CLOSE cursor1; @@ -9641,8 +9334,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ekt_refresh` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -9650,6 +9341,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ekt_refresh`( `vSelf` INT, vMailFk INT) @@ -9660,32 +9353,24 @@ BEGIN DECLARE vRewriteKop INT DEFAULT NULL; DECLARE vTruncatePutOrder INT DEFAULT NULL; DECLARE vBarcode CHAR(15) DEFAULT NULL; - DECLARE vAuction SMALLINT; - DECLARE vClock SMALLINT; - DECLARE vDate DATE; - DECLARE vAgj INT; DECLARE vKop INT; DECLARE vPutOrderFk BIGINT; - SELECT auction, klo, fec, agj, kop, putOrderFk - INTO vAuction, vClock, vDate, vAgj, vKop, vPutOrderFk + SELECT kop, putOrderFk + INTO vKop, vPutOrderFk FROM ekt WHERE id = vSelf; -- 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; + SELECT CONCAT( + LPAD(IFNULL(auction,0), 3, 0), + LPAD(IFNULL(klo, 99), 2, 0), + LPAD(DAYOFYEAR(fec), 3, 0), + COALESCE(agj, RIGHT(batchNumber,7), id)) + INTO vBarcode + FROM ekt + WHERE id = vSelf; -- Rewrites the kop parameter @@ -9717,8 +9402,150 @@ 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 `ekt_scan` */; +/*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ekt_scan`(vBarcode VARCHAR(512)) +BEGIN +/** + * Busca transaciones a partir de un código de barras, las marca como escaneadas + * y las devuelve. + * Ver https://wiki.verdnatura.es/index.php/Ekt#Algoritmos_de_lectura + * + * @param vBarcode Código de compra de una etiqueta de subasta + * @param vLabels Cantidad escaneada + * @table tmp.ekt(ektFk) Transacciones escaneadas + */ + DECLARE vIsFound BOOL; + DECLARE vUsefulAuctionLeftSegmentLength INT; + DECLARE vStandardBarcodeLength INT; + DECLARE vFloridayBarcodeLength INT; + DECLARE vFloramondoBarcodeLength INT; + DECLARE vAuction INT; + DECLARE vKlo INT; + DECLARE vFec DATE; + DECLARE vShortAgj INT; + DECLARE vLongAgj INT; + DECLARE vXtraLongAgj INT; + DECLARE vDefaultKlo INT; + + SELECT + ec.usefulAuctionLeftSegmentLength, + ec.standardBarcodeLength, + ec.floridayBarcodeLength, + ec.floramondoBarcodeLength, + ec.defaultKlo + INTO + vUsefulAuctionLeftSegmentLength, + vStandardBarcodeLength, + vFloridayBarcodeLength, + vFloramondoBarcodeLength, + vDefaultKlo + FROM edi.ektConfig ec; + + DROP TEMPORARY TABLE IF EXISTS tmp.ekt; + CREATE TEMPORARY TABLE tmp.ekt + ENGINE = MEMORY + SELECT id ektFk FROM ekt LIMIT 0; + + CASE + WHEN LENGTH(vBarcode) <= vFloridayBarcodeLength THEN + INSERT INTO tmp.ekt + SELECT id + FROM edi.ektRecent e + WHERE e.cps = vBarcode + OR e.batchNumber = vBarcode; + + WHEN LENGTH(vBarcode) = vFloramondoBarcodeLength THEN + INSERT INTO tmp.ekt + SELECT e.id + FROM edi.ektRecent e + WHERE e.pro = MID(vBarcode,2,6) + AND CAST(e.ptd AS SIGNED) = MID(vBarcode,8,5); + + ELSE + SET vBarcode = LPAD(vBarcode,vStandardBarcodeLength,'0'); + SET vAuction = MID(vBarcode, 1, 3); + SET vKlo = MID(vBarcode, 4, 2); + SET vFec = MAKEDATE(YEAR(util.VN_CURDATE()), MID(vBarcode, 6, 3)); + SET vShortAgj = MID(vBarcode, 9, 5); + SET vLongAgj = MID(vBarcode, 9, 7); + SET vXtraLongAgj = MID(vBarcode, 9, 8); + + -- Clásico de subasta + -- Trade standard + -- Trade que construye como la subasta + -- Trade como el anterior pero sin trade code + INSERT INTO tmp.ekt + SELECT id + FROM ekt + WHERE fec = vFec + AND (( + vKlo = vDefaultKlo + AND (klo = vKlo OR klo IS NULL OR klo = 0) + AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj)) + OR (klo = vKlo + AND auction = vAuction + AND agj = vShortAgj) + ) + ORDER BY agj DESC + LIMIT 1; + + SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; + + -- BatchNumber largo + IF NOT vIsFound THEN + INSERT INTO tmp.ekt + SELECT id + FROM edi.ektRecent e + WHERE e.batchNumber + = LEFT(vBarcode,vUsefulAuctionLeftSegmentLength) + AND e.batchNumber > 0; + + SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; + END IF; + + -- Order Number + IF NOT vIsFound THEN + INSERT INTO tmp.ekt + SELECT id + FROM edi.ektRecent e + WHERE e.putOrderFk = vBarcode; + + SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; + END IF; + + -- deliveryNumber incrustado + IF NOT vIsFound THEN + INSERT INTO tmp.ekt + SELECT id + FROM edi.ektRecent e + WHERE e.deliveryNumber + = MID(vBarcode, 4, 13) + AND e.deliveryNumber > 0; + + SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; + END IF; + END CASE; + + IF vIsFound THEN + UPDATE ekt e + JOIN tmp.ekt t ON t.ektFk = e.id + SET e.scanned = TRUE; + 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 `floramondo_offerRefresh` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -9726,6 +9553,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `floramondo_offerRefresh`() proc: BEGIN @@ -9758,7 +9587,7 @@ proc: BEGIN LEAVE proc; END IF; - SET vStartingTime = NOW(); + SET vStartingTime = util.VN_NOW(); TRUNCATE edi.offerList ; @@ -9874,19 +9703,19 @@ proc: BEGIN AND i.quality <=> o.Quality JOIN vn.itemType it ON it.id = i.typeFk LEFT JOIN vn.sale s ON s.itemFk = i.id - LEFT JOIN vn.ticket t ON t.id = s.ticketFk AND t.shipped > TIMESTAMPADD(WEEK, -1, CURDATE()) + LEFT JOIN vn.ticket t ON t.id = s.ticketFk AND t.shipped > TIMESTAMPADD(WEEK, -1, util.VN_CURDATE()) LEFT JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk LEFT JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID - LEFT JOIN edi.putOrder po ON po.supplyResponseID = i.supplyResponseFk AND po.OrderTradeLineDateTime > TIMESTAMPADD(WEEK, -1, CURDATE()) + LEFT JOIN edi.putOrder po ON po.supplyResponseID = i.supplyResponseFk AND po.OrderTradeLineDateTime > TIMESTAMPADD(WEEK, -1, util.VN_CURDATE()) SET i.supplyResponseFk = o.srID WHERE ( sr.ID IS NULL OR sr.NumberOfUnits = 0 - OR di.LatestOrderDateTime < NOW() + OR di.LatestOrderDateTime < util.VN_NOW() OR di.ID IS NULL) AND it.isInventory AND t.id IS NULL AND po.id IS NULL; - -- select now(),'Antes de crear ITO'; + -- select util.VN_NOW(),'Antes de crear ITO'; DROP TEMPORARY TABLE IF EXISTS itemToInsert; CREATE TEMPORARY TABLE itemToInsert ENGINE = MEMORY SELECT o.*, CAST(NULL AS DECIMAL(6,0)) as itemFk @@ -10067,7 +9896,7 @@ proc: BEGIN JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID JOIN vn.floramondoConfig fc WHERE mp.isLatestOrderDateTimeRelevant - AND di.LatestOrderDateTime > IF(fc.MaxLatestOrderHour > HOUR(NOW()), CURDATE(), TIMESTAMPADD(DAY,1,CURDATE())); + AND di.LatestOrderDateTime > IF(fc.MaxLatestOrderHour > HOUR(util.VN_NOW()), util.VN_CURDATE(), TIMESTAMPADD(DAY,1,util.VN_CURDATE())); UPDATE vn.floramondoConfig SET nextLanded = vLanded @@ -10082,7 +9911,7 @@ proc: BEGIN LEFT JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID LEFT JOIN edi.deliveryInformation di ON di.ID = b.deliveryFk SET b.quantity = 0 - WHERE (IFNULL(di.LatestOrderDateTime,NOW()) <= NOW() + WHERE (IFNULL(di.LatestOrderDateTime,util.VN_NOW()) <= util.VN_NOW() OR i.supplyResponseFk IS NULL OR sr.NumberOfUnits = 0) AND am.name = 'LOGIFLORA' @@ -10104,7 +9933,7 @@ proc: BEGIN WHERE (b.quantity <> o.NumberOfUnits * o.NumberOfItemsPerCask OR b.buyingValue <> o.price); -- Se inserta el resto - SET vLastInserted := NOW(); + SET vLastInserted := util.VN_NOW(); -- Inserta la oferta INSERT INTO vn.buy( entryFk, @@ -10194,15 +10023,13 @@ proc: BEGIN AND typeFk = 17; INSERT INTO edi.log(tableName, fieldName,fieldValue) - VALUES('floramondo_offerRefresh','Tiempo de proceso',TIMEDIFF(NOW(),vStartingTime)); + VALUES('floramondo_offerRefresh','Tiempo de proceso',TIMEDIFF(util.VN_NOW(),vStartingTime)); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_freeAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -10210,52 +10037,54 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_freeAdd`() BEGIN - + /** * Rellena la tabla item_free con los id ausentes en vn.item - * + * */ - + DECLARE vCounter INT DEFAULT 400000; DECLARE vCounterNewItems INT DEFAULT 0; - + DECLARE vMaxItem INT; DECLARE vExists BOOLEAN DEFAULT FALSE; SELECT MAX(id) - INTO vMaxItem + INTO vMaxItem FROM vn.item; - + DROP TEMPORARY TABLE IF EXISTS tmp.itemBusy; CREATE TEMPORARY TABLE tmp.itemBusy (id INT PRIMARY KEY) - SELECT i.id + SELECT i.id FROM vn.item i WHERE id >= 400000 UNION ALL - SELECT ifr.id + SELECT ifr.id FROM edi.item_free ifr; - + WHILE vCounter < vMaxItem DO - + SET vCounter = vCounter + 1; - + SELECT count(*) INTO vExists FROM tmp.itemBusy WHERE id = vCounter; - + IF NOT vExists THEN - + SET vCounterNewItems = vCounterNewItems + 1; - + INSERT INTO edi.item_free(id) VALUES (vCounter); - + END IF; END WHILE; @@ -10268,22 +10097,22 @@ 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_getNewByEkt` */; /*!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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getNewByEkt`(vEktFk INT, OUT vItemFk INT) BEGIN /** * Devuelve un número nuevo de item a partir de un registro de la tabla edi.ekt - * + * * @param vEktFk Identificador de la tabla edi.ekt */ @@ -10292,17 +10121,17 @@ BEGIN SELECT MIN(id) id INTO vItemFk FROM edi.item_free; - DELETE FROM edi.item_free + DELETE FROM edi.item_free WHERE id = vItemFk; - + COMMIT; - + IF ISNULL(vItemFk) THEN SELECT MAX(i.id) + 1 INTO vItemFk FROM vn.item i; END IF; - + INSERT INTO vn.item(id, @@ -10329,118 +10158,118 @@ BEGIN least(IF((e.package = 800),((e.package * 10) + e.pac), e.package), ifnull(idt.bucket_id, '999')) packageFk, e.cat, TRUE - FROM edi.ekt e - JOIN edi.item i ON i.id = e.`ref` - JOIN edi.item_groupToOffer igto ON igto.group_code = i.group_id - LEFT JOIN edi.item_defaultType idt ON idt.item_id = e.`ref` + FROM edi.ekt e + JOIN edi.item i ON i.id = e.`ref` + JOIN edi.item_groupToOffer igto ON igto.group_code = i.group_id + LEFT JOIN edi.item_defaultType idt ON idt.item_id = e.`ref` WHERE e.id = vEktFk; SET @isTriggerDisabled = TRUE; - + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT vItemFk, t.id , e.item , 1 - FROM edi.ekt e + SELECT vItemFk, t.id , e.item , 1 + FROM edi.ekt e JOIN vn.tag t ON t.`name` = 'Producto' WHERE e.id = vEktFk AND NOT ISNULL(e.item); INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT vItemFk, t.id , e.cat , 3 - FROM edi.ekt e + SELECT vItemFk, t.id , e.cat , 3 + FROM edi.ekt e JOIN vn.tag t ON t.`name` = 'Calidad' WHERE e.id = vEktFk AND NOT ISNULL(e.cat); - + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT vItemFk, t.id , s.company_name , 4 - FROM edi.ekt e + SELECT vItemFk, t.id , s.company_name , 4 + FROM edi.ekt e JOIN edi.supplier s ON s.supplier_id = e.pro JOIN vn.tag t ON t.`name` = 'Productor' WHERE e.id = vEktFk AND NOT ISNULL(s.company_name); INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT vItemFk, t.id , e.s1, 5 + SELECT vItemFk, t.id , e.s1, 5 FROM edi.ekt e - LEFT JOIN edi.item_feature eif ON eif.item_id = e.`ref` - AND eif.presentation_order = 1 + LEFT JOIN edi.item_feature eif ON eif.item_id = e.`ref` + AND eif.presentation_order = 1 AND eif.expiry_date IS NULL - LEFT JOIN edi.`value` ev ON ev.type_id = eif.feature + LEFT JOIN edi.`value` ev ON ev.type_id = eif.feature AND e.s1 = ev.type_value JOIN vn.tag t ON t.ediTypeFk = eif.feature WHERE e.id = vEktFk AND NOT ISNULL(e.s1); - + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT vItemFk, t.id , e.s2, 6 + SELECT vItemFk, t.id , e.s2, 6 FROM edi.ekt e - LEFT JOIN edi.item_feature eif ON eif.item_id = e.`ref` - AND eif.presentation_order = 2 + LEFT JOIN edi.item_feature eif ON eif.item_id = e.`ref` + AND eif.presentation_order = 2 AND eif.expiry_date IS NULL - LEFT JOIN edi.`value` ev ON ev.type_id = eif.feature + LEFT JOIN edi.`value` ev ON ev.type_id = eif.feature AND e.s2 = ev.type_value JOIN vn.tag t ON t.ediTypeFk = eif.feature WHERE e.id = vEktFk AND NOT ISNULL(e.s2); - + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT vItemFk, t.id , e.s3, 7 + SELECT vItemFk, t.id , e.s3, 7 FROM edi.ekt e - LEFT JOIN edi.item_feature eif ON eif.item_id = e.`ref` - AND eif.presentation_order = 3 + LEFT JOIN edi.item_feature eif ON eif.item_id = e.`ref` + AND eif.presentation_order = 3 AND eif.expiry_date IS NULL - LEFT JOIN edi.`value` ev ON ev.type_id = eif.feature + LEFT JOIN edi.`value` ev ON ev.type_id = eif.feature AND e.s3 = ev.type_value JOIN vn.tag t ON t.ediTypeFk = eif.feature WHERE e.id = vEktFk AND NOT ISNULL(e.s3); - + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT vItemFk, t.id , e.s4, 8 + SELECT vItemFk, t.id , e.s4, 8 FROM edi.ekt e - LEFT JOIN edi.item_feature eif ON eif.item_id = e.`ref` + LEFT JOIN edi.item_feature eif ON eif.item_id = e.`ref` AND eif.presentation_order = 4 AND eif.expiry_date IS NULL - LEFT JOIN edi.`value` ev ON ev.type_id = eif.feature + LEFT JOIN edi.`value` ev ON ev.type_id = eif.feature AND e.s4 = ev.type_value JOIN vn.tag t ON t.ediTypeFk = eif.feature WHERE e.id = vEktFk AND NOT ISNULL(e.s4); - + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT vItemFk, t.id , e.s5, 9 + SELECT vItemFk, t.id , e.s5, 9 FROM edi.ekt e - LEFT JOIN edi.item_feature eif ON eif.item_id = e.`ref` + LEFT JOIN edi.item_feature eif ON eif.item_id = e.`ref` AND eif.presentation_order = 5 AND eif.expiry_date IS NULL - LEFT JOIN edi.`value` ev ON ev.type_id = eif.feature + LEFT JOIN edi.`value` ev ON ev.type_id = eif.feature AND e.s5 = ev.type_value JOIN vn.tag t ON t.ediTypeFk = eif.feature WHERE e.id = vEktFk AND NOT ISNULL(e.s5); INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT vItemFk, t.id , e.s6, 10 + SELECT vItemFk, t.id , e.s6, 10 FROM edi.ekt e - LEFT JOIN edi.item_feature eif ON eif.item_id = e.`ref` + LEFT JOIN edi.item_feature eif ON eif.item_id = e.`ref` AND eif.presentation_order = 6 AND eif.expiry_date IS NULL - LEFT JOIN edi.`value` ev ON ev.type_id = eif.feature + LEFT JOIN edi.`value` ev ON ev.type_id = eif.feature AND e.s6 = ev.type_value JOIN vn.tag t ON t.ediTypeFk = eif.feature WHERE e.id = vEktFk AND NOT ISNULL(e.s6); INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT vItemFk, t.id, IFNULL(ink.name, ik.color), 11 - FROM edi.ekt e + SELECT vItemFk, t.id, IFNULL(ink.name, ik.color), 11 + FROM edi.ekt e JOIN vn.tag t ON t.`name` = 'Color' - LEFT JOIN edi.feature f ON f.item_id = e.`ref` + LEFT JOIN edi.feature f ON f.item_id = e.`ref` LEFT JOIN edi.`type` tp ON tp.type_id = f.feature_type_id AND tp.`description` = 'Hoofdkleur 1' LEFT JOIN vn.ink ON ink.dutchCode = f.feature_value LEFT JOIN vn.itemInk ik ON ik.longName = e.item WHERE e.id = vEktFk - AND ( ink.name IS NOT NULL + AND ( ink.name IS NOT NULL OR ik.color IS NOT NULL) LIMIT 1; @@ -10452,16 +10281,14 @@ BEGIN CALL vn.item_refreshTags(); - SET @isTriggerDisabled = FALSE; - + SET @isTriggerDisabled = FALSE; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `mail_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -10469,6 +10296,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `mail_new`( vMessageId VARCHAR(100) @@ -10499,7 +10328,7 @@ BEGIN sender = vSender, senderFk = vSenderId, messageId = vMessageId; - + IF vIsDuplicated THEN SELECT id INTO vSelf FROM mail @@ -10513,8 +10342,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_calcCompByFloramondo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -10522,29 +10349,31 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_calcCompByFloramondo`(vSelf INT) BEGIN - + /** * Recalcula "a pelo" los componentes para un ticket de Floramondo - * + * * Pendiente de concretar la solución cuando Logiflora conteste. - * + * * @param vSelf Identificador de vn.ticket */ - + CALL cache.last_buy_refresh(TRUE); - DELETE sc.* + DELETE sc.* FROM vn.saleComponent sc - JOIN vn.sale s ON s.id = sc.saleFk + JOIN vn.sale s ON s.id = sc.saleFk WHERE s.ticketFk = vSelf; UPDATE vn.sale s - JOIN vn.item i ON i.id = s.itemFk + JOIN vn.item i ON i.id = s.itemFk JOIN edi.floraHollandConfig fhc - LEFT JOIN cache.last_buy lb ON lb.item_id = i.id + LEFT JOIN cache.last_buy lb ON lb.item_id = i.id LEFT JOIN vn.buy b ON b.id = lb.buy_id LEFT JOIN vn.warehouse w ON w.id = lb.warehouse_id AND w.name = 'Floramondo' SET s.price = b.buyingValue * (1 + fhc.floramondoMargin) @@ -10553,18 +10382,18 @@ BEGIN INSERT INTO vn.saleComponent(saleFk, componentFk, value) SELECT s.id, c.id, MAX(b.buyingValue) FROM vn.sale s - JOIN vn.item i ON i.id = s.itemFk + JOIN vn.item i ON i.id = s.itemFk LEFT JOIN cache.last_buy lb ON lb.item_id = i.id LEFT JOIN vn.buy b ON b.id = lb.buy_id LEFT JOIN vn.warehouse w ON w.id = lb.warehouse_id AND w.name = 'Floramondo' JOIN vn.component c ON c.code = 'purchaseValue' WHERE s.ticketFk = vSelf GROUP BY s.id; - + INSERT INTO vn.saleComponent(saleFk, componentFk, value) - SELECT s.id, c.id, MAX(b.buyingValue) * fhc.floramondoMargin + SELECT s.id, c.id, MAX(b.buyingValue) * fhc.floramondoMargin FROM vn.sale s - JOIN vn.item i ON i.id = s.itemFk + JOIN vn.item i ON i.id = s.itemFk JOIN edi.floraHollandConfig fhc LEFT JOIN cache.last_buy lb ON lb.item_id = i.id LEFT JOIN vn.buy b ON b.id = lb.buy_id @@ -10584,7 +10413,7 @@ DELIMITER ; -- Current Database: `hedera` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `hedera` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `hedera` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `hedera`; @@ -10596,11 +10425,11 @@ DROP TABLE IF EXISTS `androidUser`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `androidUser` ( - `androidId` varchar(200) CHARACTER SET utf8 NOT NULL, + `androidId` varchar(200) CHARACTER SET utf8mb3 NOT NULL, `userFk` int(10) unsigned NOT NULL, PRIMARY KEY (`userFk`,`androidId`), CONSTRAINT `androidUser_ibfk_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10618,7 +10447,7 @@ CREATE TABLE `basketOrder` ( CONSTRAINT `basketOrder_ibfk_1` FOREIGN KEY (`orderFk`, `clientFk`) REFERENCES `order` (`id`, `customer_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `basketOrder_ibfk_2` FOREIGN KEY (`orderFk`) REFERENCES `order` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `basketOrder_ibfk_3` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10629,10 +10458,10 @@ DROP TABLE IF EXISTS `browser`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `browser` ( - `name` varchar(30) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Browser name in browscap', + `name` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'Browser name in browscap', `version` float NOT NULL COMMENT 'Minimal version', UNIQUE KEY `name` (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='List of compatible web browsers and its version'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='List of compatible web browsers and its version'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10644,21 +10473,21 @@ DROP TABLE IF EXISTS `config`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `config` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `defaultLang` char(2) CHARACTER SET utf8 NOT NULL COMMENT 'The default language if none is specified', + `defaultLang` char(2) CHARACTER SET utf8mb3 NOT NULL COMMENT 'The default language if none is specified', `https` tinyint(3) unsigned NOT NULL COMMENT 'Wether to force de use of HTTPS', `cookieLife` smallint(5) unsigned NOT NULL COMMENT 'The cookies life, in days', - `jwtKey` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'The key used to encode/decode JWT tokens', - `defaultForm` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Form loaded at web login', - `restUri` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'The URI for rest service', - `testRestUri` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'The URI for test rest service', - `guestUser` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Guest user name', - `testDomain` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The address for beta website', - `productionDomain` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The address for production website', - `pdfsDir` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Directory where PDFs are allocated', - `dmsDir` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Directory where documents are allocated', + `jwtKey` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'The key used to encode/decode JWT tokens', + `defaultForm` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'Form loaded at web login', + `restUri` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'The URI for rest service', + `testRestUri` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'The URI for test rest service', + `guestUser` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'Guest user name', + `testDomain` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'The address for beta website', + `productionDomain` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'The address for production website', + `pdfsDir` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'Directory where PDFs are allocated', + `dmsDir` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'Directory where documents are allocated', PRIMARY KEY (`id`), KEY `jwtkey_IX` (`jwtKey`) COMMENT 'Prueba de Ernesto 3.8.2020. MySQL se queja de no tener indices. Si, se que solo tiene un registro pero molesta para depurar otros.' -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global configuration parameters'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Global configuration parameters'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10670,9 +10499,9 @@ DROP TABLE IF EXISTS `contact`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `contact` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `recipient` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `recipient` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10684,14 +10513,14 @@ DROP TABLE IF EXISTS `image`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `image` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `collectionFk` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `collectionFk` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `name` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, `updated` int(11) DEFAULT NULL, - `nRefs` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Number of references, don''t modify this column manually', + `nRefs` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Number of references, don''t modify this column manually', PRIMARY KEY (`id`), UNIQUE KEY `collection` (`collectionFk`,`name`), CONSTRAINT `image_ibfk_1` FOREIGN KEY (`collectionFk`) REFERENCES `imageCollection` (`name`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10703,24 +10532,24 @@ DROP TABLE IF EXISTS `imageCollection`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `imageCollection` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `desc` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `desc` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, `maxWidth` int(10) unsigned NOT NULL, `maxHeight` int(10) unsigned NOT NULL, - `model` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `property` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `schema` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Deprecated', - `table` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Deprecated', - `column` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Deprecated', - `readRoleFk` int(10) unsigned DEFAULT '1', - `writeRoleFk` int(10) unsigned DEFAULT '1', + `model` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `property` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `schema` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'Deprecated', + `table` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'Deprecated', + `column` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'Deprecated', + `readRoleFk` int(10) unsigned DEFAULT 1, + `writeRoleFk` int(10) unsigned DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`), KEY `role_id_writeRoleFk` (`writeRoleFk`), KEY `role_id_readRoleFk` (`readRoleFk`), CONSTRAINT `role_id_readRoleFk` FOREIGN KEY (`readRoleFk`) REFERENCES `account`.`role` (`id`) ON UPDATE CASCADE, CONSTRAINT `role_id_writeRoleFk` FOREIGN KEY (`writeRoleFk`) REFERENCES `account`.`role` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10735,11 +10564,11 @@ CREATE TABLE `imageCollectionSize` ( `collectionFk` int(10) unsigned NOT NULL, `width` int(10) unsigned NOT NULL, `height` int(10) unsigned NOT NULL, - `crop` tinyint(3) unsigned NOT NULL DEFAULT '0', + `crop` tinyint(3) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `image_schema_id` (`collectionFk`), CONSTRAINT `imageCollectionSize_ibfk_1` FOREIGN KEY (`collectionFk`) REFERENCES `imageCollection` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10755,7 +10584,7 @@ CREATE TABLE `imageConfig` ( `useXsendfile` tinyint(4) NOT NULL COMMENT 'Whether to use the apache module XSendfile', `url` varchar(255) NOT NULL COMMENT 'Public URL where image are hosted', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COMMENT='Global image parameters'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='Global image parameters'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10766,12 +10595,12 @@ DROP TABLE IF EXISTS `language`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `language` ( - `code` varchar(10) CHARACTER SET utf8 NOT NULL, - `name` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `orgName` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `isActive` tinyint(1) NOT NULL DEFAULT '0', + `code` varchar(10) CHARACTER SET utf8mb3 NOT NULL, + `name` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL, + `orgName` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `isActive` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10783,12 +10612,12 @@ DROP TABLE IF EXISTS `link`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `link` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `description` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `link` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `image` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL, + `description` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `link` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `image` varchar(30) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -10863,17 +10692,17 @@ DROP TABLE IF EXISTS `location`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `location` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, - `lat` varchar(12) COLLATE utf8_unicode_ci NOT NULL, - `lng` varchar(12) COLLATE utf8_unicode_ci NOT NULL, - `title` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `address` varchar(75) COLLATE utf8_unicode_ci DEFAULT NULL, - `postcode` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `city` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `province` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `phone` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `language` char(2) COLLATE utf8_unicode_ci DEFAULT NULL, + `lat` varchar(12) COLLATE utf8mb3_unicode_ci NOT NULL, + `lng` varchar(12) COLLATE utf8mb3_unicode_ci NOT NULL, + `title` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `address` varchar(75) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `postcode` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `city` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `province` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `phone` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `language` char(2) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10885,15 +10714,15 @@ DROP TABLE IF EXISTS `mailConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mailConfig` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Identifier', - `host` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'localhost' COMMENT 'SMTP host', - `port` smallint(6) NOT NULL DEFAULT '465' COMMENT 'SMTP port', - `secure` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Wether to use a secure connection', - `sender` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'The sender mail address', - `senderName` varchar(75) CHARACTER SET utf8 NOT NULL COMMENT 'The sender name', - `user` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'SMTP user', - `password` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'SMTP password, base64 encoded', + `host` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'localhost' COMMENT 'SMTP host', + `port` smallint(6) NOT NULL DEFAULT 465 COMMENT 'SMTP port', + `secure` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Wether to use a secure connection', + `sender` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'The sender mail address', + `senderName` varchar(75) CHARACTER SET utf8mb3 NOT NULL COMMENT 'The sender name', + `user` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'SMTP user', + `password` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'SMTP password, base64 encoded', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10906,7 +10735,7 @@ DROP TABLE IF EXISTS `mainAccount`; CREATE TABLE `mainAccount` ( `accountFk` mediumint(8) unsigned NOT NULL, PRIMARY KEY (`accountFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10932,16 +10761,16 @@ DROP TABLE IF EXISTS `menu`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `menu` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `description` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `path` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `description` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL, + `path` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `roleFk` int(10) unsigned NOT NULL, `parentFk` int(10) unsigned DEFAULT NULL, - `displayOrder` tinyint(4) unsigned NOT NULL DEFAULT '1', + `displayOrder` tinyint(4) unsigned NOT NULL DEFAULT 1, PRIMARY KEY (`id`), KEY `group_id` (`roleFk`), KEY `parent` (`parentFk`), CONSTRAINT `menu_ibfk_1` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10953,11 +10782,11 @@ DROP TABLE IF EXISTS `message`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `message` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `code` char(35) COLLATE utf8_unicode_ci NOT NULL, - `description` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `code` char(35) COLLATE utf8mb3_unicode_ci NOT NULL, + `description` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code` (`code`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10969,11 +10798,11 @@ DROP TABLE IF EXISTS `metatag`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `metatag` ( `id` int(11) NOT NULL, - `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `content` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `content` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11282,19 +11111,19 @@ DROP TABLE IF EXISTS `news`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `news` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, - `title` varchar(150) COLLATE utf8_unicode_ci NOT NULL, - `text` text COLLATE utf8_unicode_ci NOT NULL, - `image` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `title` varchar(150) COLLATE utf8mb3_unicode_ci NOT NULL, + `text` text COLLATE utf8mb3_unicode_ci NOT NULL, + `image` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `userFk` int(10) unsigned NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `priority` tinyint(3) unsigned NOT NULL DEFAULT '3', - `tag` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'new', + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `priority` tinyint(3) unsigned NOT NULL DEFAULT 3, + `tag` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'new', PRIMARY KEY (`id`), KEY `user` (`userFk`), KEY `tag` (`tag`), CONSTRAINT `news_ibfk_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`account` (`id`) ON UPDATE CASCADE, CONSTRAINT `news_ibfk_2` FOREIGN KEY (`tag`) REFERENCES `newsTag` (`name`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -11368,10 +11197,10 @@ DROP TABLE IF EXISTS `newsTag`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `newsTag` ( - `name` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `description` varchar(25) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL, + `description` varchar(25) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11385,15 +11214,15 @@ CREATE TABLE `order` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `date_send` date NOT NULL DEFAULT '0000-00-00', `customer_id` int(11) NOT NULL, - `delivery_method_id` int(11) DEFAULT '3', - `agency_id` int(11) DEFAULT '2', + `delivery_method_id` int(11) DEFAULT 3, + `agency_id` int(11) DEFAULT 2, `address_id` int(11) DEFAULT NULL, - `company_id` smallint(5) unsigned NOT NULL DEFAULT '442', - `note` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `source_app` set('WEB','ANDROID','IOS','SALIX','TPV','TABLET_VN','') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'TPV', - `is_bionic` tinyint(1) NOT NULL DEFAULT '1', - `confirmed` tinyint(1) NOT NULL DEFAULT '0', - `date_make` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `company_id` smallint(5) unsigned NOT NULL DEFAULT 442, + `note` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `source_app` set('WEB','ANDROID','IOS','SALIX','TPV','TABLET_VN','') COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'TPV', + `is_bionic` tinyint(1) NOT NULL DEFAULT 1, + `confirmed` tinyint(1) NOT NULL DEFAULT 0, + `date_make` timestamp NOT NULL DEFAULT current_timestamp(), `first_row_stamp` datetime DEFAULT NULL, `confirm_date` datetime DEFAULT NULL, `taxableBase` decimal(10,2) NOT NULL, @@ -11411,7 +11240,7 @@ CREATE TABLE `order` ( CONSTRAINT `order_ibfk_5` FOREIGN KEY (`address_id`) REFERENCES `vn`.`address` (`id`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_8` FOREIGN KEY (`delivery_method_id`) REFERENCES `vn`.`deliveryMethod` (`id`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_9` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -11425,7 +11254,7 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `hedera`.`order_afterInsert` AFTER INSERT ON `order` FOR EACH ROW -BEGIN +BEGIN IF NEW.address_id = 2850 THEN -- Fallo que se insertan no se sabe como tickets en este cliente CALL vn.mail_insert( @@ -11434,7 +11263,7 @@ BEGIN 'Creada order al address 2850', CONCAT(account.myUser_getName(), ' ha creado la order ',NEW.id) ); - + END IF; END */;; DELIMITER ; @@ -11456,7 +11285,7 @@ DELIMITER ;; FOR EACH ROW BEGIN CALL stock.log_add('order', NEW.id, OLD.id); - + IF !(OLD.address_id <=> NEW.address_id) OR !(OLD.company_id <=> NEW.company_id) OR !(OLD.customer_id <=> NEW.customer_id) THEN @@ -11510,7 +11339,7 @@ CREATE TABLE `orderConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, `employeeFk` int(10) unsigned NOT NULL, `defaultAgencyFk` int(11) DEFAULT NULL, - `guestMethod` varchar(45) CHARACTER SET utf8 NOT NULL, + `guestMethod` varchar(45) CHARACTER SET utf8mb3 NOT NULL, `guestAgencyFk` int(11) NOT NULL, `guestAddressFk` int(11) NOT NULL, `reserveTime` time NOT NULL, @@ -11527,7 +11356,7 @@ CREATE TABLE `orderConfig` ( CONSTRAINT `orderConfig_ibfk_3` FOREIGN KEY (`guestAgencyFk`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `orderConfig_ibfk_4` FOREIGN KEY (`defaultAgencyFk`) REFERENCES `vn`.`agencyMode` (`id`), CONSTRAINT `orderConfig_ibfk_5` FOREIGN KEY (`guestAddressFk`) REFERENCES `vn`.`address` (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11541,9 +11370,8 @@ CREATE TABLE `orderRecalc` ( `id` int(11) NOT NULL AUTO_INCREMENT, `orderFk` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), - KEY `orderRecalc_ibfk_1` (`orderFk`), - CONSTRAINT `orderRecalc_ibfk_1` FOREIGN KEY (`orderFk`) REFERENCES `order` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Queue of changed orders to recalc it''s total'; + KEY `orderRecalc_ibfk_1` (`orderFk`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Queue of changed orders to recalc it''s total'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11555,14 +11383,14 @@ DROP TABLE IF EXISTS `orderRow`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `orderRow` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `orderFk` int(10) unsigned NOT NULL DEFAULT '0', - `itemFk` int(11) NOT NULL DEFAULT '0', + `orderFk` int(10) unsigned NOT NULL DEFAULT 0, + `itemFk` int(11) NOT NULL DEFAULT 0, `warehouseFk` int(11) DEFAULT NULL, `shipment` date DEFAULT NULL, - `amount` smallint(6) unsigned NOT NULL DEFAULT '0', + `amount` smallint(6) unsigned NOT NULL DEFAULT 0, `price` decimal(10,2) DEFAULT NULL, `rate` smallint(5) unsigned DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `saleFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `item` (`itemFk`), @@ -11573,7 +11401,7 @@ CREATE TABLE `orderRow` ( CONSTRAINT `orderRow_ibfk_2` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE, CONSTRAINT `orderRow_ibfk_3` FOREIGN KEY (`orderFk`) REFERENCES `order` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `orderRow_ibfk_4` FOREIGN KEY (`saleFk`) REFERENCES `vn`.`sale` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -11590,12 +11418,12 @@ DELIMITER ;; BEGIN DECLARE vIsFirst BOOL; - SELECT (first_row_stamp IS NULL) INTO vIsFirst - FROM `order` + SELECT (first_row_stamp IS NULL) INTO vIsFirst + FROM `order` WHERE id = NEW.orderFk; IF vIsFirst THEN - UPDATE `order` SET first_row_stamp = NOW() + UPDATE `order` SET first_row_stamp = util.VN_NOW() WHERE id = NEW.orderFk; END IF; END */;; @@ -11683,7 +11511,7 @@ CREATE TABLE `orderRowComponent` ( PRIMARY KEY (`rowFk`,`componentFk`), KEY `component_id` (`componentFk`), CONSTRAINT `orderRowComponent_ibfk_1` FOREIGN KEY (`rowFk`) REFERENCES `orderRow` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11746,12 +11574,12 @@ DROP TABLE IF EXISTS `restPriv`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `restPriv` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `methodPath` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `methodPath` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, `role` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `role` (`role`), CONSTRAINT `restPriv_ibfk_1` FOREIGN KEY (`role`) REFERENCES `account`.`role` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11763,14 +11591,14 @@ DROP TABLE IF EXISTS `shelf`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `shelf` ( `id` int(10) unsigned NOT NULL, - `name` varchar(30) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL, `nTrays` tinyint(3) unsigned NOT NULL, `trayheight` mediumint(8) unsigned NOT NULL, `topTrayHeight` mediumint(8) unsigned NOT NULL, `width` mediumint(8) unsigned NOT NULL, `depth` mediumint(8) unsigned NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Dimensiones de las estanterias'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Dimensiones de las estanterias'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11782,14 +11610,14 @@ DROP TABLE IF EXISTS `shelfConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `shelfConfig` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(25) COLLATE utf8_unicode_ci NOT NULL, - `namePrefix` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(25) COLLATE utf8mb3_unicode_ci NOT NULL, + `namePrefix` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `warehouse` smallint(5) unsigned NOT NULL, `family` smallint(5) unsigned NOT NULL, `shelf` int(10) unsigned NOT NULL, `maxAmount` smallint(5) unsigned DEFAULT NULL, `showPacking` tinyint(4) NOT NULL, - `stack` tinyint(4) NOT NULL DEFAULT '0', + `stack` tinyint(4) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `shelf_id` (`shelf`), KEY `family_id` (`family`), @@ -11797,7 +11625,7 @@ CREATE TABLE `shelfConfig` ( CONSTRAINT `shelfConfig_ibfk_1` FOREIGN KEY (`family`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `shelfConfig_ibfk_2` FOREIGN KEY (`shelf`) REFERENCES `shelf` (`id`) ON UPDATE CASCADE, CONSTRAINT `shelfConfig_ibfk_3` FOREIGN KEY (`warehouse`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11809,13 +11637,13 @@ DROP TABLE IF EXISTS `social`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `social` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `title` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `link` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `icon` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + `title` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `link` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `icon` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, `priority` tinyint(3) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `priority` (`priority`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11827,9 +11655,9 @@ DROP TABLE IF EXISTS `survey`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `survey` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `question` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `question` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11842,11 +11670,11 @@ DROP TABLE IF EXISTS `surveyAnswer`; CREATE TABLE `surveyAnswer` ( `id` int(10) unsigned NOT NULL, `surveyFk` int(10) unsigned NOT NULL, - `answer` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `votes` int(10) unsigned NOT NULL DEFAULT '0', + `answer` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL, + `votes` int(10) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `survey` (`surveyFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11863,7 +11691,7 @@ CREATE TABLE `surveyVote` ( KEY `surveyVote_ibfk_2` (`userFk`), CONSTRAINT `surveyVote_ibfk_1` FOREIGN KEY (`surveyFk`) REFERENCES `survey` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `surveyVote_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11880,15 +11708,15 @@ CREATE TABLE `tpvConfig` ( `transactionType` tinyint(3) unsigned NOT NULL, `maxAmount` int(10) unsigned DEFAULT NULL, `employeeFk` int(10) unsigned NOT NULL, - `url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The bank web service URL for production environment', - `testMode` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT 'Whether test mode is enabled', - `testUrl` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT 'The bank web service URL for test environment', - `testKey` varchar(50) CHARACTER SET utf8 DEFAULT NULL COMMENT 'The bank secret key for test environment', - `merchantUrl` varchar(255) CHARACTER SET utf8 DEFAULT NULL, + `url` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'The bank web service URL for production environment', + `testMode` tinyint(3) unsigned NOT NULL DEFAULT 0 COMMENT 'Whether test mode is enabled', + `testUrl` varchar(255) CHARACTER SET utf8mb3 DEFAULT NULL COMMENT 'The bank web service URL for test environment', + `testKey` varchar(50) CHARACTER SET utf8mb3 DEFAULT NULL COMMENT 'The bank secret key for test environment', + `merchantUrl` varchar(255) CHARACTER SET utf8mb3 DEFAULT NULL, PRIMARY KEY (`id`), KEY `employee_id` (`employeeFk`), CONSTRAINT `employee_id` FOREIGN KEY (`employeeFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Virtual TPV parameters'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Virtual TPV parameters'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11899,10 +11727,10 @@ DROP TABLE IF EXISTS `tpvError`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tpvError` ( - `code` char(7) COLLATE utf8_unicode_ci NOT NULL, - `message` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `code` char(7) COLLATE utf8mb3_unicode_ci NOT NULL, + `message` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT=' List of possible TPV errors'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT=' List of possible TPV errors'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11914,14 +11742,14 @@ DROP TABLE IF EXISTS `tpvImapConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tpvImapConfig` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `host` varchar(150) COLLATE utf8_unicode_ci NOT NULL, - `user` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `pass` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `cleanPeriod` varchar(15) CHARACTER SET utf8 NOT NULL, - `successFolder` varchar(150) CHARACTER SET utf8 DEFAULT NULL, - `errorFolder` varchar(150) CHARACTER SET utf8 DEFAULT NULL, + `host` varchar(150) COLLATE utf8mb3_unicode_ci NOT NULL, + `user` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `pass` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `cleanPeriod` varchar(15) CHARACTER SET utf8mb3 NOT NULL, + `successFolder` varchar(150) CHARACTER SET utf8mb3 DEFAULT NULL, + `errorFolder` varchar(150) CHARACTER SET utf8mb3 DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='IMAP configuration parameters for virtual TPV'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='IMAP configuration parameters for virtual TPV'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11933,15 +11761,15 @@ DROP TABLE IF EXISTS `tpvMerchant`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tpvMerchant` ( `id` int(10) unsigned NOT NULL COMMENT 'Merchant identifier', - `description` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Small description', + `description` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'Small description', `companyFk` smallint(6) unsigned DEFAULT NULL COMMENT 'Company associated with the merchant', `bankFk` int(10) NOT NULL COMMENT 'The bank where merchant receipts are created', - `secretKey` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'The merchant secret key to sign transactions', + `secretKey` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'The merchant secret key to sign transactions', PRIMARY KEY (`id`), KEY `bank_id` (`bankFk`), KEY `company_id` (`companyFk`), KEY `id` (`id`,`companyFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Virtual TPV providers'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Virtual TPV providers'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11952,12 +11780,12 @@ DROP TABLE IF EXISTS `tpvMerchantEnable`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tpvMerchantEnable` ( - `merchantFk` int(10) unsigned NOT NULL DEFAULT '0', + `merchantFk` int(10) unsigned NOT NULL DEFAULT 0, `companyFk` smallint(6) unsigned NOT NULL, PRIMARY KEY (`merchantFk`,`companyFk`), UNIQUE KEY `company_id` (`companyFk`), CONSTRAINT `tpvMerchantEnable_ibfk_1` FOREIGN KEY (`merchantFk`, `companyFk`) REFERENCES `tpvMerchant` (`id`, `companyFk`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Virtual TPV enabled providers'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Virtual TPV enabled providers'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11969,9 +11797,9 @@ DROP TABLE IF EXISTS `tpvResponse`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tpvResponse` ( `id` smallint(5) unsigned NOT NULL, - `message` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `message` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='List of possible TPV reponses'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='List of possible TPV reponses'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11988,9 +11816,9 @@ CREATE TABLE `tpvTransaction` ( `receiptFk` int(11) DEFAULT NULL, `amount` int(10) unsigned NOT NULL, `response` smallint(5) unsigned DEFAULT NULL COMMENT 'Status notified by bank: NULL if no notification, 0 if success, error otherwise', - `errorCode` char(7) COLLATE utf8_unicode_ci DEFAULT NULL, - `status` enum('started','ok','ko') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'started', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `errorCode` char(7) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `status` enum('started','ok','ko') COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'started', + `created` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `merchant_id` (`merchantFk`), KEY `receipt_id` (`receiptFk`), @@ -12000,7 +11828,7 @@ CREATE TABLE `tpvTransaction` ( CONSTRAINT `receipt_id` FOREIGN KEY (`receiptFk`) REFERENCES `vn`.`receipt` (`Id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_2` FOREIGN KEY (`merchantFk`) REFERENCES `tpvMerchant` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Transactions realized through the virtual TPV'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12011,15 +11839,15 @@ DROP TABLE IF EXISTS `userSession`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `userSession` ( - `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `lastUpdate` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `ssid` char(64) COLLATE utf8_unicode_ci NOT NULL, - `data` text COLLATE utf8_unicode_ci, + `created` datetime NOT NULL DEFAULT current_timestamp(), + `lastUpdate` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `ssid` char(64) COLLATE utf8mb3_unicode_ci NOT NULL, + `data` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `userVisitFk` int(10) unsigned DEFAULT NULL, UNIQUE KEY `ssid` (`ssid`), KEY `userVisit` (`userVisitFk`), KEY `lastUpdate` (`lastUpdate`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12035,7 +11863,7 @@ CREATE TABLE `visit` ( PRIMARY KEY (`id`), KEY `firstAgent` (`firstAgentFk`), CONSTRAINT `visit_ibfk_1` FOREIGN KEY (`firstAgentFk`) REFERENCES `visitAgent` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12048,14 +11876,14 @@ DROP TABLE IF EXISTS `visitAccess`; CREATE TABLE `visitAccess` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `agentFk` int(10) unsigned NOT NULL, - `stamp` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `stamp` datetime NOT NULL DEFAULT current_timestamp(), `ip` int(10) unsigned DEFAULT NULL, - `referer` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `referer` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `visit_access_idx_agent` (`agentFk`), KEY `stamp` (`stamp`), CONSTRAINT `visitAccess_ibfk_1` FOREIGN KEY (`agentFk`) REFERENCES `visitAgent` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12069,18 +11897,18 @@ CREATE TABLE `visitAgent` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `visitFk` int(10) unsigned NOT NULL, `firstAccessFk` int(10) unsigned DEFAULT NULL, - `platform` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, - `browser` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, - `version` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `platform` varchar(30) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `browser` varchar(30) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `version` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `javascript` tinyint(3) unsigned DEFAULT NULL, `cookies` tinyint(3) unsigned DEFAULT NULL, - `agent` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `agent` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `visit_id` (`visitFk`), KEY `firstAccess` (`firstAccessFk`), CONSTRAINT `visitAgent_ibfk_1` FOREIGN KEY (`visitFk`) REFERENCES `visit` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `visitAgent_ibfk_2` FOREIGN KEY (`firstAccessFk`) REFERENCES `visitAccess` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12094,13 +11922,13 @@ CREATE TABLE `visitUser` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `accessFk` int(10) unsigned NOT NULL, `userFk` int(10) unsigned DEFAULT NULL, - `stamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `stamp` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `access_id` (`accessFk`), KEY `date_time` (`stamp`), KEY `user_id` (`userFk`), CONSTRAINT `visitUser_ibfk_1` FOREIGN KEY (`accessFk`) REFERENCES `visitAccess` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12131,8 +11959,6 @@ DELIMITER ; -- -- Dumping routines for database 'hedera' -- -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `myBasket_getId` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12140,12 +11966,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `MYBASKET_GETID`() RETURNS int(11) +CREATE DEFINER=`root`@`localhost` FUNCTION `myBasket_getId`() RETURNS int(11) DETERMINISTIC BEGIN DECLARE vOrder INT; - + SELECT orderFk INTO vOrder FROM basketOrder WHERE clientFk = account.myUser_getId(); @@ -12156,8 +11984,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `myClient_getDebt` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12165,6 +11991,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `myClient_getDebt`(vDate DATE) RETURNS decimal(10,2) DETERMINISTIC @@ -12181,8 +12009,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `myUser_checkRestPriv` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12190,6 +12016,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `myUser_checkRestPriv`(vMethodPath VARCHAR(255)) RETURNS tinyint(1) DETERMINISTIC @@ -12208,7 +12036,7 @@ BEGIN IF vCount = 0 THEN RETURN FALSE; - END IF; + END IF; SELECT COUNT(*) > 0 INTO vHasRole @@ -12224,8 +12052,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `order_getTotal` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12233,6 +12059,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `order_getTotal`(vSelf INT) RETURNS decimal(10,2) READS SQL DATA @@ -12267,8 +12095,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `catalog_calcFromMyAddress` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12276,6 +12102,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calcFromMyAddress`(vDelivery DATE, vAddress INT) BEGIN @@ -12289,14 +12117,14 @@ BEGIN * @return tmp.ticketComponent * @return tmp.ticketLot * @return tmp.zoneGetShipped - */ + */ DECLARE vAgencyMode INT; - + SELECT a.agencyModeFk INTO vAgencyMode FROM myClient c JOIN vn.address a ON a.clientFk = c.id - WHERE a.id = vAddress; + WHERE a.id = vAddress; CALL vn.available_calc(vDelivery, vAddress, vAgencyMode); @@ -12309,7 +12137,7 @@ BEGIN JOIN tmp.availableCalc a ON a.calcFk = c.calc_id WHERE c.available > 0 GROUP BY c.item_id; - + CALL vn.catalog_calculate(vDelivery, vAddress, vAgencyMode); DROP TEMPORARY TABLE tmp.item; @@ -12319,8 +12147,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `catalog_calcFromMyAddress_beta` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12328,6 +12154,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calcFromMyAddress_beta`(vDelivery DATE, vAddress INT) BEGIN @@ -12361,7 +12189,7 @@ BEGIN JOIN tmp.availableCalc a ON a.calcFk = c.calc_id WHERE c.available > 0 GROUP BY c.item_id; - + CALL vn.catalog_calculate_beta(vDelivery, vAddress, vAgencyMode); DROP TEMPORARY TABLE tmp.item; @@ -12371,8 +12199,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `image_ref` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12380,6 +12206,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `image_ref`( vCollection VARCHAR(255), @@ -12409,8 +12237,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `image_unref` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12418,6 +12244,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `image_unref`( vCollection VARCHAR(255), @@ -12439,8 +12267,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_calcCatalog` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12448,6 +12274,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_calcCatalog`( vSelf INT, @@ -12463,7 +12291,7 @@ BEGIN */ DROP TEMPORARY TABLE IF EXISTS tmp.item; CREATE TEMPORARY TABLE tmp.item - ENGINE = MEMORY + ENGINE = MEMORY SELECT vSelf itemFk; CALL vn.catalog_calculate(vLanded, vAddressFk, vAgencyModeFk); @@ -12487,8 +12315,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_getList` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12496,6 +12322,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getList`(IN `vWarehouse` SMALLINT, IN `vShipping` DATE, IN `vCategory` INT, IN `vRate` TINYINT) BEGIN @@ -12536,8 +12364,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_getVisible` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12545,6 +12371,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getVisible`( vWarehouse TINYINT, @@ -12552,7 +12380,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getVisible`( vType INT, vPrefix VARCHAR(255)) BEGIN - + /** * Gets visible items of the specified type at specified date. * @@ -12561,7 +12389,7 @@ BEGIN * @param vType The type id * @param vPrefix The article prefix to filter or %NULL for all * @return tmp.itemVisible Visible items - */ + */ DECLARE vPrefixLen SMALLINT; DECLARE vFilter VARCHAR(255) DEFAULT NULL; DECLARE vDateInv DATE DEFAULT vn2008.date_inv(); @@ -12570,13 +12398,13 @@ BEGIN GET DIAGNOSTICS CONDITION 1 @message = MESSAGE_TEXT; CALL vn.mail_insert( - 'cau@verdnatura.es', - NULL, + 'cau@verdnatura.es', + NULL, CONCAT('hedera.item_getVisible error: ', @message), CONCAT( - 'warehouse: ', IFNULL(vWarehouse, ''), - ', Fecha:', IFNULL(vDate, ''), - ', tipo: ', IFNULL(vType,''), + 'warehouse: ', IFNULL(vWarehouse, ''), + ', Fecha:', IFNULL(vDate, ''), + ', tipo: ', IFNULL(vType,''), ', prefijo: ', IFNULL(vPrefix,''))); RESIGNAL; END; @@ -12612,7 +12440,7 @@ BEGIN FROM vn.buy b JOIN vn.entry e ON e.id = b.entryFk JOIN vn.travel t ON t.id = e.travelFk - WHERE t.shipped BETWEEN vDateInv AND CURDATE() + WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE() AND t.warehouseOutFk = vWarehouse AND NOT e.isRaid AND t.isDelivered @@ -12621,7 +12449,7 @@ BEGIN FROM vn.sale m JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticketState s ON s.ticket = t.id - WHERE t.shipped BETWEEN vDateInv AND CURDATE() + WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE() AND t.warehouseFk = vWarehouse AND s.alertLevel = 3 ) t @@ -12655,13 +12483,13 @@ BEGIN IF(p.depth > 0, p.depth, 0) depth, p.width, p.height, CEIL(s.quantity / t.packing) etiquetas FROM vn.item i - JOIN `filter` f ON f.itemFk = i.id + JOIN `filter` f ON f.itemFk = i.id JOIN currentStock s ON s.itemFk = i.id LEFT JOIN tmp t ON t.itemFk = i.id LEFT JOIN vn.packaging p ON p.id = t.packageFk WHERE CEIL(s.quantity / t.packing) > 0 -- FIXME: Column Cubos.box not included in view vn.packaging - /* AND p.box */; + /* AND p.box */ ; DROP TEMPORARY TABLE `filter`, @@ -12673,8 +12501,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_listAllocation` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12682,6 +12508,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_listAllocation`(IN `vWh` TINYINT, IN `vDate` DATE, IN `vType` INT, IN `vPrefix` VARCHAR(255), IN `vUseIds` BOOLEAN) BEGIN @@ -12714,8 +12542,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myBasket_addItem` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12723,6 +12549,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_addItem`( vWarehouse INT, @@ -12736,8 +12564,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myBasket_calcCatalogFromItem` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12745,6 +12571,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_calcCatalogFromItem`(vItem INT) BEGIN @@ -12766,8 +12594,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myBasket_calcCatalogFull` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12775,6 +12601,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_calcCatalogFull`() BEGIN @@ -12796,8 +12624,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myBasket_check` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12805,6 +12631,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_check`() BEGIN @@ -12829,8 +12657,8 @@ BEGIN IF vStatus = 'OK' THEN CALL order_checkConfig(vSelf); - - IF vStatus = 'OK' AND vCreated < TIMESTAMPADD(DAY, -1, NOW()) + + IF vStatus = 'OK' AND vCreated < TIMESTAMPADD(DAY, -1, util.VN_NOW()) THEN CALL order_update(vSelf); SET vStatus = 'UPDATED'; @@ -12844,8 +12672,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myBasket_configure` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12853,6 +12679,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_configure`( vDelivery DATE, @@ -12861,7 +12689,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_configure`( vAddress INT) BEGIN /** - * Configura la cesta de la compra utilizando los parámetros + * Configura la cesta de la compra utilizando los parámetros * pasados. Si los parámetros no son válidos devuelve un error. * * @param vDelivery Fecha de recogida @@ -12890,12 +12718,12 @@ BEGIN SELECT defaultAddressFk INTO vAddress FROM myClient; END IF; - + SET vSelf = myBasket_getId(); IF vSelf IS NULL THEN - + SELECT defaultCompanyFk INTO vCompany FROM orderConfig; @@ -12910,7 +12738,7 @@ BEGIN company_id = vCompany; SET vSelf = LAST_INSERT_ID(); - + INSERT INTO basketOrder SET clientFk = account.myUser_getId(), orderFk = vSelf; @@ -12923,7 +12751,7 @@ BEGIN address_id = vAddress WHERE id = vSelf; - + CALL order_update(vSelf); END IF; @@ -12936,8 +12764,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myBasket_configureForGuest` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12945,6 +12771,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_configureForGuest`() BEGIN @@ -12952,18 +12780,18 @@ BEGIN DECLARE vAgency INT; DECLARE vAddress INT; DECLARE vDate DATE; - + SELECT guestMethod, guestAgencyFk, guestAddressFk INTO vMethod, vAgency, vAddress FROM orderConfig LIMIT 1; - - SET vDate = TIMESTAMPADD(DAY, 1, CURDATE()); - + + SET vDate = TIMESTAMPADD(DAY, 1, util.VN_CURDATE()); + IF WEEKDAY(vDate) BETWEEN 5 AND 6 THEN SET vDate = TIMESTAMPADD(DAY, 7 - WEEKDAY(vDate), vDate); END IF; - + CALL myBasket_configure(vDate, vMethod, vAgency, vAddress); END ;; DELIMITER ; @@ -12971,8 +12799,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myBasket_confirm` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12980,6 +12806,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_confirm`() BEGIN @@ -12987,7 +12815,7 @@ BEGIN IF vSelf IS NOT NULL THEN CALL order_confirm(vSelf); - + DELETE FROM basketOrder WHERE orderFk = vSelf; END IF; @@ -12997,8 +12825,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myBasket_getAvailable` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13006,6 +12832,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_getAvailable`() BEGIN @@ -13021,8 +12849,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myBasket_getTax` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13030,6 +12856,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myBasket_getTax`() READS SQL DATA @@ -13043,9 +12871,9 @@ BEGIN CREATE TEMPORARY TABLE tmp.`order` ENGINE = MEMORY SELECT myBasket_getId() orderFk; - + CALL order_getTax(); - + DROP TEMPORARY TABLE IF EXISTS tmp.`order`; END ;; DELIMITER ; @@ -13053,8 +12881,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myOrder_addItem` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13062,6 +12888,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_addItem`( vSelf INT, @@ -13074,7 +12902,7 @@ BEGIN SELECT COUNT(*) INTO vIsMine FROM myOrder WHERE id = vSelf; - + IF vIsMine THEN CALL order_addItem(vSelf, vWarehouse, vItem, vAmount); END IF; @@ -13084,8 +12912,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myOrder_confirm` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13093,15 +12919,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_confirm`(vSelf INT) BEGIN DECLARE vIsMine BOOL; - - SELECT COUNT(*) INTO vIsMine + + SELECT COUNT(*) INTO vIsMine FROM myOrder WHERE id = vSelf; - + IF vIsMine THEN CALL order_confirm(vSelf); END IF; @@ -13111,8 +12939,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myOrder_getAvailable` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13120,6 +12946,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_getAvailable`(vSelf INT) BEGIN @@ -13134,7 +12962,7 @@ BEGIN SELECT COUNT(*) INTO isMine FROM myOrder WHERE id = vSelf; - + IF isMine THEN CALL order_getAvailable(vSelf); END IF; @@ -13144,8 +12972,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myOrder_newWithAddress` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13153,6 +12979,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_newWithAddress`( OUT vSelf INT, @@ -13180,15 +13008,15 @@ BEGIN START TRANSACTION; - SELECT a.agencyModeFk, a.id + SELECT a.agencyModeFk, a.id INTO vAgencyMode, vAddressFk - FROM vn.address a + FROM vn.address a WHERE a.id = vAddressFk; - + SELECT deliveryMethodFk INTO vDeliveryMethodId FROM vn.agencyMode am WHERE am.id = vAgencyMode; - + IF vCompany IS NULL THEN SELECT defaultCompanyFk INTO vCompany @@ -13206,7 +13034,7 @@ BEGIN company_id = vCompany; SET vSelf = LAST_INSERT_ID(); - + CALL order_checkConfig(vSelf); COMMIT; @@ -13216,8 +13044,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myOrder_newWithDate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13225,6 +13051,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myOrder_newWithDate`( OUT vSelf INT, @@ -13252,15 +13080,15 @@ BEGIN START TRANSACTION; - SELECT a.agencyModeFk, a.id + SELECT a.agencyModeFk, a.id INTO vAgencyMode, vAddress FROM myClient c JOIN vn.address a ON a.id = c.defaultAddressFk; - + SELECT deliveryMethodFk INTO vDeliveryMethodId FROM vn.agencyMode am WHERE am.id = vAgencyMode; - + IF vCompany IS NULL THEN SELECT defaultCompanyFk INTO vCompany @@ -13278,7 +13106,7 @@ BEGIN company_id = vCompany; SET vSelf = LAST_INSERT_ID(); - + CALL order_checkConfig(vSelf); COMMIT; @@ -13288,8 +13116,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myTicket_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13297,6 +13123,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myTicket_get`(vSelf INT) BEGIN @@ -13342,8 +13170,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myTicket_getPackages` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13351,6 +13177,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myTicket_getPackages`(vSelf INT) BEGIN @@ -13375,8 +13203,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myTicket_getRows` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13384,6 +13210,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myTicket_getRows`(vSelf INT) BEGIN @@ -13404,8 +13232,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myTicket_getServices` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13413,6 +13239,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myTicket_getServices`(vSelf INT) BEGIN @@ -13431,8 +13259,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myTicket_list` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13440,6 +13266,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myTicket_list`(vFrom DATE, vTo DATE) BEGIN @@ -13451,8 +13279,8 @@ BEGIN * @param vTo To date, if %NULL current date * @select The tickets list */ - SET vFrom = IFNULL(vFrom, DATE_FORMAT(TIMESTAMPADD(MONTH, -3, CURDATE()), '%Y-%m-01')); - SET vTo = IFNULL(vTo, TIMESTAMPADD(YEAR, 1, CURDATE())); + SET vFrom = IFNULL(vFrom, DATE_FORMAT(TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()), '%Y-%m-01')); + SET vTo = IFNULL(vTo, TIMESTAMPADD(YEAR, 1, util.VN_CURDATE())); DROP TEMPORARY TABLE IF EXISTS tmp.ticket; CREATE TEMPORARY TABLE tmp.ticket @@ -13461,7 +13289,7 @@ BEGIN SELECT t.id ticketFk FROM myTicket t WHERE shipped BETWEEN TIMESTAMP(vFrom) AND TIMESTAMP(vTo, '23:59:59'); - + CALL vn.ticketGetTotal; SELECT v.id, IFNULL(v.landed, v.shipped) landed, @@ -13483,8 +13311,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myTicket_logAccess` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13492,6 +13318,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myTicket_logAccess`(vSelf INT) BEGIN @@ -13511,8 +13339,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myTpvTransaction_end` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13520,6 +13346,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myTpvTransaction_end`(vSelf INT, vStatus VARCHAR(12)) BEGIN @@ -13544,8 +13372,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `myTpvTransaction_start` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13553,6 +13379,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `myTpvTransaction_start`(vAmount INT, vCompany INT) BEGIN @@ -13631,8 +13459,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `order_addItem` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13640,6 +13466,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_addItem`( vSelf INT, @@ -13704,7 +13532,7 @@ BEGIN IF vDone THEN LEAVE l; END IF; - + SET vAdd = vAmount - MOD(vAmount, vGrouping); SET vAmount = vAmount - vAdd; @@ -13720,7 +13548,7 @@ BEGIN rate = vRate, amount = vAdd, price = vPrice; - + SET vRow = LAST_INSERT_ID(); INSERT INTO orderRowComponent (rowFk, componentFk, price) @@ -13738,7 +13566,7 @@ BEGIN IF vAmount > 0 THEN CALL util.throw ('AMOUNT_NOT_MATCH_GROUPING'); END IF; - + COMMIT; CALL vn.ticketCalculatePurge; END ;; @@ -13747,8 +13575,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `order_calcCatalog` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13756,6 +13582,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_calcCatalog`(vSelf INT) BEGIN @@ -13781,10 +13609,10 @@ BEGIN CREATE TEMPORARY TABLE tmp.item (PRIMARY KEY (itemFk)) ENGINE = MEMORY - SELECT itemFk FROM orderRow + SELECT itemFk FROM orderRow WHERE orderFk = vSelf GROUP BY itemFk; - + CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode); DROP TEMPORARY TABLE tmp.item; @@ -13794,8 +13622,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `order_calcCatalogFromItem` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13803,6 +13629,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_calcCatalogFromItem`(vSelf INT, vItem INT) BEGIN @@ -13834,8 +13662,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `order_calcCatalogFull` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13843,6 +13669,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_calcCatalogFull`(vSelf INT) BEGIN @@ -13880,8 +13708,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `order_checkConfig` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13889,6 +13715,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_checkConfig`(vSelf INT) BEGIN @@ -13954,8 +13782,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `order_confirm` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13963,6 +13789,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_confirm`(vSelf INT) BEGIN @@ -13980,8 +13808,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `order_confirmWithUser` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13989,6 +13815,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_confirmWithUser`(IN `vOrder` INT, IN `vUserId` INT) BEGIN @@ -14118,7 +13946,7 @@ BEGIN IF vTicket IS NULL THEN - SET vShipment = IFNULL(vShipment, CURDATE()); + SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); CALL vn.ticket_add( vClientId, @@ -14150,7 +13978,7 @@ BEGIN THEN INSERT INTO vn.ticketObservation SET ticketFk = vTicket, - observationTypeFk = 4 /* salesperson */, + observationTypeFk = 4 /* salesperson */ , `description` = vNotes ON DUPLICATE KEY UPDATE `description` = CONCAT(VALUES(`description`),'. ', `description`); @@ -14247,7 +14075,7 @@ BEGIN JOIN edi.floraHollandConfig fhc JOIN hedera.`order` o ON o.id = vOrder WHERE i.id = vItem - AND di.LatestOrderDateTime > NOW() + AND di.LatestOrderDateTime > util.VN_NOW() AND vAmount > @available LIMIT 1; @@ -14281,7 +14109,7 @@ BEGIN DELETE FROM basketOrder WHERE orderFk = vOrder; - UPDATE `order` SET confirmed = TRUE, confirm_date = NOW() + UPDATE `order` SET confirmed = TRUE, confirm_date = util.VN_NOW() WHERE id = vOrder; COMMIT; @@ -14291,8 +14119,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `order_doRecalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -14300,6 +14126,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_doRecalc`() proc: BEGIN @@ -14357,8 +14185,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `order_getAvailable` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -14366,6 +14192,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_getAvailable`(vSelf INT) BEGIN @@ -14383,7 +14211,7 @@ BEGIN INTO vDelivery, vAddress, vAgencyMode FROM `order` WHERE id = vSelf; - + CALL vn.available_calc(vDelivery, vAddress, vAgencyMode); DROP TEMPORARY TABLE IF EXISTS tmp.itemAvailable; @@ -14402,8 +14230,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `order_getTax` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -14411,6 +14237,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_getTax`() READS SQL DATA @@ -14425,7 +14253,7 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; CREATE TEMPORARY TABLE tmp.addressCompany (INDEX (addressFk, companyFk)) - ENGINE = MEMORY + ENGINE = MEMORY SELECT DISTINCT o.address_id addressFk, o.company_id companyFk FROM tmp.`order` tmpOrder JOIN hedera.`order` o ON o.id = tmpOrder.orderFk; @@ -14460,7 +14288,7 @@ BEGIN JOIN vn.taxClass tc ON tc.id = bp.taxClassFk GROUP BY tmpOrder.orderFk, pgc.`code`, pgc.rate HAVING taxableBase != 0; - + DROP TEMPORARY TABLE IF EXISTS tmp.orderAmount; CREATE TEMPORARY TABLE tmp.orderAmount (INDEX (orderFk)) @@ -14469,7 +14297,7 @@ BEGIN SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax FROM tmp.orderTax GROUP BY orderFk, `code`; - + DROP TEMPORARY TABLE tmp.addressTaxArea; END ;; DELIMITER ; @@ -14477,8 +14305,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `order_getTotal` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -14486,6 +14312,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_getTotal`() BEGIN @@ -14515,8 +14343,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `order_recalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -14524,6 +14350,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_recalc`(vSelf INT) BEGIN @@ -14539,7 +14367,7 @@ BEGIN CREATE TEMPORARY TABLE tmp.`order` ENGINE = MEMORY SELECT vSelf orderFk; - + CALL order_getTax; SELECT IFNULL(SUM(taxableBase), 0.0), IFNULL(SUM(tax), 0.0) @@ -14561,8 +14389,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `order_requestRecalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -14570,6 +14396,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_requestRecalc`(vSelf INT) proc: BEGIN @@ -14589,8 +14417,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `order_update` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -14598,6 +14424,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_update`(vSelf INT) proc: BEGIN @@ -14630,7 +14458,7 @@ proc: BEGIN FROM orderRow r JOIN orderRowComponent c ON c.rowFk = r.id WHERE r.orderFk = vSelf; - + UPDATE orderRow r LEFT JOIN tmp.ticketComponentPrice p ON p.warehouseFk = r.warehouseFk @@ -14655,11 +14483,11 @@ proc: BEGIN ON t.id = c.componentFk AND (t.classRate IS NULL OR t.classRate = r.rate) WHERE r.orderFk = vSelf; - + CALL vn.ticketCalculatePurge; END IF; - UPDATE `order` SET date_make = NOW() + UPDATE `order` SET date_make = util.VN_NOW() WHERE id = vSelf; COMMIT; @@ -14669,8 +14497,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `survey_vote` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -14678,6 +14504,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `survey_vote`(vAnswer INT) BEGIN @@ -14701,8 +14529,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `tpvTransaction_confirm` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -14710,6 +14536,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `tpvTransaction_confirm`( vAmount INT @@ -14826,8 +14654,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `tpvTransaction_confirmAll` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -14835,6 +14661,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `tpvTransaction_confirmAll`(vDate DATE) BEGIN @@ -14877,8 +14705,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `tpvTransaction_confirmById` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -14886,6 +14712,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `tpvTransaction_confirmById`(vOrder INT) BEGIN @@ -14919,8 +14747,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `tpvTransaction_undo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -14928,6 +14754,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `tpvTransaction_undo`(vSelf INT) p: BEGIN @@ -14999,13 +14827,13 @@ p: BEGIN AND DATE(FECHA) = vDate AND EURODEBE = vAmount LIMIT 1; - + -- Actualiza la transaccion UPDATE tpvTransaction SET response = NULL, status = 'started' WHERE id = vSelf; - + COMMIT; END ;; DELIMITER ; @@ -15013,8 +14841,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `visitUser_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -15022,6 +14848,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `visitUser_new`( vAccess INT @@ -15038,17 +14866,15 @@ BEGIN UPDATE userSession SET userVisitFk = vUserVisit WHERE ssid = vSsid; - + DELETE FROM userSession - WHERE lastUpdate < TIMESTAMPADD(HOUR, -1, NOW()); + WHERE lastUpdate < TIMESTAMPADD(HOUR, -1, util.VN_NOW()); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `visit_listByBrowser` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -15056,6 +14882,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `visit_listByBrowser`(vFrom DATE, vTo DATE) BEGIN @@ -15084,8 +14912,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `visit_register` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -15093,6 +14919,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `visit_register`( vVisit INT @@ -15162,7 +14990,7 @@ BEGIN UPDATE visitAgent SET firstAccessFk = vAccessId WHERE id = vAgentId; END IF; - + -- Returns the visit info SELECT vVisit visit, vAccessId access; @@ -15177,7 +15005,7 @@ DELIMITER ; -- Current Database: `nst` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `nst` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `nst` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `nst`; @@ -15192,11 +15020,11 @@ CREATE TABLE `balance` ( `id` int(11) NOT NULL AUTO_INCREMENT, `lft` int(11) NOT NULL, `rgt` int(11) NOT NULL, - `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `lft_UNIQUE` (`lft`), UNIQUE KEY `rgt_UNIQUE` (`rgt`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -15212,12 +15040,12 @@ CREATE TABLE `geo` ( `rgt` int(11) DEFAULT NULL, `depth` int(11) DEFAULT NULL, `sons` int(11) DEFAULT NULL, - `item` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `item` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `lft_UNIQUE` (`lft`), UNIQUE KEY `rgt_UNIQUE` (`rgt`), CONSTRAINT `nst_geo_id` FOREIGN KEY (`id`) REFERENCES `nst` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -15231,11 +15059,11 @@ CREATE TABLE `labourTree` ( `id` int(11) NOT NULL AUTO_INCREMENT, `lft` int(11) NOT NULL, `rgt` int(11) NOT NULL, - `depth` int(11) NOT NULL DEFAULT '0', - `sons` int(11) NOT NULL DEFAULT '0', - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `depth` int(11) NOT NULL DEFAULT 0, + `sons` int(11) NOT NULL DEFAULT 0, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -15252,7 +15080,7 @@ CREATE TABLE `nst` ( PRIMARY KEY (`id`), UNIQUE KEY `lft_UNIQUE` (`lft`), UNIQUE KEY `rgt_UNIQUE` (`rgt`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -15262,8 +15090,6 @@ CREATE TABLE `nst` ( -- -- Dumping routines for database 'nst' -- -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `nodeAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -15271,6 +15097,8 @@ CREATE TABLE `nst` ( /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `nodeAdd`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45), IN `vParentFk` INT, IN `vChild` VARCHAR(100)) BEGIN @@ -15278,14 +15106,14 @@ BEGIN DECLARE vTableClone VARCHAR(45); SET vTableClone = CONCAT(vTable, 'Clone'); - + CALL util.exec(CONCAT('DROP TEMPORARY TABLE IF EXISTS tmp.', vTableClone)); CALL util.exec(CONCAT( 'CREATE TEMPORARY TABLE tmp.', vTableClone, ' ENGINE = MEMORY', ' SELECT * FROM ', vScheme, '.', vTable )); - + CALL util.exec(CONCAT( 'SELECT COUNT(c.id) INTO @childs', ' FROM ', vScheme, '.', vTable, ' p', @@ -15293,14 +15121,14 @@ BEGIN ' AND c.lft BETWEEN p.lft AND p.rgt AND c.id != ', vParentFk, ' WHERE p.id = ', vParentFk )); - + IF @childs = 0 THEN CALL util.exec(CONCAT( 'SELECT lft, depth INTO @vLeft, @vDepth', - ' FROM ', vScheme, '.', vTable, + ' FROM ', vScheme, '.', vTable, ' WHERE id = ', vParentFk )); - ELSE + ELSE CALL util.exec(CONCAT( 'SELECT c.rgt, p.depth INTO @vLeft, @vDepth', ' FROM ', vScheme, '.', vTable, ' p', @@ -15311,7 +15139,7 @@ BEGIN ' DESC LIMIT 1' )); END IF; - + CALL util.exec(CONCAT( 'UPDATE ', vScheme, '.', vTable, ' SET rgt = rgt + 2', ' WHERE rgt > @vLeft', @@ -15322,14 +15150,14 @@ BEGIN ' WHERE lft > @vLeft', ' ORDER BY lft DESC' )); - + SET vChild = REPLACE(vChild, "'", "\\'"); - + CALL util.exec(CONCAT( 'INSERT INTO ', vScheme, '.', vTable, ' (name, lft, rgt, depth)', ' VALUES ("', vChild, '", @vLeft + 1, @vLeft + 2, @vDepth + 1)' )); - + CALL util.exec(CONCAT('DROP TEMPORARY TABLE tmp.', vTableClone)); END ;; DELIMITER ; @@ -15337,8 +15165,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `nodeDelete` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -15346,6 +15172,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `nodeDelete`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45), IN `vNodeId` INT) BEGIN @@ -15361,7 +15189,7 @@ BEGIN )); CALL util.exec(CONCAT( - 'DELETE FROM ', vScheme, '.', vTable, + 'DELETE FROM ', vScheme, '.', vTable, ' WHERE lft BETWEEN @vMyLeft AND @vMyRight' )); @@ -15380,8 +15208,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `nodeMove` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -15389,10 +15215,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `nodeMove`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45), IN `vNodeId` INT, IN `vFatherId` INT) BEGIN - -- Averiguamos el ancho de la rama + -- Averiguamos el ancho de la rama CALL util.exec (sql_printf ( 'SELECT t.rgt - t.lft +1 INTO @vMyWidth FROM %t.%t t WHERE t.id = %v' ,vScheme @@ -15415,13 +15243,13 @@ BEGIN 'UPDATE %t.%t SET rgt = rgt + @vMyWidth WHERE rgt >= @vFatherRight ORDER BY rgt DESC' ,vScheme ,vTable - )); + )); CALL util.exec (sql_printf ( 'UPDATE %t.%t SET lft = lft + @vMyWidth WHERE lft >= @vFatherRight ORDER BY lft DESC' ,vScheme ,vTable - )); + )); -- Es preciso recalcular los valores del nodo en el caso de que estuviera a la derecha del nuevo padre @@ -15437,7 +15265,7 @@ BEGIN 'UPDATE %t.%t SET lft = lft + @vGap WHERE lft BETWEEN @vMyLeft AND @vMyRight ORDER BY lft DESC' ,vScheme ,vTable - )); + )); CALL util.exec (sql_printf ( 'UPDATE %t.%t SET rgt = rgt + @vGap WHERE rgt BETWEEN @vMyLeft AND @vMyRight ORDER BY rgt DESC' ,vScheme @@ -15463,8 +15291,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `nodeRecalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -15472,6 +15298,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `nodeRecalc`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45)) BEGIN @@ -15495,8 +15323,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `nodeTree` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -15504,6 +15330,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `nodeTree`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45), IN `vGap` INT, IN `vShouldShow` BOOLEAN) BEGIN @@ -15538,8 +15366,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `nodeTree_pako` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -15547,6 +15373,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `nodeTree_pako`(IN `vScheme` VARCHAR(45), IN `vTable` VARCHAR(45), IN `vGap` INT, IN `vShouldShow` BOOLEAN) BEGIN @@ -15587,7 +15415,7 @@ DELIMITER ; -- Current Database: `pbx` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `pbx` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `pbx` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `pbx`; @@ -15599,9 +15427,9 @@ DROP TABLE IF EXISTS `blacklist`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `blacklist` ( - `phone` varchar(20) COLLATE utf8_unicode_ci NOT NULL, + `phone` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`phone`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Hangup input calls from this list'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Hangup input calls from this list'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -15653,22 +15481,22 @@ DROP TABLE IF EXISTS `cdr`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cdr` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `call_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `clid` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `src` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `dst` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `dcontext` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `channel` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `dst_channel` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `last_app` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `last_data` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `duration` int(11) NOT NULL DEFAULT '0', - `billsec` int(11) NOT NULL DEFAULT '0', - `disposition` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `ama_flags` int(11) NOT NULL DEFAULT '0', - `account_code` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `unique_id` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `user_field` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', + `call_date` datetime NOT NULL DEFAULT current_timestamp(), + `clid` varchar(80) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `src` varchar(80) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `dst` varchar(80) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `dcontext` varchar(80) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `channel` varchar(80) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `dst_channel` varchar(80) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `last_app` varchar(80) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `last_data` varchar(80) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `duration` int(11) NOT NULL DEFAULT 0, + `billsec` int(11) NOT NULL DEFAULT 0, + `disposition` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `ama_flags` int(11) NOT NULL DEFAULT 0, + `account_code` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `unique_id` varchar(32) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `user_field` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `calldate` (`call_date`), KEY `dst` (`dst`), @@ -15676,7 +15504,7 @@ CREATE TABLE `cdr` ( KEY `dstchannel` (`dst_channel`), KEY `disposition` (`disposition`), KEY `src` (`src`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -15717,9 +15545,9 @@ DROP TABLE IF EXISTS `config`; CREATE TABLE `config` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `sundayFestive` tinyint(4) NOT NULL, - `countryPrefix` varchar(20) CHARACTER SET utf8 DEFAULT NULL, + `countryPrefix` varchar(20) CHARACTER SET utf8mb3 DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global configuration'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Global configuration'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -15730,11 +15558,11 @@ DROP TABLE IF EXISTS `followme`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `followme` ( - `extension` varchar(128) CHARACTER SET utf8 NOT NULL, - `phone` varchar(20) CHARACTER SET utf8 NOT NULL, + `extension` varchar(128) CHARACTER SET utf8mb3 NOT NULL, + `phone` varchar(20) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`extension`), CONSTRAINT `followme_ibfk_1` FOREIGN KEY (`extension`) REFERENCES `sip` (`extension`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -15803,13 +15631,13 @@ DROP TABLE IF EXISTS `followmeConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `followmeConfig` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `music` varchar(50) CHARACTER SET utf8 DEFAULT NULL, - `context` varchar(50) CHARACTER SET utf8 NOT NULL, - `takeCall` char(1) CHARACTER SET utf8 NOT NULL, - `declineCall` char(1) CHARACTER SET utf8 NOT NULL, + `music` varchar(50) CHARACTER SET utf8mb3 DEFAULT NULL, + `context` varchar(50) CHARACTER SET utf8mb3 NOT NULL, + `takeCall` char(1) CHARACTER SET utf8mb3 NOT NULL, + `declineCall` char(1) CHARACTER SET utf8mb3 NOT NULL, `timeout` int(11) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -15837,15 +15665,15 @@ DROP TABLE IF EXISTS `queue`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `queue` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `description` varchar(128) CHARACTER SET utf8 NOT NULL, - `name` varchar(128) CHARACTER SET utf8 NOT NULL, + `description` varchar(128) CHARACTER SET utf8mb3 NOT NULL, + `name` varchar(128) CHARACTER SET utf8mb3 NOT NULL, `config` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`), UNIQUE KEY `description` (`description`), KEY `config` (`config`), CONSTRAINT `queue_ibfk_1` FOREIGN KEY (`config`) REFERENCES `queueConfig` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Queues'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Queues'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -15916,14 +15744,14 @@ DROP TABLE IF EXISTS `queueConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `queueConfig` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `strategy` varchar(128) CHARACTER SET utf8 NOT NULL, + `strategy` varchar(128) CHARACTER SET utf8mb3 NOT NULL, `timeout` int(10) unsigned NOT NULL, `retry` int(10) unsigned NOT NULL, `weight` int(10) unsigned NOT NULL, `maxLen` int(10) unsigned NOT NULL, `ringInUse` tinyint(4) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Default values for queues configuration'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Default values for queues configuration'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -15935,14 +15763,14 @@ DROP TABLE IF EXISTS `queueMember`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `queueMember` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `queue` varchar(128) CHARACTER SET utf8 NOT NULL, - `extension` varchar(128) CHARACTER SET utf8 NOT NULL, + `queue` varchar(128) CHARACTER SET utf8mb3 NOT NULL, + `extension` varchar(128) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `queue` (`queue`,`extension`), KEY `extension` (`extension`), CONSTRAINT `queueMember_ibfk_1` FOREIGN KEY (`queue`) REFERENCES `queue` (`name`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `queueMember_ibfk_2` FOREIGN KEY (`extension`) REFERENCES `sip` (`extension`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Queue members'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Queue members'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -15970,12 +15798,12 @@ DROP TABLE IF EXISTS `queuePhone`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `queuePhone` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `queue` varchar(128) CHARACTER SET utf8 NOT NULL, - `phone` varchar(128) CHARACTER SET utf8 NOT NULL, + `queue` varchar(128) CHARACTER SET utf8mb3 NOT NULL, + `phone` varchar(128) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `queue` (`queue`,`phone`), CONSTRAINT `queuePhone_ibfk_1` FOREIGN KEY (`queue`) REFERENCES `queue` (`name`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -16030,11 +15858,11 @@ CREATE TABLE `schedule` ( `weekDay` tinyint(3) unsigned NOT NULL COMMENT '0 = Monday, 6 = Sunday', `timeStart` time NOT NULL, `timeEnd` time NOT NULL, - `queue` varchar(128) CHARACTER SET utf8 NOT NULL, + `queue` varchar(128) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`id`), KEY `queue` (`queue`), CONSTRAINT `schedule_ibfk_1` FOREIGN KEY (`queue`) REFERENCES `queue` (`name`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16045,15 +15873,15 @@ DROP TABLE IF EXISTS `sip`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sip` ( - `user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'The user id', - `extension` varchar(128) CHARACTER SET utf8 NOT NULL COMMENT 'The softphone extension', - `md5Secret` varchar(80) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'MD5 hash of extension and password', - `secret` varchar(80) CHARACTER SET utf8 DEFAULT NULL COMMENT 'Deprecated', - `caller_id` varchar(80) CHARACTER SET utf8 DEFAULT NULL COMMENT 'Deprecated', + `user_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'The user id', + `extension` varchar(128) CHARACTER SET utf8mb3 NOT NULL COMMENT 'The softphone extension', + `md5Secret` varchar(80) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'MD5 hash of extension and password', + `secret` varchar(80) CHARACTER SET utf8mb3 DEFAULT NULL COMMENT 'Deprecated', + `caller_id` varchar(80) CHARACTER SET utf8mb3 DEFAULT NULL COMMENT 'Deprecated', PRIMARY KEY (`user_id`), UNIQUE KEY `extension` (`extension`), CONSTRAINT `sip_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='SIP accounts'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='SIP accounts'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -16191,27 +16019,27 @@ DROP TABLE IF EXISTS `sipConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sipConfig` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `host` varchar(40) CHARACTER SET utf8 DEFAULT NULL, - `deny` varchar(95) CHARACTER SET utf8 NOT NULL, - `permit` varchar(95) CHARACTER SET utf8 NOT NULL, - `type` enum('user','peer','friend') CHARACTER SET utf8 NOT NULL, - `context` varchar(80) CHARACTER SET utf8 NOT NULL, - `incomingLimit` varchar(10) CHARACTER SET utf8 NOT NULL, - `pickupGroup` varchar(10) CHARACTER SET utf8 NOT NULL, - `careInvite` varchar(10) CHARACTER SET utf8 NOT NULL, - `insecure` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `transport` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `avpf` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `icesupport` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `encryption` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `dtlsenable` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `dtlverify` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `dtlscertfile` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `dtlsprivatekey` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `dtlssetup` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `nat` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `host` varchar(40) CHARACTER SET utf8mb3 DEFAULT NULL, + `deny` varchar(95) CHARACTER SET utf8mb3 NOT NULL, + `permit` varchar(95) CHARACTER SET utf8mb3 NOT NULL, + `type` enum('user','peer','friend') CHARACTER SET utf8mb3 NOT NULL, + `context` varchar(80) CHARACTER SET utf8mb3 NOT NULL, + `incomingLimit` varchar(10) CHARACTER SET utf8mb3 NOT NULL, + `pickupGroup` varchar(10) CHARACTER SET utf8mb3 NOT NULL, + `careInvite` varchar(10) CHARACTER SET utf8mb3 NOT NULL, + `insecure` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `transport` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `avpf` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `icesupport` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `encryption` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `dtlsenable` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `dtlverify` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `dtlscertfile` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `dtlsprivatekey` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `dtlssetup` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `nat` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Default values for SIP accounts'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Default values for SIP accounts'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16223,17 +16051,17 @@ DROP TABLE IF EXISTS `sipReg`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sipReg` ( `userId` int(10) unsigned NOT NULL, - `ipAddr` varchar(45) CHARACTER SET utf8 DEFAULT NULL, + `ipAddr` varchar(45) CHARACTER SET utf8mb3 DEFAULT NULL, `regSeconds` bigint(20) unsigned DEFAULT NULL, - `port` varchar(50) CHARACTER SET utf8 DEFAULT NULL, - `defaultUser` varchar(50) CHARACTER SET utf8 DEFAULT NULL, - `userAgent` varchar(80) CHARACTER SET utf8 DEFAULT NULL, - `lastMs` varchar(50) CHARACTER SET utf8 DEFAULT NULL, - `fullContact` varchar(50) CHARACTER SET utf8 DEFAULT NULL, - `regServer` varchar(20) CHARACTER SET utf8 DEFAULT NULL, + `port` varchar(50) CHARACTER SET utf8mb3 DEFAULT NULL, + `defaultUser` varchar(50) CHARACTER SET utf8mb3 DEFAULT NULL, + `userAgent` varchar(80) CHARACTER SET utf8mb3 DEFAULT NULL, + `lastMs` varchar(50) CHARACTER SET utf8mb3 DEFAULT NULL, + `fullContact` varchar(50) CHARACTER SET utf8mb3 DEFAULT NULL, + `regServer` varchar(20) CHARACTER SET utf8mb3 DEFAULT NULL, PRIMARY KEY (`userId`), CONSTRAINT `sipReg_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `sip` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='SIP registrations'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='SIP registrations'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16243,8 +16071,6 @@ CREATE TABLE `sipReg` ( -- -- Dumping routines for database 'pbx' -- -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `clientFromPhone` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -16252,6 +16078,8 @@ CREATE TABLE `sipReg` ( /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `clientFromPhone`(vPhone VARCHAR(255)) RETURNS int(11) DETERMINISTIC @@ -16266,8 +16094,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `phone_format` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -16275,8 +16101,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `phone_format`(vPhone VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `phone_format`(vPhone VARCHAR(255)) RETURNS varchar(255) CHARSET utf8mb3 DETERMINISTIC BEGIN DECLARE vI INT DEFAULT 0; @@ -16287,7 +16115,7 @@ BEGIN WHILE vI < vLen DO SET vChr = SUBSTR(vPhone, vI + 1, 1); - + IF vChr REGEXP '^[0-9]$' THEN SET vNewPhone = CONCAT(vNewPhone, vChr); @@ -16295,7 +16123,7 @@ BEGIN THEN SET vNewPhone = CONCAT(vNewPhone, '00'); END IF; - + SET vI = vI + 1; END WHILE; @@ -16314,8 +16142,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `phone_isValid` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -16323,6 +16149,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `phone_isValid`(vPhone VARCHAR(255)) BEGIN @@ -16349,8 +16177,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `queue_isValid` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -16358,6 +16184,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `queue_isValid`(vQueue VARCHAR(255)) BEGIN @@ -16382,8 +16210,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sip_getExtension` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -16391,29 +16217,29 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sip_getExtension`(vUserId INT(10)) BEGIN - + /* * Devuelve la extensión pbx del usuario - * - * @param vUserId Id del usuario - * + * + * @param vUserId Id del usuario + * */ SELECT extension - FROM sip s + FROM sip s WHERE s.user_id = vUserId; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sip_isValid` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -16421,6 +16247,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sip_isValid`(vExtension VARCHAR(255)) BEGIN @@ -16446,8 +16274,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sip_setPassword` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -16455,6 +16281,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sip_setPassword`( vUser VARCHAR(255), @@ -16475,7 +16303,7 @@ DELIMITER ; -- Current Database: `postgresql` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `postgresql` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `postgresql` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `postgresql`; @@ -16499,7 +16327,7 @@ CREATE TABLE `address` ( KEY `address_town_id_idx` (`town_id`), CONSTRAINT `address_ibfk_1` FOREIGN KEY (`address_type_id`) REFERENCES `address_type` (`address_type_id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `address_ibfk_2` FOREIGN KEY (`town_id`) REFERENCES `townKk` (`town_id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16513,17 +16341,17 @@ CREATE TABLE `address_type` ( `address_type_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(20) NOT NULL, PRIMARY KEY (`address_type_id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `bank_account` +-- Table structure for table `bank_account__` -- -DROP TABLE IF EXISTS `bank_account`; +DROP TABLE IF EXISTS `bank_account__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `bank_account` ( +CREATE TABLE `bank_account__` ( `bank_account_id` int(11) NOT NULL AUTO_INCREMENT, `client_id__` int(11) DEFAULT NULL, `account` char(50) DEFAULT NULL, @@ -16545,7 +16373,7 @@ CREATE TABLE `bank_account` ( CONSTRAINT `bank_account_bank_account_type` FOREIGN KEY (`bank_account_type_id`) REFERENCES `bank_account_type` (`bank_account_type_id`) ON UPDATE CASCADE, CONSTRAINT `bank_account_nation_id` FOREIGN KEY (`nation_id`) REFERENCES `vn`.`country` (`id`) ON UPDATE CASCADE, CONSTRAINT `bank_account_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16559,7 +16387,7 @@ CREATE TABLE `bank_account_type` ( `bank_account_type_id` int(11) NOT NULL AUTO_INCREMENT, `name` char(15) DEFAULT NULL, PRIMARY KEY (`bank_account_type_id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16577,35 +16405,38 @@ CREATE TABLE `bank_bic__` ( `referenciaVNL` varchar(35) DEFAULT NULL, PRIMARY KEY (`nrbe`), KEY `bankbic_ikey1` (`bic`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `business` +-- Table structure for table `business__` -- -DROP TABLE IF EXISTS `business`; +DROP TABLE IF EXISTS `business__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `business` ( +CREATE TABLE `business__` ( `business_id` int(11) NOT NULL AUTO_INCREMENT, `client_id` int(11) DEFAULT NULL, `provider_id__` int(11) DEFAULT NULL, - `companyCodeFk` char(3) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `companyCodeFk` char(3) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, `date_start` date DEFAULT NULL, `date_end` date DEFAULT NULL, - `workerBusiness` longtext, + `workerBusiness` longtext DEFAULT NULL, `reasonEndFk` int(11) DEFAULT NULL, - `payedHolidays` int(11) DEFAULT NULL, + `payedHolidays` decimal(5,2) NOT NULL DEFAULT 0.00, `occupationCodeFk` varchar(1) DEFAULT NULL, + `workerFk` int(10) unsigned NOT NULL, PRIMARY KEY (`business_id`), KEY `business_client` (`client_id`), KEY `business_occupationCodeFk` (`occupationCodeFk`), KEY `business_companyCodeFk` (`companyCodeFk`), - CONSTRAINT `business_client` FOREIGN KEY (`client_id`) REFERENCES `profile` (`profile_id`) ON DELETE CASCADE ON UPDATE CASCADE, + KEY `business_workerFk_idx` (`workerFk`), + CONSTRAINT `business_client` FOREIGN KEY (`client_id`) REFERENCES `profile__` (`profile_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `business_companyCodeFk` FOREIGN KEY (`companyCodeFk`) REFERENCES `vn`.`company` (`code`) ON UPDATE CASCADE, - CONSTRAINT `business_occupationCodeFk` FOREIGN KEY (`occupationCodeFk`) REFERENCES `vn`.`occupationCode` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; + CONSTRAINT `business_occupationCodeFk` FOREIGN KEY (`occupationCodeFk`) REFERENCES `vn`.`occupationCode` (`code`) ON UPDATE CASCADE, + CONSTRAINT `business_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -16616,32 +16447,12 @@ CREATE TABLE `business` ( /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `postgresql`.`business_beforeUpdate` - BEFORE UPDATE ON `business` - FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `postgresql`.`business_beforeInsert` + BEFORE INSERT ON `business__` FOR EACH ROW BEGIN - DECLARE isOverlapping BOOL; - - IF !(OLD.date_start <=> NEW.date_start AND OLD.date_end <=> NEW.date_end) THEN - - SELECT COUNT(*) > 0 INTO isOverlapping - FROM business b - WHERE (util.hasDateOverlapped( - NEW.date_start, - IFNULL(NEW.date_end,b.date_start), - b.date_start, - IFNULL(b.date_end,NEW.date_start)) - OR (NEW.date_end <=> NULL AND b.date_end <=> NULL)) - AND b.business_id <> OLD.business_id - AND client_id = OLD.client_id - ; - - IF isOverlapping THEN - CALL util.throw ('IS_OVERLAPPING'); - END IF; - + IF NEW.date_end IS NULL THEN + SET NEW.payedHolidays = 0; END IF; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -16650,20 +16461,20 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; -- --- Table structure for table `business_labour` +-- Table structure for table `business_labour__` -- -DROP TABLE IF EXISTS `business_labour`; +DROP TABLE IF EXISTS `business_labour__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `business_labour` ( +CREATE TABLE `business_labour__` ( `business_id` int(11) NOT NULL, - `notes` longtext, + `notes` longtext DEFAULT NULL, `department_id` int(11) NOT NULL, - `professional_category_id` int(11) DEFAULT '0', - `incentivo` double DEFAULT '0', - `calendar_labour_type_id` int(11) DEFAULT '1', - `porhoras` smallint(6) NOT NULL DEFAULT '0', + `professional_category_id` int(11) DEFAULT 0, + `incentivo` double DEFAULT 0, + `calendar_labour_type_id` int(11) DEFAULT 1, + `porhoras` smallint(6) NOT NULL DEFAULT 0, `labour_agreement_id` int(11) DEFAULT NULL, `workcenter_id` int(11) NOT NULL, PRIMARY KEY (`business_id`), @@ -16671,34 +16482,33 @@ CREATE TABLE `business_labour` ( KEY `fki_workcenter_labour` (`workcenter_id`), KEY `horario_tipo` (`calendar_labour_type_id`), KEY `business_labour_department_idx` (`department_id`), - CONSTRAINT `bus_restriction` FOREIGN KEY (`business_id`) REFERENCES `business` (`business_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `business_labour_FK` FOREIGN KEY (`workcenter_id`) REFERENCES `vn`.`workCenter` (`id`) ON UPDATE CASCADE, CONSTRAINT `business_labour_agreement` FOREIGN KEY (`labour_agreement_id`) REFERENCES `labour_agreement` (`labour_agreement_id`) ON UPDATE CASCADE, + CONSTRAINT `business_labour_business_id` FOREIGN KEY (`business_id`) REFERENCES `vn`.`business` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `business_labour_department_id` FOREIGN KEY (`department_id`) REFERENCES `vn`.`department` (`id`) ON UPDATE CASCADE, CONSTRAINT `horario_tipo` FOREIGN KEY (`calendar_labour_type_id`) REFERENCES `calendar_labour_type` (`calendar_labour_type_id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `business_labour_payroll` +-- Table structure for table `business_labour_payroll__` -- -DROP TABLE IF EXISTS `business_labour_payroll`; +DROP TABLE IF EXISTS `business_labour_payroll__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `business_labour_payroll` ( +CREATE TABLE `business_labour_payroll__` ( `business_id` int(11) NOT NULL, `cod_tarifa` int(11) DEFAULT NULL, `cod_categoria` int(11) DEFAULT NULL, `cod_contrato` int(11) DEFAULT NULL, - `importepactado` decimal(10,2) NOT NULL DEFAULT '0.00', + `importepactado` decimal(10,2) NOT NULL DEFAULT 0.00, PRIMARY KEY (`business_id`), KEY `business_labour_payroll_cod_categoria_idx` (`cod_categoria`), KEY `business_labour_payroll_FK` (`cod_contrato`), CONSTRAINT `business_labour_payroll_FK` FOREIGN KEY (`cod_contrato`) REFERENCES `vn`.`workerBusinessType` (`id`) ON UPDATE CASCADE, - CONSTRAINT `business_labour_payroll_cod_categoria` FOREIGN KEY (`cod_categoria`) REFERENCES `vn2008`.`payroll_categorias` (`codcategoria`) ON UPDATE CASCADE, - CONSTRAINT `business_labour_payroll_fk1` FOREIGN KEY (`business_id`) REFERENCES `business` (`business_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `business_labour_payroll_business_id` FOREIGN KEY (`business_id`) REFERENCES `vn`.`business` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16711,7 +16521,7 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `calendar_employee` ( `id` tinyint NOT NULL, - `business_id` tinyint NOT NULL, + `businessFk` tinyint NOT NULL, `calendar_state_id` tinyint NOT NULL, `date` tinyint NOT NULL ) ENGINE=MyISAM */; @@ -16729,7 +16539,7 @@ CREATE TABLE `calendar_free__` ( `type` varchar(20) NOT NULL, `rgb` varchar(7) DEFAULT NULL, PRIMARY KEY (`calendar_free_id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16755,7 +16565,7 @@ CREATE TABLE `calendar_labour__` ( CONSTRAINT `fk_calendar_labour_calendar_free1` FOREIGN KEY (`calendar_free_id`) REFERENCES `calendar_free__` (`calendar_free_id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_calendar_labour_legend_id` FOREIGN KEY (`calendar_labour_legend_id`) REFERENCES `calendar_labour_legend__` (`calendar_labour_legend_id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `workcenter_calendar` FOREIGN KEY (`workcenter_id`) REFERENCES `workcenter__` (`workcenter_id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16767,10 +16577,10 @@ DROP TABLE IF EXISTS `calendar_labour_legend__`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `calendar_labour_legend__` ( `calendar_labour_legend_id` int(11) NOT NULL AUTO_INCREMENT, - `descripcion` longtext, + `descripcion` longtext DEFAULT NULL, PRIMARY KEY (`calendar_labour_legend_id`), UNIQUE KEY `calendar_labour_legend_calendar_labour_legend_id_key` (`calendar_labour_legend_id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16785,10 +16595,10 @@ CREATE TABLE `calendar_labour_type` ( `descripcion` varchar(50) DEFAULT NULL, `pausa_remunerada` time DEFAULT NULL, `hours_week` smallint(6) DEFAULT NULL, - `isPartial` tinyint(1) NOT NULL DEFAULT '0', + `isPartial` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`calendar_labour_type_id`), UNIQUE KEY `hours_labour_hours_labour_id_key` (`calendar_labour_type_id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16802,7 +16612,7 @@ CREATE TABLE `currency__` ( `currency_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(15) NOT NULL, PRIMARY KEY (`currency_id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16814,10 +16624,10 @@ DROP TABLE IF EXISTS `erte_COVID19`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `erte_COVID19` ( `personFk` int(11) NOT NULL, - `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`personFk`), CONSTRAINT `erte_COVID19_FK` FOREIGN KEY (`personFk`) REFERENCES `vn`.`person__` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16829,19 +16639,19 @@ DROP TABLE IF EXISTS `income_employee`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `income_employee` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `debe` decimal(10,2) NOT NULL DEFAULT '0.00', - `haber` decimal(10,2) NOT NULL DEFAULT '0.00', + `debe` decimal(10,2) NOT NULL DEFAULT 0.00, + `haber` decimal(10,2) NOT NULL DEFAULT 0.00, `id_incomeType` int(11) DEFAULT NULL, `odbc_date` date DEFAULT NULL, `workerFk` int(11) unsigned NOT NULL, `person_id__` int(11) DEFAULT NULL, - `concepto` longtext, + `concepto` longtext DEFAULT NULL, PRIMARY KEY (`id`), KEY `income_employeeId_incomeType_idx` (`id_incomeType`), KEY `income_employee_workerFk_idx` (`workerFk`), CONSTRAINT `income_employeeId_incomeType` FOREIGN KEY (`id_incomeType`) REFERENCES `vn2008`.`payroll_conceptos` (`conceptoid`) ON UPDATE CASCADE, CONSTRAINT `income_employee_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16854,10 +16664,10 @@ DROP TABLE IF EXISTS `incometype_employee`; CREATE TABLE `incometype_employee` ( `id_incometype` int(11) NOT NULL, `descripcion` varchar(255) DEFAULT NULL, - `nomina` smallint(6) DEFAULT '0', - `isExtraSalarial` tinyint(4) NOT NULL DEFAULT '0', + `nomina` smallint(6) DEFAULT 0, + `isExtraSalarial` tinyint(4) NOT NULL DEFAULT 0, PRIMARY KEY (`id_incometype`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16869,15 +16679,15 @@ DROP TABLE IF EXISTS `journey`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `journey` ( `journey_id` int(11) NOT NULL AUTO_INCREMENT, - `day_id` smallint(6) NOT NULL DEFAULT '1' COMMENT 'Lunes = 1 \nDomingo = 7', + `day_id` smallint(6) NOT NULL DEFAULT 1 COMMENT 'Lunes = 1 \nDomingo = 7', `start` time DEFAULT NULL, `end` time DEFAULT NULL, `business_id` int(11) NOT NULL, PRIMARY KEY (`journey_id`), UNIQUE KEY `day_id` (`day_id`,`start`,`end`,`business_id`), - KEY `fki_business_journey` (`business_id`), - CONSTRAINT `business_journey` FOREIGN KEY (`business_id`) REFERENCES `business` (`business_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; + KEY `journey_business_id_idx` (`business_id`), + CONSTRAINT `journey_business_id` FOREIGN KEY (`business_id`) REFERENCES `vn`.`business` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16895,7 +16705,7 @@ CREATE TABLE `labour_agreement` ( `date_START` date DEFAULT NULL, `date_END` date DEFAULT NULL, PRIMARY KEY (`labour_agreement_id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16913,7 +16723,7 @@ CREATE TABLE `media` ( PRIMARY KEY (`media_id`), KEY `media_media_type_id_idx` (`media_type_id`), CONSTRAINT `media_ibfk_1` FOREIGN KEY (`media_type_id`) REFERENCES `media_type` (`media_type_id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16928,7 +16738,7 @@ CREATE TABLE `media_type` ( `name` varchar(15) NOT NULL, PRIMARY KEY (`media_type_id`), UNIQUE KEY `media_type_name_key` (`name`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16940,15 +16750,15 @@ DROP TABLE IF EXISTS `nation__`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `nation__` ( `nation_id` int(11) NOT NULL AUTO_INCREMENT, - `currency_id` int(11) NOT NULL DEFAULT '1', + `currency_id` int(11) NOT NULL DEFAULT 1, `name` varchar(20) NOT NULL, `brief` char(3) NOT NULL, - `flag` longblob, + `flag` longblob DEFAULT NULL, PRIMARY KEY (`nation_id`), UNIQUE KEY `nation_name_key` (`name`), KEY `nation_currency_id_idx` (`currency_id`), CONSTRAINT `nation___ibfk_1` FOREIGN KEY (`currency_id`) REFERENCES `currency__` (`currency_id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16962,7 +16772,7 @@ CREATE TABLE `periodos__` ( `fecha` date NOT NULL, `periodo` int(11) DEFAULT NULL, PRIMARY KEY (`fecha`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16979,12 +16789,12 @@ CREATE TABLE `person__` ( `nif` varchar(15) DEFAULT NULL, `birth` date DEFAULT NULL, `firstname` varchar(20) DEFAULT NULL, - `p2` longtext, + `p2` longtext DEFAULT NULL, `nis` int(11) DEFAULT NULL, `id_trabajador` int(10) unsigned DEFAULT NULL, - `isDisable` smallint(6) NOT NULL DEFAULT '0', - `isFreelance` smallint(6) NOT NULL DEFAULT '0' COMMENT 'M Male\nF Female', - `isSsDiscounted` smallint(6) NOT NULL DEFAULT '0', + `isDisable` smallint(6) NOT NULL DEFAULT 0, + `isFreelance` smallint(6) NOT NULL DEFAULT 0 COMMENT 'M Male\nF Female', + `isSsDiscounted` smallint(6) NOT NULL DEFAULT 0, `sex` enum('M','F') NOT NULL DEFAULT 'F' COMMENT 'M Masculino F Femenino', PRIMARY KEY (`person_id`), UNIQUE KEY `person_nis` (`person_id`), @@ -16994,7 +16804,7 @@ CREATE TABLE `person__` ( KEY `index1` (`person_id`,`name`,`nickname`,`firstname`), KEY `person_worker` (`id_trabajador`), CONSTRAINT `Person_ibfk_1` FOREIGN KEY (`id_trabajador`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17008,12 +16818,12 @@ CREATE TABLE `professional_category` ( `professional_category_id` int(11) NOT NULL AUTO_INCREMENT, `category_name` varchar(50) NOT NULL, `professional_levels_id` int(11) DEFAULT NULL, - `fichajes` tinyint(4) NOT NULL DEFAULT '1', + `fichajes` tinyint(4) NOT NULL DEFAULT 1, `holiday_days` decimal(3,1) DEFAULT NULL, `dayBreak` int(11) DEFAULT NULL, PRIMARY KEY (`professional_category_id`), UNIQUE KEY `professional_category_name_category_key` (`category_name`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17028,27 +16838,27 @@ CREATE TABLE `professional_levels` ( `level_name` varchar(5) DEFAULT NULL, `price_overtime` double DEFAULT NULL, PRIMARY KEY (`professional_levels_id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `profile` +-- Table structure for table `profile__` -- -DROP TABLE IF EXISTS `profile`; +DROP TABLE IF EXISTS `profile__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `profile` ( +CREATE TABLE `profile__` ( `profile_id` int(11) NOT NULL AUTO_INCREMENT, `person_id__` int(11) DEFAULT NULL, - `profile_type_id` int(11) NOT NULL DEFAULT '1', + `profile_type_id` int(11) NOT NULL DEFAULT 1, `workerFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`profile_id`), KEY `profile_person_id_idx` (`person_id__`), KEY `profile_profile_type_id_idx` (`profile_type_id`), KEY `profile_workerFk_idx` (`workerFk`), CONSTRAINT `profile_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17065,7 +16875,7 @@ CREATE TABLE `profile_address` ( PRIMARY KEY (`profile_address_id`), KEY `profile_address_address_id_idx` (`address_id`), KEY `profile_address_profile_id_idx` (`profile_id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17083,8 +16893,8 @@ CREATE TABLE `profile_media` ( KEY `profile_media_media_id_idx` (`media_id`), KEY `profile_media_profile_id_idx` (`profile_id`), CONSTRAINT `fk_profile_media_media1` FOREIGN KEY (`media_id`) REFERENCES `media` (`media_id`) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT `media_ibfk_20` FOREIGN KEY (`profile_id`) REFERENCES `profile` (`profile_id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; + CONSTRAINT `media_ibfk_20` FOREIGN KEY (`profile_id`) REFERENCES `profile__` (`profile_id`) ON DELETE NO ACTION ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17098,7 +16908,7 @@ CREATE TABLE `profile_type` ( `profile_type_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(15) NOT NULL, PRIMARY KEY (`profile_type_id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17116,7 +16926,7 @@ CREATE TABLE `province` ( UNIQUE KEY `province_name_key` (`name`), KEY `province_nation_id_idx` (`nation_id`), CONSTRAINT `fk_province_nation1` FOREIGN KEY (`nation_id`) REFERENCES `nation__` (`nation_id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17134,7 +16944,7 @@ CREATE TABLE `townKk` ( PRIMARY KEY (`town_id`), KEY `town_province_id_idx` (`province_id`), CONSTRAINT `townKk_ibfk_1` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17146,7 +16956,7 @@ DROP TABLE IF EXISTS `workcenter__`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workcenter__` ( `workcenter_id` int(11) NOT NULL AUTO_INCREMENT, - `name` longtext, + `name` longtext DEFAULT NULL, `center_id` int(11) DEFAULT NULL, `counter` bigint(20) DEFAULT NULL, `warehouseFk` smallint(6) DEFAULT NULL, @@ -17155,7 +16965,7 @@ CREATE TABLE `workcenter__` ( PRIMARY KEY (`workcenter_id`), KEY `workcenter_geoFk_idx` (`geoFk`), CONSTRAINT `workCenter_geoFk` FOREIGN KEY (`geoFk`) REFERENCES `vn`.`zoneGeo` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17166,12 +16976,12 @@ DROP TABLE IF EXISTS `workerTimeControlConfig__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerTimeControlConfig__` ( - `id` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `id` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `warehouseFk` smallint(6) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `warehouseFk_1_idx` (`warehouseFk`), CONSTRAINT `warehouseFk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17183,17 +16993,17 @@ DROP TABLE IF EXISTS `workers20190711_FichadasAbril`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workers20190711_FichadasAbril` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT '0', - `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, - `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, - `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, + `person_id` int(11) NOT NULL DEFAULT 0, + `nif` varchar(15) CHARACTER SET utf8mb3 DEFAULT NULL, + `Apellidos` varchar(60) CHARACTER SET utf8mb3 NOT NULL, + `Nombre` varchar(20) CHARACTER SET utf8mb3 DEFAULT NULL, `Fecha` date DEFAULT NULL, `Hora` int(2) DEFAULT NULL, `Minuto` int(2) DEFAULT NULL, `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT '8.00', + `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17208,7 +17018,7 @@ CREATE TABLE `workers20190711_FichadasAbril` ( -- Current Database: `sage` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `sage` /*!40100 DEFAULT CHARACTER SET utf8 */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `sage` /*!40100 DEFAULT CHARACTER SET utf8mb3 */; USE `sage`; @@ -17224,7 +17034,7 @@ CREATE TABLE `ClavesOperacion` ( `Descripcion` varchar(250) NOT NULL, PRIMARY KEY (`ClaveOperacionFactura_`), UNIQUE KEY `ClaveOperacionFactura__UNIQUE` (`ClaveOperacionFactura_`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17244,7 +17054,7 @@ CREATE TABLE `Municipios` ( `Autonomia` smallint(6) NOT NULL, `Nacion` tinyint(4) NOT NULL, PRIMARY KEY (`Codigo`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17256,20 +17066,20 @@ DROP TABLE IF EXISTS `Naciones`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `Naciones` ( `countryFk` mediumint(8) NOT NULL, - `CodigoNacion` smallint(6) NOT NULL DEFAULT '108', - `CodigoNacion347` smallint(6) NOT NULL DEFAULT '108', - `Nacion` varchar(25) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `SiglaNacion` varchar(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'ES', - `TipoCodigo` varchar(1) CHARACTER SET utf8 NOT NULL DEFAULT 'A', - `Longitud1` tinyint(4) NOT NULL DEFAULT '0', - `Longitud2` tinyint(4) NOT NULL DEFAULT '0', - `Longitud3` tinyint(4) NOT NULL DEFAULT '0', - `Longitud4` tinyint(4) NOT NULL DEFAULT '0', - `NacionCEE` smallint(6) NOT NULL DEFAULT '0', + `CodigoNacion` smallint(6) NOT NULL DEFAULT 108, + `CodigoNacion347` smallint(6) NOT NULL DEFAULT 108, + `Nacion` varchar(25) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `SiglaNacion` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'ES', + `TipoCodigo` varchar(1) CHARACTER SET utf8mb3 NOT NULL DEFAULT 'A', + `Longitud1` tinyint(4) NOT NULL DEFAULT 0, + `Longitud2` tinyint(4) NOT NULL DEFAULT 0, + `Longitud3` tinyint(4) NOT NULL DEFAULT 0, + `Longitud4` tinyint(4) NOT NULL DEFAULT 0, + `NacionCEE` smallint(6) NOT NULL DEFAULT 0, `FechaCEE` datetime DEFAULT NULL, - `NacionISO` varchar(3) CHARACTER SET utf8 NOT NULL DEFAULT '', + `NacionISO` varchar(3) CHARACTER SET utf8mb3 NOT NULL DEFAULT '', PRIMARY KEY (`countryFk`,`CodigoNacion`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17283,10 +17093,10 @@ CREATE TABLE `Provincias` ( `provinceFk` smallint(6) NOT NULL, `CodigoProvincia` varchar(5) NOT NULL DEFAULT '', `CodigoMatricula` varchar(2) NOT NULL DEFAULT '', - `Provincia` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `RecargoProvincial` decimal(28,10) NOT NULL DEFAULT '0.0000000000', + `Provincia` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `RecargoProvincial` decimal(28,10) NOT NULL DEFAULT 0.0000000000, PRIMARY KEY (`CodigoProvincia`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17297,12 +17107,12 @@ DROP TABLE IF EXISTS `TiposIva`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `TiposIva` ( - `CodigoIva` smallint(6) NOT NULL DEFAULT '0', - `CodigoTerritorio` smallint(6) NOT NULL DEFAULT '0', + `CodigoIva` smallint(6) NOT NULL DEFAULT 0, + `CodigoTerritorio` smallint(6) NOT NULL DEFAULT 0, `Iva` varchar(30) NOT NULL DEFAULT '', - `BaseCorrectora` decimal(28,10) NOT NULL DEFAULT '0.0000000000', - `PorcentajeIva` decimal(28,10) NOT NULL DEFAULT '0.0000000000', - `RecargoEquivalencia` decimal(28,10) NOT NULL DEFAULT '0.0000000000', + `BaseCorrectora` decimal(28,10) NOT NULL DEFAULT 0.0000000000, + `PorcentajeIva` decimal(28,10) NOT NULL DEFAULT 0.0000000000, + `RecargoEquivalencia` decimal(28,10) NOT NULL DEFAULT 0.0000000000, `CuentaIvaSoportado` varchar(15) NOT NULL DEFAULT '', `CuentaIvaRepercutido` varchar(15) NOT NULL DEFAULT '', `CuentaRecargo` varchar(15) NOT NULL DEFAULT '', @@ -17321,10 +17131,10 @@ CREATE TABLE `TiposIva` ( `CuentaIVARecCaja` varchar(15) NOT NULL DEFAULT '', `CuentaIVARecCajaPu` varchar(15) NOT NULL DEFAULT '', `CuentaIVARecCajaVen` varchar(15) NOT NULL DEFAULT '', - `IGICImplicito` smallint(6) NOT NULL DEFAULT '0', - `isIntracommunity` tinyint(2) NOT NULL DEFAULT '0', + `IGICImplicito` smallint(6) NOT NULL DEFAULT 0, + `isIntracommunity` tinyint(2) NOT NULL DEFAULT 0, PRIMARY KEY (`CodigoIva`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17335,9 +17145,9 @@ DROP TABLE IF EXISTS `TiposRetencion`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `TiposRetencion` ( - `CodigoRetencion` smallint(6) NOT NULL DEFAULT '0', + `CodigoRetencion` smallint(6) NOT NULL DEFAULT 0, `Retencion` varchar(50) NOT NULL DEFAULT '', - `PorcentajeRetencion` decimal(28,10) NOT NULL DEFAULT '0.0000000000', + `PorcentajeRetencion` decimal(28,10) NOT NULL DEFAULT 0.0000000000, `CuentaCargo` varchar(15) DEFAULT NULL, `CuentaAbono` varchar(15) DEFAULT NULL, `ClaveIrpf` varchar(2) DEFAULT NULL, @@ -17345,7 +17155,7 @@ CREATE TABLE `TiposRetencion` ( `CuentaAbonoANT_` varchar(15) DEFAULT NULL, `IdTipoRetencion` varchar(45) DEFAULT NULL, PRIMARY KEY (`CodigoRetencion`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17356,13 +17166,13 @@ DROP TABLE IF EXISTS `TiposTransacciones`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `TiposTransacciones` ( - `CodigoTransaccion` tinyint(4) NOT NULL DEFAULT '0', + `CodigoTransaccion` tinyint(4) NOT NULL DEFAULT 0, `Transaccion` varchar(50) NOT NULL DEFAULT '', `TipoFactura` varchar(1) NOT NULL DEFAULT '', - `Autofactura` smallint(6) NOT NULL DEFAULT '0', + `Autofactura` smallint(6) NOT NULL DEFAULT 0, `ClaveOperacionDefecto` varchar(1) NOT NULL DEFAULT '', PRIMARY KEY (`CodigoTransaccion`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17388,127 +17198,127 @@ DROP TABLE IF EXISTS `clientesProveedores`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `clientesProveedores` ( `CodigoEmpresa` smallint(6) NOT NULL, - `ClienteOProveedor` varchar(1) COLLATE utf8_unicode_ci NOT NULL, + `ClienteOProveedor` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL, `CodigoClienteProveedor` int(11) NOT NULL, - `RazonSocial` varchar(40) COLLATE utf8_unicode_ci NOT NULL, - `RazonSocial2` varchar(40) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `Nombre` varchar(35) COLLATE utf8_unicode_ci NOT NULL, - `Domicilio` varchar(40) COLLATE utf8_unicode_ci NOT NULL, - `Cargo1` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `Nombre1` varchar(30) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `Cargo2` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `Nombre2` varchar(30) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoCuenta` varchar(15) CHARACTER SET utf8 NOT NULL, - `CifDni` varchar(13) COLLATE utf8_unicode_ci NOT NULL, - `CifEuropeo` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `CodigoSigla` varchar(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `ViaPublica` varchar(40) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `Numero1` varchar(4) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `Numero2` varchar(4) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `Escalera` varchar(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `Piso` varchar(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `Puerta` varchar(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `Letra` varchar(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoPostal` varchar(8) COLLATE utf8_unicode_ci NOT NULL, - `CodigoMunicipio` varchar(7) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `Municipio` varchar(25) COLLATE utf8_unicode_ci NOT NULL, - `ColaMunicipio` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoProvincia` varchar(5) COLLATE utf8_unicode_ci NOT NULL, - `Provincia` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `CodigoNacion` smallint(6) NOT NULL DEFAULT '0', - `Nacion` varchar(25) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `Telefono` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `Telefono2` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `Telefono3` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `Fax` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoTransaccion` tinyint(4) NOT NULL DEFAULT '0', + `RazonSocial` varchar(40) COLLATE utf8mb3_unicode_ci NOT NULL, + `RazonSocial2` varchar(40) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `Nombre` varchar(35) COLLATE utf8mb3_unicode_ci NOT NULL, + `Domicilio` varchar(40) COLLATE utf8mb3_unicode_ci NOT NULL, + `Cargo1` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `Nombre1` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `Cargo2` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `Nombre2` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoCuenta` varchar(15) CHARACTER SET utf8mb3 NOT NULL, + `CifDni` varchar(13) COLLATE utf8mb3_unicode_ci NOT NULL, + `CifEuropeo` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL, + `CodigoSigla` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `ViaPublica` varchar(40) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `Numero1` varchar(4) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `Numero2` varchar(4) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `Escalera` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `Piso` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `Puerta` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `Letra` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoPostal` varchar(8) COLLATE utf8mb3_unicode_ci NOT NULL, + `CodigoMunicipio` varchar(7) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `Municipio` varchar(25) COLLATE utf8mb3_unicode_ci NOT NULL, + `ColaMunicipio` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoProvincia` varchar(5) COLLATE utf8mb3_unicode_ci NOT NULL, + `Provincia` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL, + `CodigoNacion` smallint(6) NOT NULL DEFAULT 0, + `Nacion` varchar(25) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `Telefono` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL, + `Telefono2` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL, + `Telefono3` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `Fax` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoTransaccion` tinyint(4) NOT NULL DEFAULT 0, `CodigoRetencion` smallint(6) NOT NULL, - `Deducible` smallint(6) NOT NULL DEFAULT '0', - `CodigoIva` smallint(6) NOT NULL DEFAULT '0', - `Mediacion` smallint(6) NOT NULL DEFAULT '0', - `Exclusion347` smallint(6) NOT NULL DEFAULT '0', - `NumeroPlazos` tinyint(4) NOT NULL DEFAULT '1', - `DiasPrimerPlazo` smallint(6) NOT NULL DEFAULT '0', - `DiasEntrePlazos` smallint(6) NOT NULL DEFAULT '0', - `DiasFijos1` tinyint(4) NOT NULL DEFAULT '0', - `DiasFijos2` tinyint(4) NOT NULL DEFAULT '0', - `DiasFijos3` tinyint(4) NOT NULL DEFAULT '0', - `InicioNoPago` smallint(6) NOT NULL DEFAULT '0', - `FinNoPago` smallint(6) NOT NULL DEFAULT '0', - `ControlarFestivos` smallint(6) NOT NULL DEFAULT '0', - `DiasRetroceso` tinyint(4) NOT NULL DEFAULT '0', - `MesesComerciales` smallint(6) NOT NULL DEFAULT '0', - `RemesaHabitual` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoTipoEfecto` smallint(6) NOT NULL DEFAULT '0', - `Email1` varchar(250) COLLATE utf8_unicode_ci NOT NULL, - `Email2` varchar(250) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoCategoriaCliente_` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'CLI', - `IdDelegacion` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoMotivoBajaClienteLc` varchar(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoDepartamento` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoCanal` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoBanco` varchar(6) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoAgencia` varchar(6) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `DC` varchar(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CCC` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `IBAN` varchar(34) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoCondiciones` smallint(6) NOT NULL DEFAULT '0', - `StatusTraspasadoIME` tinyint(4) NOT NULL DEFAULT '0', - `TipoImportacionIME` tinyint(4) NOT NULL DEFAULT '2', - `TipoPlanCuentaIME` smallint(6) NOT NULL DEFAULT '2', - `Contrapartida` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoCuentaImpagado` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoCuentaEfecto` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `Comentarios` text COLLATE utf8_unicode_ci NOT NULL, - `CodigoTerritorio` smallint(6) NOT NULL DEFAULT '0', - `CodigoIdioma_` varchar(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `TarifaPrecio` smallint(6) NOT NULL DEFAULT '0', - `%Descuento` decimal(28,10) NOT NULL DEFAULT '0.0000000000', - `%Rappel` decimal(28,10) NOT NULL DEFAULT '0.0000000000', - `%ProntoPago` decimal(28,10) NOT NULL DEFAULT '0.0000000000', - `%Financiacion` decimal(28,10) NOT NULL DEFAULT '0.0000000000', - `CodigoComisionista` int(11) NOT NULL DEFAULT '0', - `TarifaDescuento` smallint(6) NOT NULL DEFAULT '0', - `SiglaNacion` varchar(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `MarcaMenorSinNif` smallint(6) NOT NULL DEFAULT '0', - `PersonaFisicaJuridica` varchar(1) COLLATE utf8_unicode_ci NOT NULL, - `SiglaNacionRepresentante` varchar(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CifDniRepresentante` varchar(13) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `NombreRepresentante` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', + `Deducible` smallint(6) NOT NULL DEFAULT 0, + `CodigoIva` smallint(6) NOT NULL DEFAULT 0, + `Mediacion` smallint(6) NOT NULL DEFAULT 0, + `Exclusion347` smallint(6) NOT NULL DEFAULT 0, + `NumeroPlazos` tinyint(4) NOT NULL DEFAULT 1, + `DiasPrimerPlazo` smallint(6) NOT NULL DEFAULT 0, + `DiasEntrePlazos` smallint(6) NOT NULL DEFAULT 0, + `DiasFijos1` tinyint(4) NOT NULL DEFAULT 0, + `DiasFijos2` tinyint(4) NOT NULL DEFAULT 0, + `DiasFijos3` tinyint(4) NOT NULL DEFAULT 0, + `InicioNoPago` smallint(6) NOT NULL DEFAULT 0, + `FinNoPago` smallint(6) NOT NULL DEFAULT 0, + `ControlarFestivos` smallint(6) NOT NULL DEFAULT 0, + `DiasRetroceso` tinyint(4) NOT NULL DEFAULT 0, + `MesesComerciales` smallint(6) NOT NULL DEFAULT 0, + `RemesaHabitual` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoTipoEfecto` smallint(6) NOT NULL DEFAULT 0, + `Email1` varchar(250) COLLATE utf8mb3_unicode_ci NOT NULL, + `Email2` varchar(250) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoCategoriaCliente_` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'CLI', + `IdDelegacion` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoMotivoBajaClienteLc` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoDepartamento` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoCanal` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoBanco` varchar(6) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoAgencia` varchar(6) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `DC` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CCC` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `IBAN` varchar(34) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoCondiciones` smallint(6) NOT NULL DEFAULT 0, + `StatusTraspasadoIME` tinyint(4) NOT NULL DEFAULT 0, + `TipoImportacionIME` tinyint(4) NOT NULL DEFAULT 2, + `TipoPlanCuentaIME` smallint(6) NOT NULL DEFAULT 2, + `Contrapartida` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoCuentaImpagado` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoCuentaEfecto` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `Comentarios` text COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoTerritorio` smallint(6) NOT NULL DEFAULT 0, + `CodigoIdioma_` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `TarifaPrecio` smallint(6) NOT NULL DEFAULT 0, + `%Descuento` decimal(28,10) NOT NULL DEFAULT 0.0000000000, + `%Rappel` decimal(28,10) NOT NULL DEFAULT 0.0000000000, + `%ProntoPago` decimal(28,10) NOT NULL DEFAULT 0.0000000000, + `%Financiacion` decimal(28,10) NOT NULL DEFAULT 0.0000000000, + `CodigoComisionista` int(11) NOT NULL DEFAULT 0, + `TarifaDescuento` smallint(6) NOT NULL DEFAULT 0, + `SiglaNacion` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `MarcaMenorSinNif` smallint(6) NOT NULL DEFAULT 0, + `PersonaFisicaJuridica` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL, + `SiglaNacionRepresentante` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CifDniRepresentante` varchar(13) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `NombreRepresentante` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', `TipoDocumentoPersona` smallint(6) NOT NULL, - `TipoCif` varchar(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `MotivoBajaClienteLc` varchar(30) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `PuntosSR` decimal(28,10) NOT NULL DEFAULT '0.0000000000', - `TarjetaSR` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', + `TipoCif` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `MotivoBajaClienteLc` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `PuntosSR` decimal(28,10) NOT NULL DEFAULT 0.0000000000, + `TarjetaSR` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', `FechaNacimiento` datetime DEFAULT NULL, - `Domicilio2` varchar(40) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CuentaProvision` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoTransportista` int(11) NOT NULL DEFAULT '0', - `FormadePago` varchar(35) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `ObservacionesCliente` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoTipoClienteLc` varchar(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `TipoCliente` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoActividadLc` varchar(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `Actividad` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `IndicadorIva` varchar(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoRuta_` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `NombreEmpleado` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `PrimerApellidoEmpleado` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `SegundoApellidoEmpleado` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `sysTick` int(11) NOT NULL DEFAULT '0', - `RiesgoMaximo` decimal(28,10) NOT NULL DEFAULT '0.0000000000', - `PlazoMedioPCMA` smallint(6) NOT NULL DEFAULT '0', - `CriterioIvaIME` smallint(6) NOT NULL DEFAULT '0', - `ReferenciaMandato` varchar(35) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `%Comision` decimal(28,10) NOT NULL DEFAULT '0.0000000000', - `CodigoZona` int(11) NOT NULL DEFAULT '0', - `BloqueoAlbaran` smallint(6) NOT NULL DEFAULT '0', - `CodigoSeccion` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoSector_` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CodigoProyecto` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', + `Domicilio2` varchar(40) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CuentaProvision` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoTransportista` int(11) NOT NULL DEFAULT 0, + `FormadePago` varchar(35) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `ObservacionesCliente` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoTipoClienteLc` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `TipoCliente` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoActividadLc` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `Actividad` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `IndicadorIva` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoRuta_` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `NombreEmpleado` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `PrimerApellidoEmpleado` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `SegundoApellidoEmpleado` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `sysTick` int(11) NOT NULL DEFAULT 0, + `RiesgoMaximo` decimal(28,10) NOT NULL DEFAULT 0.0000000000, + `PlazoMedioPCMA` smallint(6) NOT NULL DEFAULT 0, + `CriterioIvaIME` smallint(6) NOT NULL DEFAULT 0, + `ReferenciaMandato` varchar(35) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `%Comision` decimal(28,10) NOT NULL DEFAULT 0.0000000000, + `CodigoZona` int(11) NOT NULL DEFAULT 0, + `BloqueoAlbaran` smallint(6) NOT NULL DEFAULT 0, + `CodigoSeccion` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoSector_` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CodigoProyecto` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', PRIMARY KEY (`CodigoEmpresa`,`ClienteOProveedor`,`CodigoClienteProveedor`), KEY `CodigoCuenta` (`CodigoCuenta`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17543,7 +17353,7 @@ CREATE TABLE `invoiceType` ( PRIMARY KEY (`code`), UNIQUE KEY `code_UNIQUE` (`code`), UNIQUE KEY `codeSage_UNIQUE` (`codeSage`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17555,14 +17365,14 @@ DROP TABLE IF EXISTS `movContaIVA`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `movContaIVA` ( `id` int(11) NOT NULL, - `CodigoDivisa` varchar(3) COLLATE utf8_unicode_ci NOT NULL, + `CodigoDivisa` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, `BaseIva1` double DEFAULT NULL, `PorBaseCorrectora1` double DEFAULT NULL, `PorIva1` double DEFAULT NULL, `CuotaIva1` double DEFAULT NULL, `PorRecargoEquivalencia1` double DEFAULT NULL, `RecargoEquivalencia1` double DEFAULT NULL, - `CodigoTransaccion1` double NOT NULL DEFAULT '0', + `CodigoTransaccion1` double NOT NULL DEFAULT 0, `CodigoIva1` smallint(6) NOT NULL, `BaseIva2` double DEFAULT NULL, `PorBaseCorrectora2` double DEFAULT NULL, @@ -17570,7 +17380,7 @@ CREATE TABLE `movContaIVA` ( `CuotaIva2` double DEFAULT NULL, `PorRecargoEquivalencia2` double DEFAULT NULL, `RecargoEquivalencia2` double DEFAULT NULL, - `CodigoTransaccion2` double NOT NULL DEFAULT '0', + `CodigoTransaccion2` double NOT NULL DEFAULT 0, `CodigoIva2` smallint(6) NOT NULL, `BaseIva3` double DEFAULT NULL, `PorBaseCorrectora3` double DEFAULT NULL, @@ -17578,7 +17388,7 @@ CREATE TABLE `movContaIVA` ( `CuotaIva3` double DEFAULT NULL, `PorRecargoEquivalencia3` double DEFAULT NULL, `RecargoEquivalencia3` double DEFAULT NULL, - `CodigoTransaccion3` double NOT NULL DEFAULT '0', + `CodigoTransaccion3` double NOT NULL DEFAULT 0, `CodigoIva3` smallint(6) NOT NULL, `BaseIva4` double DEFAULT NULL, `PorBaseCorrectora4` double DEFAULT NULL, @@ -17586,46 +17396,46 @@ CREATE TABLE `movContaIVA` ( `CuotaIva4` double DEFAULT NULL, `PorRecargoEquivalencia4` double DEFAULT NULL, `RecargoEquivalencia4` double DEFAULT NULL, - `CodigoTransaccion4` double NOT NULL DEFAULT '0', + `CodigoTransaccion4` double NOT NULL DEFAULT 0, `CodigoIva4` smallint(6) NOT NULL, `Año` int(11) DEFAULT NULL, - `Serie` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `Serie` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `Factura` int(11) DEFAULT NULL, - `SuFacturaNo` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, + `SuFacturaNo` varchar(40) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `FechaFactura` date DEFAULT NULL, `ImporteFactura` double DEFAULT NULL, - `TipoFactura` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `CodigoCuentaFactura` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `CifDni` varchar(13) COLLATE utf8_unicode_ci DEFAULT NULL, - `Nombre` varchar(35) COLLATE utf8_unicode_ci DEFAULT NULL, + `TipoFactura` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `CodigoCuentaFactura` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `CifDni` varchar(13) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `Nombre` varchar(35) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `CodigoRetencion` int(2) DEFAULT NULL, `BaseRetencion` double DEFAULT NULL, `PorRetencion` double DEFAULT NULL, `ImporteRetencion` double DEFAULT NULL, - `SiglaNacion` varchar(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'ES', + `SiglaNacion` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'ES', `EjercicioFactura` int(2) DEFAULT NULL, `FechaOperacion` date DEFAULT NULL, `Exclusion347` int(2) DEFAULT NULL, - `MantenerAsiento` int(2) DEFAULT '-1', + `MantenerAsiento` int(2) DEFAULT -1, `Metalico347` int(2) DEFAULT NULL, - `ClaveOperacionFactura` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `ClaveOperacionFactura` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `TipoRectificativa` int(2) DEFAULT NULL, `FechaFacturaOriginal` date DEFAULT NULL, `CuotaIvaOriginal` double DEFAULT NULL, `BaseImponibleOriginal` double DEFAULT NULL, `ClaseAbonoRectificativas` int(2) DEFAULT NULL, `RecargoEquivalenciaOriginal` double DEFAULT NULL, - `LibreA1` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `IvaDeducible1` int(2) NOT NULL DEFAULT '-1', - `IvaDeducible2` int(2) NOT NULL DEFAULT '-1', - `IvaDeducible3` int(2) NOT NULL DEFAULT '-1', - `IvaDeducible4` int(2) NOT NULL DEFAULT '-1', + `LibreA1` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `IvaDeducible1` int(2) NOT NULL DEFAULT -1, + `IvaDeducible2` int(2) NOT NULL DEFAULT -1, + `IvaDeducible3` int(2) NOT NULL DEFAULT -1, + `IvaDeducible4` int(2) NOT NULL DEFAULT -1, `FechaGrabacion` date DEFAULT NULL, - `Intracomunitaria` tinyint(1) DEFAULT '0', - `moveData` tinyint(1) DEFAULT '1', + `Intracomunitaria` tinyint(1) DEFAULT 0, + `moveData` tinyint(1) DEFAULT 1, PRIMARY KEY (`id`), CONSTRAINT `movContaIVA_fk1` FOREIGN KEY (`id`) REFERENCES `vn`.`XDiario` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Informa del valor de los campos de IVA para enlazar en la tabla vn.movConta'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Informa del valor de los campos de IVA para enlazar en la tabla vn.movConta'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17639,10 +17449,10 @@ CREATE TABLE `pgcToSage` ( `id` int(11) NOT NULL AUTO_INCREMENT, `taxCodeSage` int(11) NOT NULL, `transactionCode` int(11) NOT NULL, - `accountTaxInput` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `accountTaxOutput` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `accountTaxInput` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL, + `accountTaxOutput` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COMMENT='Tabla relaciona cuentas pgc con Código de IVA y Código de Transacción en Sage'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='Tabla relaciona cuentas pgc con Código de IVA y Código de Transacción en Sage'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17654,28 +17464,28 @@ DROP TABLE IF EXISTS `planCuentasPGC`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `planCuentasPGC` ( `CodigoEmpresa` smallint(6) NOT NULL, - `CodigoCuenta` varchar(15) CHARACTER SET utf8 NOT NULL, - `Cuenta` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `ClienteOProveedor` varchar(1) COLLATE utf8_unicode_ci NOT NULL, - `CodigoDivisa` varchar(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `IndicadorProrrata` smallint(6) NOT NULL DEFAULT '0', - `TipoPlanCuentaIME` smallint(6) NOT NULL DEFAULT '2', - `StatusAnalitica` smallint(6) NOT NULL DEFAULT '0', - `AnaCodigoCuenta` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `StatusTraspasadoIME` tinyint(4) NOT NULL DEFAULT '0', - `TipoImportacionIME` tinyint(4) NOT NULL DEFAULT '0', - `CierrePatrimonio_` smallint(6) NOT NULL DEFAULT '0', - `CuentaPatrimonio_` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `CuentaVarios` smallint(6) NOT NULL DEFAULT '0', - `TodasLasActividades` smallint(6) NOT NULL DEFAULT '0', - `ValorDelegacion` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `ValorDepartamento` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `ValorProyecto` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `ValorCanal` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `ValorSeccion` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', + `CodigoCuenta` varchar(15) CHARACTER SET utf8mb3 NOT NULL, + `Cuenta` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `ClienteOProveedor` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL, + `CodigoDivisa` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `IndicadorProrrata` smallint(6) NOT NULL DEFAULT 0, + `TipoPlanCuentaIME` smallint(6) NOT NULL DEFAULT 2, + `StatusAnalitica` smallint(6) NOT NULL DEFAULT 0, + `AnaCodigoCuenta` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `StatusTraspasadoIME` tinyint(4) NOT NULL DEFAULT 0, + `TipoImportacionIME` tinyint(4) NOT NULL DEFAULT 0, + `CierrePatrimonio_` smallint(6) NOT NULL DEFAULT 0, + `CuentaPatrimonio_` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `CuentaVarios` smallint(6) NOT NULL DEFAULT 0, + `TodasLasActividades` smallint(6) NOT NULL DEFAULT 0, + `ValorDelegacion` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `ValorDepartamento` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `ValorProyecto` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `ValorCanal` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `ValorSeccion` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', PRIMARY KEY (`CodigoEmpresa`,`CodigoCuenta`), KEY `CodigoCuenta` (`CodigoCuenta`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17699,8 +17509,43 @@ SET character_set_client = @saved_cs_client; -- -- Dumping routines for database 'sage' -- +/*!50003 DROP FUNCTION IF EXISTS `company_getCode` */; +/*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `company_getCode`(vCompanyFk INT) RETURNS int(2) + READS SQL DATA +BEGIN +/** + * Devuelve la correspondencía del código de empresa de sage. + * Tiene en cuenta el entorno + * + * @param vSelf Id de empresa de verdnatura + * @return Código de empresa sage + */ + DECLARE vCompanySageFk INT(2); + + SELECT IF(c.environment = 'production', + co.companyCode, + co.companyCodeTest + ) INTO vCompanySageFk + FROM util.config c + JOIN vn.company co + WHERE co.id = vCompanyFk; + + RETURN vCompanySageFk; +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 `accountingMovements_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -17708,6 +17553,8 @@ SET character_set_client = @saved_cs_client; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `accountingMovements_add`(vYear INT, vCompanyFk INT) BEGIN @@ -17731,29 +17578,29 @@ BEGIN DECLARE vBookEntries TEXT; SELECT SiglaNacion INTO vCountryCanariasCode - FROM Naciones + FROM Naciones WHERE Nacion ='ISLAS CANARIAS'; SELECT SiglaNacion INTO vCountryCeutaMelillaCode - FROM Naciones + FROM Naciones WHERE Nacion ='CEUTA Y MELILLA'; SELECT CodigoTransaccion INTO vDuaTransactionFk FROM TiposTransacciones WHERE Transaccion = 'Import. bienes y serv. corrientes pdte. liquidar'; - - SELECT CodigoIva INTO vTaxImportFk + + SELECT CodigoIva INTO vTaxImportFk FROM TiposIva - WHERE Iva = 'IVA 21% importaciones'; - - SELECT CodigoIva INTO vTaxImportReducedFk + WHERE Iva = 'IVA 21% importaciones'; + + SELECT CodigoIva INTO vTaxImportReducedFk FROM TiposIva WHERE Iva = 'IVA 10% importaciones'; - SELECT CodigoIva INTO vTaxImportSuperReducedFk + SELECT CodigoIva INTO vTaxImportSuperReducedFk FROM TiposIva WHERE Iva = 'H.P. IVA Soportado Impor 4%'; - + SELECT CodigoTransaccion INTO vTransactionExportFk FROM TiposTransacciones WHERE Transaccion = 'Exportaciones definitivas'; @@ -17763,22 +17610,22 @@ BEGIN WHERE Transaccion = 'Envíos definitivos a Canarias, Ceuta y Melilla'; SELECT codeSage INTO vInvoiceTypeInformativeCode - FROM invoiceType WHERE code ='informative'; + FROM invoiceType WHERE code ='informative'; SELECT CAST(CONCAT(vYear, '-01-01') AS DATETIME), util.dayEnd(CAST(CONCAT(vYear, '-12-31') AS DATE)) INTO vDatedFrom, vDatedTo; - + TRUNCATE movContaIVA; - - DELETE FROM movConta - WHERE enlazadoSage = FALSE + + DELETE FROM movConta + WHERE enlazadoSage = FALSE AND Asiento <> 1 ; - + CALL clientSupplier_add(vCompanyFk); CALL pgc_add(vCompanyFk); CALL invoiceOut_manager(vYear, vCompanyFk); CALL invoiceIn_manager(vYear, vCompanyFk); - + INSERT INTO movConta(TipoEntrada, Ejercicio, CodigoEmpresa, @@ -17854,7 +17701,7 @@ BEGIN BaseImponibleOriginal, CuotaIvaOriginal, ClaseAbonoRectificativas, - RecargoEquivalenciaOriginal, + RecargoEquivalenciaOriginal, LibreA1, CodigoIva1, CodigoIva2, @@ -17867,8 +17714,8 @@ BEGIN Intracomunitaria ) SELECT 'EN' TipoEntrada, - YEAR(x.FECHA) Ejercicio, - IF (@@hostname = 'db', c.companyCode, companyCodeTest) AS CodigoEmpresa, + YEAR(x.FECHA) Ejercicio, + company_getCode(vCompanyFk) AS CodigoEmpresa, x.ASIEN Asiento, IF(EURODEBE <> 0 OR (EURODEBE = 0 AND EUROHABER IS NULL), 'D', 'H') CargoAbono, x.SUBCTA CodigoCuenta, @@ -17953,64 +17800,63 @@ BEGIN mci.IvaDeducible4, mci.Intracomunitaria FROM vn.XDiario x - JOIN vn.company c ON c.id = x.empresa_id - LEFT JOIN movContaIVA mci ON mci.id = x.id - LEFT JOIN (SELECT * + LEFT JOIN movContaIVA mci ON mci.id = x.id + LEFT JOIN (SELECT * FROM (SELECT DISTINCT ASIEN, FECREGCON, FECHA_EX FROM vn.XDiario - WHERE enlazadoSage = FALSE + WHERE enlazadoSage = FALSE ORDER BY ASIEN, FECREGCON DESC, FECHA_EX DESC LIMIT 10000000000000000000 ) sub GROUP BY ASIEN - )sub2 ON sub2.ASIEN = x.ASIEN - LEFT JOIN ( SELECT DISTINCT(account),cu.code + )sub2 ON sub2.ASIEN = x.ASIEN + LEFT JOIN ( SELECT DISTINCT(account),cu.code FROM vn.bank b JOIN vn.currency cu ON cu.id = b.currencyFk WHERE cu.code <> 'EUR' -- no se informa cuando la divisa en EUR - )sub3 ON sub3.account = x.SUBCTA - WHERE x.enlazadoSage = FALSE + )sub3 ON sub3.account = x.SUBCTA + WHERE x.enlazadoSage = FALSE AND x.empresa_id = vCompanyFk AND x.FECHA BETWEEN vDatedFrom AND vDatedTo; -- Metálicos UPDATE movConta m - JOIN (SELECT Asiento, - c.socialName name, - c.fi, - n.SiglaNacion, - m.CodigoCuenta, + JOIN (SELECT Asiento, + c.socialName name, + c.fi, + n.SiglaNacion, + m.CodigoCuenta, m.Contrapartida - FROM movConta m + FROM movConta m LEFT JOIN vn.client c ON c.id = IF(m.CargoAbono = 'H', CAST(SUBSTRING(m.CodigoCuenta, 3, LENGTH(m.CodigoCuenta)) AS UNSIGNED), CAST(SUBSTRING(m.Contrapartida, 3, LENGTH(m.Contrapartida)) AS UNSIGNED)) - LEFT JOIN Naciones n ON n.countryFk = c.countryFk - WHERE m.Metalico347 = TRUE - AND m.enlazadoSage = FALSE - )sub ON m.Asiento = sub.Asiento + LEFT JOIN Naciones n ON n.countryFk = c.countryFk + WHERE m.Metalico347 = TRUE + AND m.enlazadoSage = FALSE + )sub ON m.Asiento = sub.Asiento SET m.Metalico347 = TRUE, m.TipoFactura = vInvoiceTypeInformativeCode, m.CifDni = sub.fi, m.Nombre = sub.name, - m.SiglaNacion = sub.SiglaNacion + m.SiglaNacion = sub.SiglaNacion WHERE m.enlazadoSage = FALSE; UPDATE movConta m SET m.Metalico347 = FALSE, m.TipoFactura = '' - WHERE m.CargoAbono = 'D' - AND m.enlazadoSage = FALSE; + WHERE m.CargoAbono = 'D' + AND m.enlazadoSage = FALSE; -- Elimina cuentas de cliente/proveedor que no se utilizarán en la importación - DELETE cp + DELETE cp FROM clientesProveedores cp - LEFT JOIN movConta mc ON mc.codigoCuenta = cp.codigoCuenta + LEFT JOIN movConta mc ON mc.codigoCuenta = cp.codigoCuenta AND mc.enlazadoSage = FALSE WHERE mc.codigoCuenta IS NULL; -- Elimina cuentas contables que no se utilizarán en la importación - DELETE pc - FROM planCuentasPGC pc + DELETE pc + FROM planCuentasPGC pc LEFT JOIN movConta mc ON mc.codigoCuenta = pc.codigoCuenta AND mc.enlazadoSage = FALSE WHERE mc.codigoCuenta IS NULL; @@ -18019,7 +17865,7 @@ BEGIN UPDATE movConta mci JOIN vn.XDiario x ON x.ASIEN = mci.Asiento JOIN TiposIva ti ON ti.CodigoIva = x.IVA - JOIN vn.pgcMaster pm ON pm.code = mci.CodigoCuenta COLLATE utf8_general_ci + JOIN vn.pgcMaster pm ON pm.code = mci.CodigoCuenta COLLATE utf8mb3_unicode_ci SET mci.BaseIva1 = x.BASEEURO, mci.PorIva1 = x.IVA, mci.CuotaIva1 = CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10, 2)), @@ -18032,13 +17878,13 @@ BEGIN mci.ImporteFactura = mci.ImporteFactura + x.BASEEURO + CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10, 2)) WHERE pm.description = 'HP Iva pendiente' AND mci.enlazadoSage = FALSE - AND x.SERIE = vSerialDua COLLATE utf8_general_ci + AND x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci AND ti.Iva = 'I.V.A. 10% Nacional'; UPDATE movConta mci JOIN vn.XDiario x ON x.ASIEN = mci.Asiento JOIN TiposIva ti ON ti.CodigoIva = x.IVA - JOIN vn.pgcMaster pm ON pm.code = mci.CodigoCuenta COLLATE utf8_general_ci + JOIN vn.pgcMaster pm ON pm.code = mci.CodigoCuenta COLLATE utf8mb3_unicode_ci SET mci.BaseIva2 = x.BASEEURO , mci.PorIva2 = x.IVA, mci.CuotaIva2 = CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10,2)), @@ -18048,13 +17894,13 @@ BEGIN mci.ImporteFactura = mci.ImporteFactura + x.BASEEURO + CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10, 2)) WHERE pm.description = 'HP Iva pendiente' AND mci.enlazadoSage = FALSE - AND x.SERIE = vSerialDua COLLATE utf8_general_ci + AND x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci AND ti.Iva = 'I.V.A. 21%'; - + UPDATE movConta mci JOIN vn.XDiario x ON x.ASIEN = mci.Asiento JOIN TiposIva ti ON ti.CodigoIva = x.IVA - JOIN vn.pgcMaster pm ON pm.code = mci.CodigoCuenta COLLATE utf8_general_ci + JOIN vn.pgcMaster pm ON pm.code = mci.CodigoCuenta COLLATE utf8mb3_unicode_ci SET mci.BaseIva3 = x.BASEEURO , mci.PorIva3 = x.IVA, mci.CuotaIva3 = CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10,2)), @@ -18064,23 +17910,23 @@ BEGIN mci.ImporteFactura = mci.ImporteFactura + x.BASEEURO + CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10, 2)) WHERE pm.description = 'HP Iva pendiente' AND mci.enlazadoSage = FALSE - AND x.SERIE = vSerialDua COLLATE utf8_general_ci + AND x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci AND ti.Iva = 'I.V.A. 4%'; -- Rectificativas - UPDATE movConta mci - JOIN (SELECT x.ASIEN, x.FECHA_RT, x.SERIE_RT, x.FACTU_RT - FROM movConta mci + UPDATE movConta mci + JOIN (SELECT x.ASIEN, x.FECHA_RT, x.SERIE_RT, x.FACTU_RT + FROM movConta mci JOIN vn.XDiario x ON x.ASIEN = mci.Asiento - WHERE mci.TipoRectificativa > 0 - AND mci.enlazadoSage = FALSE + WHERE mci.TipoRectificativa > 0 + AND mci.enlazadoSage = FALSE AND x.FACTU_RT IS NOT NULL GROUP BY x.ASIEN ) sub ON sub.ASIEN = mci.Asiento - SET mci.EjercicioFacturaOriginal = YEAR(sub.FECHA_RT), - mci.SerieFacturaOriginal = sub.SERIE_RT, - mci.NumeroFacturaOriginal = sub.FACTU_RT - WHERE mci.TipoRectificativa > 0 AND + SET mci.EjercicioFacturaOriginal = YEAR(sub.FECHA_RT), + mci.SerieFacturaOriginal = sub.SERIE_RT, + mci.NumeroFacturaOriginal = sub.FACTU_RT + WHERE mci.TipoRectificativa > 0 AND mci.enlazadoSage = FALSE ; -- Exportaciones Andorras y Canarias cambia TT (la cuenta es compartida) @@ -18089,24 +17935,24 @@ BEGIN CodigoTransaccion2 = IF(CodigoTransaccion2 = 0, 0, vTransactionExportTaxFreeFk), CodigoTransaccion3 = IF(CodigoTransaccion3 = 0, 0, vTransactionExportTaxFreeFk), CodigoTransaccion4 = IF(CodigoTransaccion4 = 0, 0, vTransactionExportTaxFreeFk) - WHERE enlazadoSage = FALSE - AND (CodigoTransaccion1 = vTransactionExportFk - OR CodigoTransaccion2 = vTransactionExportFk - OR CodigoTransaccion3 = vTransactionExportFk - OR CodigoTransaccion4 = vTransactionExportFk) - AND SiglaNacion IN (vCountryCanariasCode COLLATE utf8_general_ci, vCountryCeutaMelillaCode COLLATE utf8_general_ci); + WHERE enlazadoSage = FALSE + AND (CodigoTransaccion1 = vTransactionExportFk + OR CodigoTransaccion2 = vTransactionExportFk + OR CodigoTransaccion3 = vTransactionExportFk + OR CodigoTransaccion4 = vTransactionExportFk) + AND SiglaNacion IN (vCountryCanariasCode COLLATE utf8mb3_unicode_ci, vCountryCeutaMelillaCode COLLATE utf8mb3_unicode_ci); UPDATE movConta mc SET CodigoDivisa = 'USD', FactorCambio = TRUE, ImporteCambio = ABS( CAST( IF( ImporteDivisa <> 0 AND ImporteCambio = 0, ImporteAsiento / ImporteDivisa, ImporteCambio) AS DECIMAL( 10, 2))) - WHERE enlazadoSage = FALSE + WHERE enlazadoSage = FALSE AND (ImporteCambio <> 0 OR ImporteDivisa <> 0 OR FactorCambio); UPDATE movConta mc SET importeDivisa= -importeDivisa - WHERE enlazadoSage = FALSE - AND importeDivisa > 0 + WHERE enlazadoSage = FALSE + AND importeDivisa > 0 AND ImporteAsiento < 0; -- Comprobación que los importes e ivas sean correctos, avisa vía CAU @@ -18117,11 +17963,11 @@ BEGIN WHERE mc.enlazadoSage = FALSE GROUP BY mc.Asiento)sub JOIN (SELECT x.ASIEN, SUM(IFNULL(x.EURODEBE,0) + IFNULL(x.EUROHABER,0)) amount - FROM vn.XDiario x + FROM vn.XDiario x WHERE x.enlazadoSage = FALSE GROUP BY ASIEN)sub2 ON sub2.ASIEN = sub.Asiento WHERE sub.amount <> sub2.amount - UNION ALL + UNION ALL SELECT sub.Asiento FROM (SELECT Asiento, SUM(BaseIva1 + BaseIva2 + BaseIva3 + BaseIva4) amountTaxableBase FROM movConta @@ -18130,13 +17976,13 @@ BEGIN GROUP BY Asiento) sub JOIN (SELECT ASIEN, SUM(BASEEURO) amountTaxableBase FROM (SELECT ASIEN, SUM(BASEEURO) BASEEURO - FROM vn.XDiario - WHERE FACTURA + FROM vn.XDiario + WHERE FACTURA AND auxiliar <> '*' AND enlazadoSage = FALSE GROUP BY FACTURA, ASIEN)sub3 GROUP BY ASIEN) sub2 ON sub2.ASIEN = sub.Asiento - WHERE sub.amountTaxableBase<>sub2.amountTaxableBase + WHERE sub.amountTaxableBase<>sub2.amountTaxableBase AND sub.amountTaxableBase/2 <> sub2.amountTaxableBase) sub; IF vBookEntries IS NOT NULL THEN @@ -18152,8 +17998,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientSupplier_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -18161,22 +18005,24 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clientSupplier_add`(vCompanyFk INT) BEGIN /** - * Prepara los datos de clientes y proveedores para exportarlos a Sage + * Prepara los datos de clientes y proveedores para exportarlos a Sage * @vCompanyFk Empresa dela que se quiere trasladar datos */ DECLARE vCountryCeutaMelillaFk INT; DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2); SELECT SiglaNacion INTO vCountryCanariasCode - FROM Naciones + FROM Naciones WHERE Nacion ='ISLAS CANARIAS'; SELECT CodigoNacion, SiglaNacion INTO vCountryCeutaMelillaFk, vCountryCeutaMelillaCode - FROM Naciones + FROM Naciones WHERE Nacion ='CEUTA Y MELILLA'; TRUNCATE TABLE clientesProveedores; @@ -18207,8 +18053,8 @@ BEGIN CodigoRetencion, Email1, iban) - SELECT - IF (@@hostname = 'db', co.companyCode, co.companyCodeTest), + SELECT + company_getCode(vCompanyFk), 'C', c.id, c.socialName, @@ -18221,15 +18067,15 @@ BEGIN IFNULL(c.city, ''), IFNULL(pr.CodigoProvincia, ''), IFNULL(p.name, ''), - IF(n.SiglaNacion = vCountryCanariasCode COLLATE utf8_general_ci, IF(@isCeutaMelilla := IF(pr.Provincia IN ('CEUTA', 'MELILLA'), TRUE, FALSE), vCountryCeutaMelillaFk, IF (@isCanarias, vCountryCanariasCode, n.CodigoNacion)), n.CodigoNacion), - IF(n.SiglaNacion = vCountryCanariasCode COLLATE utf8_general_ci, IF(@isCeutaMelilla, vCountryCeutaMelillaCode, IF (@isCanarias, vCountryCanariasCode, n.SiglaNacion)), n.SiglaNacion), + IF(n.SiglaNacion = vCountryCanariasCode COLLATE utf8mb3_unicode_ci, IF(@isCeutaMelilla := IF(pr.Provincia IN ('CEUTA', 'MELILLA'), TRUE, FALSE), vCountryCeutaMelillaFk, IF (@isCanarias, vCountryCanariasCode, n.CodigoNacion)), n.CodigoNacion), + IF(n.SiglaNacion = vCountryCanariasCode COLLATE utf8mb3_unicode_ci, IF(@isCeutaMelilla, vCountryCeutaMelillaCode, IF (@isCanarias, vCountryCanariasCode, n.SiglaNacion)), n.SiglaNacion), IF((c.fi REGEXP '^([[:blank:]]|[[:digit:]])'), 'J','F'), - IF(cu.code IN('ES','EX'), - 1, + IF(cu.code IN('ES','EX'), + 1, IF((cu.isUeeMember AND c.isVies), 2, 4)), IFNULL(c.taxTypeSageFk,0), - IF(n.SiglaNacion = vCountryCanariasCode COLLATE utf8_general_ci, - IF(@isCeutaMelilla, 'CEUTA Y MELILLA', IF (@isCanarias, 'ISLAS CANARIAS', n.Nacion)), + IF(n.SiglaNacion = vCountryCanariasCode COLLATE utf8mb3_unicode_ci, + IF(@isCeutaMelilla, 'CEUTA Y MELILLA', IF (@isCanarias, 'ISLAS CANARIAS', n.Nacion)), n.Nacion), IFNULL(c.phone, ''), IFNULL(c.mobile, ''), @@ -18239,15 +18085,14 @@ BEGIN IFNULL(c.iban, '') FROM vn.`client` c JOIN clientLastTwoMonths clm ON clm.clientFk = c.id - JOIN vn.company co ON co.id = clm.companyFk LEFT JOIN vn.country cu ON cu.id = c.countryFk LEFT JOIN Naciones n ON n.countryFk = cu.id LEFT JOIN vn.province p ON p.id = c.provinceFk LEFT JOIN Provincias pr ON pr.provinceFk = p.id - WHERE c.isRelevant - AND co.id = vCompanyFk + WHERE c.isRelevant + AND clm.companyFk = vCompanyFk UNION ALL - SELECT IF (@@hostname = 'db', c.companyCode, companyCodeTest), + SELECT company_getCode(vCompanyFk), 'P', s.id, s.name, @@ -18261,7 +18106,7 @@ BEGIN IFNULL(pr.CodigoProvincia, ''), IFNULL(p.name, ''), n.CodigoNacion, - n.SiglaNacion COLLATE utf8_general_ci, + n.SiglaNacion COLLATE utf8mb3_unicode_ci, IF((s.nif REGEXP '^([[:blank:]]|[[:digit:]])'),'J','F'), IF(co.country IN ('España', 'España exento'), 1,IF(co.isUeeMember = 1, 2, 4)), IFNULL(s.taxTypeSageFk, 0), @@ -18273,16 +18118,15 @@ BEGIN IFNULL(SUBSTR(sc.email, 1, (COALESCE(NULLIF(LOCATE(',', sc.email), 0), 99) - 1)), ''), IFNULL(iban, '') FROM vn.supplier s - JOIN supplierLastThreeMonths pl ON pl.supplierFk = s.id + JOIN supplierLastThreeMonths pl ON pl.supplierFk = s.id LEFT JOIN vn.country co ON co.id = s.countryFk LEFT JOIN Naciones n ON n.countryFk = co.id LEFT JOIN vn.province p ON p.id = s.provinceFk LEFT JOIN Provincias pr ON pr.provinceFk = p.id LEFT JOIN vn.supplierContact sc ON sc.supplierFk = s.id LEFT JOIN vn.supplierAccount sa ON sa.supplierFk = s.id - JOIN vn.company c ON c.id = pl.companyFk - WHERE c.id = vCompanyFk AND - s.isActive AND + WHERE pl.companyFk = vCompanyFk AND + s.isActive AND s.nif <> '' GROUP BY pl.supplierFk, pl.companyFk; END ;; @@ -18291,8 +18135,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceIn_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -18300,15 +18142,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceIn_add`(vInvoiceInFk INT, vXDiarioFk INT) BEGIN /** * Traslada la info de contabilidad relacionada con las facturas recibidas - * + * * @vInvoiceInFk Factura recibida * @vXDiarioFk Id tabla XDiario - */ + */ DECLARE vDone BOOL DEFAULT FALSE; DECLARE vBase DOUBLE; DECLARE vVat DOUBLE; @@ -18324,24 +18168,24 @@ BEGIN DECLARE vInvoiceTypeReceived VARCHAR(1); DECLARE vInvoiceTypeInformative VARCHAR(1); - DECLARE vCursor CURSOR FOR + DECLARE vCursor CURSOR FOR SELECT it.taxableBase, CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)), t.PorcentajeIva, it.transactionTypeSageFk, it.taxTypeSageFk, t.isIntracommunity, - tt.ClaveOperacionDefecto + tt.ClaveOperacionDefecto FROM vn.invoiceIn i - JOIN vn.invoiceInTax it ON it.InvoiceInFk = i.id + JOIN vn.invoiceInTax it ON it.InvoiceInFk = i.id JOIN TiposIva t ON t.CodigoIva = it.taxTypeSageFk JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk LEFT JOIN vn.dua d ON d.id = vInvoiceInFk - WHERE i.id = vInvoiceInFk + WHERE i.id = vInvoiceInFk AND d.id IS NULL; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + DELETE FROM movContaIVA WHERE id = vXDiarioFk; @@ -18364,22 +18208,22 @@ BEGIN vTaxCode, vIsIntracommunity, vOperationCode; - - IF vDone THEN + + IF vDone THEN LEAVE l; END IF; - SET vTransactionCodeOld = vTransactionCode; - SET vTaxCodeOld = vTaxCode; + SET vTransactionCodeOld = vTransactionCode; + SET vTaxCodeOld = vTaxCode; - IF vOperationCode IS NOT NULL THEN + IF vOperationCode IS NOT NULL THEN UPDATE movContaIVA SET ClaveOperacionFactura = vOperationCode WHERE id = vXDiarioFk; END IF; - + SET vCounter = vCounter + 1; - CASE vCounter + CASE vCounter WHEN 1 THEN UPDATE movContaIVA SET BaseIva1 = vBase, @@ -18415,21 +18259,21 @@ BEGIN WHERE id = vXDiarioFk; ELSE SELECT vXDiarioFk INTO vXDiarioFk; - END CASE; + END CASE; IF vIsIntracommunity THEN UPDATE movContaIVA SET Intracomunitaria = TRUE WHERE id = vXDiarioFk; END IF; - - SET vTransactionCodeOld = vTransactionCode; - SET vTaxCodeOld = vTaxCode; - + + SET vTransactionCodeOld = vTransactionCode; + SET vTaxCodeOld = vTaxCode; + END LOOP; CLOSE vCursor; - + UPDATE movContaIVA mci JOIN tmp.invoiceIn ii ON ii.id = vInvoiceInFk JOIN vn.XDiario x ON x.id = mci.id @@ -18441,11 +18285,11 @@ BEGIN mci.Serie = ii.serial, mci.Factura = ii.serialNumber, mci.FechaFactura = ii.issued, - mci.ImporteFactura = IFNULL(mci.BaseIva1, 0) + IFNULL(mci.CuotaIva1, 0) + - IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) + - IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) + + mci.ImporteFactura = IFNULL(mci.BaseIva1, 0) + IFNULL(mci.CuotaIva1, 0) + + IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) + + IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) + IFNULL(mci.BaseIva4, 0) + IFNULL(mci.CuotaIva4, 0), - mci.TipoFactura = IF(id.id, IF( ii.serial = vSerialDua, vInvoiceTypeReceived, vInvoiceTypeInformative), vInvoiceTypeReceived), + mci.TipoFactura = IF(id.id, IF( ii.serial = vSerialDua COLLATE utf8mb3_unicode_ci, vInvoiceTypeReceived, vInvoiceTypeInformative), vInvoiceTypeReceived), mci.CodigoCuentaFactura = x.SUBCTA, mci.CifDni = IF(LEFT(TRIM(s.nif), 2) = n.SiglaNacion, SUBSTRING(TRIM(s.nif), 3), s.nif), mci.Nombre = s.name, @@ -18473,7 +18317,7 @@ BEGIN JOIN (SELECT SUM(x2.BASEEURO) taxableBase, SUM(x2.EURODEBE) taxBase FROM vn.XDiario x1 JOIN vn.XDiario x2 ON x1.ASIEN = x2.ASIEN - WHERE x2.BASEEURO <> 0 + WHERE x2.BASEEURO <> 0 AND x1.id = vXDiarioFk )sub JOIN ClavesOperacion co ON co.Descripcion = 'Arrendamiento de locales de negocio' @@ -18481,8 +18325,8 @@ BEGIN mci.ClaveOperacionFactura = IF( t.Retencion = 'ARRENDAMIENTO Y SUBARRENDAMIENTO', co.ClaveOperacionFactura_, mci.ClaveOperacionFactura), mci.BaseRetencion = IF (t.Retencion = 'ACTIVIDADES AGRICOLAS O GANADERAS', sub.taxableBase + sub.taxBase, sub.taxableBase), mci.PorRetencion = t.PorcentajeRetencion, - mci.ImporteRetencion = iit.taxableBase * - 1 - WHERE mci.id = vXDiarioFk + mci.ImporteRetencion = iit.taxableBase * - 1 + WHERE mci.id = vXDiarioFk AND e.name = 'Retenciones' AND id.id IS NULL; @@ -18492,8 +18336,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceIn_manager` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -18501,14 +18343,16 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceIn_manager`(vYear INT, vCompanyFk INT) BEGIN /** - * Traslada la info de contabilidad relacionada con las facturas recibidas - * + * Traslada la info de contabilidad relacionada con las facturas recibidas + * * @vYear Año contable del que se quiere trasladar la información - * @vCompany Empresa de la que se quiere trasladar datos + * @vCompany Empresa de la que se quiere trasladar datos */ DECLARE vDone BOOL DEFAULT FALSE; DECLARE vInvoiceFk INT; @@ -18520,22 +18364,22 @@ BEGIN DECLARE vAccountTaxOutstanding VARCHAR(10); DECLARE vInvoiceTypeSended VARCHAR(1); DECLARE vCursor CURSOR FOR - SELECT IFNULL(x.CLAVE, x.FACTURA) invoiceInFk, + SELECT IFNULL(x.CLAVE, x.FACTURA) invoiceInFk, x.id XDiarioFk - FROM vn.XDiario x + FROM vn.XDiario x JOIN(SELECT DISTINCT(x.ASIEN) FROM vn.XDiario x LEFT JOIN vn.invoiceIn ii ON x.CLAVE = ii.id LEFT JOIN vn.invoiceInTax it ON it.invoiceInFk = ii.id - WHERE(it.taxTypeSageFk IS NOT NULL OR x.SERIE = vSerialDua COLLATE utf8_general_ci) - AND x.enlazadoSage = FALSE + WHERE(it.taxTypeSageFk IS NOT NULL OR x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci) + AND x.enlazadoSage = FALSE AND x.FECHA BETWEEN vDatedFrom AND vDatedTo - AND x.empresa_id = vCompanyFk + AND x.empresa_id = vCompanyFk ) sub ON sub.ASIEN = x.ASIEN WHERE x.CLAVE IS NOT NULL; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + SELECT CAST(CONCAT(vYear, '-01-01') AS DATETIME), util.dayEnd(CAST(CONCAT(vYear, '-12-31') AS DATE)) INTO vDatedFrom, vDatedTo; @@ -18549,16 +18393,16 @@ BEGIN SELECT codeSage INTO vInvoiceTypeSended FROM invoiceType WHERE `code` ='sended'; - + DROP TEMPORARY TABLE IF EXISTS tmp.invoiceDua; CREATE TEMPORARY TABLE tmp.invoiceDua - SELECT x.id + SELECT x.id FROM vn.XDiario x JOIN vn.company c ON c.id = x.empresa_id JOIN (SELECT ASIEN - FROM vn.XDiario x - WHERE x.enlazadoSage = FALSE - AND x.SUBCTA = vAccountTaxOutstanding COLLATE utf8_general_ci + FROM vn.XDiario x + WHERE x.enlazadoSage = FALSE + AND x.SUBCTA = vAccountTaxOutstanding COLLATE utf8mb3_unicode_ci AND x.FECHA BETWEEN vDatedFrom AND vDatedTo )sub ON sub.ASIEN = x.ASIEN WHERE NOT x.CONTRA <=> vAccountVNL; @@ -18567,7 +18411,7 @@ BEGIN CREATE TEMPORARY TABLE tmp.invoiceIn SELECT i.id, i.supplierRef, - i.serial COLLATE utf8_general_ci serial, + i.serial COLLATE utf8mb3_unicode_ci serial, i.supplierFk, i.issued, IF(expenceFkDeductible, FALSE, i.isVatDeductible) isVatDeductible, @@ -18576,7 +18420,7 @@ BEGIN FROM vn.invoiceIn i JOIN vn.currency c ON c.id = i.currencyFk WHERE i.bookEntried BETWEEN vDatedFrom AND vDatedTo - UNION ALL + UNION ALL SELECT d.id, d.code, vSerialDua, @@ -18585,8 +18429,8 @@ BEGIN FALSE, d.id, '' -- EUROS - FROM vn.dua d - WHERE d.issued IS NOT NULL + FROM vn.dua d + WHERE d.issued IS NOT NULL AND code IS NOT NULL; OPEN vCursor; @@ -18594,7 +18438,7 @@ BEGIN l: LOOP FETCH vCursor INTO vInvoiceFk, vXDiarioFk; - IF vDone THEN + IF vDone THEN LEAVE l; END IF; CALL invoiceIn_add(vInvoiceFk, vXDiarioFk); @@ -18682,21 +18526,21 @@ BEGIN JOIN (SELECT x.ASIEN, x.id FROM vn.XDiario x JOIN(SELECT DISTINCT(x.ASIEN) ASIEN - FROM vn.XDiario x + FROM vn.XDiario x JOIN (SELECT DISTINCT(ASIEN) FROM vn.XDiario x - WHERE SUBCTA LIKE '472%' + WHERE SUBCTA LIKE '472%' AND x.enlazadoSage = FALSE AND x.empresa_id = vCompanyFk AND x.FECHA BETWEEN vDatedFrom AND vDatedTo ) sub ON sub.ASIEN = x.ASIEN WHERE x.SUBCTA LIKE '477%' )sub2 ON sub2.ASIEN = x.ASIEN - WHERE x.CONTRA IS NOT NULL + WHERE x.CONTRA IS NOT NULL AND x.SUBCTA LIKE '477%' GROUP BY x.ASIEN )sub3 ON sub3.ASIEN = x.ASIEN; - + INSERT INTO movContaIVA (`id`, `CodigoDivisa`, @@ -18767,9 +18611,9 @@ BEGIN `FechaGrabacion`, `Intracomunitaria`, `moveData`) - SELECT * + SELECT * FROM tmp.movContaIVA; - + DROP TEMPORARY TABLE tmp.movContaIVA; END ;; @@ -18778,8 +18622,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceOut_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -18787,14 +18629,16 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_add`(IN vInvoiceOutFk INT, IN vXDiarioFk INT) BEGIN /** - * Traslada la info de contabilidad relacionada con las facturas emitidas - * + * Traslada la info de contabilidad relacionada con las facturas emitidas + * * @vYear Año contable del que se quiere trasladar la información - * @vCompany Empresa de la que se quiere trasladar datos + * @vCompany Empresa de la que se quiere trasladar datos */ DECLARE vDone BOOL DEFAULT FALSE; DECLARE vMaxLengthName INT DEFAULT 35; @@ -18811,14 +18655,14 @@ BEGIN DECLARE vIsIntracommunity BOOL DEFAULT FALSE; DECLARE vInvoiceTypeSended VARCHAR(1); DECLARE vOperationCode VARCHAR(1); - + DECLARE vCursor CURSOR FOR - SELECT oit.taxableBase, - oit.vat, - pgc.rate, - pgc.mod347, - pgcRE.rate, - oitRE.vat, + SELECT oit.taxableBase, + oit.vat, + pgc.rate, + pgc.mod347, + pgcRE.rate, + oitRE.vat, tc.transactionCode, tc.taxCode, tc.isIntracommunity, @@ -18827,22 +18671,22 @@ BEGIN JOIN vn.pgc ON pgc.code = oit.pgcFk LEFT JOIN vn.pgcEqu e ON e.vatFk = oit.pgcFk LEFT JOIN vn.pgcEqu eRE ON eRE.equFk = oit.pgcFk - LEFT JOIN vn.invoiceOutTax oitRE ON oitRE.invoiceOutFk = oit.invoiceOutFk + LEFT JOIN vn.invoiceOutTax oitRE ON oitRE.invoiceOutFk = oit.invoiceOutFk AND oitRE.pgcFk = e.equFk LEFT JOIN vn.pgc pgcRE ON pgcRE.code = oitRE.pgcFk - LEFT JOIN vn.taxCode tc ON tc.code = pgc.code COLLATE 'utf8_general_ci' + LEFT JOIN vn.taxCode tc ON tc.code = pgc.code COLLATE 'utf8mb3_unicode_ci' WHERE eRE.equFk IS NULL AND oit.invoiceOutFk = vInvoiceOutFk GROUP BY pgc.code; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + SELECT codeSage INTO vInvoiceTypeSended FROM invoiceType WHERE code ='sended'; - + DELETE FROM movContaIVA WHERE id = vXDiarioFk; - + INSERT INTO movContaIVA(id) VALUES (vXDiarioFk); OPEN vCursor; @@ -18859,13 +18703,13 @@ BEGIN vIsIntracommunity, vOperationCode; - IF vDone THEN + IF vDone THEN LEAVE l; END IF; SET vCounter = vCounter + 1; - - CASE vCounter + + CASE vCounter WHEN 1 THEN UPDATE movContaIVA SET BaseIva1 = vBase, @@ -18906,7 +18750,7 @@ BEGIN CodigoTransaccion4 = vTransactionCode, CodigoIva4 = vTaxCode WHERE id = vXDiarioFk; - END CASE; + END CASE; UPDATE movContaIVA SET Exclusion347 = NOT vMod347, @@ -18917,7 +18761,7 @@ BEGIN END LOOP; CLOSE vCursor; - + UPDATE movContaIVA mci JOIN vn.invoiceOut i ON i.id = vInvoiceOutFk LEFT JOIN vn.invoiceCorrection ic ON ic.correctedFk = vInvoiceOutFk @@ -18942,25 +18786,25 @@ BEGIN mci.MantenerAsiento = TRUE, mci.FechaFacturaOriginal = x.FECHA_EX WHERE mci.id = vXDiarioFk; - + SELECT correctedFk INTO vInvoiceOutCorrectedFk FROM vn.invoiceCorrection WHERE correctingFk = vInvoiceOutFk; - - IF vInvoiceOutCorrectedFk THEN + + IF vInvoiceOutCorrectedFk THEN UPDATE movContaIVA mci JOIN vn.invoiceOut i ON i.id = vInvoiceOutCorrectedFk JOIN vn.invoiceCorrection ic ON ic.correctedFk = vInvoiceOutCorrectedFk - JOIN (SELECT SUM(IF(IFNULL(e.vatFk, TRUE), iot.taxableBase, 0)) taxableBase, + JOIN (SELECT SUM(IF(IFNULL(e.vatFk, TRUE), iot.taxableBase, 0)) taxableBase, SUM(IF(IFNULL(e.vatFk, TRUE), iot.vat, 0)) vat, SUM(IF(IFNULL(e.vatFk, TRUE), 0, iot.vat)) equ FROM vn.invoiceOutTax iot - LEFT JOIN vn.pgcEqu e ON e.vatFk = iot.pgcFk + LEFT JOIN vn.pgcEqu e ON e.vatFk = iot.pgcFk WHERE iot.invoiceOutFk = vInvoiceOutCorrectedFk ) tax JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa' SET mci.TipoRectificativa = 2, - mci.ClaseAbonoRectificativas = 1, + mci.ClaseAbonoRectificativas = 1, mci.FechaFacturaOriginal = i.issued, mci.FechaOperacion = i.issued, mci.BaseImponibleOriginal = tax.taxableBase, @@ -18978,8 +18822,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceOut_manager` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -18987,14 +18829,16 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_manager`(vYear INT, vCompanyFk INT) BEGIN /** - * Traslada la info de contabilidad relacionada con las facturas emitidas - * + * Traslada la info de contabilidad relacionada con las facturas emitidas + * * @vYear Año contable del que se quiere trasladar la información - * @vCompany Empresa de la que se quiere trasladar datos + * @vCompany Empresa de la que se quiere trasladar datos */ DECLARE vDone BOOL DEFAULT FALSE; DECLARE vInvoiceFk INT; @@ -19011,7 +18855,7 @@ BEGIN JOIN (SELECT x.ASIEN, CONCAT(x.SERIE, x.FACTURA) refFk FROM vn.XDiario x WHERE x.enlazadoSage = FALSE - AND x.FACTURA + AND x.FACTURA AND x.empresa_id = vCompanyFk AND x.FECHA BETWEEN vDatedFrom AND vDatedTo GROUP BY refFk @@ -19020,19 +18864,19 @@ BEGIN )sub2 ON sub2.refFk = i.ref; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + SELECT CAST(CONCAT(vYear, '-01-01') AS DATETIME), util.dayEnd(CAST(CONCAT(vYear, '-12-31') AS DATE)) INTO vDatedFrom, vDatedTo; - + OPEN vCursor; l: LOOP FETCH vCursor INTO vInvoiceFk, vXDiarioFk; - IF vDone THEN + IF vDone THEN LEAVE l; END IF; - + CALL invoiceOut_add(vInvoiceFk, vXDiarioFk); END LOOP; @@ -19045,8 +18889,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `pgc_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -19054,11 +18896,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `pgc_add`(vCompanyFk INT) BEGIN /** - * Añade cuentas del plan general contable para exportarlos a Sage + * Añade cuentas del plan general contable para exportarlos a Sage * @vCompanyFk Empresa de la que se quiere trasladar datos */ TRUNCATE TABLE planCuentasPGC; @@ -19068,29 +18912,25 @@ BEGIN CodigoCuenta, Cuenta, ClienteOProveedor) - SELECT * - FROM (SELECT IF(@@hostname = 'db', c.companyCode, companyCodeTest) companyFk, + SELECT * + FROM (SELECT company_getCode(vCompanyFk) companyFk, e.id accountFk, UCASE(e.name), '' FROM vn.expence e - JOIN vn.company c - WHERE c.id = vCompanyFk - UNION - SELECT IF(@@hostname = 'db', c.companyCode, companyCodeTest), - b.account, + UNION + SELECT company_getCode(vCompanyFk), + b.account, UCASE(b.bank), - '' + '' FROM vn.bank b - JOIN vn.company c - WHERE c.id = vCompanyFk - AND b.isActive + WHERE b.isActive AND b.`account` - UNION + UNION SELECT CodigoEmpresa, CodigoCuenta, Nombre, - ClienteOProveedor + ClienteOProveedor FROM clientesProveedores)sub GROUP BY companyFk, accountFk; END ;; @@ -19104,7 +18944,7 @@ DELIMITER ; -- Current Database: `salix` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `salix` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `salix` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `salix`; @@ -19117,17 +18957,17 @@ DROP TABLE IF EXISTS `ACL`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ACL` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `model` varchar(512) CHARACTER SET utf8 DEFAULT NULL, - `property` varchar(512) CHARACTER SET utf8 DEFAULT NULL, - `accessType` set('READ','WRITE','*') COLLATE utf8_unicode_ci DEFAULT 'READ', - `permission` set('DENY','ALLOW') COLLATE utf8_unicode_ci DEFAULT 'ALLOW', - `principalType` set('ROLE','USER') COLLATE utf8_unicode_ci DEFAULT 'ROLE', - `principalId` varchar(512) CHARACTER SET utf8 DEFAULT NULL, + `model` varchar(512) CHARACTER SET utf8mb3 DEFAULT NULL, + `property` varchar(512) CHARACTER SET utf8mb3 DEFAULT NULL, + `accessType` set('READ','WRITE','*') COLLATE utf8mb3_unicode_ci DEFAULT 'READ', + `permission` set('DENY','ALLOW') COLLATE utf8mb3_unicode_ci DEFAULT 'ALLOW', + `principalType` set('ROLE','USER') COLLATE utf8mb3_unicode_ci DEFAULT 'ROLE', + `principalId` varchar(512) CHARACTER SET utf8mb3 DEFAULT NULL, PRIMARY KEY (`id`), KEY `model_ix` (`model`(255)) COMMENT 'ernesto 3.8.2020. Mysql pide indices', KEY `property_ix` (`property`(255)), KEY `accessType_ix` (`accessType`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19138,13 +18978,13 @@ DROP TABLE IF EXISTS `AccessToken`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `AccessToken` ( - `id` varchar(255) CHARACTER SET utf8 NOT NULL, + `id` varchar(255) CHARACTER SET utf8mb3 NOT NULL, `ttl` int(11) DEFAULT NULL, - `scopes` varchar(255) CHARACTER SET utf8 DEFAULT NULL, + `scopes` varchar(255) CHARACTER SET utf8mb3 DEFAULT NULL, `created` datetime DEFAULT NULL, `userId` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19227,9 +19067,9 @@ DROP TABLE IF EXISTS `defaultViewConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `defaultViewConfig` ( - `tableCode` varchar(25) COLLATE utf8_unicode_ci NOT NULL, - `columns` text COLLATE utf8_unicode_ci NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='The default configuration of columns for views'; + `tableCode` varchar(25) COLLATE utf8mb3_unicode_ci NOT NULL, + `columns` text COLLATE utf8mb3_unicode_ci NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='The default configuration of columns for views'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19241,12 +19081,12 @@ DROP TABLE IF EXISTS `fieldAcl`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `fieldAcl` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `model` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `property` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `actionType` set('insert','update','*') COLLATE utf8_unicode_ci DEFAULT '*', - `role` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `model` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `property` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `actionType` set('insert','update','*') COLLATE utf8mb3_unicode_ci DEFAULT '*', + `role` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19257,9 +19097,9 @@ DROP TABLE IF EXISTS `module`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `module` ( - `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19272,11 +19112,11 @@ DROP TABLE IF EXISTS `userConfigView`; CREATE TABLE `userConfigView` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userFk` int(10) unsigned NOT NULL, - `tableCode` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `configuration` text COLLATE utf8_unicode_ci, + `tableCode` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `configuration` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `uniqueUser_TableCode` (`userFk`,`tableCode`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19291,7 +19131,7 @@ CREATE TABLE `userConfigView` ( -- Current Database: `stock` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `stock` /*!40100 DEFAULT CHARACTER SET utf8 */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `stock` /*!40100 DEFAULT CHARACTER SET utf8mb3 */; USE `stock`; @@ -19307,7 +19147,7 @@ CREATE TABLE `inbound` ( `tableName` set('buy','sale') NOT NULL, `tableId` int(10) unsigned NOT NULL, `isSync` tinyint(4) NOT NULL, - `isPicked` tinyint(4) NOT NULL DEFAULT '0', + `isPicked` tinyint(4) NOT NULL DEFAULT 0, `warehouseFk` int(10) unsigned NOT NULL, `itemFk` int(10) unsigned NOT NULL, `dated` datetime NOT NULL, @@ -19318,7 +19158,7 @@ CREATE TABLE `inbound` ( UNIQUE KEY `source` (`tableName`,`tableId`), KEY `warehouseFk` (`warehouseFk`,`itemFk`,`dated`,`expired`,`available`), KEY `isSync` (`isSync`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -19333,8 +19173,8 @@ DELIMITER ;; BEFORE INSERT ON `inbound` FOR EACH ROW BEGIN - SET NEW.isPicked = NEW.isPicked OR NEW.dated < CURDATE(); - + SET NEW.isPicked = NEW.isPicked OR NEW.dated < util.VN_CURDATE(); + CALL visible_log( NEW.isPicked, NEW.warehouseFk, @@ -19396,7 +19236,7 @@ CREATE TABLE `inboundPick` ( PRIMARY KEY (`inboundFk`,`outboundFk`,`quantity`), UNIQUE KEY `buyFk` (`inboundFk`,`outboundFk`), KEY `saleFk` (`outboundFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19413,7 +19253,7 @@ CREATE TABLE `log` ( `tableId` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `tableName` (`tableName`,`tableId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19428,7 +19268,7 @@ CREATE TABLE `outbound` ( `tableName` set('sale','buy','orderRow') NOT NULL, `tableId` int(10) unsigned NOT NULL, `isSync` tinyint(3) unsigned NOT NULL, - `isPicked` tinyint(4) NOT NULL DEFAULT '0', + `isPicked` tinyint(4) NOT NULL DEFAULT 0, `warehouseFk` int(10) unsigned NOT NULL, `itemFk` int(10) unsigned NOT NULL, `dated` datetime NOT NULL, @@ -19441,7 +19281,7 @@ CREATE TABLE `outbound` ( KEY `warehouseFk` (`warehouseFk`,`itemFk`,`dated`), KEY `expired` (`expired`), KEY `isSync` (`isSync`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -19457,8 +19297,8 @@ DELIMITER ;; FOR EACH ROW BEGIN SET NEW.lack = NEW.quantity; - SET NEW.isPicked = NEW.isPicked OR NEW.dated < CURDATE(); - + SET NEW.isPicked = NEW.isPicked OR NEW.dated < util.VN_CURDATE(); + CALL visible_log( NEW.isPicked, NEW.warehouseFk, @@ -19518,7 +19358,7 @@ CREATE TABLE `visible` ( `warehouseFk` int(10) unsigned NOT NULL, `quantity` int(11) NOT NULL, PRIMARY KEY (`itemFk`,`warehouseFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19567,8 +19407,6 @@ DELIMITER ; -- -- Dumping routines for database 'stock' -- -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `inbound_addPick` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -19576,6 +19414,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `inbound_addPick`( vSelf INT, @@ -19596,8 +19436,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `inbound_removePick` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -19605,6 +19443,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `inbound_removePick`( vSelf INT, @@ -19629,8 +19469,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `inbound_requestQuantity` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -19638,6 +19476,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `inbound_requestQuantity`( vSelf INT, @@ -19669,7 +19509,7 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + SET vSupplied = 0; OPEN vPicks; @@ -19685,7 +19525,7 @@ BEGIN SET vPickGranted = LEAST(vRequested - vSupplied, vPickQuantity); SET vSupplied = vSupplied + vPickGranted; CALL inbound_removePick(vSelf, vOutboundFk, vPickGranted, vPickQuantity); - + UPDATE outbound SET isSync = FALSE, lack = lack + vPickGranted @@ -19703,8 +19543,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `inbound_sync` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -19712,6 +19550,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `inbound_sync`(vSelf INT) BEGIN @@ -19765,7 +19605,7 @@ BEGIN END IF; SET vSupplied = LEAST(vAvailable, vLack); - + IF vSupplied > 0 THEN SET vAvailable = vAvailable - vSupplied; UPDATE outbound @@ -19778,7 +19618,7 @@ BEGIN SET vSupplied = vSupplied + vSuppliedFromRequest; SET vAvailable = vAvailable - vSuppliedFromRequest; END IF; - + IF vSupplied > 0 THEN CALL inbound_addPick(vSelf, vOutboundFk, vSupplied); END IF; @@ -19800,8 +19640,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `log_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -19809,6 +19647,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `log_add`(IN `vTableName` VARCHAR(255), IN `vNewId` VARCHAR(255), IN `vOldId` VARCHAR(255)) proc: BEGIN @@ -19834,8 +19674,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `log_clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -19843,6 +19681,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `log_clean`() BEGIN @@ -19854,8 +19694,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `log_delete` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -19863,6 +19701,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `log_delete`(vTableName VARCHAR(255), vTableId INT) proc: BEGIN @@ -19886,8 +19726,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `log_refreshAll` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -19895,6 +19733,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `log_refreshAll`() BEGIN @@ -19907,7 +19747,7 @@ BEGIN DO RELEASE_LOCK('stock.log_sync'); RESIGNAL; END; - + IF !GET_LOCK('stock.log_sync', 30) THEN CALL util.throw('Lock timeout exceeded'); END IF; @@ -19932,8 +19772,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `log_refreshBuy` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -19941,6 +19779,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `log_refreshBuy`( `vTableName` VARCHAR(255), @@ -20019,8 +19859,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `log_refreshOrder` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20028,13 +19866,15 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `log_refreshOrder`( `vTableName` VARCHAR(255), `vTableId` INT) BEGIN DECLARE vExpireTime INT DEFAULT 20; - DECLARE vExpired DATETIME DEFAULT TIMESTAMPADD(MINUTE, -vExpireTime, NOW()); + DECLARE vExpired DATETIME DEFAULT TIMESTAMPADD(MINUTE, -vExpireTime, util.VN_NOW()); DROP TEMPORARY TABLE IF EXISTS tValues; CREATE TEMPORARY TABLE tValues @@ -20079,8 +19919,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `log_refreshSale` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20088,6 +19926,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `log_refreshSale`( `vTableName` VARCHAR(255), @@ -20157,8 +19997,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `log_sync` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20166,6 +20004,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `log_sync`(vSync BOOL) proc: BEGIN @@ -20238,7 +20078,7 @@ proc: BEGIN -- Deletes expired outbounds - DELETE FROM outbound WHERE expired <= NOW(); + DELETE FROM outbound WHERE expired <= util.VN_NOW(); -- Attaches desync inbounds @@ -20293,8 +20133,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `log_syncNoWait` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20302,6 +20140,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `log_syncNoWait`() BEGIN @@ -20322,8 +20162,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `outbound_requestQuantity` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20331,6 +20169,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `outbound_requestQuantity`( vSelf INT, @@ -20378,7 +20218,7 @@ BEGIN SET vPickGranted = LEAST(vRequested - vSupplied, vPickQuantity); SET vSupplied = vSupplied + vPickGranted; CALL inbound_removePick(vInboundFk, vSelf, vPickGranted, vPickQuantity); - + UPDATE inbound SET isSync = FALSE, available = available + vPickGranted @@ -20396,8 +20236,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `outbound_sync` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20405,6 +20243,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `outbound_sync`(vSelf INT) BEGIN @@ -20487,8 +20327,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `visible_log` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20496,6 +20334,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `visible_log`( vIsPicked BOOL, @@ -20525,10 +20365,25 @@ DELIMITER ; -- Current Database: `util` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `util` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `util` /*!40100 DEFAULT CHARACTER SET utf8mb4 */; USE `util`; +-- +-- Table structure for table `binlogQueue` +-- + +DROP TABLE IF EXISTS `binlogQueue`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `binlogQueue` ( + `code` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `logName` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `position` bigint(20) unsigned NOT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Binary log position of asynchronous queues'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `config` -- @@ -20538,12 +20393,12 @@ DROP TABLE IF EXISTS `config`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `config` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `dbVersion` char(11) CHARACTER SET utf8 DEFAULT NULL COMMENT 'The current database version', - `hasTriggersDisabled` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Defines if triggers are disabled', - `environment` varchar(45) CHARACTER SET utf8 DEFAULT NULL COMMENT 'The current Database environment', + `dbVersion` char(11) CHARACTER SET utf8mb3 DEFAULT NULL COMMENT 'The current database version', + `hasTriggersDisabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Defines if triggers are disabled', + `environment` varchar(45) CHARACTER SET utf8mb3 DEFAULT NULL COMMENT 'The current Database environment', `lastDump` datetime DEFAULT NULL COMMENT 'Timestamp of the last data dump', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global configuration table'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Global configuration table'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20555,17 +20410,50 @@ DROP TABLE IF EXISTS `debug`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `debug` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `connectionId` int(10) unsigned DEFAULT NULL, - `user` varchar(255) CHARACTER SET utf8 DEFAULT NULL, - `host` varchar(255) CHARACTER SET utf8 DEFAULT NULL, - `variable` varchar(255) CHARACTER SET utf8 DEFAULT NULL, - `value` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `user` varchar(255) CHARACTER SET utf8mb3 DEFAULT NULL, + `host` varchar(255) CHARACTER SET utf8mb3 DEFAULT NULL, + `variable` varchar(255) CHARACTER SET utf8mb3 DEFAULT NULL, + `value` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `created` (`created`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Log de depuración'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Log de depuración'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `eventLog` +-- + +DROP TABLE IF EXISTS `eventLog`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `eventLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `date` datetime NOT NULL, + `event` varchar(512) COLLATE utf8mb3_unicode_ci NOT NULL, + `error` varchar(1024) COLLATE utf8mb3_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + KEY `date` (`date`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Event scheduler error log'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `eventLogGrouped` +-- + +DROP TABLE IF EXISTS `eventLogGrouped`; +/*!50001 DROP VIEW IF EXISTS `eventLogGrouped`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `eventLogGrouped` ( + `lastHappened` tinyint NOT NULL, + `nErrors` tinyint NOT NULL, + `event` tinyint NOT NULL, + `error` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `version` -- @@ -20574,13 +20462,13 @@ DROP TABLE IF EXISTS `version`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `version` ( - `code` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `number` char(11) COLLATE utf8_unicode_ci DEFAULT NULL, - `gitCommit` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `number` char(11) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `gitCommit` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `updated` datetime DEFAULT NULL, - `lastNumber` char(11) COLLATE utf8_unicode_ci DEFAULT NULL, + `lastNumber` char(11) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20591,15 +20479,15 @@ DROP TABLE IF EXISTS `versionLog`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `versionLog` ( - `code` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `number` char(11) COLLATE utf8_unicode_ci NOT NULL, - `file` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `user` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `number` char(11) COLLATE utf8mb3_unicode_ci NOT NULL, + `file` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `user` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `updated` datetime NOT NULL, `errorNumber` int(10) unsigned DEFAULT NULL, - `errorMessage` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `errorMessage` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`code`,`number`,`file`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20630,8 +20518,6 @@ DELIMITER ; -- -- Dumping routines for database 'util' -- -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `accountShortToStandard` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20639,8 +20525,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `accountShortToStandard`(vAccount VARCHAR(10)) RETURNS varchar(10) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `accountShortToStandard`(vAccount VARCHAR(10)) RETURNS varchar(10) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN RETURN REPLACE(vAccount, '.', REPEAT('0', 11 - LENGTH(vAccount))); @@ -20650,8 +20538,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `capitalizeFirst` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20659,8 +20545,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `capitalizeFirst`(vString VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `capitalizeFirst`(vString VARCHAR(255)) RETURNS varchar(255) CHARSET utf8mb3 NO SQL DETERMINISTIC BEGIN @@ -20678,11 +20566,11 @@ BEGIN WHILE vI < vLen DO SET vSpaceIni = vI; - + WHILE MID(vString, vI, 1) REGEXP '[[:space:]]' DO SET vI = vI + 1; END WHILE; - + SET vWordIni = vI; SET vI = vWordIni + 1; @@ -20704,8 +20592,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `crypt` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20713,25 +20599,25 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `crypt`(vText VARCHAR(255), vKey VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `crypt`(vText VARCHAR(255), vKey VARCHAR(255)) RETURNS varchar(255) CHARSET utf8mb3 READS SQL DATA BEGIN DECLARE vResult VARCHAR(255); - + CALL vn.crypt(vText, vKey, vResult); RETURN vResult; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `cryptOff` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20739,25 +20625,25 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `cryptOff`(vText VARCHAR(255), vKey VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `cryptOff`(vText VARCHAR(255), vKey VARCHAR(255)) RETURNS varchar(255) CHARSET utf8mb3 READS SQL DATA BEGIN DECLARE vResult VARCHAR(255); - + CALL vn.cryptOff(vText, vKey, vResult); RETURN vResult; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `dayEnd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20765,8 +20651,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `dayend`(vDated DATE) RETURNS datetime +CREATE DEFINER=`root`@`localhost` FUNCTION `dayEnd`(vDated DATE) RETURNS datetime NO SQL DETERMINISTIC BEGIN @@ -20783,8 +20671,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `firstDayOfMonth` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20792,6 +20678,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `firstDayOfMonth`(vDate DATE) RETURNS date NO SQL @@ -20810,8 +20698,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `firstDayOfYear` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20819,6 +20705,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `firstDayOfYear`(vDate DATE) RETURNS date NO SQL @@ -20837,8 +20725,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `formatRow` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20846,8 +20732,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `formatRow`(vType CHAR(3), vValues VARCHAR(512)) RETURNS varchar(512) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `formatRow`(vType CHAR(3), vValues VARCHAR(512)) RETURNS varchar(512) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN DECLARE vRow VARCHAR(512); @@ -20870,8 +20758,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `formatTable` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20879,8 +20765,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `formatTable`(vFields VARCHAR(512), vOldValues VARCHAR(512), vNewValues VARCHAR(512)) RETURNS text CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `formatTable`(vFields VARCHAR(512), vOldValues VARCHAR(512), vNewValues VARCHAR(512)) RETURNS text CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN DECLARE vTable TEXT; @@ -20905,8 +20793,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `hasDateOverlapped` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20914,10 +20800,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `hasDateOverlapped`(vSarted1 DATE, vEnded1 DATE, vSarted2 DATE, vEnded2 DATE) RETURNS tinyint(1) DETERMINISTIC -BEGIN +BEGIN RETURN GREATEST(vSarted1, vSarted2) <= LEAST(vEnded1,vEnded2); @@ -20927,8 +20815,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `hmacSha2` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20936,8 +20822,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `hmacSha2`(`vAlg` SMALLINT, `vMsg` MEDIUMBLOB, `vKey` MEDIUMBLOB) RETURNS varchar(128) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `hmacSha2`(`vAlg` SMALLINT, `vMsg` MEDIUMBLOB, `vKey` MEDIUMBLOB) RETURNS varchar(128) CHARSET utf8mb3 NO SQL DETERMINISTIC BEGIN @@ -20946,7 +20834,7 @@ BEGIN */ DECLARE vHashlen INT UNSIGNED; DECLARE vOpad, vIpad TINYBLOB; - + CASE vAlg WHEN 224 THEN SET vHashlen = 64; WHEN 256 THEN SET vHashlen = 64; @@ -20954,16 +20842,16 @@ BEGIN WHEN 512 THEN SET vHashlen = 128; ELSE CALL throw ('WRONG_ALGORYTHM_IDENTIFICATOR_USED'); END CASE; - + IF LENGTH(vKey) > vHashlen THEN SET vKey = UNHEX(SHA2(vKey, vAlg)); END IF; - + SET vKey = RPAD(vKey, vHashlen, 0x00); - + SET vIpad = stringXor(vKey, 0x36); SET vOpad = stringXor(vKey, 0x5C); - + RETURN SHA2(CONCAT(vOpad, UNHEX(SHA2(CONCAT(vIpad, vMsg), vAlg))), vAlg); END ;; DELIMITER ; @@ -20971,8 +20859,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `isLeapYear` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -20980,21 +20866,21 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `lang` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21002,8 +20888,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `lang`() RETURNS char(2) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `lang`() RETURNS char(2) CHARSET utf8mb3 NO SQL DETERMINISTIC BEGIN @@ -21019,8 +20907,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `lastDayOfYear` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21028,6 +20914,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `lastDayOfYear`(vDate DATE) RETURNS date NO SQL @@ -21046,8 +20934,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `midnight` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21055,12 +20941,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `midnight`() RETURNS datetime READS SQL DATA BEGIN - - RETURN TIMESTAMP(CURDATE(), '23:59:59'); + + RETURN TIMESTAMP(util.VN_CURDATE(), '23:59:59'); END ;; DELIMITER ; @@ -21068,8 +20956,18 @@ 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 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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!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 `nextWeek` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21077,6 +20975,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `nextWeek`(vYearWeek INT) RETURNS int(11) DETERMINISTIC @@ -21087,7 +20987,7 @@ BEGIN * modo 3. */ DECLARE vYear INT DEFAULT FLOOR(vYearWeek / 100); - + IF vYearWeek < YEARWEEK(CONCAT(vYear, '-12-31'), 3) THEN RETURN vYearWeek + 1; ELSE @@ -21099,8 +20999,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `quarterFirstDay` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21108,6 +21006,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `quarterFirstDay`(vYear INT, vQuarter INT) RETURNS date DETERMINISTIC @@ -21119,8 +21019,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `stringXor` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21128,6 +21026,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `stringXor`(vString MEDIUMBLOB, vConst TINYINT UNSIGNED) RETURNS mediumblob NO SQL @@ -21138,16 +21038,16 @@ BEGIN */ DECLARE vLen, vPos INT UNSIGNED; DECLARE vResult MEDIUMBLOB; - + SET vLen = LENGTH(vString); SET vPos = 1; SET vResult = ''; - + WHILE vPos <= vLen DO SET vResult = CONCAT(vResult, LPAD(HEX( ORD(SUBSTR(vString, vPos, 1)) ^ vConst), 2, '0')); SET vPos = vPos + 1; END WHILE; - + RETURN UNHEX(vResult); END ;; DELIMITER ; @@ -21155,8 +21055,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `today` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21164,26 +21062,26 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `today`() RETURNS date DETERMINISTIC BEGIN /** * Devuelve la fecha actual. Usar en lugar de la función nativa - * CURDATE() en aquellos que se necesite rendimiento ya que la + * util.VN_CURDATE() en aquellos que se necesite rendimiento ya que la * la última no es determinista. * * @return La fecha actual */ - RETURN CURDATE(); + RETURN util.VN_CURDATE(); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `tomorrow` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21191,6 +21089,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `tomorrow`() RETURNS date DETERMINISTIC @@ -21200,15 +21100,13 @@ BEGIN * * @return La fecha de mañana */ - RETURN TIMESTAMPADD(DAY, 1, CURDATE()); + RETURN TIMESTAMPADD(DAY, 1, util.VN_CURDATE()); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `twoDaysAgo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21216,6 +21114,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `twoDaysAgo`() RETURNS date DETERMINISTIC @@ -21225,15 +21125,73 @@ BEGIN * * @return La fecha de antes de ayer */ - RETURN TIMESTAMPADD(DAY, -2, CURDATE()); + RETURN TIMESTAMPADD(DAY, -2, util.VN_CURDATE()); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `VN_CURDATE` */; +/*!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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `VN_CURDATE`() RETURNS date + DETERMINISTIC +BEGIN + RETURN DATE(mockedDate()); +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 `VN_CURTIME` */; +/*!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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `VN_CURTIME`() RETURNS time + DETERMINISTIC +BEGIN + RETURN TIME(mockedDate()); +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 `VN_NOW` */; +/*!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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `VN_NOW`() RETURNS datetime + DETERMINISTIC +BEGIN + RETURN mockedDate(); +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 `yearRelativePosition` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21241,8 +21199,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `yearRelativePosition`(vYear INT) RETURNS varchar(20) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `yearRelativePosition`(vYear INT) RETURNS varchar(20) CHARSET utf8mb3 DETERMINISTIC BEGIN /** @@ -21252,16 +21212,16 @@ BEGIN * @param vYear Año a evaluar * @return La posicion relativa del año */ - DECLARE vCurYear INT DEFAULT YEAR(CURDATE()); + DECLARE vCurYear INT DEFAULT YEAR(util.VN_CURDATE()); IF vYear = vCurYear THEN RETURN 'curYear'; END IF; - + IF vYear = vCurYear - 1 THEN RETURN 'lastYear'; END IF; - + IF vYear = vCurYear - 2 THEN RETURN 'twoYearsAgo'; END IF; @@ -21273,8 +21233,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `yesterday` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21282,6 +21240,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `yesterday`() RETURNS date DETERMINISTIC @@ -21291,15 +21251,13 @@ BEGIN * * @return La fecha de ayer */ - RETURN TIMESTAMPADD(DAY, -1, CURDATE()); + RETURN TIMESTAMPADD(DAY, -1, util.VN_CURDATE()); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `compareObjects` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21307,6 +21265,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `compareObjects`(vChain VARCHAR(45),vCompare VARCHAR(45)) READS SQL DATA @@ -21322,10 +21282,10 @@ BEGIN */ SET vChain = CONCAT('%', vChain, '%'); SET vCompare = CONCAT('%', vCompare, '%'); - SELECT * FROM + SELECT * FROM ( SELECT t1.* FROM - ( + ( SELECT `db`, `name`, @@ -21352,7 +21312,7 @@ BEGIN 'TRIGGER', `ACTION_STATEMENT`, NULL, - NULL + NULL FROM `information_schema`.`TRIGGERS` WHERE `ACTION_STATEMENT` LIKE vChain COLLATE utf8_general_ci UNION ALL @@ -21362,7 +21322,7 @@ BEGIN 'VIEW', `VIEW_DEFINITION`, NULL, - NULL + NULL FROM `information_schema`.`VIEWS` WHERE `VIEW_DEFINITION` LIKE vChain COLLATE utf8_general_ci ) t1 @@ -21393,7 +21353,7 @@ BEGIN 'TRIGGER', `ACTION_STATEMENT`, NULL, - NULL + NULL FROM `information_schema`.`TRIGGERS` WHERE `ACTION_STATEMENT` LIKE vCompare COLLATE utf8_general_ci UNION ALL @@ -21403,7 +21363,7 @@ BEGIN 'VIEW', `VIEW_DEFINITION`, NULL, - NULL + NULL FROM `information_schema`.`VIEWS` WHERE `VIEW_DEFINITION` LIKE vCompare COLLATE utf8_general_ci) t2 ON t2.name = t1.name ORDER BY t1.`db`, t1.`name` @@ -21414,8 +21374,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `debugAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21423,6 +21381,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `debugAdd`(vVariable VARCHAR(255), vValue VARCHAR(255)) MODIFIES SQL DATA @@ -21434,7 +21394,7 @@ BEGIN * @param vValue Valor de la variable */ DECLARE vIndex INT DEFAULT INSTR(USER(), '@'); - + INSERT INTO debug SET `connectionId` = CONNECTION_ID(), `user` = LEFT(USER(), vIndex - 1), @@ -21447,8 +21407,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `exec` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21456,6 +21414,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `exec`(vSqlQuery TEXT) BEGIN @@ -21477,8 +21437,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `findObject` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21486,6 +21444,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `findObject`(vChain VARCHAR(45)) READS SQL DATA @@ -21500,7 +21460,7 @@ BEGIN SET vChain = CONCAT('%', vChain, '%'); SELECT * FROM - ( + ( SELECT `routine_schema` `schema`, `routine_name` `name`, @@ -21527,7 +21487,7 @@ BEGIN 'TRIGGER', `ACTION_STATEMENT`, NULL, - NULL + NULL FROM `information_schema`.`TRIGGERS` WHERE `ACTION_STATEMENT` LIKE vChain COLLATE utf8_general_ci UNION ALL @@ -21537,7 +21497,7 @@ BEGIN 'VIEW', `VIEW_DEFINITION`, NULL, - NULL + NULL FROM `information_schema`.`VIEWS` WHERE `VIEW_DEFINITION` LIKE vChain COLLATE utf8_general_ci ) t @@ -21548,8 +21508,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `procNoOverlap` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21557,6 +21515,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `procNoOverlap`(procName VARCHAR(255)) SQL SECURITY INVOKER @@ -21585,8 +21545,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `proc_changedPrivs` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21594,6 +21552,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_changedPrivs`() BEGIN @@ -21613,8 +21573,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `proc_restorePrivs` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21622,6 +21580,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_restorePrivs`() BEGIN @@ -21641,8 +21601,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `proc_savePrivs` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21650,6 +21608,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_savePrivs`() BEGIN @@ -21669,15 +21629,15 @@ 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `slowLog_prune`() BEGIN @@ -21693,7 +21653,7 @@ BEGIN RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`; DELETE FROM `mysql`.`slow_log_temp` - WHERE start_time < TIMESTAMPADD(WEEK, -1, NOW()); + WHERE start_time < TIMESTAMPADD(WEEK, -1, util.VN_NOW()); RENAME TABLE `mysql`.`slow_log_temp` TO `mysql`.`slow_log`; @@ -21705,8 +21665,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `throw` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21714,6 +21672,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `throw`(vMessage CHAR(55)) BEGIN @@ -21730,8 +21690,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `time_createTable` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21739,6 +21697,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `time_createTable`(vStarted DATE, vEnded DATE) BEGIN @@ -21751,15 +21711,39 @@ BEGIN INSERT INTO tmp.time (dated) VALUES (vCurrentDate); SET vCurrentDate = DATE_ADD(vCurrentDate, INTERVAL 1 DAY); 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 `udf_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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`$itBoss`@`%` PROCEDURE `udf_test`(vLoops BIGINT) +BEGIN + DECLARE vI BIGINT DEFAULT 0; + DECLARE vRes VARCHAR(255); + WHILE vI < vLoops DO + SELECT minacum(2, -10, 1) INTO vRes; + SELECT multimax(10, 20) INTO vRes; + SELECT sql_printf('SELECT %v FROM %t', TRUE, 'myTable') INTO vRes; + SET vI = vI + 1; + 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 `warn` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21767,6 +21751,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `warn`(vCode CHAR(35)) BEGIN @@ -21783,7 +21769,7 @@ DELIMITER ; -- Current Database: `vn` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `vn` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `vn` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `vn`; @@ -21813,21 +21799,21 @@ CREATE TABLE `XDiario` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ASIEN` double DEFAULT NULL, `FECHA` datetime DEFAULT NULL, - `SUBCTA` varchar(12) CHARACTER SET utf8 DEFAULT NULL, - `CONTRA` varchar(12) CHARACTER SET utf8 DEFAULT NULL, - `CONCEPTO` varchar(50) CHARACTER SET utf8 DEFAULT NULL, + `SUBCTA` varchar(12) CHARACTER SET utf8mb3 DEFAULT NULL, + `CONTRA` varchar(12) CHARACTER SET utf8mb3 DEFAULT NULL, + `CONCEPTO` varchar(50) CHARACTER SET utf8mb3 DEFAULT NULL, `EURODEBE` decimal(10,2) DEFAULT NULL, `EUROHABER` decimal(10,2) DEFAULT NULL, `BASEEURO` decimal(10,2) DEFAULT NULL, - `SERIE` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `FACTURA` varchar(8) COLLATE utf8_unicode_ci DEFAULT '0', + `SERIE` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `FACTURA` varchar(8) COLLATE utf8mb3_unicode_ci DEFAULT '0', `BASEIMPO` decimal(10,2) DEFAULT NULL, `IVA` decimal(10,2) DEFAULT NULL, - `RECEQUIV` decimal(10,2) DEFAULT '0.00', - `DOCUMENTO` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `DEPARTA` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, + `RECEQUIV` decimal(10,2) DEFAULT 0.00, + `DOCUMENTO` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `DEPARTA` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `CLAVE` int(11) DEFAULT NULL, - `ESTADO` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `ESTADO` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `NCASADO` decimal(10,2) DEFAULT NULL, `TCASADO` decimal(10,2) DEFAULT NULL, `TRANS` decimal(10,2) DEFAULT NULL, @@ -21835,49 +21821,49 @@ CREATE TABLE `XDiario` ( `DEBEME` decimal(10,2) DEFAULT NULL, `HABERME` decimal(10,2) DEFAULT NULL, `PTAHABER` decimal(10,2) DEFAULT NULL, - `AUXILIAR` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `SUCURSAL` varchar(4) COLLATE utf8_unicode_ci DEFAULT NULL, + `AUXILIAR` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `SUCURSAL` varchar(4) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `PTADEBE` decimal(10,2) DEFAULT NULL, - `CODDIVISA` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, + `CODDIVISA` varchar(5) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `IMPAUXME` decimal(10,2) DEFAULT NULL, - `MONEDAUSO` varchar(1) COLLATE utf8_unicode_ci DEFAULT '2', - `NOCONV` tinyint(1) NOT NULL DEFAULT '0', - `NUMEROINV` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `TIPOOPE` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `NFACTICK` tinyint(1) NOT NULL DEFAULT '1', - `TERIDNIF` tinyint(1) NOT NULL DEFAULT '2', - `TERNIF` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'I.F.', - `TERNOM` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Nombre Importador', - `OPBIENES` tinyint(1) NOT NULL DEFAULT '1', - `TIPOFAC` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `TIPOIVA` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `L340` tinyint(2) NOT NULL DEFAULT '0', - `enlazado` tinyint(1) NOT NULL DEFAULT '0', + `MONEDAUSO` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT '2', + `NOCONV` tinyint(1) NOT NULL DEFAULT 0, + `NUMEROINV` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `TIPOOPE` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `NFACTICK` tinyint(1) NOT NULL DEFAULT 1, + `TERIDNIF` tinyint(1) NOT NULL DEFAULT 2, + `TERNIF` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'I.F.', + `TERNOM` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'Nombre Importador', + `OPBIENES` tinyint(1) NOT NULL DEFAULT 1, + `TIPOFAC` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `TIPOIVA` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `L340` tinyint(2) NOT NULL DEFAULT 0, + `enlazado` tinyint(1) NOT NULL DEFAULT 0, `FECHA_EX` date DEFAULT NULL COMMENT 'FEcha de expedicion de la factura', - `LRECT349` tinyint(1) NOT NULL DEFAULT '0', - `empresa_id` smallint(5) unsigned NOT NULL DEFAULT '442', - `LDIFADUAN` tinyint(4) NOT NULL DEFAULT '0', - `METAL` tinyint(1) NOT NULL DEFAULT '0', - `METALIMP` decimal(10,2) NOT NULL DEFAULT '0.00', - `CLIENTE` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, - `METALEJE` varchar(4) COLLATE utf8_unicode_ci DEFAULT NULL, + `LRECT349` tinyint(1) NOT NULL DEFAULT 0, + `empresa_id` smallint(5) unsigned NOT NULL DEFAULT 442, + `LDIFADUAN` tinyint(4) NOT NULL DEFAULT 0, + `METAL` tinyint(1) NOT NULL DEFAULT 0, + `METALIMP` decimal(10,2) NOT NULL DEFAULT 0.00, + `CLIENTE` varchar(12) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `METALEJE` varchar(4) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `FECHA_OP` date DEFAULT NULL COMMENT 'FEcha de operacion', - `FACTURAEX` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Numero de factura del proveedor', + `FACTURAEX` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'Numero de factura del proveedor', `TIPOCLAVE` int(3) DEFAULT NULL, `TIPOEXENCI` int(3) DEFAULT NULL, `TIPONOSUJE` int(3) DEFAULT NULL, `TIPOFACT` int(3) DEFAULT NULL, `TIPORECTIF` int(3) DEFAULT NULL, - `SERIE_RT` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, - `FACTU_RT` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `SERIE_RT` varchar(2) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `FACTU_RT` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `BASEIMP_RT` decimal(10,2) DEFAULT NULL, `BASEIMP_RF` decimal(10,2) DEFAULT NULL, - `RECTIFICA` int(1) NOT NULL DEFAULT '0', + `RECTIFICA` int(1) NOT NULL DEFAULT 0, `FECHA_RT` date DEFAULT NULL, - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `created` timestamp NULL DEFAULT current_timestamp(), + `updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `FECREGCON` date DEFAULT NULL, - `enlazadoSage` tinyint(1) NOT NULL DEFAULT '0', + `enlazadoSage` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `empresa_id` (`empresa_id`), KEY `ASIENidx` (`id`,`ASIEN`), @@ -21885,7 +21871,7 @@ CREATE TABLE `XDiario` ( KEY `XDiario` (`enlazado`), KEY `enlazadoSage` (`enlazadoSage`), CONSTRAINT `XDiario_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -21900,7 +21886,7 @@ DELIMITER ;; BEFORE INSERT ON `XDiario` FOR EACH ROW BEGIN - IF (NOT isDateRangeAccounting(NEW.FECHA) AND NEW.FECHA IS NOT NULL) OR + IF (NOT isDateRangeAccounting(NEW.FECHA) AND NEW.FECHA IS NOT NULL) OR (NOT isDateRangeAccounting(NEW.FECHA_EX) AND NEW.FECHA_EX IS NOT NULL) OR (NOT isDateRangeAccounting(NEW.FECHA_OP) AND NEW.FECHA_OP IS NOT NULL) OR (NOT isDateRangeAccounting(NEW.FECHA_RT) AND NEW.FECHA_RT IS NOT NULL) OR @@ -21926,10 +21912,10 @@ DELIMITER ;; BEFORE UPDATE ON `XDiario` FOR EACH ROW BEGIN - IF (!(NEW.FECHA <=> OLD.FECHA) AND NOT isDateRangeAccounting(NEW.FECHA)) OR - (!(NEW.FECHA_EX <=> OLD.FECHA_EX) AND NOT isDateRangeAccounting(NEW.FECHA_EX)) OR - (!(NEW.FECHA_OP <=> OLD.FECHA_OP) AND NOT isDateRangeAccounting(NEW.FECHA_OP)) OR - (!(NEW.FECHA_RT <=> OLD.FECHA_RT) AND NOT isDateRangeAccounting(NEW.FECHA_RT)) OR + IF (!(NEW.FECHA <=> OLD.FECHA) AND NOT isDateRangeAccounting(NEW.FECHA)) OR + (!(NEW.FECHA_EX <=> OLD.FECHA_EX) AND NOT isDateRangeAccounting(NEW.FECHA_EX)) OR + (!(NEW.FECHA_OP <=> OLD.FECHA_OP) AND NOT isDateRangeAccounting(NEW.FECHA_OP)) OR + (!(NEW.FECHA_RT <=> OLD.FECHA_RT) AND NOT isDateRangeAccounting(NEW.FECHA_RT)) OR (!(NEW.FECREGCON <=> OLD.FECREGCON) AND NOT isDateRangeAccounting(NEW.FECREGCON)) THEN CALL util.throw ('Fecha fuera de rango'); END IF; @@ -21941,21 +21927,6 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; --- --- Temporary table structure for view `__coolerPathDetail` --- - -DROP TABLE IF EXISTS `__coolerPathDetail`; -/*!50001 DROP VIEW IF EXISTS `__coolerPathDetail`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `__coolerPathDetail` ( - `id` tinyint NOT NULL, - `coolerPathFk` tinyint NOT NULL, - `hallway` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `absenceType` -- @@ -21967,17 +21938,17 @@ CREATE TABLE `absenceType` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(30) NOT NULL, `rgb` varchar(7) NOT NULL, - `color` bigint(20) DEFAULT '0', + `color` bigint(20) DEFAULT 0, `permissionRate` decimal(3,2) DEFAULT NULL, `code` varchar(45) DEFAULT NULL, - `isAllowedToWork` tinyint(4) NOT NULL DEFAULT '0', - `isPrintable` tinyint(1) NOT NULL DEFAULT '0', + `isAllowedToWork` tinyint(4) NOT NULL DEFAULT 0, + `isPrintable` tinyint(1) NOT NULL DEFAULT 0, `discountRate` decimal(3,2) DEFAULT NULL, - `holidayEntitlementRate` decimal(3,2) DEFAULT '1.00', - `isNaturalDay` tinyint(1) DEFAULT '0' COMMENT 'Para el cálculo de los salarios de los repartidores', - `isCalculate` tinyint(1) DEFAULT '0' COMMENT 'Para el cálculo de los salarios de los repartidores', + `holidayEntitlementRate` decimal(3,2) DEFAULT 1.00, + `isNaturalDay` tinyint(1) DEFAULT 0 COMMENT 'Para el cálculo de los salarios de los repartidores', + `isCalculate` tinyint(1) DEFAULT 0 COMMENT 'Para el cálculo de los salarios de los repartidores', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21988,14 +21959,14 @@ DROP TABLE IF EXISTS `accounting`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `accounting` ( - `id` int(11) NOT NULL DEFAULT '0', - `bank` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `account` varchar(10) CHARACTER SET utf8 DEFAULT NULL, - `accountingTypeFk` smallint(6) NOT NULL DEFAULT '0', + `id` int(11) NOT NULL DEFAULT 0, + `bank` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `account` varchar(10) CHARACTER SET utf8mb3 DEFAULT NULL, + `accountingTypeFk` smallint(6) NOT NULL DEFAULT 0, `entityFk` int(10) unsigned DEFAULT NULL, - `isActive` tinyint(4) NOT NULL DEFAULT '1', - `currencyFk` tinyint(3) unsigned DEFAULT '1', - `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `isActive` tinyint(4) NOT NULL DEFAULT 1, + `currencyFk` tinyint(3) unsigned DEFAULT 1, + `code` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `BancosBanco` (`bank`), KEY `fk_Bancos_entity1_idx` (`entityFk`), @@ -22004,7 +21975,7 @@ CREATE TABLE `accounting` ( CONSTRAINT `Bancoscurrency` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`) ON UPDATE CASCADE, CONSTRAINT `accounting_FK` FOREIGN KEY (`entityFk`) REFERENCES `bankEntity` (`id`) ON UPDATE CASCADE, CONSTRAINT `bank_FK` FOREIGN KEY (`accountingTypeFk`) 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'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */; -- @@ -22019,7 +21990,7 @@ CREATE TABLE `accountingConfig` ( `minDate` date NOT NULL, `maxDate` date NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22030,16 +22001,16 @@ DROP TABLE IF EXISTS `accountingType`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `accountingType` ( - `id` smallint(6) NOT NULL DEFAULT '0', - `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, - `receiptDescription` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Descripción por defecto al crear nuevo recibo', - `code` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `isAutoConciliated` tinyint(1) DEFAULT '1' COMMENT 'Si hay que marcar como conciliado el recibo al usar este tipo', + `id` smallint(6) NOT NULL DEFAULT 0, + `description` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, + `receiptDescription` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'Descripción por defecto al crear nuevo recibo', + `code` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isAutoConciliated` tinyint(1) DEFAULT 1 COMMENT 'Si hay que marcar como conciliado el recibo al usar este tipo', `maxAmount` int(11) DEFAULT NULL, - `daysInFuture` int(11) DEFAULT '0', + `daysInFuture` int(11) DEFAULT 0, PRIMARY KEY (`id`), KEY `accountingType_code_IDX` (`code`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='descripcio dels valors de la columna "cash" de la taula vn2008.Bancios'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='descripcio dels valors de la columna "cash" de la taula vn2008.Bancios'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22053,7 +22024,7 @@ CREATE TABLE `activeContrat__` ( `date` date NOT NULL, `business_id` int(11) NOT NULL, PRIMARY KEY (`date`,`business_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22065,12 +22036,12 @@ DROP TABLE IF EXISTS `activityTaxDismissed`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `activityTaxDismissed` ( `clientFk` int(11) NOT NULL, - `isNotified` tinyint(1) DEFAULT '0', - `isDismissed` tinyint(1) DEFAULT '0', - `notified` int(11) DEFAULT '0', + `isNotified` tinyint(1) DEFAULT 0, + `isDismissed` tinyint(1) DEFAULT 0, + `notified` int(11) DEFAULT 0, PRIMARY KEY (`clientFk`), CONSTRAINT `clientFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22082,30 +22053,30 @@ DROP TABLE IF EXISTS `address`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `address` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `clientFk` int(11) NOT NULL DEFAULT '0', - `warehouseFk__` smallint(6) unsigned DEFAULT '1', - `street` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `city` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `clientFk` int(11) NOT NULL DEFAULT 0, + `warehouseFk__` smallint(6) unsigned DEFAULT 1, + `street` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `city` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `provinceFk` smallint(5) unsigned DEFAULT NULL, - `postalCode` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `phone` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `mobile` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `nickname` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, - `isDefaultAddress` tinyint(1) NOT NULL DEFAULT '0', - `agencyModeFk` int(11) NOT NULL DEFAULT '2', - `notes__` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `hasInsurance__` tinyint(1) NOT NULL DEFAULT '0', + `postalCode` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `phone` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `mobile` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `nickname` varchar(40) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isDefaultAddress` tinyint(1) NOT NULL DEFAULT 0, + `agencyModeFk` int(11) NOT NULL DEFAULT 2, + `notes__` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `hasInsurance__` tinyint(1) NOT NULL DEFAULT 0, `porte__` double DEFAULT NULL, - `isActive` tinyint(4) NOT NULL DEFAULT '1', + `isActive` tinyint(4) NOT NULL DEFAULT 1, `postcodeOLD__` int(11) unsigned DEFAULT NULL, `longitude` decimal(11,7) DEFAULT NULL, `latitude` decimal(11,7) DEFAULT NULL, - `codPosOld__` char(5) COLLATE utf8_unicode_ci DEFAULT NULL, + `codPosOld__` char(5) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `isEqualizated` tinyint(1) DEFAULT NULL, `customsAgentFk` int(11) DEFAULT NULL, - `incotermsFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `isVilassarBuyer__` tinyint(4) NOT NULL DEFAULT '0', - `isLogifloraAllowed` tinyint(4) NOT NULL DEFAULT '0', + `incotermsFk` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isVilassarBuyer__` tinyint(4) NOT NULL DEFAULT 0, + `isLogifloraAllowed` tinyint(4) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `Id_Agencia` (`agencyModeFk`), KEY `Id_cliente` (`clientFk`), @@ -22122,7 +22093,7 @@ CREATE TABLE `address` ( CONSTRAINT `address_ibfk_3` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE, CONSTRAINT `address_ibfk_4` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `address_incotermsFk` FOREIGN KEY (`incotermsFk`) REFERENCES `incoterms` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -22148,11 +22119,11 @@ BEGIN END IF; IF NEW.isEqualizated IS NULL THEN - SELECT isEqualizated + SELECT isEqualizated INTO vIsEqualizated FROM client WHERE id = NEW.clientFk; - + SET NEW.isEqualizated = vIsEqualizated; END IF; END */;; @@ -22174,11 +22145,11 @@ DELIMITER ;; BEFORE UPDATE ON `address` FOR EACH ROW BEGIN - + IF !(NEW.phone <=> OLD.phone) AND (NEW.phone <> '') THEN CALL pbx.phone_isValid(NEW.phone); END IF; - + IF !(NEW.mobile <=> OLD.mobile) AND (NEW.mobile <> '')THEN CALL pbx.phone_isValid(NEW.mobile); END IF; @@ -22204,16 +22175,16 @@ DELIMITER ;; BEGIN -- Recargos de equivalencia distintos implican facturacion por consignatario IF NEW.isEqualizated != OLD.isEqualizated THEN - IF + IF (SELECT COUNT(*) FROM ( SELECT DISTINCT (isEqualizated = FALSE) as Equ - FROM address + FROM address WHERE clientFk = NEW.clientFk ) t1 ) > 1 - THEN - UPDATE client + THEN + UPDATE client SET hasToInvoiceByAddress = TRUE WHERE id = NEW.clientFk; END IF; @@ -22221,10 +22192,10 @@ BEGIN IF NEW.isDefaultAddress AND NEW.isActive = FALSE THEN CALL util.throw ('Cannot desactivate the default address'); END IF; - + IF NOT (NEW.isEqualizated <=> OLD.isEqualizated) THEN INSERT IGNORE INTO ticketRecalc (ticketFk) - SELECT id FROM ticket t + SELECT id FROM ticket t WHERE t.addressFk = NEW.id AND t.refFk IS NULL; END IF; @@ -22244,12 +22215,12 @@ DROP TABLE IF EXISTS `addressFilter`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `addressFilter` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `provinceFk` smallint(5) unsigned DEFAULT NULL, `countryFk` mediumint(8) unsigned DEFAULT NULL, - `isLogifloraAllowed` tinyint(1) DEFAULT '0', - `isVNHSupplier` tinyint(1) DEFAULT '0' COMMENT 'corresponde al campo edi.VMPSettings.isVNHSupplier', - `isEarlyBird` tinyint(1) DEFAULT '0' COMMENT 'corresponde al campo edi.marketPlace.isEarlybird', + `isLogifloraAllowed` tinyint(1) DEFAULT 0, + `isVNHSupplier` tinyint(1) DEFAULT 0 COMMENT 'corresponde al campo edi.VMPSettings.isVNHSupplier', + `isEarlyBird` tinyint(1) DEFAULT 0 COMMENT 'corresponde al campo edi.marketPlace.isEarlybird', `warehouseFk` smallint(5) unsigned DEFAULT NULL, `beforeDated` date DEFAULT NULL, `afterDated` date DEFAULT NULL, @@ -22260,7 +22231,7 @@ CREATE TABLE `addressFilter` ( CONSTRAINT `addressFilter_FK` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `addressFilter_FK_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `addressFilter_FK_2` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Establece los criterios para habilitar las compras directas a Logiflora'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Establece los criterios para habilitar las compras directas a Logiflora'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22272,10 +22243,10 @@ DROP TABLE IF EXISTS `addressForPackaging`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `addressForPackaging` ( `addressFk` int(11) NOT NULL, - `packagingValue` decimal(10,2) NOT NULL DEFAULT '0.04', + `packagingValue` decimal(10,2) NOT NULL DEFAULT 0.04, PRIMARY KEY (`addressFk`), CONSTRAINT `addresForPackaging_fk1` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22289,13 +22260,13 @@ CREATE TABLE `addressObservation` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `addressFk` int(11) NOT NULL, `observationTypeFk` tinyint(3) unsigned NOT NULL, - `description` text COLLATE utf8_unicode_ci NOT NULL, + `description` text COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `Id_Consigna` (`addressFk`,`observationTypeFk`), KEY `addressObservationFgn_idx` (`observationTypeFk`), CONSTRAINT `addressFgn` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `addressObservationFgn` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Observaciones de los consignatarios'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22307,16 +22278,16 @@ DROP TABLE IF EXISTS `agency`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `agency` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(25) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(25) COLLATE utf8mb3_unicode_ci NOT NULL, `warehouseFk` smallint(5) unsigned DEFAULT NULL COMMENT 'A nulo si se puede enrutar desde todos los almacenes', - `isVolumetric__` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Si el calculo del porte se hacer por volumen', - `bankFk__` int(11) NOT NULL DEFAULT '8' COMMENT 'para realizar los reembolsos', + `isVolumetric__` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Si el calculo del porte se hacer por volumen', + `bankFk__` int(11) NOT NULL DEFAULT 8 COMMENT 'para realizar los reembolsos', `warehouseAliasFk` smallint(5) unsigned DEFAULT NULL, - `isOwn` tinyint(1) NOT NULL DEFAULT '0', - `labelZone__` tinyint(4) NOT NULL DEFAULT '0', + `isOwn` tinyint(1) NOT NULL DEFAULT 0, + `labelZone__` tinyint(4) NOT NULL DEFAULT 0, `workCenterFk` int(11) DEFAULT NULL, `supplierFk__` int(11) DEFAULT NULL, - `isAnyVolumeAllowed` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Permite vender productos que tengan vn.itemType.IsUnconventionalSize = TRUE', + `isAnyVolumeAllowed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Permite vender productos que tengan vn.itemType.IsUnconventionalSize = TRUE', PRIMARY KEY (`id`), KEY `warehouse_id` (`warehouseFk`), KEY `Id_Banco` (`bankFk__`), @@ -22327,7 +22298,7 @@ CREATE TABLE `agency` ( CONSTRAINT `agency_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `agency_ibfk_2` FOREIGN KEY (`bankFk__`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE, CONSTRAINT `agency_ibfk_3` FOREIGN KEY (`workCenterFk`) REFERENCES `workCenter` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -22367,7 +22338,7 @@ CREATE TABLE `agencyExtraCharge` ( PRIMARY KEY (`id`), UNIQUE KEY `agencyExtraChargeUniqueIdx` (`agencyFk`,`sinced`,`sizeMin`), CONSTRAINT `agencyExtraChargeFk1` FOREIGN KEY (`agencyFk`) REFERENCES `agency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22379,22 +22350,23 @@ DROP TABLE IF EXISTS `agencyMode`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `agencyMode` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `description` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `description` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `deliveryMethodFk` int(11) DEFAULT NULL, - `m3` double DEFAULT '0', - `cod71__` tinyint(3) unsigned DEFAULT '0', - `web` smallint(1) unsigned zerofill NOT NULL DEFAULT '0', + `m3` double DEFAULT 0, + `cod71__` tinyint(3) unsigned DEFAULT 0, + `web` smallint(1) unsigned zerofill NOT NULL DEFAULT 0, `agencyFk` smallint(5) unsigned NOT NULL, - `inflation` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT 'Este valor se utiliza para aumentar el valor del componente porte.', - `isVolumetric` tinyint(1) NOT NULL DEFAULT '0', - `reportMail` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - `showAgencyName` tinyint(1) DEFAULT '1' COMMENT 'obsoleta', - `isActive` tinyint(1) NOT NULL DEFAULT '1', - `isExternalAgency` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta', - `flag` blob COMMENT 'obsoleta', - `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `isRiskFree` tinyint(1) NOT NULL DEFAULT '0', + `inflation` decimal(5,2) NOT NULL DEFAULT 0.00 COMMENT 'Este valor se utiliza para aumentar el valor del componente porte.', + `isVolumetric` tinyint(1) NOT NULL DEFAULT 0, + `reportMail` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `showAgencyName` tinyint(1) DEFAULT 1 COMMENT 'obsoleta', + `isActive` tinyint(1) NOT NULL DEFAULT 1, + `isExternalAgency` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'obsoleta', + `flag` blob DEFAULT NULL COMMENT 'obsoleta', + `code` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isRiskFree` tinyint(1) NOT NULL DEFAULT 0, + `hasWeightVolumetric` int(11) NOT NULL DEFAULT 0 COMMENT 'Tiene en cuenta el peso volumetrico para los calculos', PRIMARY KEY (`id`), KEY `Agencias` (`name`), KEY `Vista` (`deliveryMethodFk`), @@ -22402,7 +22374,7 @@ CREATE TABLE `agencyMode` ( KEY `agencyMode_code` (`code`), CONSTRAINT `agencyMode_agencyFk` FOREIGN KEY (`agencyFk`) REFERENCES `agency` (`id`) ON UPDATE CASCADE, CONSTRAINT `agencyMode_deliveryMethodFk` FOREIGN KEY (`deliveryMethodFk`) REFERENCES `deliveryMethod` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22437,7 +22409,7 @@ CREATE TABLE `agencyTermConfig` ( `vatAccountSupported` varchar(15) DEFAULT NULL, `vatPercentage` decimal(28,10) DEFAULT NULL, `transaction` varchar(50) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22448,10 +22420,10 @@ DROP TABLE IF EXISTS `alertLevel`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `alertLevel` ( - `code` varchar(45) CHARACTER SET utf8 NOT NULL, + `code` varchar(45) CHARACTER SET utf8mb3 NOT NULL, `id` int(11) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22462,10 +22434,10 @@ DROP TABLE IF EXISTS `amortizationType`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `amortizationType` ( - `code` varchar(45) CHARACTER SET utf8 NOT NULL, - `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(45) CHARACTER SET utf8mb3 NOT NULL, + `description` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22496,7 +22468,7 @@ CREATE TABLE `assignedTicketToWorker` ( PRIMARY KEY (`id`), UNIQUE KEY `idWorker_UNIQUE` (`idWorker`), UNIQUE KEY `idTicket_UNIQUE` (`idTicket`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla para relacionar un ticket con el sacador del altillo '; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla para relacionar un ticket con el sacador del altillo '; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22508,13 +22480,13 @@ DROP TABLE IF EXISTS `autoRadioConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `autoRadioConfig` ( `id` int(11) NOT NULL, - `password` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `user` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `url` varchar(75) COLLATE utf8_unicode_ci DEFAULT NULL, + `password` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `user` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `url` varchar(75) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `client` int(32) DEFAULT NULL, - `center` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, + `center` varchar(2) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22527,12 +22499,12 @@ DROP TABLE IF EXISTS `autoRadioLogCall`; CREATE TABLE `autoRadioLogCall` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ticketFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `response` longtext COLLATE utf8_unicode_ci NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `response` longtext COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), KEY `ticket_idx` (`ticketFk`), CONSTRAINT `ticket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22544,13 +22516,13 @@ DROP TABLE IF EXISTS `autonomousRegion__`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `autonomousRegion__` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(50) CHARACTER SET utf8 NOT NULL, + `name` varchar(50) CHARACTER SET utf8mb3 NOT NULL, `geoFk` int(11) DEFAULT NULL, `countryFk` mediumint(8) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `countryFk` (`countryFk`), CONSTRAINT `countryFk` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22562,7 +22534,7 @@ DROP TABLE IF EXISTS `autonomy`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `autonomy` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, `countryFk` mediumint(8) unsigned NOT NULL, `geoFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), @@ -22570,7 +22542,7 @@ CREATE TABLE `autonomy` ( KEY `autonomy_FK_1` (`geoFk`), CONSTRAINT `autonomy_FK` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `autonomy_FK_1` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Comunidades autónomas o su equivalente en otros paises. Agrupación de provincias, en una categoria inferior a country.'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Comunidades autónomas o su equivalente en otros paises. Agrupación de provincias, en una categoria inferior a country.'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -22584,8 +22556,8 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`autonomy_BI` BEFORE INSERT ON `autonomy` FOR EACH ROW -BEGIN - +BEGIN + SET NEW.geoFk = zoneGeo_new('autonomy', NEW.`name`, (SELECT geoFk FROM country WHERE id = NEW.countryFk)); END */;; @@ -22635,7 +22607,7 @@ DELIMITER ;; AFTER DELETE ON `autonomy` FOR EACH ROW BEGIN - CALL zoneGeo_delete(OLD.geoFk); + CALL zoneGeo_delete(OLD.geoFk); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -22652,19 +22624,19 @@ DROP TABLE IF EXISTS `awb`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `awb` ( `id` smallint(11) unsigned NOT NULL AUTO_INCREMENT, - `code` varchar(18) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(18) COLLATE utf8mb3_unicode_ci NOT NULL, `package` float unsigned NOT NULL, `weight` float unsigned DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `transitoryFk` int(11) DEFAULT NULL, - `taxFk` int(10) unsigned DEFAULT '62', - `duakk` varchar(18) COLLATE utf8_unicode_ci DEFAULT NULL, + `taxFk` int(10) unsigned DEFAULT 62, + `duakk` varchar(18) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `docFk` int(11) DEFAULT NULL, - `amount` double NOT NULL DEFAULT '0', + `amount` double NOT NULL DEFAULT 0, `freightFk` int(11) DEFAULT NULL, `m3` double unsigned DEFAULT NULL, `stems` int(10) unsigned DEFAULT NULL, - `flightFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `flightFk` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `volumeWeight` float unsigned DEFAULT NULL, `hb` decimal(10,1) unsigned DEFAULT NULL, `rate` decimal(10,2) unsigned DEFAULT NULL, @@ -22673,12 +22645,13 @@ CREATE TABLE `awb` ( `operated` datetime DEFAULT NULL, `bookEntried` date DEFAULT NULL, `invoiceInFk` mediumint(8) unsigned DEFAULT NULL, - `isChecked` tinyint(3) DEFAULT '0', - `isTransitoryChecked` tinyint(3) DEFAULT '0', + `isChecked` tinyint(3) DEFAULT 0, + `isTransitoryChecked` tinyint(3) DEFAULT 0, `year` int(4) DEFAULT NULL, - `observation` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `hasFreightPrepaid` tinyint(3) DEFAULT '0', + `observation` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `hasFreightPrepaid` tinyint(3) DEFAULT 0, `invoiceInPaletizedFk` mediumint(8) unsigned DEFAULT NULL, + `propertyNumber` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `codigo_UNIQUE` (`code`,`year`), KEY `proveedor_id` (`transitoryFk`), @@ -22695,7 +22668,7 @@ CREATE TABLE `awb` ( CONSTRAINT `awb_FK_2` FOREIGN KEY (`freightFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `awb_FK_3` FOREIGN KEY (`invoiceInPaletizedFk`) REFERENCES `invoiceIn` (`id`) ON UPDATE CASCADE, CONSTRAINT `awb_ibfk_1` FOREIGN KEY (`taxFk`) REFERENCES `taxCode` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -22710,8 +22683,8 @@ DELIMITER ;; BEFORE INSERT ON `awb` FOR EACH ROW BEGIN - - SET NEW.year= year(CURDATE()); + + SET NEW.year= year(util.VN_CURDATE()); END */;; @@ -22764,15 +22737,15 @@ DROP TABLE IF EXISTS `bankEntity`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `bankEntity` ( - `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', + `countryFk` mediumint(8) unsigned NOT NULL DEFAULT 1, `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `bic` varchar(11) CHARACTER SET utf8 NOT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `bic` varchar(11) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `bic_UNIQUE` (`bic`), KEY `fg_entity1_idx` (`countryFk`), CONSTRAINT `fg_entity1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Entidades bancarias '; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Entidades bancarias '; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -22826,42 +22799,11 @@ DROP TABLE IF EXISTS `bankEntityConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `bankEntityConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `bicLength` tinyint(4) DEFAULT '11' COMMENT 'Tamaño del campo bic', + `bicLength` tinyint(4) DEFAULT 11 COMMENT 'Tamaño del campo bic', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Temporary table structure for view `bankPolicy` --- - -DROP TABLE IF EXISTS `bankPolicy`; -/*!50001 DROP VIEW IF EXISTS `bankPolicy`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `bankPolicy` ( - `id` tinyint NOT NULL, - `ref` tinyint NOT NULL, - `amount` tinyint NOT NULL, - `balanceInterestDrawn` tinyint NOT NULL, - `commissionAvailableBalances` tinyint NOT NULL, - `openingCommission` tinyint NOT NULL, - `started` tinyint NOT NULL, - `ended` tinyint NOT NULL, - `bankFk` tinyint NOT NULL, - `companyFk` tinyint NOT NULL, - `supplierFk` tinyint NOT NULL, - `description` tinyint NOT NULL, - `hasGuarantee` tinyint NOT NULL, - `dmsFk` tinyint NOT NULL, - `notaryFk` tinyint NOT NULL, - `currencyFk` tinyint NOT NULL, - `amortizationTypeFk` tinyint NOT NULL, - `periodicityTypeFk` tinyint NOT NULL, - `insuranceExpired` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `beach` -- @@ -22870,10 +22812,10 @@ DROP TABLE IF EXISTS `beach`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `beach` ( - `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `warehouseFk` smallint(6) NOT NULL DEFAULT '60', + `code` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `warehouseFk` smallint(6) NOT NULL DEFAULT 60, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Ubicaciones respecto a la playa del almacén'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Ubicaciones respecto a la playa del almacén'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22890,7 +22832,7 @@ CREATE TABLE `bionicConfig` ( `verdnaturaVolumeBox` int(11) NOT NULL, `itemCarryBox` int(11) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22902,12 +22844,12 @@ DROP TABLE IF EXISTS `bookingPlanner`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `bookingPlanner` ( `id` int(10) NOT NULL AUTO_INCREMENT, - `effectived` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `pgcFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `taxAreaFk` varchar(15) CHARACTER SET utf8 NOT NULL DEFAULT 'SPAIN', + `effectived` timestamp NOT NULL DEFAULT current_timestamp(), + `pgcFk` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, + `taxAreaFk` varchar(15) CHARACTER SET utf8mb3 NOT NULL DEFAULT 'SPAIN', `priority` int(2) unsigned DEFAULT NULL, - `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT '1', - `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', + `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT 1, + `countryFk` mediumint(8) unsigned NOT NULL DEFAULT 1, PRIMARY KEY (`id`), KEY `pgcFk_bookingPlanner_idx` (`pgcFk`), KEY `taxClassFk` (`taxClassFk`), @@ -22917,7 +22859,7 @@ CREATE TABLE `bookingPlanner` ( CONSTRAINT `bookingPlanner_ibfk_1` FOREIGN KEY (`pgcFk`) REFERENCES `pgc` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `bookingPlanner_ibfk_2` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `bookingPlanner_ibfk_3` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON DELETE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22932,16 +22874,16 @@ CREATE TABLE `botanicExport` ( `ediGenusFk` mediumint(8) unsigned NOT NULL, `ediSpecieFk` mediumint(8) unsigned DEFAULT NULL, `countryFk` mediumint(8) unsigned DEFAULT NULL, - `restriction` enum('Sin restriccion','Importacion Prohibida','pasaporte fitosanitario','pasaporte individual','declaracion origen') CHARACTER SET utf8 NOT NULL, - `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `isProtectedZone` tinyint(1) NOT NULL DEFAULT '0', - `code` enum('importProhibited','phytosanitaryPassport','individualPassport') COLLATE utf8_unicode_ci DEFAULT NULL, + `restriction` enum('Sin restriccion','Importacion Prohibida','pasaporte fitosanitario','pasaporte individual','declaracion origen') CHARACTER SET utf8mb3 NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isProtectedZone` tinyint(1) NOT NULL DEFAULT 0, + `code` enum('importProhibited','phytosanitaryPassport','individualPassport') COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Paises` (`countryFk`), KEY `botanicExport_ibfk_2_idx` (`ediGenusFk`), KEY `botanicExport_ibfk_3_idx` (`ediSpecieFk`), CONSTRAINT `botanicExport_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Especifica los generos y especies prohibidos en paises'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Especifica los generos y especies prohibidos en paises'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -22975,14 +22917,14 @@ DROP TABLE IF EXISTS `budget`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `budget` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `name` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, `started` date DEFAULT NULL, `finished` date DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, `departmentFk` int(11) DEFAULT NULL, `supplierFk` int(11) DEFAULT NULL, - `photo` blob, + `photo` blob DEFAULT NULL, `amount` decimal(10,2) DEFAULT NULL, `projectFk` int(11) NOT NULL, PRIMARY KEY (`id`), @@ -22994,7 +22936,7 @@ CREATE TABLE `budget` ( CONSTRAINT `budget_FK_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `budget_FK_2` FOREIGN KEY (`departmentFk`) REFERENCES `department` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `budget_FK_3` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Master de presupuestos de project'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Master de presupuestos de project'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23013,7 +22955,7 @@ CREATE TABLE `budgetDms` ( KEY `budgetDms_FK_1` (`dmsFk`), CONSTRAINT `budgetDms_FK` FOREIGN KEY (`budgetFk`) REFERENCES `budget` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `budgetDms_FK_1` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Gestion documental de budget'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Gestion documental de budget'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23026,7 +22968,7 @@ DROP TABLE IF EXISTS `budgetInvoiceIn`; CREATE TABLE `budgetInvoiceIn` ( `id` int(11) NOT NULL AUTO_INCREMENT, `budgetFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `invoiceInFk` mediumint(8) unsigned NOT NULL, `amount` decimal(10,2) NOT NULL, PRIMARY KEY (`id`), @@ -23034,7 +22976,7 @@ CREATE TABLE `budgetInvoiceIn` ( KEY `budgetInvoiceIn_FK_1` (`invoiceInFk`), CONSTRAINT `budgetInvoiceIn_FK` FOREIGN KEY (`budgetFk`) REFERENCES `budget` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `budgetInvoiceIn_FK_1` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Facturas relativas al presupuesto'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Facturas relativas al presupuesto'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23047,15 +22989,15 @@ DROP TABLE IF EXISTS `budgetNotes`; CREATE TABLE `budgetNotes` ( `id` int(11) NOT NULL AUTO_INCREMENT, `budgetFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `txt` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `txt` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, `userFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `budgetNotes_FK` (`budgetFk`), KEY `budgetNotes_FK_2` (`userFk`), CONSTRAINT `budgetNotes_FK` FOREIGN KEY (`budgetFk`) REFERENCES `budget` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `budgetNotes_FK_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Historico de budget'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Historico de budget'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -23070,11 +23012,11 @@ DELIMITER ;; BEFORE INSERT ON `budgetNotes` FOR EACH ROW BEGIN - + IF ISNULL(NEW.userFk) THEN - + SET NEW.userFk = account.myUser_getId(); - + END IF; END */;; @@ -23084,6 +23026,185 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `business` +-- + +DROP TABLE IF EXISTS `business`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `business` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `companyCodeFk` char(3) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `started` date DEFAULT NULL, + `ended` date DEFAULT NULL, + `workerBusiness` longtext DEFAULT NULL, + `reasonEndFk` int(11) DEFAULT NULL, + `payedHolidays` decimal(5,2) NOT NULL DEFAULT 0.00, + `occupationCodeFk` varchar(1) DEFAULT NULL, + `workerFk` int(10) unsigned NOT NULL, + `notes` longtext DEFAULT NULL, + `departmentFk` int(11) DEFAULT NULL, + `workerBusinessProfessionalCategoryFk` int(11) DEFAULT NULL, + `calendarTypeFk` int(11) DEFAULT 1, + `isHourlyLabor` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Contrato por horas', + `workcenterFk` int(11) NOT NULL, + `rate` int(11) DEFAULT NULL, + `workerBusinessCategoryFk` int(11) DEFAULT NULL, + `workerBusinessTypeFk` int(11) DEFAULT NULL, + `amount` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT 'Importe pactado', + `workerBusinessAgreementFk` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `business_occupationCodeFk` (`occupationCodeFk`), + KEY `business_companyCodeFk` (`companyCodeFk`), + KEY `business_workerFk_idx` (`workerFk`), + KEY `business_departmentFk_idx` (`departmentFk`), + KEY `business_workerBusinessProfessionalCategoryFk_idx` (`workerBusinessProfessionalCategoryFk`), + KEY `business_calendarTypeFk_idx` (`calendarTypeFk`), + KEY `business_workerBusinessCategoryFk` (`workerBusinessCategoryFk`), + KEY `business_workerBusinessTypeFk_idx` (`workerBusinessTypeFk`), + KEY `business_workerBusinessAgreementFk_idx` (`workerBusinessAgreementFk`), + CONSTRAINT `business_calendarTypeFk` FOREIGN KEY (`calendarTypeFk`) REFERENCES `postgresql`.`calendar_labour_type` (`calendar_labour_type_id`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `business_companyCodeFk` FOREIGN KEY (`companyCodeFk`) REFERENCES `company` (`code`) ON UPDATE CASCADE, + CONSTRAINT `business_departmentFk` FOREIGN KEY (`departmentFk`) REFERENCES `department` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `business_occupationCodeFk` FOREIGN KEY (`occupationCodeFk`) REFERENCES `occupationCode` (`code`) ON UPDATE CASCADE, + CONSTRAINT `business_workerBusinessAgreementFk` FOREIGN KEY (`workerBusinessAgreementFk`) REFERENCES `postgresql`.`labour_agreement` (`labour_agreement_id`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `business_workerBusinessProfessionalCategoryFk` FOREIGN KEY (`workerBusinessProfessionalCategoryFk`) REFERENCES `postgresql`.`professional_category` (`professional_category_id`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `business_workerBusinessTypeFk` FOREIGN KEY (`workerBusinessTypeFk`) REFERENCES `workerBusinessType` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `business_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; +/*!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_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_beforeInsert` + BEFORE INSERT ON `business` + FOR EACH ROW +BEGIN + IF NEW.ended IS NULL THEN + SET NEW.payedHolidays = 0; + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_afterInsert` + AFTER INSERT ON `business` + FOR EACH ROW +BEGIN + CALL worker_updateBusiness(NEW.workerFk); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_beforeUpdate` + BEFORE UPDATE ON `business` + FOR EACH ROW +BEGIN + DECLARE isOverlapping BOOL; + + IF NEW.ended IS NULL THEN + SET NEW.payedHolidays = 0; + END IF; + + IF !(OLD.started <=> NEW.started AND OLD.ended <=> NEW.ended) THEN + + SELECT COUNT(*) > 0 INTO isOverlapping + FROM business b + WHERE (util.hasDateOverlapped( + NEW.started, + IFNULL(NEW.ended, b.started), + b.started, + IFNULL(b.ended, NEW.started)) + OR (NEW.ended <=> NULL AND b.ended <=> NULL)) + AND b.id <> OLD.id + AND workerFk = OLD.workerFk; + + IF isOverlapping THEN + CALL util.throw ('IS_OVERLAPPING'); + 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 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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_afterUpdate` + AFTER UPDATE ON `business` + FOR EACH ROW +BEGIN + CALL worker_updateBusiness(NEW.workerFk); + + IF NOT (OLD.workerFk <=> NEW.workerFk) THEN + CALL worker_updateBusiness(OLD.workerFk); + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_afterDelete` + AFTER DELETE ON `business` + FOR EACH ROW +BEGIN + CALL worker_updateBusiness(OLD.workerFk); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; + -- -- Temporary table structure for view `businessCalendar` -- @@ -23109,9 +23230,9 @@ DROP TABLE IF EXISTS `businessReasonEnd`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `businessReasonEnd` ( `id` tinyint(3) NOT NULL AUTO_INCREMENT, - `reason` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `reason` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23122,10 +23243,10 @@ DROP TABLE IF EXISTS `businessType`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `businessType` ( - `code` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `description` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23137,33 +23258,33 @@ DROP TABLE IF EXISTS `buy`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `buy` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `entryFk` int(11) NOT NULL DEFAULT '0', - `itemFk` int(11) NOT NULL DEFAULT '90', - `quantity` int(11) DEFAULT '0', - `dispatched` int(11) NOT NULL DEFAULT '0', - `buyingValue` decimal(10,3) DEFAULT '0.000', - `freightValue` decimal(10,3) DEFAULT '0.000', - `isIgnored` tinyint(1) NOT NULL DEFAULT '0', - `stickers` int(11) NOT NULL DEFAULT '0', - `packing` int(11) DEFAULT '0', - `grouping` smallint(5) unsigned NOT NULL DEFAULT '1', - `groupingMode` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0=sin obligar 1=groping 2=packing', + `entryFk` int(11) NOT NULL DEFAULT 0, + `itemFk` int(11) NOT NULL DEFAULT 90, + `quantity` int(11) DEFAULT 0, + `dispatched` int(11) NOT NULL DEFAULT 0, + `buyingValue` decimal(10,3) DEFAULT 0.000, + `freightValue` decimal(10,3) DEFAULT 0.000, + `isIgnored` tinyint(1) NOT NULL DEFAULT 0, + `stickers` int(11) NOT NULL DEFAULT 0, + `packing` int(11) DEFAULT 0, + `grouping` smallint(5) unsigned NOT NULL DEFAULT 1, + `groupingMode` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=sin obligar 1=groping 2=packing', `containerFk` smallint(5) unsigned DEFAULT NULL, - `comissionValue` decimal(10,3) DEFAULT '0.000', - `packageValue` decimal(10,3) DEFAULT '0.000', - `location` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, - `packageFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT '--', - `price1` decimal(10,2) DEFAULT '0.00', - `price2` decimal(10,2) DEFAULT '0.00', - `price3` decimal(10,2) DEFAULT '0.00', - `minPrice` decimal(10,2) DEFAULT '0.00', - `producer` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `printedStickers` int(11) DEFAULT '0', - `workerFk` int(11) DEFAULT '0', - `isChecked` tinyint(1) NOT NULL DEFAULT '0', - `isPickedOff` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Esta mercancia no va a la zona de picking.', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `__cm2` int(10) unsigned NOT NULL DEFAULT '0', + `comissionValue` decimal(10,3) DEFAULT 0.000, + `packageValue` decimal(10,3) DEFAULT 0.000, + `location` varchar(5) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `packageFk` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT '--', + `price1` decimal(10,2) DEFAULT 0.00, + `price2` decimal(10,2) DEFAULT 0.00, + `price3` decimal(10,2) DEFAULT 0.00, + `minPrice` decimal(10,2) DEFAULT 0.00, + `producer` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `printedStickers` int(11) DEFAULT 0, + `workerFk` int(11) DEFAULT 0, + `isChecked` tinyint(1) NOT NULL DEFAULT 0, + `isPickedOff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Esta mercancia no va a la zona de picking.', + `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `__cm2` int(10) unsigned NOT NULL DEFAULT 0, `ektFk` int(11) DEFAULT NULL, `weight` decimal(10,2) unsigned DEFAULT NULL, `deliveryFk` int(11) DEFAULT NULL, @@ -23185,7 +23306,7 @@ CREATE TABLE `buy` ( CONSTRAINT `buy_ibfk_2` FOREIGN KEY (`packageFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE, CONSTRAINT `buy_id` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `buy_itemfk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -23278,7 +23399,7 @@ trig: BEGIN LEAVE trig; END IF; - IF @isTriggerDisabled THEN + IF @isTriggerDisabled THEN LEAVE trig; END IF; @@ -23376,7 +23497,7 @@ trig: BEGIN DECLARE vItemName VARCHAR(50); DECLARE vNewValues VARCHAR(255); DECLARE vOldValues VARCHAR(255); - + IF !(NEW.id <=> OLD.id) OR !(NEW.entryFk <=> OLD.entryFk) OR !(NEW.itemFk <=> OLD.itemFk) @@ -23384,45 +23505,39 @@ trig: BEGIN OR !(NEW.created <=> OLD.created) THEN CALL stock.log_add('buy', NEW.id, OLD.id); END IF; - + IF @isModeInventory THEN LEAVE trig; END IF; - IF @isTriggerDisabled THEN + IF @isTriggerDisabled THEN LEAVE trig; END IF; CALL buy_afterUpsert(NEW.id); - IF !(NEW.weight <=> OLD.weight) AND NEW.weight THEN - UPDATE item - SET density = NEW.weight / (item_getVolume(NEW.itemFk, NEW.packageFk) / 1000000) - WHERE id = NEW.itemFk; - END IF; - SELECT w.isBuyerToBeEmailed, t.landed INTO vIsBuyerToBeEmailed, vLanded FROM entry e JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseInFk + JOIN warehouse w ON w.id = t.warehouseInFk WHERE e.id = NEW.entryFk; - - SELECT it.workerFk, i.longName + + SELECT it.workerFk, i.longName INTO vBuyerFk, vItemName FROM itemCategory k JOIN itemType it ON it.categoryFk = k.id JOIN item i ON i.typeFk = it.id WHERE i.id = OLD.itemFk; - - IF vIsBuyerToBeEmailed AND - vBuyerFk != account.myUser_getId() AND - vLanded = CURDATE() THEN - IF !(NEW.itemFk <=> OLD.itemFk) OR - !(NEW.quantity <=> OLD.quantity) OR + + IF vIsBuyerToBeEmailed AND + vBuyerFk != account.myUser_getId() AND + vLanded = util.VN_CURDATE() THEN + IF !(NEW.itemFk <=> OLD.itemFk) OR + !(NEW.quantity <=> OLD.quantity) OR !(NEW.packing <=> OLD.packing) OR - !(NEW.grouping <=> OLD.grouping) OR - !(NEW.packageFk <=> OLD.packageFk) OR + !(NEW.grouping <=> OLD.grouping) OR + !(NEW.packageFk <=> OLD.packageFk) OR !(NEW.weight <=> OLD.weight) THEN CALL vn.mail_insert( CONCAT(account.user_getNameFromId(vBuyerFk),'@verdnatura.es'), @@ -23432,6 +23547,10 @@ trig: BEGIN ); END IF; END IF; + + IF OLD.printedStickers <> 0 AND NEW.printedStickers = 0 THEN + CALL util.debugAdd('buy_deleted', CONCAT(OLD.id,' ', OLD.itemFk,' ', vn.getWorkerCode())); + END IF; /* IF (!(NEW.entryFk <=> OLD.entryFk) OR !(NEW.quantity <=> OLD.quantity) @@ -23477,7 +23596,7 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_beforeDelete` BEFORE DELETE ON buy FOR EACH ROW -BEGIN +BEGIN IF OLD.printedStickers <> 0 THEN CALL util.throw("it is not possible to delete buys with printed labels "); END IF; @@ -23499,17 +23618,15 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_afterDelete` AFTER DELETE ON `buy` FOR EACH ROW -trig: BEGIN +trig: BEGIN DECLARE vValues VARCHAR(255); - IF @isTriggerDisabled THEN + IF @isTriggerDisabled THEN LEAVE trig; END IF; CALL stock.log_add('buy', NULL, OLD.id); - CALL util.debugAdd('buy_deleted', CONCAT(OLD.id,' ', OLD.itemFk,' ', vn.getWorkerCode())); - /*IF entry_isInventoryOrPrevious(OLD.entryFk) THEN SET vValues = CONCAT_WS(',', OLD.entryFk, @@ -23537,12 +23654,12 @@ DROP TABLE IF EXISTS `buyMark`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `buyMark` ( `id` int(11) NOT NULL, - `comment` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `comment` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `mark` tinyint(1) DEFAULT NULL, - `odbcDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `odbcDate` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), CONSTRAINT `Compres_mark_ibfk_1` FOREIGN KEY (`id`) REFERENCES `buy` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23588,13 +23705,12 @@ CREATE TABLE `calendar` ( `dayOffTypeFk` int(11) NOT NULL, `dated` date NOT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `business_id_date` (`businessFk`,`dated`), KEY `calendar_employee_business_labour_id_idx` (`businessFk`), KEY `calendar_employee_calendar_state_calendar_state_id_idx` (`dayOffTypeFk`), KEY `id_index` (`id`), CONSTRAINT `calendar_FK` FOREIGN KEY (`dayOffTypeFk`) REFERENCES `absenceType` (`id`) ON UPDATE CASCADE, - CONSTRAINT `calendar_businessFk` FOREIGN KEY (`businessFk`) REFERENCES `postgresql`.`business` (`business_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; + CONSTRAINT `calendar_businessFk` FOREIGN KEY (`businessFk`) REFERENCES `business` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23618,7 +23734,7 @@ CREATE TABLE `calendarHolidays` ( CONSTRAINT `calendarHolidaysNameFk` FOREIGN KEY (`calendarHolidaysNameFk`) REFERENCES `calendarHolidaysName` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `calendarholidaystypeFk` FOREIGN KEY (`calendarHolidaysTypeFk`) REFERENCES `calendarHolidaysType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `workCenterFk` FOREIGN KEY (`workCenterFk`) REFERENCES `workCenter` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23632,7 +23748,7 @@ CREATE TABLE `calendarHolidaysName` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23647,7 +23763,7 @@ CREATE TABLE `calendarHolidaysType` ( `name` varchar(50) NOT NULL, `hexColour` char(7) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23659,12 +23775,12 @@ DROP TABLE IF EXISTS `campaign`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `campaign` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `code` enum('mothersDay','allSaints','valentinesDay') COLLATE utf8_unicode_ci NOT NULL, - `dated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `scopeDays` int(11) NOT NULL DEFAULT '15', + `code` enum('mothersDay','allSaints','valentinesDay') COLLATE utf8mb3_unicode_ci NOT NULL, + `dated` datetime NOT NULL DEFAULT current_timestamp(), + `scopeDays` int(11) NOT NULL DEFAULT 15, PRIMARY KEY (`id`), UNIQUE KEY `campaign_dated_uindex` (`dated`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23676,10 +23792,10 @@ DROP TABLE IF EXISTS `category`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `category` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `nick` varchar(3) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `nick` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23691,13 +23807,13 @@ DROP TABLE IF EXISTS `chain`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `chain` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `rappel` decimal(5,2) NOT NULL DEFAULT '0.00', + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `rappel` decimal(5,2) NOT NULL DEFAULT 0.00, `componentFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `chain_FK` (`componentFk`), CONSTRAINT `chain_FK` FOREIGN KEY (`componentFk`) REFERENCES `component` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Grupos de clientes'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Grupos de clientes'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23710,17 +23826,17 @@ DROP TABLE IF EXISTS `chat`; CREATE TABLE `chat` ( `id` int(11) NOT NULL AUTO_INCREMENT, `senderFk` int(10) unsigned DEFAULT NULL, - `recipient` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `recipient` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `dated` datetime DEFAULT NULL, `checkUserStatus` tinyint(1) DEFAULT NULL, - `message` text COLLATE utf8_unicode_ci, + `message` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `status` tinyint(1) DEFAULT NULL, `attempts` int(1) DEFAULT NULL, - `error` text COLLATE utf8_unicode_ci, + `error` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `chat_FK` (`senderFk`), CONSTRAINT `chat_FK` FOREIGN KEY (`senderFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23732,12 +23848,12 @@ DROP TABLE IF EXISTS `chatConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `chatConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `host` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `api` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `user` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `password` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + `host` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `api` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `user` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `password` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23751,16 +23867,16 @@ CREATE TABLE `claim` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `ticketCreated` date NOT NULL, `claimDepartmentFk__` tinyint(3) unsigned DEFAULT NULL, - `claimStateFk` int(10) unsigned NOT NULL DEFAULT '1', - `observation` text COLLATE utf8_unicode_ci, + `claimStateFk` int(10) unsigned NOT NULL DEFAULT 1, + `observation` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `clientFk` int(11) NOT NULL, `workerFk` int(11) NOT NULL, - `responsibility` int(1) unsigned NOT NULL DEFAULT '3', - `isChargedToMana` tinyint(1) NOT NULL DEFAULT '0', - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `responsibility` int(1) unsigned NOT NULL DEFAULT 3, + `isChargedToMana` tinyint(1) NOT NULL DEFAULT 0, + `created` timestamp NULL DEFAULT current_timestamp(), `ticketFk` int(11) DEFAULT NULL, `hasToPickUp` tinyint(1) NOT NULL, - `packages` smallint(10) unsigned DEFAULT '0' COMMENT 'packages received by the client', + `packages` smallint(10) unsigned DEFAULT 0 COMMENT 'packages received by the client', PRIMARY KEY (`id`), KEY `cl_dep_id` (`claimDepartmentFk__`), KEY `cl_est_id` (`claimStateFk`), @@ -23771,7 +23887,7 @@ CREATE TABLE `claim` ( CONSTRAINT `claim_ibfk_3` FOREIGN KEY (`claimStateFk`) REFERENCES `claimState` (`id`) ON UPDATE CASCADE, CONSTRAINT `claim_ibfk_4` FOREIGN KEY (`claimDepartmentFk__`) REFERENCES `vn2008`.`cl_dep` (`id`) ON UPDATE CASCADE, CONSTRAINT `claim_ibfk_5` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Reclamaciones, tabla principal'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23785,15 +23901,15 @@ CREATE TABLE `claimBeginning` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `claimFk` int(10) unsigned NOT NULL, `saleFk` int(11) DEFAULT NULL, - `claimComplaintFk__` int(10) unsigned NOT NULL DEFAULT '1', - `claimRequestFk__` int(1) unsigned NOT NULL DEFAULT '1', + `claimComplaintFk__` int(10) unsigned NOT NULL DEFAULT 1, + `claimRequestFk__` int(1) unsigned NOT NULL DEFAULT 1, `quantity` double DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Movimiento` (`saleFk`), KEY `cl_main_id` (`claimFk`), CONSTRAINT `claimBeginning_ibfk_7` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimBeginning_ibfk_8` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de las reclamaciones'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Detalle de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -23814,7 +23930,7 @@ BEGIN FROM sale WHERE id = NEW.saleFk; - UPDATE claim + UPDATE claim SET ticketFk = vTicket WHERE id = NEW.claimFk; END */;; @@ -23833,10 +23949,10 @@ DROP TABLE IF EXISTS `claimConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `claimConfig` ( `id` int(11) NOT NULL, - `pickupContact` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL, + `pickupContact` varchar(250) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `maxResponsibility` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23848,12 +23964,12 @@ DROP TABLE IF EXISTS `claimDestination`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `claimDestination` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `description` varchar(15) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL, `addressFk` int(10) DEFAULT NULL COMMENT 'Indica el consignatario para el ticket que regulariza el inventario', PRIMARY KEY (`id`), KEY `clSolAddressFk_idx` (`addressFk`), CONSTRAINT `clSolAddressFk` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Solucion ofrecida a la reclamación'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Solucion ofrecida a la reclamación'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23866,12 +23982,12 @@ DROP TABLE IF EXISTS `claimDevelopment`; CREATE TABLE `claimDevelopment` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `claimFk` int(10) unsigned NOT NULL, - `claimResponsibleFk` int(10) unsigned NOT NULL DEFAULT '1', + `claimResponsibleFk` int(10) unsigned NOT NULL DEFAULT 1, `workerFk` int(10) unsigned DEFAULT NULL, - `claimReasonFk` int(10) unsigned NOT NULL DEFAULT '1', - `claimResultFk` int(10) unsigned NOT NULL DEFAULT '1', - `claimRedeliveryFk` tinyint(3) unsigned NOT NULL DEFAULT '1', - `claimDestinationFk` tinyint(3) unsigned NOT NULL DEFAULT '2', + `claimReasonFk` int(10) unsigned NOT NULL DEFAULT 1, + `claimResultFk` int(10) unsigned NOT NULL DEFAULT 1, + `claimRedeliveryFk` tinyint(3) unsigned NOT NULL DEFAULT 1, + `claimDestinationFk` tinyint(3) unsigned NOT NULL DEFAULT 2, PRIMARY KEY (`id`), KEY `cl_main_id` (`claimFk`), KEY `cl_res_id` (`claimResponsibleFk`), @@ -23887,7 +24003,7 @@ CREATE TABLE `claimDevelopment` ( CONSTRAINT `claimDevelopment_ibfk_7` FOREIGN KEY (`claimReasonFk`) REFERENCES `claimReason` (`id`) ON UPDATE CASCADE, CONSTRAINT `claimDevelopment_ibfk_8` FOREIGN KEY (`claimResultFk`) REFERENCES `claimResult` (`id`) ON UPDATE CASCADE, CONSTRAINT `claimDevelopment_ibfk_9` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Causas de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23904,7 +24020,7 @@ CREATE TABLE `claimDms` ( KEY `dmsFk_idx` (`dmsFk`), CONSTRAINT `claimFk` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `dmsFk` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23918,9 +24034,9 @@ CREATE TABLE `claimEnd` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `saleFk` int(11) DEFAULT NULL, `claimFk` int(10) unsigned NOT NULL, - `workerFk` int(10) unsigned NOT NULL DEFAULT '20', + `workerFk` int(10) unsigned NOT NULL DEFAULT 20, `claimDestinationFk` tinyint(4) DEFAULT NULL, - `isGreuge` tinyint(4) NOT NULL DEFAULT '0', + `isGreuge` tinyint(4) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `cl_main_id` (`claimFk`), KEY `Id_Trabajador` (`workerFk`), @@ -23929,7 +24045,7 @@ CREATE TABLE `claimEnd` ( CONSTRAINT `claimEnd_ibfk_1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimEnd_ibfk_3` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `claimEnd_ibfk_4` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23943,20 +24059,42 @@ CREATE TABLE `claimLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `originFk` int(10) 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, - `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8_unicode_ci, - `newInstance` text COLLATE utf8_unicode_ci, + `action` set('insert','update','delete') COLLATE utf8mb3_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 DEFAULT NULL, + `changedModel` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `originFk` (`originFk`), KEY `userFk` (`userFk`), CONSTRAINT `claimOriginFk` FOREIGN KEY (`originFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `claimObservation` +-- + +DROP TABLE IF EXISTS `claimObservation`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `claimObservation` ( + `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `claimFk` int(10) unsigned NOT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, + `text` text COLLATE utf8mb3_unicode_ci NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `worker_key` (`workerFk`), + KEY `claim_key` (`claimFk`), + KEY `claimObservation_created_IDX` (`created`) USING BTREE, + CONSTRAINT `claimObservation_ibfk_1` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `claimObservation_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Todas las observaciones referentes a una reclamación'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23967,15 +24105,15 @@ DROP TABLE IF EXISTS `claimRatio`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `claimRatio` ( - `clientFk` int(11) NOT NULL DEFAULT '0', + `clientFk` int(11) NOT NULL DEFAULT 0, `yearSale` decimal(10,2) DEFAULT NULL, `claimAmount` decimal(10,2) DEFAULT NULL, `claimingRate` decimal(5,2) DEFAULT NULL, `priceIncreasing` decimal(5,2) DEFAULT NULL, - `packingRate` decimal(5,2) NOT NULL DEFAULT '1.00', + `packingRate` decimal(5,2) NOT NULL DEFAULT 1.00, PRIMARY KEY (`clientFk`), CONSTRAINT `claimRatio_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23987,10 +24125,10 @@ DROP TABLE IF EXISTS `claimReason`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `claimReason` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `isTired` tinyint(1) NOT NULL DEFAULT '0', + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `isTired` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Motivos de las fallos'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Motivos de las fallos'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24002,9 +24140,9 @@ DROP TABLE IF EXISTS `claimRedelivery`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `claimRedelivery` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Método por el cual el cliente nos devuelve la mercancía'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Método por el cual el cliente nos devuelve la mercancía'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24016,10 +24154,10 @@ DROP TABLE IF EXISTS `claimResponsible`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `claimResponsible` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `responsability` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'if=1 >sensib >culpa', + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `responsability` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'if=1 >sensib >culpa', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Responsables de las causas'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Responsables de las causas'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24031,9 +24169,9 @@ DROP TABLE IF EXISTS `claimResult`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `claimResult` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Consecuencias de los motivos'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Consecuencias de los motivos'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24045,15 +24183,15 @@ DROP TABLE IF EXISTS `claimState`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `claimState` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `code` varchar(45) CHARACTER SET utf8 DEFAULT NULL, - `description` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `roleFk` int(10) unsigned NOT NULL DEFAULT '1', - `priority` int(11) NOT NULL DEFAULT '1', - `hasToNotify` tinyint(4) DEFAULT '0', + `code` varchar(45) CHARACTER SET utf8mb3 DEFAULT NULL, + `description` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL, + `roleFk` int(10) unsigned NOT NULL DEFAULT 1, + `priority` int(11) NOT NULL DEFAULT 1, + `hasToNotify` tinyint(4) DEFAULT 0, PRIMARY KEY (`id`), KEY `roleFgn_idx` (`roleFk`), CONSTRAINT `roleFgn` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Estados posibles de las reclamaciones'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Estados posibles de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24065,74 +24203,74 @@ DROP TABLE IF EXISTS `client`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `client` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `discount__` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', + `name` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `discount__` tinyint(3) unsigned NOT NULL DEFAULT 0 COMMENT 'obsoleta (comprobar)', `defaultAddressFk` int(11) DEFAULT NULL, - `street` longtext COLLATE utf8_unicode_ci, - `fi` varchar(14) COLLATE utf8_unicode_ci DEFAULT NULL, - `phone` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `fax__` varchar(11) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)', - `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)', - `isTaxDataChecked` tinyint(1) NOT NULL DEFAULT '0', - `mobile` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `accountingAccount` varchar(10) CHARACTER SET utf8 NOT NULL, - `isEqualizated` tinyint(1) NOT NULL DEFAULT '0', - `city` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL, + `street` longtext COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `fi` varchar(14) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `phone` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `fax__` varchar(11) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)', + `email` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `dueDay` smallint(6) NOT NULL DEFAULT 5, + `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 utf8mb3_unicode_ci DEFAULT NULL, + `accountingAccount` varchar(10) CHARACTER SET utf8mb3 NOT NULL, + `isEqualizated` tinyint(1) NOT NULL DEFAULT 0, + `city` varchar(25) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `provinceFk` smallint(5) unsigned DEFAULT NULL, - `postcode` varchar(8) COLLATE utf8_unicode_ci DEFAULT NULL, - `socialName` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL, - `contact` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `wholesaler__` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', - `isReExpedition__` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', - `hasToInvoice` tinyint(1) NOT NULL DEFAULT '1', - `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)', - `isFreezed` tinyint(1) NOT NULL DEFAULT '0', + `postcode` varchar(8) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `socialName` varchar(60) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `contact` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `wholesaler__` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'obsoleta (comprobar)', + `isReExpedition__` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'obsoleta (comprobar)', + `hasToInvoice` tinyint(1) NOT NULL DEFAULT 1, + `notes__` text COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)', + `administrativeNotes__` text COLLATE utf8mb3_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)', + `isFreezed` tinyint(1) NOT NULL DEFAULT 0, `salesPersonFk` int(10) unsigned DEFAULT NULL, - `credit` decimal(10,2) NOT NULL DEFAULT '0.00', + `credit` decimal(10,2) NOT NULL DEFAULT 0.00, `cyc__` double DEFAULT NULL COMMENT 'obsoleta (comprobar)', - `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', - `isActive` tinyint(1) NOT NULL DEFAULT '1', + `countryFk` mediumint(8) unsigned NOT NULL DEFAULT 1, + `isActive` tinyint(1) NOT NULL DEFAULT 1, `gestdocFk` int(11) DEFAULT NULL, - `quality` int(2) DEFAULT '11', - `payMethodFk` tinyint(3) unsigned NOT NULL DEFAULT '5', - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `isToBeMailed` tinyint(1) NOT NULL DEFAULT '1', + `quality` int(2) DEFAULT 11, + `payMethodFk` tinyint(3) unsigned NOT NULL DEFAULT 5, + `created` timestamp NULL DEFAULT current_timestamp(), + `isToBeMailed` tinyint(1) NOT NULL DEFAULT 1, `contactChannelFk` smallint(6) DEFAULT NULL, - `isVies` tinyint(4) NOT NULL DEFAULT '0', - `splitHolland__` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', - `sepaFth__` tinyint(1) DEFAULT '0' COMMENT 'campo para recibir los escritos de los clientes para el sepaobsoleta (comprobar)', - `hasSepaVnl` tinyint(1) DEFAULT '0', - `coreFth__` tinyint(1) DEFAULT '0' COMMENT 'obsoleta (comprobar)', - `hasCoreVnl` tinyint(1) DEFAULT '0', + `isVies` tinyint(4) NOT NULL DEFAULT 0, + `splitHolland__` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'obsoleta (comprobar)', + `sepaFth__` tinyint(1) DEFAULT 0 COMMENT 'campo para recibir los escritos de los clientes para el sepaobsoleta (comprobar)', + `hasSepaVnl` tinyint(1) DEFAULT 0, + `coreFth__` tinyint(1) DEFAULT 0 COMMENT 'obsoleta (comprobar)', + `hasCoreVnl` tinyint(1) DEFAULT 0, `riskCalculated` date NOT NULL, - `hasCoreVnh` tinyint(1) DEFAULT '0', - `isRelevant` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Define los clientes cuyas ventas hay que tener en cuenta en los calculos estadisticos.', - `clientTypeFk` int(11) NOT NULL DEFAULT '1', + `hasCoreVnh` tinyint(1) DEFAULT 0, + `isRelevant` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Define los clientes cuyas ventas hay que tener en cuenta en los calculos estadisticos.', + `clientTypeFk` int(11) NOT NULL DEFAULT 1, `postcodeOld__` int(11) unsigned DEFAULT NULL COMMENT 'obsoleta (comprobar)', `mailAddress` int(11) DEFAULT NULL, - `codposOLD__` char(5) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)', + `codposOLD__` char(5) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)', `creditInsurance` int(11) DEFAULT NULL, - `eypbc` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Email\\nYesterday\\nPurchases\\nBy\\nConsigna', - `hasToInvoiceByAddress` tinyint(1) DEFAULT '0', - `cplusTerIdNifFk__` int(11) NOT NULL DEFAULT '1' COMMENT 'OBSOLETO', - `isCreatedAsServed` tinyint(1) DEFAULT '0', - `hasInvoiceSimplified` tinyint(1) NOT NULL DEFAULT '0', - `iban` varchar(45) CHARACTER SET utf8 DEFAULT NULL, - `hasLcr` tinyint(1) NOT NULL DEFAULT '0', + `eypbc` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Email\\nYesterday\\nPurchases\\nBy\\nConsigna', + `hasToInvoiceByAddress` tinyint(1) DEFAULT 0, + `cplusTerIdNifFk__` int(11) NOT NULL DEFAULT 1 COMMENT 'OBSOLETO', + `isCreatedAsServed` tinyint(1) DEFAULT 0, + `hasInvoiceSimplified` tinyint(1) NOT NULL DEFAULT 0, + `iban` varchar(45) CHARACTER SET utf8mb3 DEFAULT NULL, + `hasLcr` tinyint(1) NOT NULL DEFAULT 0, `bankEntityFk` int(10) unsigned DEFAULT NULL, - `typeFk` varchar(20) CHARACTER SET utf8 NOT NULL DEFAULT 'normal', + `typeFk` varchar(20) CHARACTER SET utf8mb3 NOT NULL DEFAULT 'normal', `taxTypeSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipo de Iva por defecto asociado al cliente en SAGE', `transactionTypeSageFk` tinyint(4) DEFAULT NULL COMMENT 'Tipo de transacción por defecto asociado al cliente en SAGE', `transferorFk` int(11) DEFAULT NULL COMMENT 'Cliente que le ha transmitido la titularidad de la empresa', `lastSalesPersonFk` int(10) unsigned DEFAULT NULL COMMENT 'ultimo comercial que tuvo, para el calculo del peso en los rankings de equipo', - `businessTypeFk` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `businessTypeFk` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `hasIncoterms` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Received incoterms authorization from client', PRIMARY KEY (`id`), UNIQUE KEY `IF` (`fi`), KEY `Id_Trabajador` (`salesPersonFk`), @@ -24167,7 +24305,7 @@ CREATE TABLE `client` ( CONSTRAINT `client_transactionTypeSageFk` FOREIGN KEY (`transactionTypeSageFk`) REFERENCES `sage`.`TiposTransacciones` (`CodigoTransaccion`) ON UPDATE CASCADE, CONSTRAINT `tipos_de_cliente` FOREIGN KEY (`clientTypeFk`) REFERENCES `clientType` (`id`) ON UPDATE CASCADE, CONSTRAINT `typeFk` FOREIGN KEY (`typeFk`) REFERENCES `clientType` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -24192,7 +24330,7 @@ BEGIN END IF; SET NEW.accountingAccount = 4300000000 + NEW.id; - + SET NEW.lastSalesPersonFk = NEW.salesPersonFk; END */;; DELIMITER ; @@ -24220,19 +24358,19 @@ BEGIN IF !(NEW.phone <=> OLD.phone) AND (NEW.phone <> '') THEN CALL pbx.phone_isValid(NEW.phone); END IF; - + IF !(NEW.mobile <=> OLD.mobile) AND (NEW.mobile <> '')THEN CALL pbx.phone_isValid(NEW.mobile); END IF; SELECT id INTO vPayMethodFk - FROM vn.payMethod + FROM vn.payMethod WHERE code = 'bankDraft'; - + IF NEW.payMethodFk = vPayMethodFk AND NEW.dueDay = 0 THEN SET NEW.dueDay = 5; END IF; - + -- Avisar al comercial si ha llegado la documentación sepa/core IF NEW.hasSepaVnl AND !OLD.hasSepaVnl THEN @@ -24245,7 +24383,7 @@ BEGIN IF vText IS NOT NULL THEN - INSERT INTO mail(receiver, replyTo, `subject`, body) + INSERT INTO mail(receiver, replyTo, `subject`, body) SELECT CONCAT(IF(ac.id,u.name, 'jgallego'), '@verdnatura.es'), 'administracion@verdnatura.es', @@ -24256,18 +24394,22 @@ BEGIN LEFT JOIN account.account ac ON ac.id = u.id WHERE w.id = NEW.salesPersonFk; END IF; - + IF NEW.salespersonFk IS NULL AND OLD.salespersonFk IS NOT NULL THEN - IF (SELECT COUNT(clientFk) + IF (SELECT COUNT(clientFk) FROM clientProtected WHERE clientFk = NEW.id ) > 0 THEN CALL util.throw("HAS_CLIENT_PROTECTED"); END IF; END IF; - + SET NEW.lastSalesPersonFk = IFNULL(NEW.salesPersonFk, OLD.salesPersonFk); + IF !(NEW.businessTypeFk <=> OLD.businessTypeFk) THEN + SET NEW.isTaxDataChecked = 0; + END IF; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -24290,18 +24432,18 @@ BEGIN IF !(NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN UPDATE `address` SET isDefaultAddress = 0 WHERE clientFk = NEW.id; - + UPDATE `address` SET isDefaultAddress = 1 - WHERE id = NEW.defaultAddressFk; + WHERE id = NEW.defaultAddressFk; END IF; IF NOT (NEW.provinceFk <=> OLD.provinceFk) OR NOT (NEW.isVies <=> OLD.isVies) THEN INSERT IGNORE INTO ticketRecalc (ticketFk) - SELECT id FROM ticket t + SELECT id FROM ticket t WHERE t.clientFk = NEW.id AND t.refFk IS NULL; END IF; - + IF NOT NEW.isActive THEN UPDATE account.`user` SET active = FALSE @@ -24330,7 +24472,7 @@ CREATE TABLE `clientChain` ( KEY `clientChain_fk2_idx` (`chainFk`), CONSTRAINT `clientChain_fk1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientChain_fk2` FOREIGN KEY (`chainFk`) REFERENCES `chain` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24344,9 +24486,9 @@ CREATE TABLE `clientConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, `riskTolerance` int(11) DEFAULT NULL COMMENT 'Maximo riesgo de un cliente para preparar su pedido', `maxCreditRows` int(11) DEFAULT NULL COMMENT 'Máximo número de registros a mantener en la tabla clientCredit', - `maxPriceIncreasingRatio` decimal(2,2) NOT NULL DEFAULT '0.25' COMMENT 'máximo recobro permitido', + `maxPriceIncreasingRatio` decimal(2,2) NOT NULL DEFAULT 0.25 COMMENT 'máximo recobro permitido', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24359,10 +24501,10 @@ DROP TABLE IF EXISTS `clientContact`; CREATE TABLE `clientContact` ( `id` int(11) NOT NULL AUTO_INCREMENT, `clientFk` int(11) NOT NULL, - `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `phone` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `phone` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24376,21 +24518,21 @@ CREATE TABLE `clientCredit` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `clientFk` int(11) NOT NULL, `amount` double unsigned NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `workerFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `workers_fk_idx` (`workerFk`), KEY `credit_ClienteFk` (`clientFk`), CONSTRAINT `credit_ClienteFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `workers_fk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -24398,15 +24540,15 @@ DELIMITER ;; AFTER INSERT ON clientCredit FOR EACH ROW BEGIN - + DECLARE vSender VARCHAR(50); SELECT u.name INTO vSender FROM account.`user` u WHERE u.id = NEW.workerFk; - + IF vSender IN ('juanvi','pepe') THEN - + CALL `vn`.`mail_insert`('pako@verdnatura.es', NULL, CONCAT('ClientCredit ',vSender, ' ', NEW.clientFk, ' ' , NEW.amount, ' €'), @@ -24435,7 +24577,7 @@ CREATE TABLE `clientCreditLimit` ( PRIMARY KEY (`id`), KEY `clientCreditLimit_FK_idx` (`roleFk`), CONSTRAINT `clientCreditLimit_FK` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24453,7 +24595,7 @@ CREATE TABLE `clientDms` ( KEY `fk_clientes_gestdoc_1_idx` (`clientFk`), CONSTRAINT `clientDms_ibfk_2` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_clientes_gestdoc_3` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24472,7 +24614,7 @@ CREATE TABLE `clientItemCategory` ( KEY `clientItemCategory_FK_1` (`itemCategoryFk`), CONSTRAINT `clientItemCategory_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientItemCategory_FK_1` FOREIGN KEY (`itemCategoryFk`) REFERENCES `itemCategory` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24484,16 +24626,16 @@ DROP TABLE IF EXISTS `clientItemType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `clientItemType` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `clientFk` int(11) NOT NULL, - `itemTypeFk` varchar(3) COLLATE utf8_unicode_ci NOT NULL, - `isAllowed` tinyint(1) DEFAULT '0', + `itemTypeFk` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, + `isAllowed` tinyint(1) DEFAULT 0, PRIMARY KEY (`id`), KEY `clientItemType_FK` (`clientFk`), KEY `clientItemType_FK_1` (`itemTypeFk`), CONSTRAINT `clientItemType_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientItemType_FK_1` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`code`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='son familias de productos que se quieren sustraer a la oferta del cliente'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='son familias de productos que se quieren sustraer a la oferta del cliente'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24507,20 +24649,20 @@ CREATE TABLE `clientLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `originFk` int(11) 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, - `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8_unicode_ci, - `newInstance` text COLLATE utf8_unicode_ci, + `action` set('insert','update','delete') COLLATE utf8mb3_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 DEFAULT NULL, + `changedModel` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `originFk` (`originFk`), KEY `userFk` (`userFk`), CONSTRAINT `clientLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24547,12 +24689,12 @@ DROP TABLE IF EXISTS `clientManaCache`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `clientManaCache` ( `clientFk` int(11) NOT NULL, - `mana` decimal(10,0) NOT NULL DEFAULT '0', + `mana` decimal(10,0) NOT NULL DEFAULT 0, `dated` date NOT NULL, PRIMARY KEY (`clientFk`,`dated`), KEY `manaCustomerIdx1` (`dated`), CONSTRAINT `cliente_fk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24566,15 +24708,15 @@ CREATE TABLE `clientObservation` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `clientFk` int(11) NOT NULL, `workerFk` int(10) unsigned DEFAULT NULL, - `text` text COLLATE utf8_unicode_ci NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `text` text COLLATE utf8mb3_unicode_ci NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `Id_Trabajador` (`workerFk`), KEY `Id_Cliente` (`clientFk`), KEY `clientObservation_created_IDX` (`created`) USING BTREE, CONSTRAINT `clientObservation_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientObservation_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24587,12 +24729,12 @@ DROP TABLE IF EXISTS `clientPackagingGifts`; CREATE TABLE `clientPackagingGifts` ( `clientFk` int(11) NOT NULL, `giftFk` int(11) NOT NULL, - `added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `added` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`clientFk`,`giftFk`), KEY `clientPackagingGifts_FK_1` (`giftFk`), CONSTRAINT `clientPackagingGifts_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`), CONSTRAINT `clientPackagingGifts_FK_1` FOREIGN KEY (`giftFk`) REFERENCES `packagingGifts` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24619,12 +24761,12 @@ DROP TABLE IF EXISTS `clientProtected`; CREATE TABLE `clientProtected` ( `clientFk` int(11) NOT NULL, `workerFk` int(10) unsigned NOT NULL, - `isValidated__` tinyint(1) NOT NULL DEFAULT '0', + `isValidated__` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`clientFk`), KEY `clientProtected_fk2_idx` (`workerFk`), CONSTRAINT `clientProtected_fk1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientProtected_fk2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de clientes y comerciales que no se van a ver afectados por las desagsignaciones mensuales automaticas'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Lista de clientes y comerciales que no se van a ver afectados por las desagsignaciones mensuales automaticas'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24635,14 +24777,14 @@ DROP TABLE IF EXISTS `clientRisk`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `clientRisk` ( - `clientFk` int(11) NOT NULL DEFAULT '0', - `companyFk` smallint(6) unsigned NOT NULL DEFAULT '0', + `clientFk` int(11) NOT NULL DEFAULT 0, + `companyFk` smallint(6) unsigned NOT NULL DEFAULT 0, `amount` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`clientFk`,`companyFk`), KEY `company_id` (`companyFk`), CONSTRAINT `clientRisk_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientRisk_ibfk_2` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Saldo de apertura < 2015-01-01'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Saldo de apertura < 2015-01-01'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24656,7 +24798,7 @@ CREATE TABLE `clientSample` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `clientFk` int(10) unsigned NOT NULL, `typeFk` int(10) unsigned NOT NULL, - `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` datetime NOT NULL DEFAULT current_timestamp(), `workerFk` int(10) unsigned NOT NULL, `balance` float NOT NULL, `companyFk` smallint(5) unsigned DEFAULT NULL, @@ -24664,7 +24806,7 @@ CREATE TABLE `clientSample` ( PRIMARY KEY (`id`), KEY `empresa_id` (`companyFk`), CONSTRAINT `clientSample_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24676,12 +24818,12 @@ DROP TABLE IF EXISTS `clientType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `clientType` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(20) CHARACTER SET utf8 NOT NULL, - `type` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `isCreatedAsServed` tinyint(1) DEFAULT '0', + `code` varchar(20) CHARACTER SET utf8mb3 NOT NULL, + `type` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `isCreatedAsServed` tinyint(1) DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Establece categorias para poder agrupar las ventas'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Establece categorias para poder agrupar las ventas'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24694,10 +24836,10 @@ DROP TABLE IF EXISTS `clientUnpaid`; CREATE TABLE `clientUnpaid` ( `clientFk` int(11) NOT NULL, `dated` date NOT NULL, - `amount` double DEFAULT '0', + `amount` double DEFAULT 0, PRIMARY KEY (`clientFk`), CONSTRAINT `clientUnpaid_clientFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24714,7 +24856,7 @@ CREATE TABLE `clientYoke` ( KEY `clientYoke_fk2_idx` (`rightOx`), CONSTRAINT `clientYoke_fk1` FOREIGN KEY (`leftOx`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientYoke_fk2` FOREIGN KEY (`rightOx`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='emparejamiento de clientes a efectos de precios'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='emparejamiento de clientes a efectos de precios'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24727,19 +24869,19 @@ DROP TABLE IF EXISTS `cmr`; CREATE TABLE `cmr` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ticketFk` int(11) DEFAULT NULL, - `truckPlate` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, - `observations` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `senderInstruccions` varchar(255) COLLATE utf8_unicode_ci DEFAULT 'Flowers 4º C. Plants 14º C', - `paymentInstruccions` varchar(255) COLLATE utf8_unicode_ci DEFAULT 'Carriage paid', - `specialAgreements` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `truckPlate` varchar(30) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `observations` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `senderInstruccions` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT 'Flowers 4º C. Plants 14º C', + `paymentInstruccions` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT 'Carriage paid', + `specialAgreements` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `created` timestamp NULL DEFAULT current_timestamp(), `companyFk` smallint(5) unsigned DEFAULT NULL, `addressToFk` int(11) DEFAULT NULL, `addressFromFk` int(11) DEFAULT NULL, `supplierFk` int(11) DEFAULT NULL, - `packagesList` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `merchandiseDetail` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `state` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `packagesList` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `merchandiseDetail` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `state` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `landed` datetime DEFAULT NULL COMMENT 'Hora de llegada a destino', `ead` datetime DEFAULT NULL COMMENT 'Estimated Arriving Date', PRIMARY KEY (`id`), @@ -24753,7 +24895,7 @@ CREATE TABLE `cmr` ( CONSTRAINT `cmr_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `cmr_fk2` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `cmr_fk3` FOREIGN KEY (`addressToFk`) REFERENCES `address` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -24772,23 +24914,23 @@ BEGIN DECLARE vLastSenderInstructions VARCHAR(255); DECLARE vLastId INT; DECLARE vCurrentAgency INT; - + SELECT am.agencyFk INTO vCurrentAgency FROM vn.agencyMode am JOIN vn.ticket t ON t.agencyModeFk = am.id WHERE t.id = NEW.ticketFk; - + SELECT MAX(cmr.id) INTO vLastId FROM cmr JOIN vn.ticket t ON t.id = cmr.ticketFk JOIN vn.agencyMode am ON am.id = t.agencyModeFk - WHERE am.agencyFk = vCurrentAgency + WHERE am.agencyFk = vCurrentAgency ; - + SELECT senderInstruccions INTO vLastSenderInstructions FROM cmr WHERE id = vLastId; - + SET NEW.senderInstruccions = vLastSenderInstructions; END */;; @@ -24807,8 +24949,8 @@ DROP TABLE IF EXISTS `cmrConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cmrConfig` ( `dayOfMonth` int(11) DEFAULT NULL, - `landingDays` tinyint(4) NOT NULL DEFAULT '1' -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + `landingDays` tinyint(4) NOT NULL DEFAULT 1 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24822,13 +24964,13 @@ CREATE TABLE `cmr_expeditionPallet` ( `id` int(11) NOT NULL AUTO_INCREMENT, `cmrFk` int(11) NOT NULL, `expeditionPalletFk` int(11) NOT NULL, - `scanned` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `scanned` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `cmr_expeditionPallet_fk1_idx` (`cmrFk`), KEY `cmr_expeditionPallet_fk2_idx` (`expeditionPalletFk`), CONSTRAINT `cmr_expeditionPallet_fk1` FOREIGN KEY (`cmrFk`) REFERENCES `cmr` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `cmr_expeditionPallet_fk2` FOREIGN KEY (`expeditionPalletFk`) REFERENCES `expeditionPallet` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='relaciona los cmr con los pallets de expediciones'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='relaciona los cmr con los pallets de expediciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24886,22 +25028,26 @@ DROP TABLE IF EXISTS `collection`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `collection` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `workerFk` int(10) unsigned DEFAULT NULL, `stateFk` tinyint(3) unsigned DEFAULT NULL, - `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `saleTotalCount` int(11) NOT NULL DEFAULT '0', - `salePickedCount` int(11) NOT NULL DEFAULT '0', - `trainFk` int(11) NOT NULL DEFAULT '1', + `itemPackingTypeFk` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `saleTotalCount` int(11) NOT NULL DEFAULT 0, + `salePickedCount` int(11) NOT NULL DEFAULT 0, + `trainFk` int(11) NOT NULL DEFAULT 1, + `sectorFk` int(11) DEFAULT NULL, + `wagons` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `ticketCollection_idx` (`workerFk`), KEY `collection_id2_idx` (`stateFk`), KEY `collection_FK` (`itemPackingTypeFk`), KEY `collectionTrain_Fk` (`trainFk`), + KEY `collectionSector_FK` (`sectorFk`), + CONSTRAINT `collectionSector_FK` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `collectionTrain_Fk` FOREIGN KEY (`trainFk`) REFERENCES `train` (`id`) ON UPDATE CASCADE, CONSTRAINT `collection_id2` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `ticketCollection` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -24916,33 +25062,33 @@ DELIMITER ;; BEFORE UPDATE ON `collection` FOR EACH ROW BEGIN - + DECLARE vStateFk INT; DECLARE vTotalLines INT; DECLARE vPickedLines INT; - IF NEW.saleTotalCount <= NEW.salePickedCount - AND (NEW.saleTotalCount != OLD.saleTotalCount + IF NEW.saleTotalCount <= NEW.salePickedCount + AND (NEW.saleTotalCount != OLD.saleTotalCount OR NEW.salePickedCount != OLD.salePickedCount) - THEN - + THEN + SELECT id INTO vStateFk - FROM vn.state + FROM vn.state WHERE code = 'PREPARED'; - + SET NEW.stateFk = vStateFk; - + END IF; - IF NEW.saleTotalCount > NEW.salePickedCount - AND (NEW.saleTotalCount != OLD.saleTotalCount OR NEW.salePickedCount != OLD.salePickedCount) THEN + IF NEW.saleTotalCount > NEW.salePickedCount + AND (NEW.saleTotalCount != OLD.saleTotalCount OR NEW.salePickedCount != OLD.salePickedCount) THEN SELECT id INTO vStateFk - FROM vn.state + FROM vn.state WHERE code = 'ON_PREPARATION'; - + SET NEW.stateFk = vStateFk; - + END IF; END */;; @@ -24961,59 +25107,16 @@ DROP TABLE IF EXISTS `collectionColors`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `collectionColors` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `shelve` int(11) NOT NULL DEFAULT '1', - `wagon` int(11) NOT NULL DEFAULT '1', - `trainFk` int(11) NOT NULL DEFAULT '1', + `code` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL, + `shelve` int(11) NOT NULL DEFAULT 1, + `wagon` int(11) NOT NULL DEFAULT 1, + `trainFk` int(11) NOT NULL DEFAULT 1, PRIMARY KEY (`id`), KEY `collectionColors_FK` (`trainFk`), CONSTRAINT `collectionColors_FK` FOREIGN KEY (`trainFk`) REFERENCES `train` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Recoge los colores para las baldas de las colecciones'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Recoge los colores para las baldas de las colecciones'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Temporary table structure for view `collectionSmartTag` --- - -DROP TABLE IF EXISTS `collectionSmartTag`; -/*!50001 DROP VIEW IF EXISTS `collectionSmartTag`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `collectionSmartTag` ( - `code` tinyint NOT NULL, - `ticketFk` tinyint NOT NULL, - `level` tinyint NOT NULL, - `wagon` tinyint NOT NULL, - `shelvingFk` tinyint NOT NULL, - `collectionFk` tinyint NOT NULL, - `agencyFk` tinyint NOT NULL, - `clientFk` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `collectionSmartTag2` --- - -DROP TABLE IF EXISTS `collectionSmartTag2`; -/*!50001 DROP VIEW IF EXISTS `collectionSmartTag2`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `collectionSmartTag2` ( - `code` tinyint NOT NULL, - `ticketFk` tinyint NOT NULL, - `level` tinyint NOT NULL, - `wagon` tinyint NOT NULL, - `shelvingFk` tinyint NOT NULL, - `collectionFk` tinyint NOT NULL, - `agencyFk` tinyint NOT NULL, - `clientFk` tinyint NOT NULL, - `worker` tinyint NOT NULL, - `shipped` tinyint NOT NULL, - `landed` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `collectionVolumetry` -- @@ -25023,18 +25126,18 @@ DROP TABLE IF EXISTS `collectionVolumetry`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `collectionVolumetry` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `level` int(10) unsigned NOT NULL DEFAULT '0', - `lines` int(10) unsigned NOT NULL DEFAULT '1', - `liters` int(10) unsigned NOT NULL DEFAULT '0', - `height` int(10) unsigned NOT NULL DEFAULT '20', - `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'H', - `trainFk` int(11) NOT NULL DEFAULT '1', + `level` int(10) unsigned NOT NULL DEFAULT 0, + `lines` int(10) unsigned NOT NULL DEFAULT 1, + `liters` int(10) unsigned NOT NULL DEFAULT 0, + `height` int(10) unsigned NOT NULL DEFAULT 20, + `itemPackingTypeFk` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'H', + `trainFk` int(11) NOT NULL DEFAULT 1, PRIMARY KEY (`id`), KEY `collectionVolumetry_FK` (`itemPackingTypeFk`), KEY `collectionVolumetry_FK_1` (`trainFk`), CONSTRAINT `collectionVolumetry_FK` FOREIGN KEY (`itemPackingTypeFk`) REFERENCES `itemPackingType` (`code`) ON UPDATE CASCADE, CONSTRAINT `collectionVolumetry_FK_1` FOREIGN KEY (`trainFk`) REFERENCES `train` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25045,7 +25148,7 @@ DROP TABLE IF EXISTS `commissionConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `commissionConfig` ( - `rate` decimal(5,4) NOT NULL DEFAULT '0.0000', + `rate` decimal(5,4) NOT NULL DEFAULT 0.0000, `plusTeamAmount` int(11) DEFAULT NULL, `plusNewBornAmount` int(11) DEFAULT NULL, `plusSalesAmount` int(11) DEFAULT NULL, @@ -25064,7 +25167,7 @@ CREATE TABLE `commissionConfig` ( `maxScoreNewClient` int(11) DEFAULT NULL, `scoreDifference` int(11) DEFAULT NULL, PRIMARY KEY (`rate`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25076,27 +25179,27 @@ DROP TABLE IF EXISTS `company`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `company` ( `id` smallint(5) unsigned NOT NULL, - `code` char(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `register` varchar(120) COLLATE utf8_unicode_ci NOT NULL, + `code` char(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `register` varchar(120) COLLATE utf8mb3_unicode_ci NOT NULL, `workerManagerFk` int(10) unsigned NOT NULL, `registered` date NOT NULL, `expired` date DEFAULT NULL, - `logo` longblob, - `isOfficial` tinyint(1) unsigned NOT NULL DEFAULT '1', - `hasCyc` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0', - `rgb` varchar(6) COLLATE utf8_unicode_ci NOT NULL, - `email` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `stamp` blob, - `created` timestamp NOT NULL ON UPDATE CURRENT_TIMESTAMP, + `logo` longblob DEFAULT NULL, + `isOfficial` tinyint(1) unsigned NOT NULL DEFAULT 1, + `hasCyc` tinyint(1) unsigned zerofill NOT NULL DEFAULT 0, + `rgb` varchar(6) COLLATE utf8mb3_unicode_ci NOT NULL, + `email` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL, + `stamp` blob DEFAULT NULL, + `created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE current_timestamp(), `clientFk` int(11) DEFAULT NULL, `sage200Company` int(2) DEFAULT NULL, `supplierAccountFk` mediumint(8) unsigned DEFAULT NULL, - `isDefaulter` tinyint(4) NOT NULL DEFAULT '0', - `companyGroupFk` int(11) NOT NULL DEFAULT '1' COMMENT 'usado para calcular los greuges ', + `isDefaulter` tinyint(4) NOT NULL DEFAULT 0, + `companyGroupFk` int(11) NOT NULL DEFAULT 1 COMMENT 'usado para calcular los greuges ', `companyCode` int(2) DEFAULT NULL COMMENT 'Campo para movConta', `companyCodeTest` int(2) DEFAULT NULL, - `footnotes` longtext COLLATE utf8_unicode_ci COMMENT 'pie de paginas en las facturas', - `phytosanitary` longtext COLLATE utf8_unicode_ci, + `footnotes` longtext COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'pie de paginas en las facturas', + `phytosanitary` longtext COLLATE utf8mb3_unicode_ci DEFAULT NULL, `fhAdminNumber` int(11) DEFAULT NULL COMMENT 'número de cliente en FloraHolland', PRIMARY KEY (`id`), UNIQUE KEY `companyCode_UNIQUE` (`code`), @@ -25109,7 +25212,7 @@ CREATE TABLE `company` ( 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, CONSTRAINT `fk_empresa_grupo` FOREIGN KEY (`companyGroupFk`) REFERENCES `companyGroup` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25121,9 +25224,9 @@ DROP TABLE IF EXISTS `companyGroup`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `companyGroup` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25138,7 +25241,7 @@ CREATE TABLE `comparativeFilterType` ( `itemTypeFk` int(11) NOT NULL, PRIMARY KEY (`comparativeFilterFk`,`itemTypeFk`), CONSTRAINT `comparativeFilterType_FK` FOREIGN KEY (`comparativeFilterFk`) REFERENCES `comparativeFilter` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25150,18 +25253,18 @@ DROP TABLE IF EXISTS `component`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `component` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `typeFk` int(11) NOT NULL, `classRate` smallint(6) DEFAULT NULL, `tax` double DEFAULT NULL, - `isRenewable` tinyint(2) NOT NULL DEFAULT '1', - `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `isRequired` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Son componentes imprescindibles en toda venta', + `isRenewable` tinyint(2) NOT NULL DEFAULT 1, + `code` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isRequired` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Son componentes imprescindibles en toda venta', PRIMARY KEY (`id`), KEY `series_componentes_idx` (`typeFk`), KEY `comp` (`classRate`), CONSTRAINT `serie_componente` FOREIGN KEY (`typeFk`) REFERENCES `componentType` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25173,13 +25276,13 @@ DROP TABLE IF EXISTS `componentType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `componentType` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `type` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `isBase` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Marca aquellas series que se utilizan para calcular el precio base de las ventas, a efectos estadisticos', - `isMargin` tinyint(4) NOT NULL DEFAULT '0', - `code` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `type` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `isBase` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Marca aquellas series que se utilizan para calcular el precio base de las ventas, a efectos estadisticos', + `isMargin` tinyint(4) NOT NULL DEFAULT 0, + `code` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `Serie_UNIQUE` (`type`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Permite organizar de forma ordenada los distintos componentes'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Permite organizar de forma ordenada los distintos componentes'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25191,9 +25294,9 @@ DROP TABLE IF EXISTS `confectionType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `confectionType` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25206,52 +25309,52 @@ DROP TABLE IF EXISTS `config`; CREATE TABLE `config` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ochoa` int(10) unsigned NOT NULL, - `invoiceOutFk` int(11) DEFAULT '0', - `bookFk__` int(11) DEFAULT '0', - `serialAFk__` int(11) DEFAULT '0', - `serialEFk__` int(11) DEFAULT '0', - `serialRFk__` int(11) DEFAULT '0', - `serialCFk__` int(11) DEFAULT '0', + `invoiceOutFk` int(11) DEFAULT 0, + `bookFk__` int(11) DEFAULT 0, + `serialAFk__` int(11) DEFAULT 0, + `serialEFk__` int(11) DEFAULT 0, + `serialRFk__` int(11) DEFAULT 0, + `serialCFk__` int(11) DEFAULT 0, `serialHFk__` int(11) NOT NULL, - `serialPFk__` int(11) DEFAULT '0', - `serialTFk__` int(11) DEFAULT '0', + `serialPFk__` int(11) DEFAULT 0, + `serialTFk__` int(11) DEFAULT 0, `inventoried` datetime DEFAULT NULL, - `serialMFk__` int(11) DEFAULT '0', - `itemLog` int(11) DEFAULT '0', + `serialMFk__` int(11) DEFAULT 0, + `itemLog` int(11) DEFAULT 0, `weekGoal` int(11) DEFAULT NULL, - `photosPath` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `cashBoxNumber` int(11) DEFAULT '0', - `redCode` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `photosPath` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `cashBoxNumber` int(11) DEFAULT 0, + `redCode` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `TabletTime` datetime DEFAULT NULL, - `t0` int(11) NOT NULL DEFAULT '0', - `t1` int(11) NOT NULL DEFAULT '0', - `t2` int(11) NOT NULL DEFAULT '0', - `t3` int(11) NOT NULL DEFAULT '0', - `cc` double NOT NULL DEFAULT '0', - `palet` double NOT NULL DEFAULT '0', + `t0` int(11) NOT NULL DEFAULT 0, + `t1` int(11) NOT NULL DEFAULT 0, + `t2` int(11) NOT NULL DEFAULT 0, + `t3` int(11) NOT NULL DEFAULT 0, + `cc` double NOT NULL DEFAULT 0, + `palet` double NOT NULL DEFAULT 0, `campaign` datetime NOT NULL, `campaignLife` tinyint(3) unsigned NOT NULL, `truckDays` tinyint(3) unsigned NOT NULL, `transportCharges` double NOT NULL, - `escanerPath` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + `escanerPath` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, `printedTurn` int(4) DEFAULT NULL, - `truckLength` int(11) DEFAULT '24', + `truckLength` int(11) DEFAULT 24, `fuelConsumption` int(11) DEFAULT NULL, `petrol` decimal(10,1) DEFAULT NULL, `maintenance` decimal(10,1) DEFAULT NULL, `hourPrice` decimal(10,1) DEFAULT NULL, `meterPrice` decimal(10,1) DEFAULT NULL, `kmPrice` decimal(10,1) DEFAULT NULL, - `routeOption` int(11) DEFAULT '1', - `dbproduccion` tinyint(1) NOT NULL DEFAULT '1', - `mdbServer` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `fakeEmail` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `defaultersMaxAmount` int(10) DEFAULT '200' COMMENT 'maxima deuda permitida a partir de la cual se bloquea a un usuario', + `routeOption` int(11) DEFAULT 1, + `dbproduccion` tinyint(1) NOT NULL DEFAULT 1, + `mdbServer` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `fakeEmail` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `defaultersMaxAmount` int(10) DEFAULT 200 COMMENT 'maxima deuda permitida a partir de la cual se bloquea a un usuario', `ASIEN` bigint(20) DEFAULT NULL, - `dayStartingHour` int(11) NOT NULL DEFAULT '3' COMMENT 'Hora a la que empieza una nueva jornada de producción', + `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; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25263,9 +25366,9 @@ DROP TABLE IF EXISTS `contactChannel`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `contactChannel` ( `id` smallint(6) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Canal por el que nos ha conocido un cliente y se ha dado de'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Canal por el que nos ha conocido un cliente y se ha dado de'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25277,11 +25380,11 @@ DROP TABLE IF EXISTS `continent`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `continent` ( `id` tinyint(4) NOT NULL AUTO_INCREMENT, - `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `code` varchar(2) CHARACTER SET utf8 NOT NULL, + `name` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `code` varchar(2) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `continent_name_uindex` (`name`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='World continents'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='World continents'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25296,9 +25399,9 @@ CREATE TABLE `contratos_subvencion_270619` ( `workerFk` int(10) unsigned NOT NULL, `cod_centroFk` int(11) NOT NULL, `CodContratoFk` int(11) NOT NULL, - `journey` decimal(5,2) NOT NULL DEFAULT '8.00', - `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `nif` varchar(12) COLLATE utf8_unicode_ci NOT NULL, + `journey` decimal(5,2) NOT NULL DEFAULT 8.00, + `name` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `nif` varchar(12) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), KEY `contratos_subvencion_270619_fk2_idx` (`cod_centroFk`), KEY `contratos_subvencion_270619_fk3_idx` (`CodContratoFk`), @@ -25306,7 +25409,7 @@ CREATE TABLE `contratos_subvencion_270619` ( CONSTRAINT `contratos_subvencion_270619_fk1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `contratos_subvencion_270619_fk2` FOREIGN KEY (`cod_centroFk`) REFERENCES `vn2008`.`payroll_centros` (`cod_centro`) ON UPDATE CASCADE, CONSTRAINT `contratos_subvencion_270619_fk3` FOREIGN KEY (`CodContratoFk`) REFERENCES `vn2008`.`payroll_contratos__` (`CodContrato`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Segun los informes de vida laboral aportados por la SS'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Segun los informes de vida laboral aportados por la SS'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25319,20 +25422,20 @@ DROP TABLE IF EXISTS `conveyor`; CREATE TABLE `conveyor` ( `id` int(11) NOT NULL AUTO_INCREMENT, `typeFk` int(11) NOT NULL, - `stratum` int(11) NOT NULL DEFAULT '0', + `stratum` int(11) NOT NULL DEFAULT 0, `length` int(11) DEFAULT NULL, `width` int(11) DEFAULT NULL, `height` int(11) DEFAULT NULL, `x` int(11) DEFAULT NULL, `y` int(11) DEFAULT NULL, - `freeSpace` int(11) NOT NULL DEFAULT '0', - `isBusy` tinyint(1) NOT NULL DEFAULT '0', + `freeSpace` int(11) NOT NULL DEFAULT 0, + `isBusy` tinyint(1) NOT NULL DEFAULT 0, `tandem` int(11) DEFAULT NULL COMMENT 'agrupa conveyors para dividir las cajas por tipo en una misma ruta', `conveyorBuildingClassFk` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `conveyor_fk1_idx` (`typeFk`), CONSTRAINT `conveyor_fk1` FOREIGN KEY (`typeFk`) REFERENCES `conveyorType` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25344,11 +25447,11 @@ DROP TABLE IF EXISTS `conveyorBuildingClass`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `conveyorBuildingClass` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `priority` int(11) NOT NULL DEFAULT '0', + `description` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `priority` int(11) NOT NULL DEFAULT 0, `weightThreshold` int(11) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tipo de caja para el montaje de pallets'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tipo de caja para el montaje de pallets'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25360,13 +25463,13 @@ DROP TABLE IF EXISTS `conveyorConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `conveyorConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `itemName` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `itemName` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `length` int(11) DEFAULT NULL, `width` int(11) DEFAULT NULL, `height` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `itemName_UNIQUE` (`itemName`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25379,26 +25482,26 @@ DROP TABLE IF EXISTS `conveyorExpedition`; CREATE TABLE `conveyorExpedition` ( `expeditionFk` int(11) NOT NULL, `conveyorFk` int(11) DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `conveyorBuildingClassFk` int(11) NOT NULL DEFAULT '1', - `length` int(11) NOT NULL DEFAULT '1', - `width` int(11) NOT NULL DEFAULT '1', - `height` int(11) NOT NULL DEFAULT '1', - `x` int(11) NOT NULL DEFAULT '18100', - `y` int(11) NOT NULL DEFAULT '1', + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `conveyorBuildingClassFk` int(11) NOT NULL DEFAULT 1, + `length` int(11) NOT NULL DEFAULT 1, + `width` int(11) NOT NULL DEFAULT 1, + `height` int(11) NOT NULL DEFAULT 1, + `x` int(11) NOT NULL DEFAULT 18100, + `y` int(11) NOT NULL DEFAULT 1, `routeFk` int(11) NOT NULL, - `isIn` tinyint(4) NOT NULL DEFAULT '0', + `isIn` tinyint(4) NOT NULL DEFAULT 0, `productionMinute` int(11) DEFAULT NULL, - `isOut` tinyint(4) NOT NULL DEFAULT '0', - `truck` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `isOut` tinyint(4) NOT NULL DEFAULT 0, + `truck` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `criterion` int(11) DEFAULT NULL, - `isHeavy` tinyint(1) NOT NULL DEFAULT '1', + `isHeavy` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY (`expeditionFk`), KEY `conveyorExpedition_fk1_idx` (`conveyorFk`), KEY `conveyorExpedition_fk2_idx` (`conveyorBuildingClassFk`), CONSTRAINT `conveyorExpedition_fk1` FOREIGN KEY (`conveyorFk`) REFERENCES `conveyor` (`id`) ON UPDATE CASCADE, CONSTRAINT `conveyorExpedition_fk2` FOREIGN KEY (`conveyorBuildingClassFk`) REFERENCES `conveyorBuildingClass` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25409,12 +25512,12 @@ DROP TABLE IF EXISTS `conveyorMode`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `conveyorMode` ( - `code` varchar(20) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL, `saturacion` int(11) NOT NULL, `gap` int(11) NOT NULL, - `isActive` tinyint(4) NOT NULL DEFAULT '0', + `isActive` tinyint(4) NOT NULL DEFAULT 0, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25426,10 +25529,10 @@ DROP TABLE IF EXISTS `conveyorType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `conveyorType` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `color` int(11) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25440,11 +25543,11 @@ DROP TABLE IF EXISTS `corridor`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `corridor` ( - `code` varchar(1) COLLATE utf8_unicode_ci NOT NULL COMMENT 'letra que da nombre al pasillo', - `isAscendent` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'TRUE cuando se prepara de menor a mayor, FALSE cuando es a la inversa', + `code` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'letra que da nombre al pasillo', + `isAscendent` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'TRUE cuando se prepara de menor a mayor, FALSE cuando es a la inversa', `prepOrder` int(10) unsigned NOT NULL COMMENT 'orden de preparacion de los pasillos', PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='establece el orden y sentido de preparacion de los pasillos del parking'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='establece el orden y sentido de preparacion de los pasillos del parking'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25456,14 +25559,14 @@ DROP TABLE IF EXISTS `country`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `country` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `country` varchar(25) COLLATE utf8_unicode_ci NOT NULL, - `CEE` tinyint(1) NOT NULL DEFAULT '1', - `code` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, - `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT '1', + `country` varchar(25) COLLATE utf8mb3_unicode_ci NOT NULL, + `CEE` tinyint(1) NOT NULL DEFAULT 1, + `code` varchar(2) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT 1, `politicalCountryFk` mediumint(8) unsigned NOT NULL COMMENT 'Pais Real(apaño por culpa del España Exento)', `geoFk` int(11) DEFAULT NULL, - `hasDailyInvoice` tinyint(4) NOT NULL DEFAULT '0', - `isUeeMember` tinyint(4) NOT NULL DEFAULT '0', + `hasDailyInvoice` tinyint(4) NOT NULL DEFAULT 0, + `isUeeMember` tinyint(4) NOT NULL DEFAULT 0, `ibanLength` tinyint(4) DEFAULT NULL, `continentFk` tinyint(4) DEFAULT NULL, `a3Code` int(11) DEFAULT NULL COMMENT 'Código país para a3', @@ -25477,7 +25580,7 @@ CREATE TABLE `country` ( CONSTRAINT `country_FK` FOREIGN KEY (`politicalCountryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, CONSTRAINT `country_FK_1` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON UPDATE CASCADE, CONSTRAINT `currency_id_fk` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -25512,8 +25615,7 @@ DELIMITER ;; AFTER INSERT ON `country` FOR EACH ROW BEGIN - - UPDATE sage.Naciones + UPDATE sage.Naciones SET countryFk = NEW.id WHERE Nacion = NEW.country; @@ -25522,12 +25624,9 @@ BEGIN '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) + CONCAT('Se ha insertado un nuevo país en la tabla vn.conuntry. Para el correcto funcionamiento del sistema \n\t\t\t\tde contabilidad es necesario actualizar la columna sage.Naciones.countryFk con el valor del nuevo país. \n\t\t\t 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 */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -25609,9 +25708,9 @@ DROP TABLE IF EXISTS `cplusCorrectingType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cplusCorrectingType` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25623,9 +25722,9 @@ DROP TABLE IF EXISTS `cplusInvoiceType472`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cplusInvoiceType472` ( `id` int(10) unsigned NOT NULL, - `description` varchar(255) CHARACTER SET utf8 NOT NULL, + `description` varchar(255) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='(*18) TIPO FACTURA (Asientos)SOPORTADO – DEDUCIBLE (472)'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='(*18) TIPO FACTURA (Asientos)SOPORTADO – DEDUCIBLE (472)'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25637,9 +25736,9 @@ DROP TABLE IF EXISTS `cplusInvoiceType477`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cplusInvoiceType477` ( `id` int(10) unsigned NOT NULL, - `description` varchar(255) CHARACTER SET utf8 NOT NULL, + `description` varchar(255) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='(*18) TIPO FACTURA (Asientos)REPERCUTIDO - DEVENGADO (477)'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='(*18) TIPO FACTURA (Asientos)REPERCUTIDO - DEVENGADO (477)'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25651,9 +25750,9 @@ DROP TABLE IF EXISTS `cplusRectificationType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cplusRectificationType` ( `id` int(10) unsigned NOT NULL, - `description` varchar(255) CHARACTER SET utf8 NOT NULL, + `description` varchar(255) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='(*20) TIPO RECTIFICATIVA (Asientos)'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='(*20) TIPO RECTIFICATIVA (Asientos)'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25665,9 +25764,9 @@ DROP TABLE IF EXISTS `cplusSubjectOp`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cplusSubjectOp` ( `id` int(10) unsigned NOT NULL, - `description` varchar(255) CHARACTER SET utf8 NOT NULL, + `description` varchar(255) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='(*17) TIPO OPERACIÓN SUJETA/NO SUJETA (Asientos)'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='(*17) TIPO OPERACIÓN SUJETA/NO SUJETA (Asientos)'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25679,9 +25778,9 @@ DROP TABLE IF EXISTS `cplusTaxBreak`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cplusTaxBreak` ( `id` int(10) unsigned NOT NULL, - `description` varchar(255) CHARACTER SET utf8 NOT NULL, + `description` varchar(255) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='(*16) TIPO EXENCIÓN (Asientos)'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='(*16) TIPO EXENCIÓN (Asientos)'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25693,9 +25792,9 @@ DROP TABLE IF EXISTS `cplusTerIdNif`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cplusTerIdNif` ( `id` int(11) NOT NULL, - `description` varchar(255) CHARACTER SET utf8 NOT NULL, + `description` varchar(255) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25707,9 +25806,9 @@ DROP TABLE IF EXISTS `cplusTrascendency472`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cplusTrascendency472` ( `id` int(10) unsigned NOT NULL, - `description` varchar(255) CHARACTER SET utf8 NOT NULL, + `description` varchar(255) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='(*15) CLAVE DE RÉGIMEN ESPECIAL O TRASCENDENCIA(Asientos)SOPORTADO – DEDUCIBLE (472)'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='(*15) CLAVE DE RÉGIMEN ESPECIAL O TRASCENDENCIA(Asientos)SOPORTADO – DEDUCIBLE (472)'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25721,9 +25820,9 @@ DROP TABLE IF EXISTS `cplusTrascendency477`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cplusTrascendency477` ( `id` int(10) unsigned NOT NULL, - `description` varchar(255) CHARACTER SET utf8 NOT NULL, + `description` varchar(255) CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='(*15) CLAVE DE RÉGIMEN ESPECIAL O TRASCENDENCIA(Asientos) REPERCUTIDO - DEVENGADO (477)'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='(*15) CLAVE DE RÉGIMEN ESPECIAL O TRASCENDENCIA(Asientos) REPERCUTIDO - DEVENGADO (477)'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25742,7 +25841,7 @@ CREATE TABLE `creditClassification` ( KEY `creditClassifClientFk_idx` (`client`), KEY `creditClassifdateEnd_idx` (`dateEnd`), CONSTRAINT `creditClassifClientFk` FOREIGN KEY (`client`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -25782,7 +25881,7 @@ CREATE TABLE `creditInsurance` ( `id` int(11) NOT NULL AUTO_INCREMENT, `creditClassification` int(11) DEFAULT NULL, `credit` int(11) DEFAULT NULL, - `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `creationDate` timestamp NOT NULL DEFAULT current_timestamp(), `grade` tinyint(1) DEFAULT NULL, `creditClassificationFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), @@ -25790,14 +25889,14 @@ CREATE TABLE `creditInsurance` ( KEY `creditInsurance_creditClassificationFk` (`creditClassificationFk`), CONSTRAINT `CreditInsurance_Fk1` FOREIGN KEY (`creditClassification`) REFERENCES `creditClassification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `creditInsurance_creditClassificationFk` FOREIGN KEY (`creditClassificationFk`) REFERENCES `creditClassification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; /*!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 character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -25830,7 +25929,7 @@ BEGIN UPDATE `client` c JOIN vn.creditClassification cc ON cc.client = c.id SET creditInsurance = NEW.credit WHERE cc.id = NEW.creditClassification; - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -25847,12 +25946,12 @@ DROP TABLE IF EXISTS `currency`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `currency` ( `id` tinyint(3) unsigned NOT NULL, - `code` varchar(3) COLLATE utf8_unicode_ci NOT NULL, - `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `ratio` double NOT NULL DEFAULT '1', + `code` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `ratio` double NOT NULL DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `Moneda_UNIQUE` (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25888,7 +25987,7 @@ CREATE TABLE `dayMinute` ( PRIMARY KEY (`id`), KEY `dayMinute_ix1` (`hh`), KEY `dayMinute_ix2` (`mm`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='sirve de soporte para el calculo presencial de los trabjadores'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='sirve de soporte para el calculo presencial de los trabjadores'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25917,7 +26016,7 @@ DROP TABLE IF EXISTS `delivery`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `delivery` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `longitude` decimal(11,7) DEFAULT NULL, `latitude` decimal(11,7) DEFAULT NULL, `dated` datetime DEFAULT NULL, @@ -25925,7 +26024,7 @@ CREATE TABLE `delivery` ( PRIMARY KEY (`id`), KEY `delivery_FK` (`addressFk`), CONSTRAINT `delivery_FK` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Informa de los datos geográficos y temporales de las entregas de los repartidores'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Informa de los datos geográficos y temporales de las entregas de los repartidores'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25937,11 +26036,11 @@ DROP TABLE IF EXISTS `deliveryMethod`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `deliveryMethod` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `code` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code` (`code`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25953,10 +26052,10 @@ DROP TABLE IF EXISTS `deliveryPoint`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `deliveryPoint` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `ubication` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `ubication` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25967,18 +26066,18 @@ DROP TABLE IF EXISTS `delivery_zip`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `delivery_zip` ( - `postal_code` varchar(2) COLLATE utf8_unicode_ci NOT NULL, - `country_code` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, - `place_name` varchar(150) COLLATE utf8_unicode_ci NOT NULL, - `admin_name1` varchar(150) COLLATE utf8_unicode_ci NOT NULL, - `code_name1` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `admin_name2` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `code_name2` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, - `admin_name3` varchar(150) COLLATE utf8_unicode_ci NOT NULL, - `code_name3` varchar(5) COLLATE utf8_unicode_ci NOT NULL, - `latitude` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `longitude` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `accuracy` varchar(1) COLLATE utf8_unicode_ci NOT NULL, + `postal_code` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL, + `country_code` varchar(5) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `place_name` varchar(150) COLLATE utf8mb3_unicode_ci NOT NULL, + `admin_name1` varchar(150) COLLATE utf8mb3_unicode_ci NOT NULL, + `code_name1` varchar(150) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `admin_name2` varchar(150) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `code_name2` varchar(2) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `admin_name3` varchar(150) COLLATE utf8mb3_unicode_ci NOT NULL, + `code_name3` varchar(5) COLLATE utf8mb3_unicode_ci NOT NULL, + `latitude` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, + `longitude` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, + `accuracy` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL, `delivery_zipPK` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`delivery_zipPK`), KEY `country_code_idx` (`country_code`), @@ -25986,7 +26085,7 @@ CREATE TABLE `delivery_zip` ( KEY `postal_code_idx` (`postal_code`), KEY `admin_name3_idx` (`admin_name3`), KEY `admin_name2_idx` (`admin_name2`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25998,8 +26097,8 @@ DROP TABLE IF EXISTS `department`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `department` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `lft` int(11) DEFAULT NULL, `rgt` int(11) DEFAULT NULL, `workerFk` int(10) unsigned DEFAULT NULL COMMENT 'Id_Trabajador es el jefe del departamento', @@ -26007,19 +26106,19 @@ CREATE TABLE `department` ( `bossFk__` int(11) DEFAULT NULL, `x__` int(11) DEFAULT NULL, `y__` int(11) DEFAULT NULL, - `isProduction` tinyint(4) NOT NULL DEFAULT '0', - `isSelected` tinyint(1) NOT NULL DEFAULT '0', - `depth` int(11) NOT NULL DEFAULT '0', - `sons` decimal(10,0) NOT NULL DEFAULT '0', - `parentFk` int(11) DEFAULT '1', - `path` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `chatName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `isTeleworking` tinyint(1) DEFAULT '0', - `notificationEmail` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `hasToRefill` tinyint(1) DEFAULT '0' COMMENT 'Rellenar días sin fichadas presenciales', - `hasToSendMail` tinyint(1) DEFAULT '0' COMMENT 'Para el envio de mail en el procedimiento workerTimeControl_sendMail()', - `hasToCheckLogin` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Para comprobar en el login de la app', - `hasToMistake` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indica si al departamento pueden serles puestos errores', + `isProduction` tinyint(4) NOT NULL DEFAULT 0, + `isSelected` tinyint(1) NOT NULL DEFAULT 0, + `depth` int(11) NOT NULL DEFAULT 0, + `sons` decimal(10,0) NOT NULL DEFAULT 0, + `parentFk` int(11) DEFAULT 1, + `path` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `chatName` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isTeleworking` tinyint(1) DEFAULT 0, + `notificationEmail` varchar(150) COLLATE utf8mb3_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()', + `hasToCheckLogin` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Para comprobar en el login de la app', + `hasToMistake` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si al departamento pueden serles puestos errores', `clientFk` int(11) DEFAULT NULL COMMENT 'Cuenta de cliente que se utiliza para los compras de consumo departamental', PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`), @@ -26031,7 +26130,7 @@ CREATE TABLE `department` ( CONSTRAINT `department_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `department_FK_1` FOREIGN KEY (`parentFk`) REFERENCES `department` (`id`), CONSTRAINT `fk_department_Trabajadores1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -26078,22 +26177,22 @@ 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' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER department_beforeDelete -BEFORE DELETE -ON department FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`department_beforeDelete` + BEFORE DELETE ON `department` + FOR EACH ROW BEGIN - UPDATE postgresql.business_labour bl - JOIN vn.department d ON d.id = bl.department_id - SET bl.department_id = d.parentFk - WHERE bl.department_id = OLD.id; - + UPDATE vn.business b + JOIN vn.department d ON d.id = b.departmentFk + SET b.departmentFk = d.parentFk + WHERE b.departmentFk = OLD.id; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -26103,23 +26202,23 @@ 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' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`department_afterDelete` AFTER DELETE ON `department` FOR EACH ROW BEGIN - + UPDATE vn.department_recalc SET isChanged = TRUE; - - UPDATE postgresql.business_labour bl - JOIN vn.department d ON d.id = bl.department_id - SET bl.department_id = d.parentFk - WHERE bl.department_id = OLD.id; + + UPDATE vn.business b + JOIN vn.department d ON d.id = b.departmentFk + SET b.departmentFk = d.parentFk + WHERE b.departmentFk = OLD.id; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -26152,7 +26251,7 @@ CREATE TABLE `department_recalc` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `isChanged` tinyint(4) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26164,13 +26263,13 @@ DROP TABLE IF EXISTS `device`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `device` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `sn` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `model` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `sn` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `model` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `userFk` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `device_fk1_idx` (`userFk`), CONSTRAINT `device_fk1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26182,15 +26281,15 @@ DROP TABLE IF EXISTS `deviceLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `deviceLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `android_id` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `android_id` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, `userFk` int(10) unsigned 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, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `nameApp` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `versionApp` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `deviceLog_FK` (`userFk`), CONSTRAINT `deviceLog_FK` FOREIGN KEY (`userFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26202,13 +26301,13 @@ DROP TABLE IF EXISTS `deviceProduction`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `deviceProduction` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `imei` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `modelFk` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `macWifi` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `serialNumber` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `imei` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `modelFk` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `macWifi` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `serialNumber` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `departmentFk` int(11) DEFAULT NULL, - `isOutOfService` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0: Ok - 1: No disponible - 2: Sat', - `android_id` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `isOutOfService` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0: Ok - 1: No disponible - 2: Sat', + `android_id` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `purchased` date NOT NULL DEFAULT '1900-01-01' COMMENT 'Fecha de compra', PRIMARY KEY (`id`), UNIQUE KEY `device_id_UNIQUE` (`id`), @@ -26218,7 +26317,7 @@ CREATE TABLE `deviceProduction` ( KEY `departmentFgn` (`departmentFk`), CONSTRAINT `departmentFgn` FOREIGN KEY (`departmentFk`) REFERENCES `department` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `deviceProductionModelsFgn` FOREIGN KEY (`modelFk`) REFERENCES `deviceProductionModels` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26230,10 +26329,10 @@ DROP TABLE IF EXISTS `deviceProductionConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `deviceProductionConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `isAllUsersallowed` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Permite que cualquier usuario pueda loguearse', - `isTractorHuntingMode` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Habilita el modo cazador para usuarios que no se han logeado un tractor para sacar', + `isAllUsersallowed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Permite que cualquier usuario pueda loguearse', + `isTractorHuntingMode` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Habilita el modo cazador para usuarios que no se han logeado un tractor para sacar', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -26269,9 +26368,9 @@ DROP TABLE IF EXISTS `deviceProductionModels`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `deviceProductionModels` ( - `code` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26284,13 +26383,13 @@ DROP TABLE IF EXISTS `deviceProductionUser`; CREATE TABLE `deviceProductionUser` ( `deviceProductionFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`deviceProductionFk`), UNIQUE KEY `deviceProductionUser_UN` (`userFk`), KEY `userFgn_idx` (`userFk`), CONSTRAINT `deviceProductionUser_FK` FOREIGN KEY (`deviceProductionFk`) REFERENCES `deviceProduction` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `deviceProductionUser_PK` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26302,9 +26401,9 @@ DROP TABLE IF EXISTS `disabilityGrade`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `disabilityGrade` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Grados de discapacidad Modelo 145 IRPF', - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26316,17 +26415,17 @@ DROP TABLE IF EXISTS `dms`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `dms` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `dmsTypeFk` int(11) NOT NULL DEFAULT '1', - `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', + `dmsTypeFk` int(11) NOT NULL DEFAULT 1, + `reference` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `description` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, `hardCopyNumber` mediumint(8) unsigned DEFAULT NULL, - `contentType` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `file` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, - `hasFile` tinyint(4) NOT NULL DEFAULT '0', + `contentType` varchar(150) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `file` varchar(30) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `hasFile` tinyint(4) NOT NULL DEFAULT 0, `workerFk` int(10) unsigned DEFAULT NULL, - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `warehouseFk` smallint(5) unsigned DEFAULT '60', + `created` timestamp NULL DEFAULT current_timestamp(), + `warehouseFk` smallint(5) unsigned DEFAULT 60, PRIMARY KEY (`id`), UNIQUE KEY `emp_id` (`companyFk`,`hardCopyNumber`,`warehouseFk`), UNIQUE KEY `dms_hardCopyNumber_IDX` (`hardCopyNumber`,`warehouseFk`) USING BTREE, @@ -26337,7 +26436,7 @@ CREATE TABLE `dms` ( CONSTRAINT `dms_dmsTypeFk` FOREIGN KEY (`dmsTypeFk`) REFERENCES `dmsType` (`id`) ON UPDATE CASCADE, CONSTRAINT `dms_warehouseFk` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `dms_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='document managment system'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='document managment system'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -26354,20 +26453,20 @@ DELIMITER ;; BEGIN DECLARE vHardCopyNumber INT; DECLARE vDmsTypeCode INT; - + IF (SELECT NOT hasDms FROM warehouse WHERE id = NEW.warehouseFk) THEN CALL util.throw('this warehouse has not dms'); END IF; IF NEW.hasFile THEN - SELECT 1 + MAX(hardCopyNumber) INTO vHardCopyNumber - FROM dms + SELECT 1 + MAX(hardCopyNumber) INTO vHardCopyNumber + FROM dms WHERE warehouseFk = NEW.warehouseFk; - + SET NEW.hardCopyNumber = IFNULL(vHardCopyNumber,1); END IF; - - SELECT code INTO vDmsTypeCode + + SELECT code INTO vDmsTypeCode FROM dmsType WHERE NEW.dmsTypeFk = id; IF (vDmsTypeCode ='ticket') THEN UPDATE ticket SET isSigned = 1 WHERE id = NEW.reference; @@ -26381,9 +26480,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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -26392,24 +26491,24 @@ DELIMITER ;; FOR EACH ROW BEGIN DECLARE vHardCopyNumber INT; - + IF (NEW.hasFile <> 0) AND (OLD.hasFile = 0) AND (NEW.hardCopyNumber IS NULL) - OR + OR (NEW.hardCopyNumber = OLD.hardCopyNumber AND OLD.warehouseFk <> NEW.warehouseFk) THEN - - IF (SELECT NOT hasDms FROM warehouse WHERE id = NEW.warehouseFk) THEN + + IF (SELECT NOT hasDms FROM warehouse WHERE id = NEW.warehouseFk) THEN SET NEW.warehouseFk = (SELECT id FROM warehouse WHERE name = 'Algemesi'); END IF; - - SELECT 1 + MAX(hardCopyNumber) INTO vHardCopyNumber - FROM dms + + SELECT 1 + MAX(hardCopyNumber) INTO vHardCopyNumber + FROM dms WHERE warehouseFk = NEW.warehouseFk; - + SET NEW.hardCopyNumber = IFNULL(vHardCopyNumber,1); END IF; - + IF ((NEW.hardCopyNumber = 0) OR NEW.hardCopyNumber IS NULL) AND (OLD.hardCopyNumber <> 0) THEN - + SET NEW.hasFile = 0; END IF; END */;; @@ -26430,14 +26529,14 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`dms_beforeDelete` BEFORE DELETE ON `dms` FOR EACH ROW -BEGIN +BEGIN DECLARE vCanNotBeDeleted INT; - SELECT COUNT(*) INTO vCanNotBeDeleted - FROM dmsType dt - WHERE NOT (code <=> 'trash') + SELECT COUNT(*) INTO vCanNotBeDeleted + FROM dmsType dt + WHERE NOT (code <=> 'trash') AND dt.id = OLD.dmsTypeFk; - - IF vCanNotBeDeleted THEN + + IF vCanNotBeDeleted THEN CALL util.throw('A dms can not be deleted'); END IF; END */;; @@ -26457,12 +26556,12 @@ DROP TABLE IF EXISTS `dmsRecover`; CREATE TABLE `dmsRecover` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ticketFk` int(11) DEFAULT NULL, - `sign` text COLLATE utf8_unicode_ci, - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `sign` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `created` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `ticketFk_idx` (`ticketFk`), CONSTRAINT `ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26474,18 +26573,18 @@ DROP TABLE IF EXISTS `dmsType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `dmsType` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `path` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `path` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, `writeRoleFk` int(10) unsigned DEFAULT NULL, `readRoleFk` int(10) unsigned DEFAULT NULL, - `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `monthToDelete` int(10) unsigned DEFAULT NULL COMMENT 'Meses en el pasado para ir borrando registros, dejar a null para no borrarlos nunca', PRIMARY KEY (`id`), KEY `readRoleFk` (`readRoleFk`), KEY `writeRoleFk` (`writeRoleFk`), CONSTRAINT `readRoleFk` FOREIGN KEY (`readRoleFk`) REFERENCES `account`.`role` (`id`), CONSTRAINT `writeRoleFk` FOREIGN KEY (`writeRoleFk`) REFERENCES `account`.`role` (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26496,10 +26595,10 @@ DROP TABLE IF EXISTS `dock`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `dock` ( - `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `description` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `description` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Se utiliza para el panel de grafana: https://grafana.verdnatura.es/d/w9w3Uo-7z/'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Se utiliza para el panel de grafana: https://grafana.verdnatura.es/d/w9w3Uo-7z/'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26511,12 +26610,12 @@ DROP TABLE IF EXISTS `docuware`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `docuware` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `fileCabinetName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `dialogName` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `find` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `fileCabinetName` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `dialogName` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `find` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26528,10 +26627,10 @@ DROP TABLE IF EXISTS `docuwareConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `docuwareConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `url` varchar(75) COLLATE utf8_unicode_ci DEFAULT NULL, - `token` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL, + `url` varchar(75) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `token` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26543,7 +26642,7 @@ DROP TABLE IF EXISTS `dua`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `dua` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `awbFk` smallint(11) unsigned NOT NULL, `issued` date DEFAULT NULL, `operated` date DEFAULT NULL, @@ -26551,7 +26650,7 @@ CREATE TABLE `dua` ( `bookEntried` date DEFAULT NULL, `gestdocFk` int(11) DEFAULT NULL, `customsValue` decimal(10,2) DEFAULT NULL, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', + `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, `ASIEN` double DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`), @@ -26561,7 +26660,7 @@ CREATE TABLE `dua` ( CONSTRAINT `dua_fk1` FOREIGN KEY (`gestdocFk`) REFERENCES `dms` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `dua_fk2` FOREIGN KEY (`awbFk`) REFERENCES `awb` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `dua_fk4` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26582,7 +26681,7 @@ CREATE TABLE `duaEntry` ( KEY `fk_duaEntry_Entradas1_idx` (`entryFk`), CONSTRAINT `fk_duaEntry_Entradas1` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_duaEntry_dua1` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26596,13 +26695,13 @@ CREATE TABLE `duaIntrastat` ( `id` int(11) NOT NULL AUTO_INCREMENT, `duaFk` int(11) NOT NULL, `intrastatFk` int(8) unsigned NOT NULL, - `amount` decimal(10,2) NOT NULL DEFAULT '0.00', + `amount` decimal(10,2) NOT NULL DEFAULT 0.00, PRIMARY KEY (`id`), KEY `duaIntrastat_fk1_idx` (`intrastatFk`), KEY `duaIntrastat_fk2_idx` (`duaFk`), CONSTRAINT `duaIntrastat_fk1` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE, CONSTRAINT `duaIntrastat_fk2` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26622,7 +26721,7 @@ CREATE TABLE `duaInvoiceIn` ( KEY `duaInvoiceIn_fk2_idx` (`invoiceInFk`), CONSTRAINT `duaInvoiceIn_fk1` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `duaInvoiceIn_fk2` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Facturas asociadas a la declaración aduanera, básicamente la del agente transitario'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Facturas asociadas a la declaración aduanera, básicamente la del agente transitario'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26647,7 +26746,7 @@ CREATE TABLE `duaTax` ( CONSTRAINT `duaTax_fk1` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `duaTax_fk2` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `duaTax_fk3` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -26736,9 +26835,9 @@ DROP TABLE IF EXISTS `educationLevel`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `educationLevel` ( `id` smallint(6) NOT NULL, - `name` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Nivel de formación mismo de a3'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Nivel de formación mismo de a3'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26759,13 +26858,14 @@ CREATE TABLE `ektEntryAssign` ( `agencyModeFk` int(11) DEFAULT NULL, `supplierFk` int(11) DEFAULT NULL, `entryFk` int(11) DEFAULT NULL, - `ref` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `ref` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `addressFk` int(11) DEFAULT NULL, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, PRIMARY KEY (`id`), UNIQUE KEY `ektEntryAssign_ix1` (`kop`,`sub`,`pro`), KEY `ektEntryAssign_FK` (`addressFk`), CONSTRAINT `ektEntryAssign_FK` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='define las condiciones para asignar entradas a los ekt'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='define las condiciones para asignar entradas a los ekt'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26793,10 +26893,10 @@ DROP TABLE IF EXISTS `emergencyMedia`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `emergencyMedia` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `value` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Table to save all emergency phones', + `name` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `value` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'Table to save all emergency phones', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26808,10 +26908,10 @@ DROP TABLE IF EXISTS `energyInput`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `energyInput` ( `input` int(11) NOT NULL COMMENT 'The input number', - `description` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, `consumption` int(11) NOT NULL COMMENT 'Consumption in watts', PRIMARY KEY (`input`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Defines inputs and the power of each one'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines inputs and the power of each one'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26827,7 +26927,7 @@ CREATE TABLE `energyMeter` ( `activeTime` int(11) NOT NULL COMMENT 'Number of seconds active', `consumption` decimal(10,2) NOT NULL COMMENT 'Comsumption in watts', PRIMARY KEY (`input`,`period`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='History of consumption of each input with one hour intervals'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='History of consumption of each input with one hour intervals'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26839,24 +26939,24 @@ DROP TABLE IF EXISTS `entry`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `entry` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `supplierFk` int(11) NOT NULL DEFAULT '644', + `supplierFk` int(11) NOT NULL DEFAULT 644, `dated` datetime NOT NULL, - `ref` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `isBooked` tinyint(1) NOT NULL DEFAULT '0', - `isExcludedFromAvailable` tinyint(1) NOT NULL DEFAULT '0', - `notes` longtext COLLATE utf8_unicode_ci, - `isConfirmed` tinyint(1) NOT NULL DEFAULT '0', - `isOrdered` tinyint(1) NOT NULL DEFAULT '0', - `isRaid` tinyint(1) NOT NULL DEFAULT '0', - `commission` float DEFAULT '0', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `evaNotes` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `ref` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isBooked` tinyint(1) NOT NULL DEFAULT 0, + `isExcludedFromAvailable` tinyint(1) NOT NULL DEFAULT 0, + `notes` longtext COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isConfirmed` tinyint(1) NOT NULL DEFAULT 0, + `isOrdered` tinyint(1) NOT NULL DEFAULT 0, + `isRaid` tinyint(1) NOT NULL DEFAULT 0, + `commission` float DEFAULT 0, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `evaNotes` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `travelFk` int(11) unsigned DEFAULT NULL, - `currencyFk` tinyint(3) unsigned DEFAULT '1', - `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', + `currencyFk` tinyint(3) unsigned DEFAULT 1, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, `gestDocFk` int(11) DEFAULT NULL, `invoiceInFk` mediumint(8) unsigned DEFAULT NULL, - `isBlocked` tinyint(4) NOT NULL DEFAULT '0', + `isBlocked` tinyint(4) NOT NULL DEFAULT 0, `loadPriority` int(11) DEFAULT NULL, `kop` int(11) DEFAULT NULL, `sub` mediumint(8) unsigned DEFAULT NULL, @@ -26864,6 +26964,7 @@ CREATE TABLE `entry` ( `auction` int(11) DEFAULT NULL, `invoiceAmount` decimal(10,2) DEFAULT NULL, `buyerFk` int(10) unsigned DEFAULT NULL, + `typeFk` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'Tipo de entrada', PRIMARY KEY (`id`), KEY `Id_Proveedor` (`supplierFk`), KEY `Fecha` (`dated`), @@ -26872,12 +26973,14 @@ CREATE TABLE `entry` ( KEY `gestdoc_id` (`gestDocFk`), KEY `recibida_id` (`invoiceInFk`), KEY `entry_FK` (`buyerFk`), + KEY `entry_FK_1` (`typeFk`), CONSTRAINT `Entradas_fk8` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `entry_FK` FOREIGN KEY (`buyerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, + CONSTRAINT `entry_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `entryType` (`code`) ON UPDATE CASCADE, CONSTRAINT `entry_ibfk_1` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `entry_ibfk_6` FOREIGN KEY (`travelFk`) REFERENCES `travel` (`id`) ON UPDATE CASCADE, CONSTRAINT `entry_ibfk_7` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -26892,6 +26995,7 @@ DELIMITER ;; BEFORE INSERT ON `entry` FOR EACH ROW BEGIN + CALL supplier_checkIsActive(NEW.supplierFk); SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk); END */;; @@ -26912,7 +27016,7 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_afterInsert` AFTER INSERT ON `entry` FOR EACH ROW -BEGIN +BEGIN CALL travel_requestRecalc(NEW.travelFk); END */;; DELIMITER ; @@ -26952,7 +27056,7 @@ BEGIN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'A cloned entry cannot be moved to a travel with different warehouses'; END IF; - + IF NEW.travelFk IS NULL THEN SELECT COUNT(*) INTO vPrintedCount FROM buy @@ -26967,11 +27071,12 @@ BEGIN END IF; IF !(NEW.supplierFk <=> OLD.supplierFk) THEN + CALL supplier_checkIsActive(NEW.supplierFk); SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); END IF; IF !(NEW.travelFk <=> OLD.travelFk) - OR !(NEW.currencyFk <=> OLD.currencyFk) THEN + OR !(NEW.currencyFk <=> OLD.currencyFk) THEN SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk); END IF; @@ -27006,7 +27111,7 @@ BEGIN OR !(NEW.isRaid <=> OLD.isRaid) THEN CALL stock.log_add('entry', NEW.id, OLD.id); END IF; - + IF !(NEW.travelFk <=> OLD.travelFk) THEN CALL travel_requestRecalc(OLD.travelFk); CALL travel_requestRecalc(NEW.travelFk); @@ -27059,7 +27164,7 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_afterDelete` AFTER DELETE ON `entry` FOR EACH ROW -BEGIN +BEGIN CALL travel_requestRecalc(OLD.travelFk); END */;; DELIMITER ; @@ -27077,10 +27182,10 @@ DROP TABLE IF EXISTS `entryConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `entryConfig` ( `defaultEntry` int(11) NOT NULL, - `mailToNotify` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `inventorySupplierFk` int(11) DEFAULT '4', + `mailToNotify` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `inventorySupplierFk` int(11) DEFAULT 4, PRIMARY KEY (`defaultEntry`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27094,20 +27199,20 @@ CREATE TABLE `entryLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `originFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, - `action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL, - `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `description` text CHARACTER SET utf8, - `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8_unicode_ci, - `newInstance` text COLLATE utf8_unicode_ci, + `action` set('insert','update','delete') COLLATE utf8mb3_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 DEFAULT NULL, + `changedModel` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `logEntry_ibfk_1` (`originFk`), KEY `entryLog_ibfk_2` (`userFk`), CONSTRAINT `entryLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `entryLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27121,13 +27226,13 @@ CREATE TABLE `entryObservation` ( `id` int(11) NOT NULL AUTO_INCREMENT, `entryFk` int(11) NOT NULL, `observationTypeFk` tinyint(3) unsigned DEFAULT NULL, - `description` text COLLATE utf8_unicode_ci, + `description` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `entryFk_observationTypeFk_UNIQUE` (`entryFk`,`observationTypeFk`), KEY `observationType_id_observationTypeFk` (`observationTypeFk`), CONSTRAINT `entry_id_entryFk` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`), CONSTRAINT `observationType_id_observationTypeFk` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27144,7 +27249,21 @@ CREATE TABLE `entrySplit__` ( KEY `entrySplit_fk2_idx` (`delayedFk`), CONSTRAINT `entrySplit_fk1` FOREIGN KEY (`receivedFk`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `entrySplit_fk2` FOREIGN KEY (`delayedFk`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `entryType` +-- + +DROP TABLE IF EXISTS `entryType`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `entryType` ( + `code` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, + `description` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27158,7 +27277,7 @@ CREATE TABLE `entryVirtual` ( `entryFk` int(11) NOT NULL, PRIMARY KEY (`entryFk`), CONSTRAINT `entryVirtual_ibfk_1` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='entradas que se van moviendo automaticamente al futuro'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='entradas que se van moviendo automaticamente al futuro'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27169,12 +27288,12 @@ DROP TABLE IF EXISTS `envialiaAgency`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `envialiaAgency` ( - `id` varchar(6) COLLATE utf8_unicode_ci NOT NULL, - `route` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `agencyName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `id` varchar(6) COLLATE utf8mb3_unicode_ci NOT NULL, + `route` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `agencyName` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -27189,7 +27308,7 @@ DELIMITER ;; BEFORE DELETE ON `envialiaAgency` FOR EACH ROW BEGIN - CALL util.debugAdd("envialiaAgency", OLD.id); + CALL util.debugAdd("envialiaAgency", OLD.id); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -27206,13 +27325,13 @@ DROP TABLE IF EXISTS `envialiaCity`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `envialiaCity` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `city` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `postalCode` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `agencyFk` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `city` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `postalCode` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `agencyFk` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), KEY `agencyFk` (`agencyFk`), KEY `postalCode` (`postalCode`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -27227,7 +27346,7 @@ DELIMITER ;; BEFORE DELETE ON `envialiaCity` FOR EACH ROW BEGIN - CALL util.debugAdd("envialiaCity", OLD.id); + CALL util.debugAdd("envialiaCity", OLD.id); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -27243,16 +27362,16 @@ DROP TABLE IF EXISTS `envialiaConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `envialiaConfig` ( - `serviceType` varchar(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT '024' COMMENT 'Tipo de servicio en horas. 024 -> servicio las 24h', - `numBox` varchar(3) COLLATE utf8_unicode_ci DEFAULT '001' COMMENT 'cajas por envio', + `serviceType` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '024' COMMENT 'Tipo de servicio en horas. 024 -> servicio las 24h', + `numBox` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT '001' COMMENT 'cajas por envio', `startRange` bigint(25) DEFAULT NULL COMMENT 'Principio del rango que nos proporciona enviaría', `endRange` bigint(25) DEFAULT NULL COMMENT 'limite del rango que nos proporciona enviaría', - `cargoAgency` varchar(25) COLLATE utf8_unicode_ci DEFAULT '004666' COMMENT 'numero de verdnatura dado por enviaría', + `cargoAgency` varchar(25) COLLATE utf8mb3_unicode_ci DEFAULT '004666' COMMENT 'numero de verdnatura dado por enviaría', `actualNumber` bigint(25) DEFAULT NULL COMMENT 'Numero actual de etiquetas imprimidas , comprimido entre startRange y endRange, ', - `isAlreadyNotified` int(1) NOT NULL DEFAULT '0' COMMENT 'Booleano para que el evento vn.envialiaRangeChecker compruebe si se a enviado una notificación\n', + `isAlreadyNotified` int(1) NOT NULL DEFAULT 0 COMMENT 'Booleano para que el evento vn.envialiaRangeChecker compruebe si se a enviado una notificación\n', `notificationThrehold` int(11) DEFAULT NULL COMMENT 'Umbral para avisar a enviaría de reseetar el startRange y endRange\nSe avisara a enviaría si el umbral + el actualNumber es superior a endRange\n', PRIMARY KEY (`serviceType`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27264,11 +27383,11 @@ DROP TABLE IF EXISTS `errorLogApp`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `errorLogApp` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `error` varchar(55) COLLATE utf8_unicode_ci DEFAULT NULL, + `error` varchar(55) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `date` datetime DEFAULT NULL, `workerFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Guarda un registro de errores e la app de almacén'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Guarda un registro de errores e la app de almacén'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27281,19 +27400,19 @@ DROP TABLE IF EXISTS `errorProduction`; 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, + `firstname` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `lastname` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `rol` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `ticketNumber` int(11) DEFAULT NULL, `lineNumber` int(11) DEFAULT NULL, `error` int(11) 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, + `hourStart` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `hourEnd` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `hourWorked` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `dated` date DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27306,9 +27425,9 @@ DROP TABLE IF EXISTS `errorProduction__`; 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, + `firstname` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `lastname` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `rol` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `ticketNumber` int(11) DEFAULT NULL, `error` int(11) DEFAULT NULL, `ratio` double DEFAULT NULL, @@ -27316,7 +27435,7 @@ CREATE TABLE `errorProduction__` ( `month` int(11) DEFAULT NULL, `year` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27331,7 +27450,7 @@ CREATE TABLE `erte` ( `workerFk` int(11) NOT NULL, `started` date DEFAULT NULL, `ended` date DEFAULT NULL, - `reduction` int(3) NOT NULL DEFAULT '1', + `reduction` int(3) NOT NULL DEFAULT 1, `monday` tinyint(1) DEFAULT NULL, `tuesday` tinyint(1) DEFAULT NULL, `wednesday` tinyint(1) DEFAULT NULL, @@ -27340,7 +27459,7 @@ CREATE TABLE `erte` ( `saturday` tinyint(1) DEFAULT NULL, `sunday` tinyint(1) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27358,21 +27477,6 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `exchangeInsuranceIn` --- - -DROP TABLE IF EXISTS `exchangeInsuranceIn`; -/*!50001 DROP VIEW IF EXISTS `exchangeInsuranceIn`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `exchangeInsuranceIn` ( - `dated` tinyint NOT NULL, - `amount` tinyint NOT NULL, - `rate` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `exchangeInsuranceOut` -- @@ -27388,25 +27492,6 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `exchangeReportSourcePrevious` --- - -DROP TABLE IF EXISTS `exchangeReportSourcePrevious`; -/*!50001 DROP VIEW IF EXISTS `exchangeReportSourcePrevious`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `exchangeReportSourcePrevious` ( - `dated` tinyint NOT NULL, - `amountIn` tinyint NOT NULL, - `rateIn` tinyint NOT NULL, - `amountOut` tinyint NOT NULL, - `rateOut` tinyint NOT NULL, - `amountEntry` tinyint NOT NULL, - `rateEntry` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `excuse` -- @@ -27417,9 +27502,9 @@ DROP TABLE IF EXISTS `excuse`; CREATE TABLE `excuse` ( `id` int(11) NOT NULL AUTO_INCREMENT, `txt` varchar(255) CHARACTER SET latin1 NOT NULL, - `date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `date` datetime NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27433,18 +27518,18 @@ CREATE TABLE `expedition` ( `id` int(11) NOT NULL AUTO_INCREMENT, `agencyModeFk` int(11) NOT NULL, `ticketFk` int(10) NOT NULL, - `isBox` int(11) DEFAULT '1' COMMENT 'Este campo realmente en un campo itemFk, haciendo referencia al artículo que nos va a facturar el proveedor de transporte.\nSe debería llamar freightItemFk', - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `isBox` int(11) DEFAULT 1 COMMENT 'Este campo realmente en un campo itemFk, haciendo referencia al artículo que nos va a facturar el proveedor de transporte.\nSe debería llamar freightItemFk', + `created` timestamp NULL DEFAULT current_timestamp(), `isRefund__` bit(1) DEFAULT b'0' COMMENT 'Deprecado 01/06/2022', `isPickUp__` bit(1) DEFAULT b'0' COMMENT 'Deprecado 01/06/2022', - `itemFk` int(11) DEFAULT NULL COMMENT 'Este campo hace referencia al artículo que habria que facturar si las cajas no fueran incluidos.\\nSe debería llamar packageItemFk', + `itemFk` int(11) DEFAULT NULL COMMENT 'Si es necesario el itemFk del cubo, se obtiene mediante packagingFk, join packing.itemFk', `counter` smallint(5) unsigned NOT NULL, - `checked__` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Deprecado 01/06/2022', + `checked__` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Deprecado 01/06/2022', `workerFk` int(10) unsigned DEFAULT NULL, - `externalId` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `packagingFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `hostFk` varchar(6) COLLATE utf8_unicode_ci NOT NULL, + `externalId` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `packagingFk` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `itemPackingTypeFk` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `hostFk` varchar(6) COLLATE utf8mb3_unicode_ci NOT NULL, `stateTypeFk` int(11) DEFAULT NULL COMMENT 'Ultimo estado de la expedicion', `hasNewRoute` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`id`), @@ -27462,7 +27547,7 @@ CREATE TABLE `expedition` ( CONSTRAINT `expedition_fk3` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE, CONSTRAINT `expedition_ibfk_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`), CONSTRAINT `expedition_itemPackingTypeFk` FOREIGN KEY (`itemPackingTypeFk`) REFERENCES `itemPackingType` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -27477,27 +27562,27 @@ DELIMITER ;; BEFORE INSERT ON `expedition` FOR EACH ROW BEGIN - + DECLARE intcounter INT; DECLARE vShipFk INT; - IF NEW.isBox > 0 THEN + IF NEW.isBox > 0 THEN UPDATE ticket SET packages = nz(packages) + 1 WHERE id = NEW.ticketFk; - SELECT IFNULL(MAX(counter),0) +1 INTO intcounter - FROM expedition e - INNER JOIN ticket t1 ON e.ticketFk = t1.id + SELECT IFNULL(MAX(counter),0) +1 INTO intcounter + FROM expedition e + INNER JOIN ticket t1 ON e.ticketFk = t1.id LEFT JOIN ticketState ts ON ts.ticket = t1.id - INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped) + INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped) AND t1.warehouseFk = t2.warehouseFk - WHERE t2.id = NEW.ticketFk AND ts.alertLevel < 3 AND t1.companyFk = t2.companyFk + WHERE t2.id = NEW.ticketFk AND ts.alertLevel < 3 AND t1.companyFk = t2.companyFk AND t1.agencyModeFk = t2.agencyModeFk; SET NEW.`counter` = intcounter; END IF; - + /* SELECT shipFk INTO vShipFk FROM stowaway WHERE id = NEW.ticketFk; @@ -27525,9 +27610,9 @@ DELIMITER ;; FOR EACH ROW BEGIN IF NEW.counter <> OLD.counter THEN - IF (SELECT COUNT(*) FROM expedition e + IF (SELECT COUNT(*) FROM expedition e INNER JOIN ticket t1 ON e.ticketFk = t1.id - INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped) + INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped) WHERE t1.id = NEW.ticketFk AND counter = NEW.counter) > 0 THEN SET NEW.id = NULL; END IF; @@ -27551,11 +27636,11 @@ DELIMITER ;; BEFORE DELETE ON `expedition` FOR EACH ROW BEGIN - UPDATE ticket t - SET packages = (SELECT COUNT(counter)-1 + UPDATE ticket t + SET packages = (SELECT COUNT(counter)-1 FROM expedition e WHERE e.ticketFk = OLD.ticketFk and e.isBox) - WHERE t.id = OLD.ticketFk; - + WHERE t.id = OLD.ticketFk; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -27576,7 +27661,7 @@ CREATE TABLE `expeditionBoxVol` ( `ratio` double NOT NULL, PRIMARY KEY (`boxFk`), CONSTRAINT `expeditionBoxVol_FK` FOREIGN KEY (`boxFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Establece el volumen de cada servicio para poder comparar el teorico y el real en el control de portes'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Establece el volumen de cada servicio para poder comparar el teorico y el real en el control de portes'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27612,13 +27697,13 @@ DROP TABLE IF EXISTS `expeditionPallet`; CREATE TABLE `expeditionPallet` ( `id` int(11) NOT NULL AUTO_INCREMENT, `truckFk` int(11) NOT NULL, - `built` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `built` datetime NOT NULL DEFAULT current_timestamp(), `position` int(11) DEFAULT NULL, - `isPrint` tinyint(4) NOT NULL DEFAULT '2', + `isPrint` tinyint(4) NOT NULL DEFAULT 2, PRIMARY KEY (`id`), KEY `expeditionPallet_fk1_idx` (`truckFk`), CONSTRAINT `expeditionPallet_fk1` FOREIGN KEY (`truckFk`) REFERENCES `expeditionTruck` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -27635,13 +27720,13 @@ DELIMITER ;; BEGIN DECLARE vNewPosition INT; - + SELECT MAX(position) + 1 INTO vNewPosition FROM vn.expeditionPallet WHERE truckFk = NEW.truckFk; - + SET NEW.position = IFNULL(vNewPosition,1); - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -27680,26 +27765,6 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; --- --- Temporary table structure for view `expeditionPallet_Print` --- - -DROP TABLE IF EXISTS `expeditionPallet_Print`; -/*!50001 DROP VIEW IF EXISTS `expeditionPallet_Print`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `expeditionPallet_Print` ( - `truck` tinyint NOT NULL, - `routeFk` tinyint NOT NULL, - `zone` tinyint NOT NULL, - `eti` tinyint NOT NULL, - `palletFk` tinyint NOT NULL, - `isMatch` tinyint NOT NULL, - `warehouseFk` tinyint NOT NULL, - `nombreDia` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `expeditionRoute_Monitor` -- @@ -27746,7 +27811,7 @@ DROP TABLE IF EXISTS `expeditionScan`; CREATE TABLE `expeditionScan` ( `id` int(11) NOT NULL AUTO_INCREMENT, `expeditionFk` int(11) NOT NULL, - `scanned` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `scanned` datetime NOT NULL DEFAULT current_timestamp(), `palletFk` int(11) NOT NULL, `workerFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), @@ -27757,7 +27822,7 @@ CREATE TABLE `expeditionScan` ( CONSTRAINT `expeditionScan_fk1` FOREIGN KEY (`expeditionFk`) REFERENCES `expedition` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `expeditionScan_fk2` FOREIGN KEY (`palletFk`) REFERENCES `expeditionPallet` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `expeditionScan_fk3` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -27774,7 +27839,7 @@ DELIMITER ;; BEGIN SET NEW.workerFk = vn.getUser(); - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -27834,7 +27899,7 @@ DROP TABLE IF EXISTS `expeditionState`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `expeditionState` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `expeditionFk` int(11) NOT NULL, `typeFk` int(11) NOT NULL, `userFk` int(11) DEFAULT NULL, @@ -27843,14 +27908,14 @@ CREATE TABLE `expeditionState` ( KEY `expeditionState_FK_1` (`typeFk`), CONSTRAINT `expeditionState_FK` FOREIGN KEY (`expeditionFk`) REFERENCES `expedition` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `expeditionState_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `expeditionStateType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Historico de estados de las expediciones'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Historico de estados de las expediciones'; /*!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 character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -27858,9 +27923,9 @@ DELIMITER ;; BEFORE INSERT ON expeditionState FOR EACH ROW BEGIN - + SET NEW.userFk = account.myUser_getId(); - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -27870,9 +27935,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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -27884,7 +27949,7 @@ BEGIN UPDATE vn.expedition e SET e.stateTypeFk = NEW.typeFk WHERE e.id = NEW.expeditionFk; - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -27901,10 +27966,10 @@ DROP TABLE IF EXISTS `expeditionStateType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `expeditionStateType` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, - `code` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, + `code` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Posibles estados de una expedición'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Posibles estados de una expedición'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27977,13 +28042,13 @@ DROP TABLE IF EXISTS `expeditionTruck`; CREATE TABLE `expeditionTruck` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ETD` datetime DEFAULT NULL, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `bufferFk` int(11) DEFAULT NULL COMMENT 'buffer destino de las cajas', PRIMARY KEY (`id`), 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; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -28104,10 +28169,10 @@ DROP TABLE IF EXISTS `expence`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `expence` ( `id` varchar(10) NOT NULL, - `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `isWithheld` tinyint(4) NOT NULL DEFAULT '0', + `name` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isWithheld` tinyint(4) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28120,13 +28185,13 @@ DROP TABLE IF EXISTS `expence__`; CREATE TABLE `expence__` ( `id` varchar(10) NOT NULL, `taxTypeFk` tinyint(4) NOT NULL, - `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `isConbase` tinyint(4) NOT NULL DEFAULT '1', - `isWithheld` tinyint(4) NOT NULL DEFAULT '0', - `isForSale` tinyint(4) NOT NULL DEFAULT '0', + `name` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isConbase` tinyint(4) NOT NULL DEFAULT 1, + `isWithheld` tinyint(4) NOT NULL DEFAULT 0, + `isForSale` tinyint(4) NOT NULL DEFAULT 0, PRIMARY KEY (`id`,`taxTypeFk`), KEY `iva_tipo_id` (`taxTypeFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28175,7 +28240,7 @@ CREATE TABLE `floramondoConfig` ( `warehouseOutFk__` smallint(6) unsigned DEFAULT NULL, `agencyModeFk__` int(11) DEFAULT NULL, `MaxLatestDeliveryHour` int(11) DEFAULT NULL, - `MaxLatestOrderHour` int(11) DEFAULT '12' COMMENT 'Hora máxima para aceptar pedidos hoy', + `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`), @@ -28185,7 +28250,7 @@ CREATE TABLE `floramondoConfig` ( CONSTRAINT `floramondoConfigAgencyModeFk` FOREIGN KEY (`agencyModeFk__`) REFERENCES `agencyMode` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `floramondoConfigWarehouseInFk` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `floramondoConfigWarehouseOutFk` FOREIGN KEY (`warehouseOutFk__`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -28217,9 +28282,9 @@ DROP TABLE IF EXISTS `floramondoNotOfferDay__`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `floramondoNotOfferDay__` ( `dated` date NOT NULL, - `warehouseFk` int(11) NOT NULL DEFAULT '60', + `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'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='no muestra oferta en floramondo para ese dia y almacen'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28231,11 +28296,11 @@ DROP TABLE IF EXISTS `fuelType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `fuelType` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `code` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28247,10 +28312,10 @@ DROP TABLE IF EXISTS `gateArea`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `gateArea` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28264,13 +28329,13 @@ CREATE TABLE `genericAllocation` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemFk` int(11) NOT NULL, `typeFk` smallint(5) unsigned NOT NULL COMMENT ' vn.itemType.id', - `origin` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `color` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `quality` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `numFlores` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `category` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `productor` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `longName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `origin` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `color` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `quality` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `numFlores` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `category` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `productor` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `longName` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `size` int(11) DEFAULT NULL, `startDated` date DEFAULT NULL, `endDated` date DEFAULT NULL, @@ -28286,7 +28351,7 @@ CREATE TABLE `genericAllocation` ( KEY `genericAllocation_longName_IDX` (`longName`) USING BTREE, KEY `genericAllocation_size_IDX` (`size`) USING BTREE, CONSTRAINT `genericAllocation_FK` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los filtros para asignar códigos genéricos a los items'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Almacena los filtros para asignar códigos genéricos a los items'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28298,10 +28363,10 @@ DROP TABLE IF EXISTS `genus`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `genus` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `genus_PK2` (`name`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28315,14 +28380,14 @@ 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, + `token` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `labelType` varchar(3) COLLATE utf8mb3_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; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28335,12 +28400,12 @@ DROP TABLE IF EXISTS `glsExpedition__`; CREATE TABLE `glsExpedition__` ( `expeditionFk` int(11) NOT NULL, `barcode` bigint(20) unsigned DEFAULT NULL, - `uid` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `uid` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `codexp` int(11) DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `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; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28353,20 +28418,23 @@ DROP TABLE IF EXISTS `greuge`; CREATE TABLE `greuge` ( `Id` int(10) unsigned NOT NULL AUTO_INCREMENT, `clientFk` int(10) unsigned NOT NULL, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `amount` decimal(10,2) NOT NULL, - `shipped` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `shipped` datetime NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `greugeTypeFk` int(11) DEFAULT NULL, `ticketFk` int(11) DEFAULT NULL, + `userFK` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`Id`), KEY `greuges_type_fk_idx` (`greugeTypeFk`), KEY `Id_Ticket_Greuge_Ticket_idx` (`ticketFk`), KEY `Greuges_cliente_idx` (`clientFk`), KEY `greuge_shipped_IDX` (`shipped`) USING BTREE, + KEY `greuge_FK` (`userFK`), CONSTRAINT `Id_Ticket_Greuge_Ticket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `greuge_FK` FOREIGN KEY (`userFK`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `greuges_type_fk` FOREIGN KEY (`greugeTypeFk`) REFERENCES `greugeType` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=COMPACT; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci ROW_FORMAT=COMPACT; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -28377,14 +28445,36 @@ CREATE TABLE `greuge` ( /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`gregue_beforeInsert` + BEFORE INSERT ON greuge + FOR EACH ROW +BEGIN + IF NEW.userFk IS NULL THEN + SET NEW.userFk = account.myUser_getId(); + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`greuge_beforeUpdate` BEFORE UPDATE ON `greuge` FOR EACH ROW BEGIN - DECLARE vMaxDate DATETIME DEFAULT TIMESTAMPADD(YEAR,1,CURDATE()); + DECLARE vMaxDate DATETIME DEFAULT TIMESTAMPADD(YEAR,1,util.VN_CURDATE()); IF NEW.shipped > vMaxDate THEN - SET NEW.shipped = vMaxDate; + SET NEW.shipped = vMaxDate; END IF; END */;; DELIMITER ; @@ -28405,7 +28495,7 @@ CREATE TABLE `greugeConfig` ( `freightPickUpPrice` decimal(10,2) NOT NULL, `yearsToDelete` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28417,10 +28507,10 @@ DROP TABLE IF EXISTS `greugeType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `greugeType` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `code` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28432,19 +28522,19 @@ DROP TABLE IF EXISTS `host`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `host` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(30) CHARACTER SET utf8 NOT NULL, - `description` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(30) CHARACTER SET utf8mb3 NOT NULL, + `description` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `workerFk` int(10) unsigned DEFAULT NULL, - `windowsSerial` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, + `windowsSerial` varchar(40) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `printerFk` tinyint(3) unsigned DEFAULT NULL, - `itemPackingTypeFk__` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `itemPackingTypeFk__` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `packingSite__` tinyint(3) unsigned DEFAULT NULL, - `warehouseFk` smallint(5) unsigned DEFAULT '60', - `companyFk` smallint(5) unsigned DEFAULT '442', - `bankFk` int(11) DEFAULT '13', - `routeDaysBefore` smallint(6) DEFAULT '2', - `routeDaysAfter` smallint(6) DEFAULT '1', - `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `warehouseFk` smallint(5) unsigned DEFAULT 60, + `companyFk` smallint(5) unsigned DEFAULT 442, + `bankFk` int(11) DEFAULT 13, + `routeDaysBefore` smallint(6) DEFAULT 2, + `routeDaysAfter` smallint(6) DEFAULT 1, + `updated` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), UNIQUE KEY `host_UN` (`code`), KEY `configHost_FK_3` (`companyFk`), @@ -28459,7 +28549,7 @@ CREATE TABLE `host` ( CONSTRAINT `configHost_FK_3` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, CONSTRAINT `configHost_FK_4` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE, CONSTRAINT `configHost_FK_5` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -28474,7 +28564,7 @@ DELIMITER ;; BEFORE UPDATE ON `host` FOR EACH ROW BEGIN - SET new.updated = NOW(); + SET new.updated = util.VN_NOW(); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -28490,12 +28580,12 @@ DROP TABLE IF EXISTS `improvedGeneralLog`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `improvedGeneralLog` ( - `user` char(128) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `db` char(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `tables` char(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `type` set('Select','Insert','Update','Delete') COLLATE utf8_unicode_ci DEFAULT NULL, + `user` char(128) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `db` char(64) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `tables` char(64) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `type` set('Select','Insert','Update','Delete') COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`user`,`db`,`tables`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28506,12 +28596,12 @@ DROP TABLE IF EXISTS `improvedGeneralLogProcedures`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `improvedGeneralLogProcedures` ( - `user` char(128) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `db` varchar(250) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `routine` char(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `type` enum('FUNCTION','PROCEDURE') COLLATE utf8_unicode_ci NOT NULL, + `user` char(128) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `db` varchar(250) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `routine` char(64) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `type` enum('FUNCTION','PROCEDURE') COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`user`,`db`,`routine`,`type`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28522,10 +28612,10 @@ DROP TABLE IF EXISTS `incoterms`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `incoterms` ( - `code` varchar(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `name` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Internacional Commercial Terms'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Internacional Commercial Terms'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28536,19 +28626,19 @@ DROP TABLE IF EXISTS `ink`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ink` ( - `id` char(3) COLLATE utf8_unicode_ci NOT NULL, - `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `id` char(3) COLLATE utf8mb3_unicode_ci NOT NULL, + `name` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `picture` blob NOT NULL, `showOrder` int(11) NOT NULL, - `ball` blob, - `isCargex` tinyint(4) NOT NULL DEFAULT '0', - `dutchCode` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `hex` varchar(6) COLLATE utf8_unicode_ci DEFAULT NULL, - `isRealColor` tinyint(1) NOT NULL DEFAULT '1', + `ball` blob DEFAULT NULL, + `isCargex` tinyint(4) NOT NULL DEFAULT 0, + `dutchCode` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `hex` varchar(6) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isRealColor` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `dutchCode_UNIQUE` (`dutchCode`), CONSTRAINT `ink_fk1` FOREIGN KEY (`dutchCode`) REFERENCES `edi`.`feature` (`feature_value`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28559,12 +28649,12 @@ DROP TABLE IF EXISTS `inkI18n`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `inkI18n` ( - `inkFk` char(3) COLLATE utf8_unicode_ci NOT NULL, - `lang` char(2) CHARACTER SET utf8 NOT NULL, - `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `inkFk` char(3) COLLATE utf8mb3_unicode_ci NOT NULL, + `lang` char(2) CHARACTER SET utf8mb3 NOT NULL, + `name` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`inkFk`,`lang`), CONSTRAINT `inkI18n_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28590,14 +28680,14 @@ DROP TABLE IF EXISTS `intrastat`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `intrastat` ( `id` int(8) unsigned zerofill NOT NULL, - `description` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `import__` tinyint(4) NOT NULL DEFAULT '0', - `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT '2', - `taxCodeFk` tinyint(2) unsigned NOT NULL DEFAULT '64', + `description` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `import__` tinyint(4) NOT NULL DEFAULT 0, + `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT 2, + `taxCodeFk` tinyint(2) unsigned NOT NULL DEFAULT 64, PRIMARY KEY (`id`), KEY `iva_group_id` (`taxClassFk`), CONSTRAINT `intrastat_ibfk_1` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28617,7 +28707,7 @@ CREATE TABLE `inventoryFailure` ( `throwerFk` int(10) unsigned DEFAULT NULL, `guiltyFk` int(10) unsigned DEFAULT NULL, `causeFk` int(11) DEFAULT NULL, - `explanation` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL, + `explanation` varchar(250) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `inventoryFailure_fk1_idx` (`itemFk`), KEY `inventoryFailure_fk2_idx` (`throwerFk`), @@ -28629,7 +28719,7 @@ CREATE TABLE `inventoryFailure` ( CONSTRAINT `inventoryFailure_fk3` FOREIGN KEY (`guiltyFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inventoryFailure_fk4` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inventoryFailure_fk5` FOREIGN KEY (`causeFk`) REFERENCES `inventoryFailureCause` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28641,9 +28731,9 @@ DROP TABLE IF EXISTS `inventoryFailureCause`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `inventoryFailureCause` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28658,7 +28748,7 @@ CREATE TABLE `invoiceCorrection` ( `correctedFk` int(10) unsigned NOT NULL COMMENT 'Factura rectificada', `cplusRectificationTypeFk` int(10) unsigned NOT NULL, `cplusInvoiceType477Fk` int(10) unsigned NOT NULL, - `invoiceCorrectionTypeFk` int(11) NOT NULL DEFAULT '3', + `invoiceCorrectionTypeFk` int(11) NOT NULL DEFAULT 3, PRIMARY KEY (`correctingFk`), KEY `correctedFk_idx` (`correctedFk`), KEY `invoiceCorrection_ibfk_1_idx` (`cplusRectificationTypeFk`), @@ -28669,7 +28759,7 @@ CREATE TABLE `invoiceCorrection` ( CONSTRAINT `cplusInvoiceTyoeFk` FOREIGN KEY (`cplusInvoiceType477Fk`) REFERENCES `cplusInvoiceType477` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceCorrectionType_Fk33` FOREIGN KEY (`invoiceCorrectionTypeFk`) REFERENCES `invoiceCorrectionType` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceCorrection_ibfk_1` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `cplusRectificationType` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relacion entre las facturas rectificativas y las rectificadas.'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Relacion entre las facturas rectificativas y las rectificadas.'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28701,10 +28791,10 @@ DROP TABLE IF EXISTS `invoiceCorrectionType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `invoiceCorrectionType` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `description_UNIQUE` (`description`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28717,26 +28807,26 @@ DROP TABLE IF EXISTS `invoiceIn`; CREATE TABLE `invoiceIn` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `serialNumber` mediumint(11) unsigned DEFAULT NULL COMMENT 'insertado por Trigger', - `serial` char(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'R', + `serial` char(1) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'R', `supplierFk` int(11) NOT NULL, `issued` date DEFAULT NULL COMMENT 'Fecha de emision de la factura', - `supplierRef` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `isBooked` tinyint(1) NOT NULL DEFAULT '0', - `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT '1', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', + `supplierRef` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isBooked` tinyint(1) NOT NULL DEFAULT 0, + `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT 1, + `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, `docFk` int(11) DEFAULT NULL, `booked` date DEFAULT NULL COMMENT 'Fecha de contabilizacion', `operated` date DEFAULT NULL COMMENT 'Fecha de entrega de la mercancia o el suministro', - `cplusInvoiceType472Fk` int(10) unsigned DEFAULT '1', - `cplusRectificationTypeFk` int(10) unsigned DEFAULT '1', - `cplusSubjectOpFk` int(10) unsigned DEFAULT '1', - `cplusTaxBreakFk` int(10) unsigned DEFAULT '1', - `cplusTrascendency472Fk` int(10) unsigned DEFAULT '1', + `cplusInvoiceType472Fk` int(10) unsigned DEFAULT 1, + `cplusRectificationTypeFk` int(10) unsigned DEFAULT 1, + `cplusSubjectOpFk` int(10) unsigned DEFAULT 1, + `cplusTaxBreakFk` int(10) unsigned DEFAULT 1, + `cplusTrascendency472Fk` int(10) unsigned DEFAULT 1, `bookEntried` date DEFAULT NULL COMMENT 'Fecha Asiento', - `isVatDeductible` tinyint(1) NOT NULL DEFAULT '1', + `isVatDeductible` tinyint(1) NOT NULL DEFAULT 1, `withholdingSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipos de retención SAGE', - `expenceFkDeductible` varchar(10) CHARACTER SET utf8 DEFAULT NULL, + `expenceFkDeductible` varchar(10) CHARACTER SET utf8mb3 DEFAULT NULL, PRIMARY KEY (`id`), KEY `proveedor_id` (`supplierFk`), KEY `empresa_id` (`companyFk`), @@ -28760,7 +28850,7 @@ CREATE TABLE `invoiceIn` ( CONSTRAINT `invoiceIn_ibfk_6` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `cplusRectificationType` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceIn_ibfk_7` FOREIGN KEY (`cplusTrascendency472Fk`) REFERENCES `cplusTrascendency472` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceIn_withholdingFk` FOREIGN KEY (`withholdingSageFk`) REFERENCES `sage`.`TiposRetencion` (`CodigoRetencion`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -28780,49 +28870,49 @@ BEGIN DECLARE vIssuingCountry, vhostCountry INT; DECLARE vActive TINYINT; DECLARE vWithholdingSageFk INT; - - SELECT withholdingSageFk INTO vWithholdingSageFk - FROM vn.supplier + + SELECT withholdingSageFk INTO vWithholdingSageFk + FROM vn.supplier WHERE id = NEW.supplierFk; - SET NEW.withholdingSageFk = vWithholdingSageFk; - - SELECT countryFk, isActive INTO vIssuingCountry, vActive - FROM vn.supplier + SET NEW.withholdingSageFk = vWithholdingSageFk; + + SELECT countryFk, isActive INTO vIssuingCountry, vActive + FROM vn.supplier WHERE id = NEW.supplierFk; - - SELECT countryFk INTO vhostCountry - FROM vn.supplier + + SELECT countryFk INTO vhostCountry + FROM vn.supplier WHERE id = NEW.companyFk; IF vActive = 0 THEN CALL util.throw('INACTIVE_PROVIDER'); END IF; - - IF (SELECT COUNT(*) FROM vn.invoiceIn - WHERE supplierRef = NEW.supplierRef - AND supplierFk = NEW.supplierFk + + IF (SELECT COUNT(*) FROM vn.invoiceIn + WHERE supplierRef = NEW.supplierRef + AND supplierFk = NEW.supplierFk AND YEAR(issued) = YEAR(NEW.issued) ) THEN CALL util.throw('reference duplicated'); END IF; - + SELECT CASE WHEN (SELECT account FROM vn.supplier where id = NEW.supplierFk) LIKE '___3______' THEN 'C' - WHEN (SELECT vIssuingCountry=vhostCountry from vn.country p1 join vn.country p2 ON p2.id = vhostCountry AND p1.id = vIssuingCountry + WHEN (SELECT vIssuingCountry=vhostCountry from vn.country p1 join vn.country p2 ON p2.id = vhostCountry AND p1.id = vIssuingCountry where p1.CEE < 2 and p2.CEE < 2) = 1 THEN 'R' - WHEN (SELECT vIssuingCountry <> vhostCountry from vn.country p1 join vn.country p2 ON p2.id = vhostCountry AND p1.id = vIssuingCountry - where p1.CEE < 2 and p2.CEE < 2) = 1 THEN 'E' + WHEN (SELECT vIssuingCountry <> vhostCountry from vn.country p1 join vn.country p2 ON p2.id = vhostCountry AND p1.id = vIssuingCountry + where p1.CEE < 2 and p2.CEE < 2) = 1 THEN 'E' WHEN (SELECT vIssuingCountry<>vhostCountry from vn.country p1 join vn.country p2 ON p2.id = vhostCountry AND p1.id = vIssuingCountry - where NOT p1.CEE < 2 AND not p1.id = 1) = 1 THEN 'W' + where NOT p1.CEE < 2 AND not p1.id = 1) = 1 THEN 'W' END INTO vSerie; - + SET NEW.serial = IFNULL(vSerie,'R'); IF vSerie LIKE 'W' THEN - SELECT IFNULL(MAX(serialNumber) + 1,1) INTO vNumReceived - FROM invoiceIn - WHERE `serial` LIKE NEW.serial AND - YEAR(issued) = YEAR(NEW.issued) AND + SELECT IFNULL(MAX(serialNumber) + 1,1) INTO vNumReceived + FROM invoiceIn + WHERE `serial` LIKE NEW.serial AND + YEAR(issued) = YEAR(NEW.issued) AND companyFk = NEW.companyFk; SET NEW.serialNumber = vNumReceived; END IF; @@ -28848,9 +28938,9 @@ BEGIN DECLARE vWithholdingSageFk INT; - IF (SELECT COUNT(*) FROM vn.invoiceIn - WHERE supplierRef = NEW.supplierRef - AND supplierFk = NEW.supplierFk + IF (SELECT COUNT(*) FROM vn.invoiceIn + WHERE supplierRef = NEW.supplierRef + AND supplierFk = NEW.supplierFk AND YEAR(issued) = YEAR(NEW.issued) AND id <> NEW.id ) THEN @@ -28858,8 +28948,9 @@ BEGIN END IF; IF NEW.supplierFk != OLD.supplierFk THEN + CALL supplier_checkIsActive(NEW.supplierFk); SELECT withholdingSageFk INTO vWithholdingSageFk - FROM vn.supplier + FROM vn.supplier WHERE id = NEW.supplierFk; SET NEW.withholdingSageFk = vWithholdingSageFk; END IF; @@ -28884,23 +28975,23 @@ DELIMITER ;; FOR EACH ROW BEGIN - IF NEW.issued != OLD.issued + IF NEW.issued != OLD.issued OR NEW.currencyFk != OLD.currencyFk THEN UPDATE invoiceInTax iit JOIN invoiceIn ii ON ii.id = iit.invoiceInFk LEFT JOIN referenceRate rr ON rr.dated = ii.issued - AND rr.currencyFk = ii.currencyFk + AND rr.currencyFk = ii.currencyFk SET iit.taxableBase = IF(iit.foreignValue IS NULL, iit.taxableBase, iit.foreignValue / rr.value) WHERE ii.id = NEW.id; - + UPDATE invoiceInDueDay iidd JOIN invoiceIn ii ON ii.id = iidd.invoiceInFk LEFT JOIN referenceRate rr ON rr.dated = ii.issued - AND rr.currencyFk = ii.currencyFk + AND rr.currencyFk = ii.currencyFk SET iidd.amount = IF(iidd.foreignValue IS NULL, iidd.amount, iidd.foreignValue / rr.value) - WHERE ii.id = NEW.id; - + WHERE ii.id = NEW.id; + END IF; END */;; @@ -28921,16 +29012,16 @@ CREATE TABLE `invoiceInDueDay` ( `id` int(11) NOT NULL AUTO_INCREMENT, `invoiceInFk` mediumint(8) unsigned NOT NULL, `dueDated` date NOT NULL, - `bankFk` int(11) NOT NULL DEFAULT '3117', - `amount` decimal(10,2) NOT NULL DEFAULT '0.00', + `bankFk` int(11) NOT NULL DEFAULT 3117, + `amount` decimal(10,2) NOT NULL DEFAULT 0.00, `foreignValue` decimal(10,2) DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `recibida_id` (`invoiceInFk`), KEY `banco_id` (`bankFk`), CONSTRAINT `invoiceInDueDay_ibfk_6` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceInDueDay_ibfk_7` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -28946,26 +29037,26 @@ DELIMITER ;; FOR EACH ROW BEGIN DECLARE vIsNotified BOOLEAN; - - SELECT isNotified INTO vIsNotified - FROM vn.invoiceIn ii + + SELECT isNotified INTO vIsNotified + FROM vn.invoiceIn ii JOIN vn.supplier s ON s.id = ii.supplierFk JOIN vn.payMethod pm ON pm.id = s.payMethodFk WHERE ii.id = NEW.invoiceInFk; - - IF (NEW.dueDated <= CURDATE() AND vIsNotified) + + IF (NEW.dueDated <= util.VN_CURDATE() AND vIsNotified) THEN CALL mail_insert( 'begonya@verdnatura.es', 'begonya@verdnatura.es', 'Añadido vencimiento en el pasado', CONCAT( - account.myUser_getName(), ' ha añadido un vencimiento de ', + account.myUser_getName(), ' ha añadido un vencimiento de ', NEW.amount, '€ en una fecha pasada en la recibida ', NEW.invoiceInFk ) ); END IF; - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -28986,26 +29077,26 @@ DELIMITER ;; FOR EACH ROW BEGIN DECLARE vIsNotified BOOLEAN; - - SELECT isNotified INTO vIsNotified - FROM vn.invoiceIn ii + + SELECT isNotified INTO vIsNotified + FROM vn.invoiceIn ii JOIN vn.supplier s ON s.id = ii.supplierFk JOIN vn.payMethod pm ON pm.id = s.payMethodFk WHERE ii.id = NEW.invoiceInFk; - - IF (NEW.dueDated <= CURDATE() AND vIsNotified) + + IF (NEW.dueDated <= util.VN_CURDATE() AND vIsNotified) THEN CALL mail_insert( 'begonya@verdnatura.es', 'begonya@verdnatura.es', 'Añadido vencimiento en el pasado', CONCAT( - account.myUser_getName(), ' ha añadido un vencimiento de ', + account.myUser_getName(), ' ha añadido un vencimiento de ', NEW.amount,'€ en una fecha pasada en la recibida ',NEW.invoiceInFk ) ); END IF; - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -29024,18 +29115,18 @@ CREATE TABLE `invoiceInIntrastat` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `invoiceInFk` mediumint(8) unsigned NOT NULL, `net` decimal(10,2) DEFAULT NULL, - `intrastatFk` int(8) unsigned zerofill NOT NULL DEFAULT '06049190', + `intrastatFk` int(8) unsigned zerofill NOT NULL DEFAULT 06049190, `amount` double NOT NULL, `stems` int(11) NOT NULL, `countryFk` mediumint(8) unsigned DEFAULT NULL, - `dated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `statisticalValue` double NOT NULL DEFAULT '0', + `dated` timestamp NOT NULL DEFAULT current_timestamp(), + `statisticalValue` double NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `intrastat_id` (`intrastatFk`), KEY `invoiceInIntrastat_FK` (`invoiceInFk`), CONSTRAINT `invoiceInIntrastat_FK` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE, CONSTRAINT `invoiceInIntrastat_ibfk_1` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29054,7 +29145,7 @@ CREATE TABLE `invoiceInIntrastat__` ( KEY `recibida_id` (`invoiceInFk`), CONSTRAINT `invoiceInIntrastat___ibfk_1` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceInIntrastat___ibfk_2` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29068,20 +29159,20 @@ CREATE TABLE `invoiceInLog` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `originFk` mediumint(8) 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, - `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8_unicode_ci, - `newInstance` text COLLATE utf8_unicode_ci, + `action` set('insert','update','delete') COLLATE utf8mb3_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 DEFAULT NULL, + `changedModel` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `originFk` (`originFk`), KEY `userFk` (`userFk`), CONSTRAINT `invoiceInLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `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; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29093,12 +29184,12 @@ DROP TABLE IF EXISTS `invoiceInSage`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `invoiceInSage` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `taxClassFk` varchar(1) COLLATE utf8_unicode_ci NOT NULL, - `invoiceInSerialFk` varchar(2) COLLATE utf8_unicode_ci NOT NULL, + `taxClassFk` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL, + `invoiceInSerialFk` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL, `taxTypeSageFk` smallint(6) NOT NULL, `transactionTypeSageFk` tinyint(4) NOT NULL, - `isService` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Para diferenciar producto de servicio', - `expenceFk` varchar(10) CHARACTER SET utf8 NOT NULL, + `isService` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Para diferenciar producto de servicio', + `expenceFk` varchar(10) CHARACTER SET utf8mb3 NOT NULL, `withholdingSageFk` smallint(6) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `invoiceInSafe_unique` (`taxClassFk`,`invoiceInSerialFk`,`isService`,`withholdingSageFk`), @@ -29114,7 +29205,7 @@ CREATE TABLE `invoiceInSage` ( CONSTRAINT `invoiceInSage_taxTypeSageFk` FOREIGN KEY (`taxTypeSageFk`) REFERENCES `sage`.`TiposIva` (`CodigoIva`) ON UPDATE CASCADE, CONSTRAINT `invoiceInSage_transactionTypeSageFk` FOREIGN KEY (`transactionTypeSageFk`) REFERENCES `sage`.`TiposTransacciones` (`CodigoTransaccion`) ON UPDATE CASCADE, CONSTRAINT `invoiceInSage_withholdingSageFk` FOREIGN KEY (`withholdingSageFk`) REFERENCES `sage`.`TiposRetencion` (`CodigoRetencion`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciones de entrelas series de facturas recibidas y sus tipo de IVA con código Iva y codigo de Transación en Sage. Para precontabilizadar facturas recibidas'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Relaciones de entrelas series de facturas recibidas y sus tipo de IVA con código Iva y codigo de Transación en Sage. Para precontabilizadar facturas recibidas'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29125,16 +29216,16 @@ DROP TABLE IF EXISTS `invoiceInSerial`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `invoiceInSerial` ( - `code` varchar(2) COLLATE utf8_unicode_ci NOT NULL, - `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `cplusTerIdNifFk` int(11) NOT NULL DEFAULT '1', - `taxAreaFk` varchar(15) CHARACTER SET utf8 DEFAULT NULL, + `code` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `cplusTerIdNifFk` int(11) NOT NULL DEFAULT 1, + `taxAreaFk` varchar(15) CHARACTER SET utf8mb3 DEFAULT NULL, PRIMARY KEY (`code`), KEY `InvoiceInSerial_Fk1_idx` (`cplusTerIdNifFk`), KEY `InvoiceInSerialTaxArea_idx` (`taxAreaFk`), CONSTRAINT `InvoiceInSerialTaxArea` FOREIGN KEY (`taxAreaFk`) REFERENCES `taxArea` (`code`) ON UPDATE CASCADE, CONSTRAINT `InvoiceInSerial_Fk1` FOREIGN KEY (`cplusTerIdNifFk`) REFERENCES `cplusTerIdNif` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29149,11 +29240,11 @@ CREATE TABLE `invoiceInTax` ( `invoiceInFk` mediumint(8) unsigned NOT NULL, `taxCodeFk` int(10) DEFAULT NULL, `taxableBase` decimal(10,2) NOT NULL, - `expenceFk` varchar(10) CHARACTER SET utf8 NOT NULL, + `expenceFk` varchar(10) CHARACTER SET utf8mb3 NOT NULL, `foreignValue` decimal(10,2) DEFAULT NULL, `taxTypeSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipo de IVA SAGE', `transactionTypeSageFk` tinyint(4) DEFAULT NULL COMMENT 'Tipo de transacción SAGE', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), PRIMARY KEY (`id`), KEY `recibida_id` (`invoiceInFk`), KEY `recibida_iva_ibfk_2` (`taxCodeFk`), @@ -29164,7 +29255,7 @@ CREATE TABLE `invoiceInTax` ( CONSTRAINT `invoiceInTax_ibfk_5` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceInTax_transactionTypeSageFk` FOREIGN KEY (`transactionTypeSageFk`) REFERENCES `sage`.`TiposTransacciones` (`CodigoTransaccion`) ON UPDATE CASCADE, CONSTRAINT `recibida_iva_taxTypeSageFk` FOREIGN KEY (`taxTypeSageFk`) REFERENCES `sage`.`TiposIva` (`CodigoIva`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29176,13 +29267,13 @@ DROP TABLE IF EXISTS `invoiceInTaxBookingAccount`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `invoiceInTaxBookingAccount` ( `id` int(10) NOT NULL AUTO_INCREMENT, - `effectived` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `account` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `taxAreaFk` varchar(15) CHARACTER SET utf8 NOT NULL, + `effectived` timestamp NOT NULL DEFAULT current_timestamp(), + `account` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, + `taxAreaFk` varchar(15) CHARACTER SET utf8mb3 NOT NULL, `priority` int(2) unsigned DEFAULT NULL, - `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT '1', - `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', - `rate` decimal(5,2) NOT NULL DEFAULT '0.00', + `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT 1, + `countryFk` mediumint(8) unsigned NOT NULL DEFAULT 1, + `rate` decimal(5,2) NOT NULL DEFAULT 0.00, PRIMARY KEY (`id`), KEY `invoiceInTaxBookingAccount_fk1_idx` (`taxAreaFk`), KEY `invoiceInTaxBookingAccount_fk2_idx` (`taxClassFk`), @@ -29190,7 +29281,7 @@ CREATE TABLE `invoiceInTaxBookingAccount` ( CONSTRAINT `invoiceInTaxBookingAccount_fk1` FOREIGN KEY (`taxAreaFk`) REFERENCES `taxArea` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceInTaxBookingAccount_fk2` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceInTaxBookingAccount_fk3` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29202,28 +29293,28 @@ DROP TABLE IF EXISTS `invoiceOut`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `invoiceOut` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `ref` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `serial` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, + `ref` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL, + `serial` varchar(2) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `issued` date DEFAULT NULL, - `amount` decimal(12,2) DEFAULT '0.00', + `amount` decimal(12,2) DEFAULT 0.00, `dued` datetime DEFAULT NULL, `bankFk` int(11) DEFAULT NULL, - `clientFk` int(11) DEFAULT '0', - `taxableBase7__` decimal(12,2) DEFAULT '0.00', - `taxableBase16__` decimal(12,2) DEFAULT '0.00', - `equ1__` decimal(12,2) DEFAULT '0.00', - `equ4__` decimal(12,2) DEFAULT '0.00', - `vat7__` decimal(12,2) DEFAULT '0.00', - `vat16__` decimal(12,2) DEFAULT '0.00', - `workerFk__` int(11) DEFAULT '0', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', - `hasPdf` tinyint(3) unsigned NOT NULL DEFAULT '0', + `clientFk` int(11) DEFAULT 0, + `taxableBase7__` decimal(12,2) DEFAULT 0.00, + `taxableBase16__` decimal(12,2) DEFAULT 0.00, + `equ1__` decimal(12,2) DEFAULT 0.00, + `equ4__` decimal(12,2) DEFAULT 0.00, + `vat7__` decimal(12,2) DEFAULT 0.00, + `vat16__` decimal(12,2) DEFAULT 0.00, + `workerFk__` int(11) DEFAULT 0, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, + `hasPdf` tinyint(3) unsigned NOT NULL DEFAULT 0, `booked` date DEFAULT NULL, - `cplusInvoiceType477Fk` int(10) unsigned NOT NULL DEFAULT '1', - `cplusTaxBreakFk` int(10) unsigned NOT NULL DEFAULT '1', - `cplusSubjectOpFk` int(10) unsigned NOT NULL DEFAULT '1', - `cplusTrascendency477Fk` int(10) unsigned NOT NULL DEFAULT '1', + `cplusInvoiceType477Fk` int(10) unsigned NOT NULL DEFAULT 1, + `cplusTaxBreakFk` int(10) unsigned NOT NULL DEFAULT 1, + `cplusSubjectOpFk` int(10) unsigned NOT NULL DEFAULT 1, + `cplusTrascendency477Fk` int(10) unsigned NOT NULL DEFAULT 1, PRIMARY KEY (`id`,`ref`), UNIQUE KEY `Id_Factura` (`ref`), KEY `Id_Banco` (`bankFk`), @@ -29244,7 +29335,7 @@ CREATE TABLE `invoiceOut` ( CONSTRAINT `invoiceOut_serial` FOREIGN KEY (`serial`) REFERENCES `invoiceOutSerial` (`code`), CONSTRAINT `invoice_bank_id` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoice_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -29258,34 +29349,32 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceOut_beforeInsert` BEFORE INSERT ON `invoiceOut` FOR EACH ROW --- Edit trigger body code below this line. Do not edit lines above this one BEGIN DECLARE vRef CHAR(10) ; - + IF YEAR(NEW.issued) <= 2021 THEN - + SELECT CONCAT(NEW.serial, - IFNULL(RIGHT(MAX(i.ref), LENGTH(i.ref)-1) , - RPAD(CONCAT(c.sage200Company, RIGHT(YEAR(CURDATE()), 2)), 7,'0')) + 1) INTO vRef + IFNULL(RIGHT(MAX(i.ref), LENGTH(i.ref)-1) , + RPAD(CONCAT(c.sage200Company, RIGHT(YEAR(util.VN_CURDATE()), 2)), 7,'0')) + 1) INTO vRef FROM invoiceOut i LEFT JOIN company c ON c.id = i.companyFk WHERE i.serial = NEW.serial - AND i.issued BETWEEN util.firstDayOfYear(NEW.issued) AND util.dayEnd(util.lastDayOfYear(NEW.issued)) + AND i.issued BETWEEN util.firstDayOfYear(NEW.issued) AND util.dayEnd(util.lastDayOfYear(NEW.issued)) AND c.id = NEW.companyFk; ELSE - + SELECT CONCAT(NEW.serial, - IFNULL(RIGHT(MAX(i.ref), LENGTH(i.ref)-1) , - RPAD(CONCAT(c.sage200Company, RIGHT(YEAR(CURDATE()), 2)), 8,'0')) + 1) INTO vRef + IFNULL(RIGHT(MAX(i.ref), LENGTH(i.ref)-1) , + RPAD(CONCAT(c.sage200Company, RIGHT(YEAR(util.VN_CURDATE()), 2)), 8,'0')) + 1) INTO vRef FROM invoiceOut i LEFT JOIN company c ON c.id = i.companyFk WHERE i.serial = NEW.serial - AND i.issued BETWEEN util.firstDayOfYear(NEW.issued) AND util.dayEnd(util.lastDayOfYear(NEW.issued)) + AND i.issued BETWEEN util.firstDayOfYear(NEW.issued) AND util.dayEnd(util.lastDayOfYear(NEW.issued)) AND c.id = NEW.companyFk; END IF; - + SET NEW.ref = vRef; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -29306,15 +29395,15 @@ DELIMITER ;; FOR EACH ROW BEGIN CALL clientRisk_update(NEW.clientFk, NEW.companyFk, NEW.amount); - IF (SELECT COUNT(*) - FROM client - WHERE id = NEW.clientFk + IF (SELECT COUNT(*) + FROM client + WHERE id = NEW.clientFk AND businessTypeFk = 'officialOrganism' ) THEN CALL mail_insert('administracion@verdnatura.es', NULL, CONCAT('Se ha emitido una factura al organismo: ', NEW.clientFk), - CONCAT('Presentar factura en FACE https://salix.verdnatura.es/#!/invoice-out/', + CONCAT('Presentar factura en FACE https://salix.verdnatura.es/#!/invoice-out/', NEW.id, '/summary')); END IF; @@ -29376,15 +29465,15 @@ DROP TABLE IF EXISTS `invoiceOutExpence`; CREATE TABLE `invoiceOutExpence` ( `id` int(11) NOT NULL AUTO_INCREMENT, `invoiceOutFk` int(10) unsigned NOT NULL, - `amount` decimal(10,2) NOT NULL DEFAULT '0.00', - `expenceFk` varchar(10) CHARACTER SET utf8 NOT NULL, - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `amount` decimal(10,2) NOT NULL DEFAULT 0.00, + `expenceFk` varchar(10) CHARACTER SET utf8mb3 NOT NULL, + `created` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `invoiceOutExpence_FK_1_idx` (`invoiceOutFk`), KEY `invoiceOutExpence_expenceFk_idx` (`expenceFk`), CONSTRAINT `invoiceOutExpence_FK_1` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutExpence_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Desglosa la base imponible de una factura en funcion del tipo de gasto/venta'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Desglosa la base imponible de una factura en funcion del tipo de gasto/venta'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29395,18 +29484,18 @@ DROP TABLE IF EXISTS `invoiceOutSerial`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `invoiceOutSerial` ( - `code` varchar(2) COLLATE utf8_unicode_ci NOT NULL, - `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `isTaxed` tinyint(1) NOT NULL DEFAULT '1', - `taxAreaFk` varchar(15) CHARACTER SET utf8 NOT NULL DEFAULT 'NATIONAL', - `isCEE` tinyint(1) NOT NULL DEFAULT '0', - `cplusInvoiceType477Fk` int(10) unsigned DEFAULT '1', - `footNotes` longtext COLLATE utf8_unicode_ci, - `isRefEditable` tinyint(4) NOT NULL DEFAULT '0', + `code` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isTaxed` tinyint(1) NOT NULL DEFAULT 1, + `taxAreaFk` varchar(15) CHARACTER SET utf8mb3 NOT NULL DEFAULT 'NATIONAL', + `isCEE` tinyint(1) NOT NULL DEFAULT 0, + `cplusInvoiceType477Fk` int(10) unsigned DEFAULT 1, + `footNotes` longtext COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isRefEditable` tinyint(4) NOT NULL DEFAULT 0, PRIMARY KEY (`code`), KEY `taxAreaFk_idx` (`taxAreaFk`), CONSTRAINT `invoiceOutSeriaTaxArea` FOREIGN KEY (`taxAreaFk`) REFERENCES `taxArea` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29420,16 +29509,16 @@ CREATE TABLE `invoiceOutTax` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `invoiceOutFk` int(10) unsigned NOT NULL, `taxableBase` decimal(10,2) NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `vat` decimal(10,2) NOT NULL DEFAULT '0.00', - `pgcFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0000000000', + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `vat` decimal(10,2) NOT NULL DEFAULT 0.00, + `pgcFk` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '0000000000', PRIMARY KEY (`id`), UNIQUE KEY `invoiceOutTax_Resctriccion` (`invoiceOutFk`,`pgcFk`), KEY `invoiceOutFk_idx` (`invoiceOutFk`), KEY `pgcFk` (`pgcFk`), CONSTRAINT `invoiceOutFk` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutTax_ibfk_1` FOREIGN KEY (`pgcFk`) REFERENCES `pgc` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29441,11 +29530,11 @@ DROP TABLE IF EXISTS `invoiceOutTaxConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `invoiceOutTaxConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `taxClassCodeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `taxClassCodeFk` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `taxTypeSageFk` smallint(6) DEFAULT NULL, `transactionTypeSageFk` tinyint(4) DEFAULT NULL, - `isService` tinyint(1) DEFAULT '0', - `expenceFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `isService` tinyint(1) DEFAULT 0, + `expenceFk` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `invoiceOutTaxConfig_FK` (`taxClassCodeFk`), KEY `invoiceOutTaxConfig_FK_1` (`taxTypeSageFk`), @@ -29453,7 +29542,7 @@ CREATE TABLE `invoiceOutTaxConfig` ( CONSTRAINT `invoiceOutTaxConfig_FK` FOREIGN KEY (`taxClassCodeFk`) REFERENCES `taxClass` (`code`), CONSTRAINT `invoiceOutTaxConfig_FK_1` FOREIGN KEY (`taxTypeSageFk`) REFERENCES `sage`.`TiposIva` (`CodigoIva`), CONSTRAINT `invoiceOutTaxConfig_FK_2` FOREIGN KEY (`transactionTypeSageFk`) REFERENCES `sage`.`TiposTransacciones` (`CodigoTransaccion`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29465,12 +29554,12 @@ DROP TABLE IF EXISTS `invoiceOut_queue`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `invoiceOut_queue` ( `invoiceFk` int(10) unsigned NOT NULL, - `queued` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `queued` datetime NOT NULL DEFAULT current_timestamp(), `printed` datetime DEFAULT NULL, - `status` varchar(50) COLLATE utf8_unicode_ci DEFAULT '', + `status` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT '', PRIMARY KEY (`invoiceFk`), CONSTRAINT `invoiceOut_queue_invoiceOut_id_fk` FOREIGN KEY (`invoiceFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Queue for PDF invoicing'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Queue for PDF invoicing'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29483,68 +29572,69 @@ DROP TABLE IF EXISTS `item`; CREATE TABLE `item` ( `id` int(11) NOT NULL AUTO_INCREMENT, `equivalent` int(11) unsigned DEFAULT NULL, - `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `size` int(10) unsigned DEFAULT NULL, - `stems` int(11) DEFAULT '1', - `minPrice` double DEFAULT '0', - `isToPrint` tinyint(1) NOT NULL DEFAULT '0', - `isDeliveryNote__` tinyint(1) NOT NULL DEFAULT '0', - `taxClassFk__` tinyint(4) unsigned NOT NULL DEFAULT '1', - `family` varchar(3) CHARACTER SET utf8 NOT NULL DEFAULT 'VT', - `box` tinyint(1) NOT NULL DEFAULT '0', - `category` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, + `stems` int(11) DEFAULT 1, + `minPrice` double DEFAULT 0, + `isToPrint` tinyint(1) NOT NULL DEFAULT 0, + `isDeliveryNote__` tinyint(1) NOT NULL DEFAULT 0, + `taxClassFk__` tinyint(4) unsigned NOT NULL DEFAULT 1, + `family` varchar(3) CHARACTER SET utf8mb3 NOT NULL DEFAULT 'VT', + `box` tinyint(1) NOT NULL DEFAULT 0, + `category` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `originFk` tinyint(2) unsigned NOT NULL, - `doPhoto` tinyint(4) NOT NULL DEFAULT '0', - `image` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `inkFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `niche__` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `intrastatFk` int(8) unsigned zerofill NOT NULL DEFAULT '06039010', - `hasMinPrice` tinyint(1) NOT NULL DEFAULT '0', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `isOnOffer__` tinyint(4) NOT NULL DEFAULT '0', - `isBargain__` tinyint(4) NOT NULL DEFAULT '0', - `comment` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, + `doPhoto` tinyint(4) NOT NULL DEFAULT 0, + `image` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `inkFk` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `niche__` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `intrastatFk` int(8) unsigned zerofill NOT NULL DEFAULT 06039010, + `hasMinPrice` tinyint(1) NOT NULL DEFAULT 0, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `isOnOffer__` tinyint(4) NOT NULL DEFAULT 0, + `isBargain__` tinyint(4) NOT NULL DEFAULT 0, + `comment` varchar(150) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `typeFk` smallint(5) unsigned NOT NULL, - `generic` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0', + `generic` tinyint(1) unsigned zerofill NOT NULL DEFAULT 0, `producerFk` mediumint(3) unsigned DEFAULT NULL, - `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `density` int(11) NOT NULL DEFAULT '167' COMMENT 'Almacena la densidad en kg/m3 para el calculo de los portes, si no se especifica se pone por defecto la del tipo en un trigger', - `relevancy` tinyint(1) NOT NULL DEFAULT '0', - `expenceFk` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '7001000000', - `isActive` tinyint(1) NOT NULL DEFAULT '1', - `longName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `subName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `tag5` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `value5` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `tag6` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `value6` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `tag7` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `value7` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `tag8` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `value8` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `tag9` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `value9` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `tag10` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `value10` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `compression__` decimal(5,2) NOT NULL DEFAULT '1.00' COMMENT 'Relacion de compresividad entre el volumen de las entradas en Silla y el empaquetado en los envios a clientes.', - `minimum` decimal(10,0) unsigned NOT NULL DEFAULT '3' COMMENT 'Cantidad máxima de cajas / cubos que cabe en un nicho', - `upToDown` decimal(10,0) unsigned NOT NULL DEFAULT '0' COMMENT 'Se muestra el precio por kilo ', + `description` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `density` int(11) NOT NULL DEFAULT 167 COMMENT 'Almacena la densidad en kg/m3 para el calculo de los portes, si no se especifica se pone por defecto la del tipo en un trigger', + `relevancy` tinyint(1) NOT NULL DEFAULT 0, + `expenceFk` varchar(10) CHARACTER SET utf8mb3 NOT NULL DEFAULT '7001000000', + `isActive` tinyint(1) NOT NULL DEFAULT 1, + `longName` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `subName` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `tag5` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `value5` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `tag6` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `value6` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `tag7` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `value7` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `tag8` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `value8` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `tag9` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `value9` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `tag10` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `value10` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `compression__` decimal(5,2) NOT NULL DEFAULT 1.00 COMMENT 'Relacion de compresividad entre el volumen de las entradas en Silla y el empaquetado en los envios a clientes.', + `minimum` decimal(10,0) unsigned NOT NULL DEFAULT 3 COMMENT 'Cantidad máxima de cajas / cubos que cabe en un nicho', + `upToDown` decimal(10,0) unsigned NOT NULL DEFAULT 0 COMMENT 'Se muestra el precio por kilo ', `supplyResponseFk` int(11) DEFAULT NULL, - `hasKgPrice` tinyint(1) NOT NULL DEFAULT '0', + `hasKgPrice` tinyint(1) NOT NULL DEFAULT 0, `sectorFk__` int(11) DEFAULT NULL, - `isFloramondo` tinyint(1) NOT NULL DEFAULT '0', - `isFragile` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'articulos solo para recogidas por su fragilidad', + `isFloramondo` tinyint(1) NOT NULL DEFAULT 0, + `isFragile` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'articulos solo para recogidas por su fragilidad', `numberOfItemsPerCask` int(11) DEFAULT NULL COMMENT 'Campo para Floramondo', `embalageCode` int(11) DEFAULT NULL COMMENT 'Campo para Floramondo', - `quality` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Campo para Floramondo', + `quality` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'Campo para Floramondo', `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, + `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 utf8mb3_unicode_ci DEFAULT NULL, `packingOut` decimal(10,2) DEFAULT NULL COMMENT 'cantidad que cabe en una caja de verdnatura', `genericFk` int(11) DEFAULT NULL COMMENT 'Item genérico', `packingShelve` int(11) DEFAULT NULL COMMENT 'unidades que caben en una bandeja, en el caso de los sacadores', - `isLaid` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indica si el producto se puede tumbar a efectos del transporte desde Holanda', - `lastUsed` datetime DEFAULT CURRENT_TIMESTAMP, + `isLaid` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si el producto se puede tumbar a efectos del transporte desde Holanda', + `lastUsed` datetime DEFAULT current_timestamp(), + `weightByPiece` int(10) unsigned DEFAULT NULL COMMENT 'peso por defecto para un articulo por tallo/unidad', PRIMARY KEY (`id`), UNIQUE KEY `item_supplyResponseFk_idx` (`supplyResponseFk`), KEY `Color` (`inkFk`), @@ -29574,7 +29664,7 @@ CREATE TABLE `item` ( CONSTRAINT `item_ibfk_5` FOREIGN KEY (`typeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, CONSTRAINT `itemsupplyResponseFk` FOREIGN KEY (`supplyResponseFk`) REFERENCES `edi`.`supplyResponse` (`ID`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `producer_id` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -29589,24 +29679,16 @@ DELIMITER ;; BEFORE INSERT ON `item` FOR EACH ROW BEGIN - DECLARE vDensity DOUBLE; DECLARE vItemPackingType VARCHAR(1); - IF NEW.density IS NULL THEN - SELECT density INTO vDensity - FROM itemType WHERE id = NEW.typeFk; - - SET NEW.density = vDensity; - END IF; - IF NEW.itemPackingTypeFk IS NULL THEN - + SELECT itemPackingTypeFk INTO vItemPackingType - FROM vn.itemType it + FROM vn.itemType it WHERE id = NEW.typeFk; SET NEW.itemPackingTypeFk = vItemPackingType; - + END IF; END */;; DELIMITER ; @@ -29662,23 +29744,23 @@ DELIMITER ;; BEFORE UPDATE ON `item` FOR EACH ROW BEGIN - + DECLARE vNewPackingShelve INT; - IF ISNULL(NEW.packingShelve) AND NOT ISNULL(NEW.packingOut) THEN - - SELECT NEW.packingOut * vc.shelveVolume / vc.standardFlowerBox + IF ISNULL(NEW.packingShelve) AND NOT ISNULL(NEW.packingOut) THEN + + SELECT NEW.packingOut * vc.shelveVolume / vc.standardFlowerBox INTO vNewPackingShelve FROM vn.volumeConfig vc; - + SET NEW.packingShelve = vNewPackingShelve; - + END IF; IF NEW.itemPackingTypeFk = '' THEN SET NEW.itemPackingTypeFk = NULL; - + END IF; END */;; @@ -29690,9 +29772,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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -29745,13 +29827,13 @@ DROP TABLE IF EXISTS `itemBarcode`; CREATE TABLE `itemBarcode` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `itemFk` int(11) NOT NULL, - `code` varchar(22) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(22) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code` (`code`), UNIQUE KEY `Id_Article_2` (`itemFk`,`code`), KEY `Id_Article` (`itemFk`), CONSTRAINT `itemBarcode_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29763,7 +29845,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 utf8mb3_unicode_ci DEFAULT NULL, `genusFk` int(11) NOT NULL, `specieFk` int(11) DEFAULT NULL, PRIMARY KEY (`itemFk`), @@ -29772,7 +29854,7 @@ CREATE TABLE `itemBotanical` ( CONSTRAINT `itemBotanicalItemFkFk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemBotanical_FK` FOREIGN KEY (`specieFk`) REFERENCES `specie` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `itemBotanical_FK_1` FOREIGN KEY (`genusFk`) REFERENCES `genus` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Sustituye a antiguo NomBotanic de Articles'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Sustituye a antiguo NomBotanic de Articles'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29798,15 +29880,15 @@ DROP TABLE IF EXISTS `itemCategory`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `itemCategory` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `order` int(10) unsigned DEFAULT NULL, - `display` tinyint(4) NOT NULL DEFAULT '1', - `color` char(6) COLLATE utf8_unicode_ci DEFAULT NULL, - `shortLife` int(11) NOT NULL DEFAULT '0' COMMENT 'Sirve para filtrar aquellos reinos que tienen precios estables', - `merchandise` tinyint(1) NOT NULL DEFAULT '1', - `icon` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `isReclining` tinyint(4) NOT NULL DEFAULT '1', + `display` tinyint(4) NOT NULL DEFAULT 1, + `color` char(6) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `shortLife` int(11) NOT NULL DEFAULT 0 COMMENT 'Sirve para filtrar aquellos reinos que tienen precios estables', + `merchandise` tinyint(1) NOT NULL DEFAULT 1, + `icon` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `code` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isReclining` tinyint(4) NOT NULL DEFAULT 1, `departmentFk` int(11) DEFAULT NULL COMMENT 'Departamento responsable del manufacturado de esta categoria', PRIMARY KEY (`id`), UNIQUE KEY `reino_UNIQUE` (`name`), @@ -29814,7 +29896,7 @@ CREATE TABLE `itemCategory` ( KEY `itemCategoryDisplayIdx` (`display`), KEY `itemCategory_FK` (`departmentFk`), CONSTRAINT `itemCategory_FK` FOREIGN KEY (`departmentFk`) REFERENCES `department` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -29849,10 +29931,10 @@ DROP TABLE IF EXISTS `itemCategoryI18n`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `itemCategoryI18n` ( `categoryFk` int(10) unsigned NOT NULL, - `lang` char(2) CHARACTER SET utf8 NOT NULL, - `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `lang` char(2) CHARACTER SET utf8mb3 NOT NULL, + `name` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`categoryFk`,`lang`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29878,27 +29960,26 @@ DROP TABLE IF EXISTS `itemCleanConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `itemCleanConfig` ( `id` int(11) NOT NULL, - `step` int(11) NOT NULL COMMENT 'Indica los items que procesa en cada ciclo', `quantity` int(11) NOT NULL COMMENT 'Indica el número de items que va a procesar', - `isStop` tinyint(1) DEFAULT NULL, + `isStop` tinyint(1) DEFAULT NULL COMMENT 'Si está a TRUE para el proceso a tiempo real', PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `itemCleanCount` +-- Table structure for table `itemCleanLog` -- -DROP TABLE IF EXISTS `itemCleanCount`; +DROP TABLE IF EXISTS `itemCleanLog`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `itemCleanCount` ( +CREATE TABLE `itemCleanLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemFrom` int(11) DEFAULT NULL COMMENT 'Indica el item por donde ha empezado', `itemDeleted` int(11) DEFAULT NULL COMMENT 'Indica la cantidad de items que ha eliminado', - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29923,9 +30004,9 @@ DROP TABLE IF EXISTS `itemConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `itemConfig` ( - `isItemTagTriggerDisabled` tinyint(1) NOT NULL DEFAULT '1', - `monthToDeactivate` int(3) NOT NULL DEFAULT '24' -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + `isItemTagTriggerDisabled` tinyint(1) NOT NULL DEFAULT 1, + `monthToDeactivate` int(3) NOT NULL DEFAULT 24 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29942,7 +30023,7 @@ CREATE TABLE `itemConversor__` ( KEY `itemConversor_fk2_idx` (`genItemFk`), CONSTRAINT `itemConversor_fk1` FOREIGN KEY (`espItemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemConversor_fk2` FOREIGN KEY (`genItemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona los item específicos con los genéricos'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Relaciona los item específicos con los genéricos'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29955,20 +30036,20 @@ DROP TABLE IF EXISTS `itemCost`; CREATE TABLE `itemCost` ( `itemFk` int(11) NOT NULL, `warehouseFk` smallint(6) unsigned NOT NULL, - `quantity` int(10) NOT NULL DEFAULT '0', - `rotation` decimal(10,4) NOT NULL DEFAULT '0.0000', - `cm3` int(11) NOT NULL DEFAULT '0', - `storage` decimal(10,4) NOT NULL DEFAULT '0.0000', - `handling` decimal(10,4) NOT NULL DEFAULT '0.0000', - `extraCharge` decimal(10,4) NOT NULL DEFAULT '0.0000', - `wasted` decimal(10,4) NOT NULL DEFAULT '0.0000', - `cm3delivery` int(11) NOT NULL DEFAULT '0', - `grams` int(11) NOT NULL DEFAULT '0' COMMENT 'peso en gramos de una unidad de venta', + `quantity` int(10) NOT NULL DEFAULT 0, + `rotation` decimal(10,4) NOT NULL DEFAULT 0.0000, + `cm3` int(11) NOT NULL DEFAULT 0, + `storage` decimal(10,4) NOT NULL DEFAULT 0.0000, + `handling` decimal(10,4) NOT NULL DEFAULT 0.0000, + `extraCharge` decimal(10,4) NOT NULL DEFAULT 0.0000, + `wasted` decimal(10,4) NOT NULL DEFAULT 0.0000, + `cm3delivery` int(11) NOT NULL DEFAULT 0, + `grams` int(11) NOT NULL DEFAULT 0 COMMENT 'peso en gramos de una unidad de venta', PRIMARY KEY (`itemFk`,`warehouseFk`), KEY `warehouse_id_rotacion_idx` (`warehouseFk`), CONSTRAINT `id_article_rotaci` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `warehouse_id_rotaci` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los valores de rotacion en los ultimos 365 dias'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Almacena los valores de rotacion en los ultimos 365 dias'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -30009,17 +30090,17 @@ BEGIN IF NEW.itemFk IN (95, 98) THEN SET NEW.cm3 = 0; END IF; - + IF !(NEW.cm3delivery <=> OLD.cm3delivery) THEN INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) - SELECT r.id + SELECT r.id FROM vn.itemCost ic JOIN vn.sale s ON s.itemFk = ic.itemFk - JOIN vn.ticket t ON t.id = s.ticketFk AND t.warehouseFk = ic.warehouseFk + JOIN vn.ticket t ON t.id = s.ticketFk AND t.warehouseFk = ic.warehouseFk JOIN vn.route r ON r.id = t.routeFk - WHERE r.isOk = FALSE + WHERE r.isOk = FALSE AND ic.itemFk = NEW.itemFk - AND r.created >= CURDATE() + AND r.created >= util.VN_CURDATE() GROUP BY r.id; IF NEW.cm3Delivery = 0 AND NEW.warehouseFk = 60 THEN CALL mail_insert( @@ -30081,10 +30162,10 @@ DROP TABLE IF EXISTS `itemFamily`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `itemFamily` ( - `code` varchar(3) CHARACTER SET utf8 NOT NULL, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(3) CHARACTER SET utf8mb3 NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30096,15 +30177,15 @@ DROP TABLE IF EXISTS `itemImageQueue`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `itemImageQueue` ( `itemFk` int(11) NOT NULL, - `url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `error` text COLLATE utf8_unicode_ci, - `attempts` int(11) DEFAULT '0', - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `priority` int(11) DEFAULT '99', + `url` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `error` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `attempts` int(11) DEFAULT 0, + `created` timestamp NULL DEFAULT current_timestamp(), + `updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `priority` int(11) DEFAULT 99, PRIMARY KEY (`itemFk`), CONSTRAINT `itemImageQueueItemIdx` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Cola para añadir las imagenes al campo vn.item.image a partir de una url'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Cola para añadir las imagenes al campo vn.item.image a partir de una url'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30132,11 +30213,11 @@ DROP TABLE IF EXISTS `itemLabel`; CREATE TABLE `itemLabel` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemFk` int(11) DEFAULT NULL, - `itemName` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `itemName` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `price` decimal(10,2) DEFAULT NULL, `labels` int(11) DEFAULT NULL COMMENT 'Tabla hecha para Ruben Espinosa, para sacar etiquetas en Holanda para un cliente.', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30150,20 +30231,20 @@ CREATE TABLE `itemLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `originFk` int(11) 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, - `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8_unicode_ci, - `newInstance` text COLLATE utf8_unicode_ci, + `action` set('insert','update','delete') COLLATE utf8mb3_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 DEFAULT NULL, + `changedModel` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `itemLogItemFk_idx` (`originFk`), KEY `itemLogUserFk_idx` (`userFk`), CONSTRAINT `itemLogItemFk` FOREIGN KEY (`originFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30175,12 +30256,12 @@ DROP TABLE IF EXISTS `itemMatchProperties`; /*!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, + `name` varchar(80) COLLATE utf8mb3_unicode_ci NOT NULL, + `producer` varchar(80) COLLATE utf8mb3_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'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Propiedades para encontrar articulos equivalentes en verdnatura'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30191,10 +30272,10 @@ DROP TABLE IF EXISTS `itemPackingType`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `itemPackingType` ( - `code` varchar(1) COLLATE utf8_unicode_ci NOT NULL, - `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL, + `description` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la linea de encajado para cada producto'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Define la linea de encajado para cada producto'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30207,9 +30288,9 @@ DROP TABLE IF EXISTS `itemPlacementSupply`; CREATE TABLE `itemPlacementSupply` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `itemFk` int(11) NOT NULL, - `quantity` decimal(10,0) NOT NULL DEFAULT '0', - `priority` int(10) unsigned NOT NULL DEFAULT '0', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `quantity` decimal(10,0) NOT NULL DEFAULT 0, + `priority` int(10) unsigned NOT NULL DEFAULT 0, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `userFk` int(10) unsigned NOT NULL COMMENT 'Persona que crea la orden', `repoUserFk` int(10) unsigned DEFAULT NULL COMMENT 'Reponedor que la tiene asignada', `sectorFk` int(11) DEFAULT NULL, @@ -30222,7 +30303,7 @@ CREATE TABLE `itemPlacementSupply` ( CONSTRAINT `itemPlacementSupply_fk2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemPlacementSupply_fk3` FOREIGN KEY (`repoUserFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemPlacementSupply_fk4` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de nichos de picking que hay que reponer'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Lista de nichos de picking que hay que reponer'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30261,11 +30342,11 @@ DROP TABLE IF EXISTS `itemPlacement__`; CREATE TABLE `itemPlacement__` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemFk` int(11) NOT NULL, - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', - `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `modificationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `reserve` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `pickable` int(11) unsigned NOT NULL DEFAULT '0', + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 1, + `code` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, + `modificationDate` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `reserve` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `pickable` int(11) unsigned NOT NULL DEFAULT 0, `sectorFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `Id_Article_UNIQUE` (`itemFk`,`warehouseFk`), @@ -30275,7 +30356,7 @@ CREATE TABLE `itemPlacement__` ( CONSTRAINT `Articles_nicho_wh_fk` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Articles_nichos_fk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemPlacement_fk3` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -30344,12 +30425,12 @@ DROP TABLE IF EXISTS `itemProposal`; CREATE TABLE `itemProposal` ( `itemFk` int(11) NOT NULL, `mateFk` int(11) NOT NULL, - `counter` int(11) NOT NULL DEFAULT '0', + `counter` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`itemFk`,`mateFk`), KEY `itemProposal_fk2_idx` (`mateFk`), CONSTRAINT `itemProposal_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemProposal_fk2` FOREIGN KEY (`mateFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='almacena los cambios realizados de unos items por otros, cuando faltaban los primeros'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='almacena los cambios realizados de unos items por otros, cuando faltaban los primeros'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30361,10 +30442,10 @@ DROP TABLE IF EXISTS `itemRepo__`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `itemRepo__` ( `itemFk` int(11) NOT NULL, - `quantity` int(10) unsigned NOT NULL DEFAULT '0', + `quantity` int(10) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`itemFk`), CONSTRAINT `itemRepo_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30394,18 +30475,18 @@ DROP TABLE IF EXISTS `itemShelving`; CREATE TABLE `itemShelving` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `itemFk` int(11) NOT NULL, - `shelvingFk` varchar(10) CHARACTER SET utf8 NOT NULL, - `shelve` varchar(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'A', - `deep__` int(11) unsigned NOT NULL DEFAULT '1', - `quantity__` int(11) NOT NULL DEFAULT '0', - `visible` int(11) NOT NULL DEFAULT '0', - `available__` int(11) NOT NULL DEFAULT '0', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `shelvingFk` varchar(10) CHARACTER SET utf8mb3 NOT NULL, + `shelve` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'A', + `deep__` int(11) unsigned NOT NULL DEFAULT 1, + `quantity__` int(11) NOT NULL DEFAULT 0, + `visible` int(11) NOT NULL DEFAULT 0, + `available__` int(11) NOT NULL DEFAULT 0, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `priority` int(11) unsigned DEFAULT NULL COMMENT 'El 0 es la mínima prioridad', `grouping` smallint(5) unsigned DEFAULT NULL, `packing` int(11) unsigned DEFAULT NULL, - `packagingFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `level__` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '1', + `packagingFk` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `level__` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '1', `userFk` int(10) unsigned DEFAULT NULL, `stars` int(11) DEFAULT NULL, PRIMARY KEY (`id`), @@ -30416,7 +30497,7 @@ CREATE TABLE `itemShelving` ( CONSTRAINT `itemShelving_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelving_fk2` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelving_fk3` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla utilizada para localizar los artículos dentro de los carros. Usado para la gestión del almacén en el altillo '; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla utilizada para localizar los artículos dentro de los carros. Usado para la gestión del almacén en el altillo '; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -30431,10 +30512,10 @@ DELIMITER ;; BEFORE INSERT ON `itemShelving` FOR EACH ROW BEGIN - + SET NEW.userFk = account.myUser_getId(); - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -30545,8 +30626,8 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_BEFORE_DELETE` BEFORE DELETE ON `itemShelving` FOR EACH ROW -INSERT INTO vn.itemShelvingLog(itemShelvingFk, - workerFk, +INSERT INTO vn.itemShelvingLog(itemShelvingFk, + workerFk, accion, shelvingFk, itemFk) @@ -30629,10 +30710,10 @@ CREATE TABLE `itemShelvingLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemShelvingFk` int(10) unsigned DEFAULT NULL, `workerFk` int(11) DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `accion` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `accion` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `itemFk` int(11) DEFAULT NULL, - `shelvingFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `shelvingFk` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `quantity` int(11) DEFAULT NULL, `visible` int(11) DEFAULT NULL, `available` int(11) DEFAULT NULL, @@ -30641,7 +30722,7 @@ CREATE TABLE `itemShelvingLog` ( `stars` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `itemShelving_Log_FK` (`itemShelvingFk`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30655,17 +30736,17 @@ CREATE TABLE `itemShelvingPlacementSupply` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `itemShelvingFk` int(10) unsigned NOT NULL, `itemPlacementSupplyFk` int(10) unsigned NOT NULL, - `quantity` decimal(10,0) NOT NULL DEFAULT '0', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `quantity` decimal(10,0) NOT NULL DEFAULT 0, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `userFk` int(10) unsigned NOT NULL, - `isPicked` tinyint(4) NOT NULL DEFAULT '0', + `isPicked` tinyint(4) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `itemShelvingPlacementSupply_fk1_idx` (`itemShelvingFk`), KEY `itemShelvingPlacementSupply_fk2_idx` (`itemPlacementSupplyFk`), KEY `itemShelvingPlacementSupply_fk3_idx` (`userFk`), CONSTRAINT `itemShelvingPlacementSupply_fk1` FOREIGN KEY (`itemShelvingFk`) REFERENCES `itemShelving` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelvingPlacementSupply_fk2` FOREIGN KEY (`itemPlacementSupplyFk`) REFERENCES `itemPlacementSupply` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de los itemShelving afectados por las ordenes de reposicion de nicho'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Detalle de los itemShelving afectados por las ordenes de reposicion de nicho'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30704,8 +30785,8 @@ CREATE TABLE `itemShelvingSale` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemShelvingFk` int(10) unsigned NOT NULL, `saleFk` int(11) NOT NULL, - `quantity` decimal(10,0) NOT NULL DEFAULT '0', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `quantity` decimal(10,0) NOT NULL DEFAULT 0, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `userFk` int(11) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `itemShelvingSale_fk1_idx` (`itemShelvingFk`), @@ -30714,7 +30795,7 @@ CREATE TABLE `itemShelvingSale` ( CONSTRAINT `itemShelvingSale_fk1` FOREIGN KEY (`itemShelvingFk`) REFERENCES `itemShelving` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelvingSale_fk2` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelvingSale_fk3` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle del producto que se retira de los carros, relacionando la linea de movimiento correspondiente'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Detalle del producto que se retira de los carros, relacionando la linea de movimiento correspondiente'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -30731,7 +30812,7 @@ DELIMITER ;; BEGIN UPDATE vn.sale - SET isPicked = TRUE + SET isPicked = TRUE WHERE id = NEW.saleFk; END */;; @@ -30852,9 +30933,9 @@ CREATE TABLE `itemTag` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemFk` int(11) NOT NULL, `tagFk` int(11) NOT NULL, - `value` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + `value` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, `intValue` int(11) DEFAULT NULL, - `priority` int(2) NOT NULL DEFAULT '0', + `priority` int(2) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `itemTagItemUq` (`itemFk`,`tagFk`), UNIQUE KEY `itemTagItemPriority` (`itemFk`,`priority`), @@ -30864,7 +30945,7 @@ CREATE TABLE `itemTag` ( KEY `itemFk_2` (`itemFk`,`tagFk`,`intValue`), CONSTRAINT `itemTagItemFk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemTagTagFk` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -30908,7 +30989,7 @@ trig: BEGIN IF @isTriggerDisabled OR visTriggerDisabled THEN LEAVE trig; END IF; - + SET vItemFk = NEW.itemFk; DROP TEMPORARY TABLE IF EXISTS tmp.item; CREATE TEMPORARY TABLE tmp.item @@ -30933,7 +31014,7 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTag_beforeUpdate` BEFORE UPDATE ON `itemTag` FOR EACH ROW -BEGIN +BEGIN IF !(OLD.`value` <=> NEW.`value`) OR !(OLD.intValue <=> NEW.intValue) THEN SET NEW.intValue = itemTag_getIntValue(NEW.`value`); @@ -30966,7 +31047,7 @@ trig: BEGIN IF @isTriggerDisabled OR visTriggerDisabled THEN LEAVE trig; END IF; - + SET vItemFk = NEW.itemFk; DROP TEMPORARY TABLE IF EXISTS tmp.item; CREATE TEMPORARY TABLE tmp.item @@ -31002,7 +31083,7 @@ trig: BEGIN IF @isTriggerDisabled OR visTriggerDisabled THEN LEAVE trig; END IF; - + SET vItemFk = OLD.itemFk; DROP TEMPORARY TABLE IF EXISTS tmp.item; CREATE TEMPORARY TABLE tmp.item @@ -31040,8 +31121,8 @@ CREATE TABLE `itemTaxCountry` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemFk` int(11) DEFAULT NULL, `countryFk` mediumint(8) unsigned DEFAULT NULL, - `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT '1', - `effectived` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT 1, + `effectived` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), UNIQUE KEY `itemFk_UNIQUE` (`itemFk`,`countryFk`), KEY `taxClassFK_idx` (`taxClassFk`), @@ -31049,7 +31130,7 @@ CREATE TABLE `itemTaxCountry` ( CONSTRAINT `countryFK_paises` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, CONSTRAINT `itemFK_Article` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `taxClassFK_Iva_Group` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31082,34 +31163,34 @@ DROP TABLE IF EXISTS `itemType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `itemType` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, - `code` varchar(3) COLLATE utf8_unicode_ci NOT NULL, - `name` varchar(30) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, + `name` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL, `gramsMin__` int(11) DEFAULT NULL, `gramsMax` int(11) DEFAULT NULL, - `order` int(11) DEFAULT '0', + `order` int(11) DEFAULT 0, `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', - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `f11__` tinyint(4) NOT NULL DEFAULT '0', - `transaction` tinyint(4) NOT NULL DEFAULT '0', + `isInventory` tinyint(4) NOT NULL DEFAULT 1 COMMENT 'Se utiliza tanto en el cálculo del inventario, como en el del informe del inventario valorado', + `created` timestamp NULL DEFAULT current_timestamp(), + `f11__` tinyint(4) NOT NULL DEFAULT 0, + `transaction` tinyint(4) NOT NULL DEFAULT 0, `making` int(10) unsigned DEFAULT NULL COMMENT 'Son productos de confección propia', - `location` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `location` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `life` smallint(5) unsigned DEFAULT NULL, - `maneuver` double NOT NULL DEFAULT '0.21', - `target` double NOT NULL DEFAULT '0.15', - `topMargin` double NOT NULL DEFAULT '0.3', - `profit` double NOT NULL DEFAULT '0.02', - `density` double NOT NULL DEFAULT '167' COMMENT 'Almacena el valor por defecto de la densidad en kg/m3 para el calculo de los portes aereos, en articulos se guarda la correcta', - `promo` double NOT NULL DEFAULT '0', - `isPackaging` tinyint(1) NOT NULL DEFAULT '0', - `hasComponents` tinyint(1) NOT NULL DEFAULT '1', - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '60', - `compression` decimal(5,2) DEFAULT '1.00', - `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `temperatureFk` varchar(10) CHARACTER SET utf8 DEFAULT NULL, - `isUnconventionalSize` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'familia con productos cuyas medidas no son aptas para la cinta transportadora o paletizar', - `isLaid` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indica si el producto se puede tumbar a efectos del transporte desde Holanda', + `maneuver` double NOT NULL DEFAULT 0.21, + `target` double NOT NULL DEFAULT 0.15, + `topMargin` double NOT NULL DEFAULT 0.3, + `profit` double NOT NULL DEFAULT 0.02, + `density` double NOT NULL DEFAULT 167 COMMENT 'Almacena el valor por defecto de la densidad en kg/m3 para el calculo de los portes aereos, en articulos se guarda la correcta', + `promo` double NOT NULL DEFAULT 0, + `isPackaging` tinyint(1) NOT NULL DEFAULT 0, + `hasComponents` tinyint(1) NOT NULL DEFAULT 1, + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 60, + `compression` decimal(5,2) DEFAULT 1.00, + `itemPackingTypeFk` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `temperatureFk` varchar(10) CHARACTER SET utf8mb3 DEFAULT NULL, + `isUnconventionalSize` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'familia con productos cuyas medidas no son aptas para la cinta transportadora o paletizar', + `isLaid` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si el producto se puede tumbar a efectos del transporte desde Holanda', `maxRefs` int(10) unsigned DEFAULT NULL COMMENT 'Indica el número máximo de referencias', PRIMARY KEY (`code`), UNIQUE KEY `tipo_id_UNIQUE` (`id`), @@ -31124,7 +31205,7 @@ CREATE TABLE `itemType` ( CONSTRAINT `itemType_ibfk_1` FOREIGN KEY (`categoryFk`) REFERENCES `itemCategory` (`id`) ON UPDATE CASCADE, CONSTRAINT `temperatureFk` FOREIGN KEY (`temperatureFk`) REFERENCES `temperature` (`code`), CONSTRAINT `warehouseFk5` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Protege la tabla tipos de updates para los 4 parámetros de los compradores, en funcion del valor del campo CodigoRojo de tblContadores.'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Protege la tabla tipos de updates para los 4 parámetros de los compradores, en funcion del valor del campo CodigoRojo de tblContadores.'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -31138,21 +31219,17 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemType_beforeUpdate` BEFORE UPDATE ON `itemType` FOR EACH ROW --- Edit trigger body code below this line. Do not edit lines above this one BEGIN - - IF NEW.itemPackingTypeFk = '' THEN - + IF NEW.itemPackingTypeFk = '' THEN + SET NEW.itemPackingTypeFk = NULL; - + END IF; - IF NEW.itemPackingTypeFk != OLD.itemPackingTypeFk THEN - - UPDATE vn.item + IF NEW.itemPackingTypeFk != OLD.itemPackingTypeFk THEN + UPDATE vn.item SET itemPackingTypeFk = NEW.itemPackingTypeFk WHERE typeFk = NEW.id; - END IF; END */;; DELIMITER ; @@ -31170,10 +31247,10 @@ DROP TABLE IF EXISTS `itemTypeI18n`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `itemTypeI18n` ( `typeFk` smallint(5) unsigned NOT NULL, - `lang` char(2) CHARACTER SET utf8 NOT NULL, - `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `lang` char(2) CHARACTER SET utf8mb3 NOT NULL, + `name` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`typeFk`,`lang`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31206,7 +31283,7 @@ CREATE TABLE `itemTypeRestriction` ( 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; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31220,14 +31297,14 @@ CREATE TABLE `itemTypeTag` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemTypeFk` smallint(5) unsigned NOT NULL, `tagFk` int(11) NOT NULL, - `priority` int(2) unsigned NOT NULL DEFAULT '0', + `priority` int(2) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `itemTypeFk_UNIQUE` (`itemTypeFk`,`tagFk`), KEY `itemTypeTagTipo_idx` (`itemTypeFk`), KEY `itemTypeTagTag_idx` (`tagFk`), CONSTRAINT `itemTypeTagTag` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `itemTypeTagTipos` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31242,7 +31319,7 @@ CREATE TABLE `itemVerdecora__` ( `codin` int(11) DEFAULT NULL, PRIMARY KEY (`itemFk`), CONSTRAINT `itemVerdecora_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona nuestros articulos con los de Verdecora'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Relaciona nuestros articulos con los de Verdecora'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31294,14 +31371,14 @@ DROP TABLE IF EXISTS `labourTree`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `labourTree` ( - `id` int(11) NOT NULL DEFAULT '0', - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `id` int(11) NOT NULL DEFAULT 0, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `lft` int(11) NOT NULL, `rgt` int(11) NOT NULL, - `depth` bigint(22) NOT NULL DEFAULT '0', + `depth` bigint(22) NOT NULL DEFAULT 0, `sons` decimal(10,0) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31371,7 +31448,7 @@ DROP TABLE IF EXISTS `ledgerConfig`; CREATE TABLE `ledgerConfig` ( `lastBookEntry` int(11) NOT NULL, PRIMARY KEY (`lastBookEntry`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31386,7 +31463,7 @@ CREATE TABLE `lungSize` ( `size` decimal(5,0) NOT NULL, `dia` date NOT NULL, PRIMARY KEY (`hora`,`size`,`dia`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31398,19 +31475,19 @@ DROP TABLE IF EXISTS `machine`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `machine` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `plate` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `serialNumber` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, - `maker` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `model` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `plate` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `serialNumber` varchar(30) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `maker` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `model` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `purchased` date DEFAULT NULL, `warehouseFk` int(11) DEFAULT NULL, `departmentFk` int(11) DEFAULT NULL, - `type` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - `use` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `type` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `use` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `productionYear` int(11) DEFAULT NULL, - `photo` blob, + `photo` blob DEFAULT NULL, `workerFk` int(10) unsigned DEFAULT NULL, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', + `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, `ppeFk` int(11) DEFAULT NULL, `supplierFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), @@ -31422,7 +31499,7 @@ CREATE TABLE `machine` ( CONSTRAINT `machine_FK` FOREIGN KEY (`ppeFk`) REFERENCES `ppe` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `machine_FK_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `machine_FK_2` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Maquinaria industrial, vehículos y demás elementos amortizables'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Maquinaria industrial, vehículos y demás elementos amortizables'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -31437,7 +31514,7 @@ DELIMITER ;; BEFORE INSERT ON `machine` FOR EACH ROW BEGIN - + SET NEW.workerFk = vn.getUser(); END */;; @@ -31458,7 +31535,7 @@ CREATE TABLE `machineDetail` ( `id` int(11) NOT NULL AUTO_INCREMENT, `machineFk` int(11) NOT NULL, `dated` date NOT NULL, - `action` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `action` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, `value` decimal(10,2) DEFAULT NULL, `workerFk` int(10) unsigned NOT NULL, `dmsFk` int(11) DEFAULT NULL, @@ -31469,7 +31546,7 @@ CREATE TABLE `machineDetail` ( CONSTRAINT `machineDetail_FK` FOREIGN KEY (`machineFk`) REFERENCES `machine` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `machineDetail_FK_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `machineDetail_FK_2` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31488,7 +31565,7 @@ CREATE TABLE `machineDms` ( KEY `machineDms_FK` (`dmsFk`), CONSTRAINT `machineDms_FK` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `machineDms_FK_1` FOREIGN KEY (`machineFk`) REFERENCES `machine` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31502,14 +31579,14 @@ CREATE TABLE `machineWorker` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `workerFk` int(10) unsigned NOT NULL, `machineFk` int(11) NOT NULL, - `inTimed` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `inTimed` datetime NOT NULL DEFAULT current_timestamp(), `outTimed` datetime DEFAULT NULL, PRIMARY KEY (`id`), KEY `machineWorker_FK_1` (`machineFk`), KEY `machineWorker_FK` (`workerFk`), CONSTRAINT `machineWorker_FK` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `machineWorker_FK_1` FOREIGN KEY (`machineFk`) REFERENCES `machine` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Registros horarios de vehículos de almacén por empleado'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Registros horarios de vehículos de almacén por empleado'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31523,7 +31600,7 @@ 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; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31535,18 +31612,18 @@ DROP TABLE IF EXISTS `mail`; /*!40101 SET character_set_client = utf8 */; 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 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, - `sent` tinyint(2) NOT NULL DEFAULT '0', - `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `attachment` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - `status` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'OK', + `receiver` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `sender` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `replyTo` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `subject` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, + `body` text COLLATE utf8mb3_unicode_ci NOT NULL, + `sent` tinyint(2) NOT NULL DEFAULT 0, + `creationDate` timestamp NOT NULL DEFAULT current_timestamp(), + `attachment` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `status` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'OK', `senderFk` int(10) unsigned DEFAULT NULL, `recipientFk` int(10) unsigned DEFAULT NULL, - `plainTextBody` text COLLATE utf8_unicode_ci, + `plainTextBody` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `sent_idx` (`sent`), KEY `creation_idx` (`creationDate`), @@ -31554,7 +31631,7 @@ CREATE TABLE `mail` ( KEY `mail_FK` (`senderFk`), CONSTRAINT `mail_FK` FOREIGN KEY (`senderFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE, CONSTRAINT `mail_FK_1` FOREIGN KEY (`recipientFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -31571,9 +31648,9 @@ DELIMITER ;; BEGIN IF NEW.sender IS NOT NULL THEN - + SET NEW.receiver = NEW.sender; - + END IF; END */;; @@ -31592,10 +31669,10 @@ DROP TABLE IF EXISTS `mailTemplates`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mailTemplates` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(50) CHARACTER SET utf8 NOT NULL, - `attachmentPath` text CHARACTER SET utf8 NOT NULL, + `name` varchar(50) CHARACTER SET utf8mb3 NOT NULL, + `attachmentPath` text CHARACTER SET utf8mb3 NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31609,8 +31686,8 @@ CREATE TABLE `mandate` ( `id` int(11) NOT NULL AUTO_INCREMENT, `clientFk` int(11) NOT NULL, `companyFk` smallint(5) unsigned NOT NULL, - `code` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `code` varchar(32) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `created` timestamp NULL DEFAULT current_timestamp(), `finished` timestamp NULL DEFAULT NULL, `mandateTypeFk` smallint(5) NOT NULL, PRIMARY KEY (`id`), @@ -31620,7 +31697,7 @@ CREATE TABLE `mandate` ( CONSTRAINT `mandato_fgkey1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `mandato_fgkey2` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `mandato_fgkey3` FOREIGN KEY (`mandateTypeFk`) REFERENCES `mandateType` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -31636,8 +31713,8 @@ DELIMITER ;; FOR EACH ROW BEGIN IF (NEW.code IS NULL) THEN - SET NEW.code=CONCAT(NEW.clientFk,'-',(SELECT AUTO_INCREMENT - FROM information_schema.TABLES + SET NEW.code=CONCAT(NEW.clientFk,'-',(SELECT AUTO_INCREMENT + FROM information_schema.TABLES WHERE TABLE_SCHEMA='vn' and TABLE_NAME='mandate')); END IF; END */;; @@ -31656,9 +31733,9 @@ DROP TABLE IF EXISTS `mandateType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mandateType` ( `id` smallint(5) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31670,12 +31747,12 @@ DROP TABLE IF EXISTS `manuscript`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `manuscript` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(45) CHARACTER SET utf8 NOT NULL, - `description` text COLLATE utf8_unicode_ci, - `enabled` tinyint(1) NOT NULL DEFAULT '1', + `code` varchar(45) CHARACTER SET utf8mb3 NOT NULL, + `description` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `enabled` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31686,9 +31763,9 @@ DROP TABLE IF EXISTS `mdbBranch`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mdbBranch` ( - `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', + `name` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', PRIMARY KEY (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31699,13 +31776,13 @@ DROP TABLE IF EXISTS `mdbVersion`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mdbVersion` ( - `app` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `branchFk` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `app` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `branchFk` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, `version` int(11) DEFAULT NULL, PRIMARY KEY (`app`,`branchFk`), KEY `mdbVersion_branchFk` (`branchFk`), CONSTRAINT `mdbVersion_branchFk` FOREIGN KEY (`branchFk`) REFERENCES `mdbBranch` (`name`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31717,9 +31794,9 @@ DROP TABLE IF EXISTS `medicalCenter`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `medicalCenter` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31734,17 +31811,17 @@ CREATE TABLE `medicalReview` ( `workerFk` int(10) unsigned NOT NULL, `centerFk` int(11) NOT NULL, `date` date DEFAULT NULL, - `time` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, + `time` varchar(5) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `isFit` tinyint(1) DEFAULT NULL, `amount` double DEFAULT NULL, - `invoice` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `remark` longtext COLLATE utf8_unicode_ci, + `invoice` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `remark` longtext COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `frgcenter_idx` (`centerFk`), KEY `frgnkWorker_idx` (`workerFk`), CONSTRAINT `frgcenter` FOREIGN KEY (`centerFk`) REFERENCES `medicalCenter` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `frgnkWorker` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31756,16 +31833,16 @@ DROP TABLE IF EXISTS `message`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `message` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `uuid` varchar(50) CHARACTER SET utf8 NOT NULL, - `sender` varchar(50) CHARACTER SET utf8 NOT NULL, - `recipient` varchar(50) CHARACTER SET utf8 NOT NULL, - `message` longtext CHARACTER SET utf8, - `sendDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `uuid` varchar(50) CHARACTER SET utf8mb3 NOT NULL, + `sender` varchar(50) CHARACTER SET utf8mb3 NOT NULL, + `recipient` varchar(50) CHARACTER SET utf8mb3 NOT NULL, + `message` longtext CHARACTER SET utf8mb3 DEFAULT NULL, + `sendDate` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `sender` (`sender`), KEY `recipient` (`recipient`), KEY `uuid` (`uuid`(8)) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31777,17 +31854,17 @@ DROP TABLE IF EXISTS `messageInbox`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `messageInbox` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `uuid` varchar(50) CHARACTER SET utf8 NOT NULL, - `sender` varchar(50) CHARACTER SET utf8 NOT NULL, - `recipient` varchar(45) CHARACTER SET utf8 NOT NULL, - `finalRecipient` varchar(50) CHARACTER SET utf8 NOT NULL, - `message` longtext CHARACTER SET utf8, - `sendDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `read` varchar(45) CHARACTER SET utf8 NOT NULL DEFAULT '0', + `uuid` varchar(50) CHARACTER SET utf8mb3 NOT NULL, + `sender` varchar(50) CHARACTER SET utf8mb3 NOT NULL, + `recipient` varchar(45) CHARACTER SET utf8mb3 NOT NULL, + `finalRecipient` varchar(50) CHARACTER SET utf8mb3 NOT NULL, + `message` longtext CHARACTER SET utf8mb3 DEFAULT NULL, + `sendDate` timestamp NULL DEFAULT current_timestamp(), + `read` varchar(45) CHARACTER SET utf8mb3 NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `uuid` (`uuid`(8)), KEY `finalRecipient` (`finalRecipient`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31839,9 +31916,9 @@ DROP TABLE IF EXISTS `mistakeType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mistakeType` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31853,15 +31930,15 @@ DROP TABLE IF EXISTS `mobileAppVersionControl`; /*!40101 SET character_set_client = utf8 */; 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', - `urlProduction` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - `urlBeta` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - `versionBeta` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `isVersionBetaCritical` tinyint(1) DEFAULT '0', + `appName` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `version` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '0', + `isVersionCritical` tinyint(1) DEFAULT 0, + `urlProduction` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `urlBeta` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `versionBeta` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isVersionBetaCritical` 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 '; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla para llevar el control de las Versions de las aplicaciones móvil '; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31878,7 +31955,7 @@ CREATE TABLE `mrw` ( `shipped` date DEFAULT NULL, `price` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31889,12 +31966,12 @@ DROP TABLE IF EXISTS `mrwService`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mrwService` ( - `agencyModeCodeFk` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `agencyModeCodeFk` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `clientType` int(11) unsigned NOT NULL, `serviceType` int(11) unsigned DEFAULT NULL, PRIMARY KEY (`agencyModeCodeFk`), CONSTRAINT `mrwService_agencyModeCodeFk` FOREIGN KEY (`agencyModeCodeFk`) REFERENCES `agencyMode` (`code`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Configuración de los servicios de MRW'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Configuración de los servicios de MRW'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31905,13 +31982,13 @@ DROP TABLE IF EXISTS `mrwServiceWeekday`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mrwServiceWeekday` ( - `agencyModeCodeFk` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `weekdays` set('mon','tue','wed','thu','fri','sat','sun') COLLATE utf8_unicode_ci NOT NULL, + `agencyModeCodeFk` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `weekdays` set('mon','tue','wed','thu','fri','sat','sun') COLLATE utf8mb3_unicode_ci NOT NULL, `serviceType` int(11) unsigned NOT NULL, - `params` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `params` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`agencyModeCodeFk`), CONSTRAINT `mrwServiceWeekday_agencyModeCodeFk` FOREIGN KEY (`agencyModeCodeFk`) REFERENCES `agencyMode` (`code`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Configuración de los servicios en relación con el día de la semana para MRW'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Configuración de los servicios en relación con el día de la semana para MRW'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31940,15 +32017,15 @@ DROP TABLE IF EXISTS `noticeCategory`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `noticeCategory` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `keyName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `subject` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `description` text COLLATE utf8_unicode_ci, - `isEnabled` tinyint(1) NOT NULL DEFAULT '1', - `requiredRole` int(11) NOT NULL DEFAULT '1', + `keyName` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `name` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `subject` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `description` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isEnabled` tinyint(1) NOT NULL DEFAULT 1, + `requiredRole` int(11) NOT NULL DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `keyName_UNIQUE` (`keyName`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31959,13 +32036,13 @@ DROP TABLE IF EXISTS `noticeSubscription`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `noticeSubscription` ( - `noticeCategoryFk` int(11) NOT NULL DEFAULT '0', - `userFk` int(10) unsigned NOT NULL DEFAULT '0', + `noticeCategoryFk` int(11) NOT NULL DEFAULT 0, + `userFk` int(10) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`noticeCategoryFk`,`userFk`), KEY `noticeSubscription_ibfk_2` (`userFk`), CONSTRAINT `noticeSubscription_ibfk_1` FOREIGN KEY (`noticeCategoryFk`) REFERENCES `noticeCategory` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `noticeSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31977,11 +32054,11 @@ DROP TABLE IF EXISTS `observationType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `observationType` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `description` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `hasNewBornMessage` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indica aquellos que deben de recibir un mensaje advirtiendo de un cliente nuevo', + `description` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL, + `code` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `hasNewBornMessage` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica aquellos que deben de recibir un mensaje advirtiendo de un cliente nuevo', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31992,12 +32069,44 @@ DROP TABLE IF EXISTS `occupationCode`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `occupationCode` ( - `code` varchar(1) CHARACTER SET utf8 NOT NULL, - `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(1) CHARACTER SET utf8mb3 NOT NULL, + `name` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Código de ocupación de la seguridad social'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Código de ocupación de la seguridad social'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `operator` +-- + +DROP TABLE IF EXISTS `operator`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `operator` ( + `workerFk` int(10) unsigned NOT NULL, + `numberOfWagons` int(11) DEFAULT 1, + PRIMARY KEY (`workerFk`), + KEY `operator_FK` (`workerFk`), + CONSTRAINT `operator_FK` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `operatorWorkerCode` +-- + +DROP TABLE IF EXISTS `operatorWorkerCode`; +/*!50001 DROP VIEW IF EXISTS `operatorWorkerCode`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `operatorWorkerCode` ( + `workerFk` tinyint NOT NULL, + `fullName` tinyint NOT NULL, + `code` tinyint NOT NULL, + `numberOfWagons` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `orderTicket` -- @@ -32007,12 +32116,12 @@ DROP TABLE IF EXISTS `orderTicket`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `orderTicket` ( `orderFk` int(10) unsigned NOT NULL, - `ticketFk` int(11) NOT NULL DEFAULT '0', + `ticketFk` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`ticketFk`,`orderFk`), KEY `order_id` (`orderFk`), CONSTRAINT `hedera_id` FOREIGN KEY (`orderFk`) REFERENCES `hedera`.`order` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `idTicketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32024,18 +32133,18 @@ DROP TABLE IF EXISTS `origin`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `origin` ( `id` tinyint(2) unsigned NOT NULL AUTO_INCREMENT, - `code` varchar(3) COLLATE utf8_unicode_ci NOT NULL, - `name` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `warehouseFk` smallint(5) unsigned DEFAULT '4', - `flag__` blob, - `nl__` tinyint(4) NOT NULL DEFAULT '0', - `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', + `code` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, + `name` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL, + `warehouseFk` smallint(5) unsigned DEFAULT 4, + `flag__` blob DEFAULT NULL, + `nl__` tinyint(4) NOT NULL DEFAULT 0, + `countryFk` mediumint(8) unsigned NOT NULL DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `Abreviatura` (`code`), KEY `warehouse_id` (`warehouseFk`), KEY `Id_Paises` (`countryFk`), CONSTRAINT `origin_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32047,10 +32156,10 @@ DROP TABLE IF EXISTS `originI18n`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `originI18n` ( `originFk` tinyint(2) unsigned NOT NULL, - `lang` char(2) CHARACTER SET utf8 NOT NULL, - `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `lang` char(2) CHARACTER SET utf8mb3 NOT NULL, + `name` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`originFk`,`lang`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32080,7 +32189,7 @@ CREATE TABLE `outgoingInvoiceVat` ( `equalizationTax` decimal(12,2) DEFAULT NULL, `Vat` decimal(12,2) DEFAULT NULL, PRIMARY KEY (`outgoingInvoice`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32096,7 +32205,7 @@ CREATE TABLE `packageChecked` ( PRIMARY KEY (`id`), UNIQUE KEY `entryFk_UNIQUE` (`itemFk`), KEY `fkItem_idx` (`itemFk`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32107,13 +32216,13 @@ DROP TABLE IF EXISTS `packageEquivalent`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `packageEquivalent` ( - `packagingFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `equivalentFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `packagingFk` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, + `equivalentFk` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`packagingFk`,`equivalentFk`), KEY `packageEquivalent_fk2_idx` (`equivalentFk`), CONSTRAINT `packageEquivalent_fk1` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `packageEquivalent_fk2` FOREIGN KEY (`equivalentFk`) REFERENCES `packaging` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='recoge los modelos de cubos que se han de sustituir a efectos de presentar informes resumidos'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='recoge los modelos de cubos que se han de sustituir a efectos de presentar informes resumidos'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32138,40 +32247,104 @@ DROP TABLE IF EXISTS `packaging`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `packaging` ( - `id` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `volume` decimal(10,2) DEFAULT '0.00', - `width` decimal(10,2) DEFAULT '0.00', - `depth` decimal(10,2) DEFAULT '0.00', - `height` decimal(10,2) DEFAULT '0.00', - `value` decimal(10,2) DEFAULT '0.00', - `isPackageReturnable` tinyint(1) NOT NULL DEFAULT '0', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `id` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, + `volume` decimal(10,2) DEFAULT 0.00, + `width` decimal(10,2) DEFAULT 0.00, + `depth` decimal(10,2) DEFAULT 0.00, + `height` decimal(10,2) DEFAULT 0.00, + `value` decimal(10,2) DEFAULT 0.00, + `isPackageReturnable` tinyint(1) NOT NULL DEFAULT 0, + `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `packagingReturnFk` int(11) DEFAULT NULL, `lower` int(11) DEFAULT NULL, `upload` int(11) DEFAULT NULL, `base` decimal(10,2) DEFAULT NULL, `itemFk` int(11) DEFAULT NULL, `price` decimal(10,2) NOT NULL, - `isBox` tinyint(1) NOT NULL DEFAULT '0', + `isBox` tinyint(1) NOT NULL DEFAULT 0, `cubicPackage` decimal(10,2) DEFAULT NULL, - `returnCost` decimal(10,2) NOT NULL DEFAULT '0.00', - `cmrName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `returnCost` decimal(10,2) NOT NULL DEFAULT 0.00, + `cmrName` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `freightItemFk` int(11) DEFAULT NULL, - `hasCompressionVariations` tinyint(1) DEFAULT '0' COMMENT 'Floramondo puede servirlos no llenos del todo', + `hasCompressionVariations` tinyint(1) DEFAULT 0 COMMENT 'Floramondo puede servirlos no llenos del todo', `conveyorBuildingClassFk` int(11) DEFAULT NULL, - `isTrolley` tinyint(1) NOT NULL DEFAULT '0', - `isPallet` tinyint(1) NOT NULL DEFAULT '0', + `isTrolley` tinyint(1) NOT NULL DEFAULT 0, + `isPallet` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `packaging_fk1` (`itemFk`), KEY `packaging_fk2_idx` (`freightItemFk`), KEY `packaging_FK` (`conveyorBuildingClassFk`), KEY `packaging_FK_1` (`packagingReturnFk`), CONSTRAINT `packaging_FK` FOREIGN KEY (`conveyorBuildingClassFk`) REFERENCES `conveyorBuildingClass` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `packaging_FK_1` FOREIGN KEY (`packagingReturnFk`) REFERENCES `vn2008`.`Cubos_Retorno` (`idCubos_Retorno`) ON UPDATE CASCADE, + CONSTRAINT `packaging_FK_1` FOREIGN KEY (`packagingReturnFk`) REFERENCES `returnBuckets` (`id`) ON UPDATE CASCADE, CONSTRAINT `packaging_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE, CONSTRAINT `packaging_fk2` FOREIGN KEY (`freightItemFk`) REFERENCES `item` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 = 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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`packaging_beforeInsert` + BEFORE INSERT ON `packaging` + FOR EACH ROW +BEGIN + DECLARE vAmount INT DEFAULT NULL; + + IF NEW.isPackageReturnable THEN + SELECT cb.freightPackagingFull INTO vAmount + FROM returnBuckets cb + WHERE cb.id = NEW.packagingReturnFk; + + SET NEW.value = IF (vAmount IS NULL, + NEW.base, + vAmount / IFNULL(NEW.upload, 0) + NEW.base); + ELSE + SET NEW.value = NEW.price + NEW.base; + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`packaging_beforeUpdate` + BEFORE UPDATE ON `packaging` + FOR EACH ROW +BEGIN + DECLARE vAmount INT DEFAULT NULL; + + IF NEW.isPackageReturnable THEN + SELECT cb.freightPackagingFull INTO vAmount + FROM returnBuckets cb + WHERE cb.id = NEW.packagingReturnFk; + + SET NEW.value = IF (vAmount IS NULL, + NEW.base, + vAmount / IFNULL(NEW.upload, 0) + NEW.base); + ELSE + SET NEW.value = NEW.price + NEW.base; + 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 `packagingConfig` @@ -32185,8 +32358,11 @@ CREATE TABLE `packagingConfig` ( `upperGap` int(11) NOT NULL, `previousPreparationMinimumSize` int(11) NOT NULL, `defaultConveyorBuildingClass` int(11) NOT NULL, + `palletPackaging` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT 'pallet USA', + `carryPackaging` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT 'cc', + `freightItemPackaging` int(11) DEFAULT 71, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Altura mínima para preparar pedidos en preparacion previa'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Altura mínima para preparar pedidos en preparacion previa'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32198,8 +32374,8 @@ DROP TABLE IF EXISTS `packagingGifts`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `packagingGifts` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `photo` blob, + `description` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `photo` blob DEFAULT NULL, `started` date NOT NULL, `ended` date NOT NULL, `warehouseFk` smallint(5) unsigned DEFAULT NULL, @@ -32212,7 +32388,39 @@ CREATE TABLE `packagingGifts` ( CONSTRAINT `PackagingGifts_FK` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`), CONSTRAINT `PackagingGifts_FK_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`), CONSTRAINT `PackagingGifts_FK_2` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `packagingWithFreight` +-- + +DROP TABLE IF EXISTS `packagingWithFreight`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `packagingWithFreight` ( + `packagingFk` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, + `priority` int(11) NOT NULL, + PRIMARY KEY (`packagingFk`), + UNIQUE KEY `packagingWithFreight_UN` (`priority`), + CONSTRAINT `packagingWithFreight_FK` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Embalajes con porte para encajado'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `packagingWithoutFreight` +-- + +DROP TABLE IF EXISTS `packagingWithoutFreight`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `packagingWithoutFreight` ( + `packagingFk` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, + `priority` int(11) NOT NULL, + PRIMARY KEY (`packagingFk`), + UNIQUE KEY `packagingWithoutFreight_UN` (`priority`), + CONSTRAINT `packagingWithoutFreight_FK` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Embalajes sin porte para encajar'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32224,7 +32432,7 @@ DROP TABLE IF EXISTS `packingSite`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `packingSite` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `hostFk` int(11) NOT NULL, `printerFk` tinyint(3) unsigned DEFAULT NULL, `collectionFk` int(11) DEFAULT NULL COMMENT 'Last collection packed on this site', @@ -32236,7 +32444,7 @@ CREATE TABLE `packingSite` ( CONSTRAINT `packingSite_FK` FOREIGN KEY (`hostFk`) REFERENCES `host` (`id`), CONSTRAINT `packingSite_FK_1` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`), CONSTRAINT `packingSite_FK_2` FOREIGN KEY (`collectionFk`) REFERENCES `collection` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32248,13 +32456,13 @@ DROP TABLE IF EXISTS `packingSiteLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `packingSiteLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `packingSiteFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `hostFk` varchar(15) COLLATE utf8_unicode_ci NOT NULL, + `packingSiteFk` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `hostFk` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL, `workerFk` int(10) unsigned NOT NULL, - `printerModelFk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `typeErrorFk` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, - `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `description` text COLLATE utf8_unicode_ci, + `printerModelFk` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `typeErrorFk` varchar(30) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `packingSiteLog_UN` (`id`), KEY `packingSiteLog_FK` (`workerFk`), @@ -32265,7 +32473,7 @@ CREATE TABLE `packingSiteLog` ( CONSTRAINT `packingSiteLog_FK_1` FOREIGN KEY (`printerModelFk`) REFERENCES `printerModel` (`code`) ON UPDATE CASCADE, CONSTRAINT `packingSiteLog_FK_2` FOREIGN KEY (`packingSiteFk`) REFERENCES `packingSite` (`code`) ON UPDATE CASCADE, CONSTRAINT `packingSiteLog_FK_4` FOREIGN KEY (`typeErrorFk`) REFERENCES `packingSiteTypeError` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32276,10 +32484,10 @@ DROP TABLE IF EXISTS `packingSiteTypeError`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `packingSiteTypeError` ( - `code` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `description` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL, + `description` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32291,16 +32499,16 @@ DROP TABLE IF EXISTS `parking`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `parking` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `column` varchar(5) CHARACTER SET utf8 DEFAULT '--', - `row` varchar(5) CHARACTER SET utf8 DEFAULT '--', - `sectorFk` int(11) NOT NULL DEFAULT '2', - `code` varchar(8) CHARACTER SET utf8 DEFAULT NULL, + `column` varchar(5) CHARACTER SET utf8mb3 DEFAULT '--', + `row` varchar(5) CHARACTER SET utf8mb3 DEFAULT '--', + `sectorFk` int(11) NOT NULL DEFAULT 2, + `code` varchar(8) CHARACTER SET utf8mb3 DEFAULT NULL, `pickingOrder` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`), KEY `parking_fk1_idx` (`sectorFk`), CONSTRAINT `parking_fk1` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla con los parkings del altillo'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla con los parkings del altillo'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -32339,7 +32547,7 @@ DELIMITER ;; BEGIN -- SET new.`code` = CONCAT(new.`column`,' - ',new.`row`) ; - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -32356,9 +32564,9 @@ DROP TABLE IF EXISTS `payDem`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `payDem` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `payDem` varchar(15) COLLATE utf8_unicode_ci NOT NULL, + `payDem` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32372,7 +32580,7 @@ CREATE TABLE `payDemDetail` ( `id` tinyint(3) unsigned NOT NULL, `detail` tinyint(3) unsigned NOT NULL, PRIMARY KEY (`id`,`detail`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32384,18 +32592,18 @@ DROP TABLE IF EXISTS `payMethod`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `payMethod` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `code` varchar(50) CHARACTER SET utf8 DEFAULT NULL, - `name` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `solution` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `outstandingDebt` tinyint(3) unsigned zerofill NOT NULL DEFAULT '000', - `graceDays` int(11) unsigned NOT NULL DEFAULT '0', - `isIbanRequiredForClients` tinyint(3) DEFAULT '0', - `isIbanRequiredForSuppliers` tinyint(3) DEFAULT '0', - `isNotified` tinyint(3) NOT NULL DEFAULT '1', - `hasVerified` tinyint(1) DEFAULT '0', - `graceMonthsDisableChecked` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Deshabilita la comprobación de los datos bancarios de todos aquellos proveedores que no hayan recibido un pago en los meses especificados', + `code` varchar(50) CHARACTER SET utf8mb3 DEFAULT NULL, + `name` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL, + `solution` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `outstandingDebt` tinyint(3) unsigned zerofill NOT NULL DEFAULT 000, + `graceDays` int(11) unsigned NOT NULL DEFAULT 0, + `isIbanRequiredForClients` tinyint(3) DEFAULT 0, + `isIbanRequiredForSuppliers` tinyint(3) DEFAULT 0, + `isNotified` tinyint(3) NOT NULL DEFAULT 1, + `hasVerified` tinyint(1) DEFAULT 0, + `graceMonthsDisableChecked` int(11) unsigned NOT NULL DEFAULT 0 COMMENT 'Deshabilita la comprobación de los datos bancarios de todos aquellos proveedores que no hayan recibido un pago en los meses especificados', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32409,16 +32617,16 @@ CREATE TABLE `payment` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `received` date NOT NULL, `supplierFk` int(11) NOT NULL, - `amount` decimal(10,2) NOT NULL DEFAULT '0.00', - `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT '1', + `amount` decimal(10,2) NOT NULL DEFAULT 0.00, + `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT 1, `divisa` decimal(10,2) DEFAULT NULL, - `bankFk` int(11) NOT NULL DEFAULT '0', + `bankFk` int(11) NOT NULL DEFAULT 0, `payMethodFk` tinyint(3) unsigned NOT NULL, - `bankingFees` double(6,2) unsigned NOT NULL DEFAULT '0.00', - `concept` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `isConciliated` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0', + `bankingFees` double(6,2) unsigned NOT NULL DEFAULT 0.00, + `concept` varchar(30) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, + `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `isConciliated` tinyint(1) unsigned zerofill NOT NULL DEFAULT 0, `exchangeInsuranceFk__` int(11) DEFAULT NULL, `dueDated` date DEFAULT NULL, `workerFk` int(10) unsigned DEFAULT NULL, @@ -32437,7 +32645,7 @@ CREATE TABLE `payment` ( CONSTRAINT `payment_FK` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`), CONSTRAINT `payment_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, CONSTRAINT `payment_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -32466,13 +32674,13 @@ BEGIN SELECT account INTO cuenta_banco FROM bank WHERE id = NEW.bankFk; - + SELECT account INTO cuenta_proveedor FROM supplier WHERE id = NEW.supplierFk; - + CALL vn.ledger_next(vNewBookEntry); - + INSERT INTO XDiario ( ASIEN, FECHA, SUBCTA, @@ -32498,7 +32706,7 @@ BEGIN cuenta_banco CONTRA, NEW.amount EURODEBE, 0 EUROHABER) gf; - + IF NEW.bankingFees <> 0 THEN INSERT INTO XDiario ( ASIEN, FECHA, @@ -32520,7 +32728,7 @@ BEGIN FROM supplier s JOIN country c ON s.countryFk = c.id WHERE s.id = NEW.supplierFk; - END IF; + END IF; END IF; SET NEW.dueDated = IFNULL(NEW.dueDated, NEW.received); @@ -32528,15 +32736,15 @@ BEGIN SELECT isActive INTO isSupplierActive FROM supplier WHERE id = NEW.supplierFk; - + IF isSupplierActive = FALSE THEN CALL util.throw('SUPPLIER_INACTIVE'); END IF; - + IF ISNULL(NEW.workerFk) THEN SET NEW.workerFk = account.myUser_getId(); END IF; - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -32558,12 +32766,12 @@ DELIMITER ;; BEGIN DECLARE vIsPayMethodChecked BOOLEAN; DECLARE vEmail VARCHAR(150); - + SELECT isPayMethodChecked INTO vIsPayMethodChecked FROM supplier WHERE id = NEW.supplierFk; - - + + IF vIsPayMethodChecked = FALSE THEN SELECT notificationEmail INTO vEmail @@ -32618,13 +32826,13 @@ DROP TABLE IF EXISTS `pcs`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `pcs` ( - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NULL DEFAULT current_timestamp(), `routeFk` int(10) unsigned DEFAULT NULL, `id` int(11) NOT NULL AUTO_INCREMENT, `pallet` int(11) DEFAULT NULL, `box` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32635,7 +32843,7 @@ DROP TABLE IF EXISTS `pcs_graf`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `pcs_graf` ( - `id` int(11) NOT NULL DEFAULT '0', + `id` int(11) NOT NULL DEFAULT 0, `dia` date DEFAULT NULL, `created` datetime DEFAULT NULL, `box` decimal(4,0) DEFAULT NULL, @@ -32646,7 +32854,7 @@ CREATE TABLE `pcs_graf` ( PRIMARY KEY (`id`), KEY `pcs_graf_index1` (`hh`), KEY `pcs_graf_index2` (`mm`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32661,7 +32869,7 @@ CREATE TABLE `pedidosInternos` ( `idArticle` int(11) DEFAULT NULL, `quantity` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32672,10 +32880,10 @@ DROP TABLE IF EXISTS `periodicityType`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `periodicityType` ( - `code` varchar(45) CHARACTER SET utf8 NOT NULL, - `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(45) CHARACTER SET utf8mb3 NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32701,25 +32909,25 @@ DROP TABLE IF EXISTS `person__`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `person__` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `firstname` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `surnames` varchar(60) COLLATE utf8_unicode_ci NOT NULL, - `fi` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `firstname` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `surnames` varchar(60) COLLATE utf8mb3_unicode_ci NOT NULL, + `fi` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `birth` date DEFAULT NULL, `readerId__` int(11) DEFAULT NULL, `workerFk` int(10) unsigned DEFAULT NULL, - `isDisable` tinyint(1) NOT NULL DEFAULT '0', - `isFreelance` tinyint(1) NOT NULL DEFAULT '0', - `isSsDiscounted` tinyint(1) NOT NULL DEFAULT '0', - `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', + `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 utf8mb3_unicode_ci DEFAULT NULL, + `p2` longtext COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `sex` enum('M','F') COLLATE utf8mb3_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 -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32731,9 +32939,9 @@ DROP TABLE IF EXISTS `personalProtectionEquipment`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `personalProtectionEquipment` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32744,20 +32952,20 @@ DROP TABLE IF EXISTS `pgc`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `pgc` ( - `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, `rate` decimal(10,2) NOT NULL, - `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `cplusTaxBreakFk` int(10) unsigned DEFAULT '1', - `mod340` tinyint(1) NOT NULL DEFAULT '0', - `mod347` tinyint(1) NOT NULL DEFAULT '0', - `cplusTrascendency477Fk` int(10) unsigned DEFAULT '1', - `isEqualizated` tinyint(1) DEFAULT '0', + `name` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `cplusTaxBreakFk` int(10) unsigned DEFAULT 1, + `mod340` tinyint(1) NOT NULL DEFAULT 0, + `mod347` tinyint(1) NOT NULL DEFAULT 0, + `cplusTrascendency477Fk` int(10) unsigned DEFAULT 1, + `isEqualizated` tinyint(1) DEFAULT 0, PRIMARY KEY (`code`), KEY `pgc_fk1_idx` (`cplusTaxBreakFk`), KEY `pgc_fk2_idx` (`cplusTrascendency477Fk`), CONSTRAINT `pgc_fk1` FOREIGN KEY (`cplusTaxBreakFk`) REFERENCES `cplusTaxBreak` (`id`) ON UPDATE CASCADE, CONSTRAINT `pgc_fk2` FOREIGN KEY (`cplusTrascendency477Fk`) REFERENCES `cplusTrascendency477` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Plan General Contable'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Plan General Contable'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32768,13 +32976,13 @@ DROP TABLE IF EXISTS `pgcEqu`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `pgcEqu` ( - `vatFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Cuenta de IVA', - `equFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Cuenta de recargo de equivalencia', + `vatFk` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'Cuenta de IVA', + `equFk` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'Cuenta de recargo de equivalencia', PRIMARY KEY (`vatFk`,`equFk`), KEY `pgcEqu_fk2_idx` (`equFk`), CONSTRAINT `pgcEqu_fk1` FOREIGN KEY (`vatFk`) REFERENCES `pgc` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `pgcEqu_fk2` FOREIGN KEY (`equFk`) REFERENCES `pgc` (`code`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Recoge las cuentas contables con recargo de equivalencia e identifica a la que corresponde al iva y la que corresponde al recargo'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Recoge las cuentas contables con recargo de equivalencia e identifica a la que corresponde al iva y la que corresponde al recargo'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32785,10 +32993,10 @@ DROP TABLE IF EXISTS `pgcMaster`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `pgcMaster` ( - `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `description` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, + `description` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='tan solo tiene las cuentas de contaplus'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='tan solo tiene las cuentas de contaplus'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32817,14 +33025,14 @@ DROP TABLE IF EXISTS `plantpassport`; CREATE TABLE `plantpassport` ( `producerFk` mediumint(3) unsigned NOT NULL, `plantpassportAuthorityFk` mediumint(3) unsigned NOT NULL, - `number` varchar(25) CHARACTER SET utf8 DEFAULT NULL, - `isRequested` tinyint(2) NOT NULL DEFAULT '0', + `number` varchar(25) CHARACTER SET utf8mb3 DEFAULT NULL, + `isRequested` tinyint(2) NOT NULL DEFAULT 0, PRIMARY KEY (`producerFk`,`plantpassportAuthorityFk`), KEY `plantpassport_authority_idx` (`plantpassportAuthorityFk`), KEY `producer_id_idx` (`producerFk`), CONSTRAINT `plantpassport_authority` FOREIGN KEY (`plantpassportAuthorityFk`) REFERENCES `plantpassportAuthority` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `producer` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='tiene la asignacion de cada productor con la autoridad certificadora'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='tiene la asignacion de cada productor con la autoridad certificadora'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32836,13 +33044,13 @@ DROP TABLE IF EXISTS `plantpassportAuthority`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `plantpassportAuthority` ( `id` mediumint(3) unsigned NOT NULL, - `denomination` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `denomination` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `countryFk` mediumint(8) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `denomination_UNIQUE` (`denomination`), KEY `Pais_id_idx` (`countryFk`), CONSTRAINT `Pais_id` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='entidades certificadoras'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='entidades certificadoras'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32853,13 +33061,13 @@ DROP TABLE IF EXISTS `postCode`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `postCode` ( - `code` varchar(30) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL, `townFk` int(11) NOT NULL, `geoFk` int(11) DEFAULT NULL, PRIMARY KEY (`code`,`townFk`), KEY `postCodeTownFk_idx` (`townFk`), CONSTRAINT `postCodeTownFk` FOREIGN KEY (`townFk`) REFERENCES `town` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -32962,25 +33170,25 @@ DROP TABLE IF EXISTS `ppe`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ppe` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `amortization` decimal(10,2) NOT NULL DEFAULT '0.00', + `amortization` decimal(10,2) NOT NULL DEFAULT 0.00, `firstAmortizated` date DEFAULT NULL, `lastAmortizated` date DEFAULT NULL, `finished` date DEFAULT NULL, - `value` decimal(10,2) NOT NULL DEFAULT '0.00', + `value` decimal(10,2) NOT NULL DEFAULT 0.00, `planFk` int(11) NOT NULL, `groupFk` int(11) DEFAULT NULL, - `account` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `endowment` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `elementAccount` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `nature` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, - `location` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `account` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `endowment` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `elementAccount` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `nature` varchar(30) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `location` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `discharged` date DEFAULT NULL, - `cause` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `photo` blob, - `isInvestmentAsset` tinyint(4) NOT NULL DEFAULT '0', + `cause` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `photo` blob DEFAULT NULL, + `isInvestmentAsset` tinyint(4) NOT NULL DEFAULT 0, `workerFk` int(10) unsigned DEFAULT NULL, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', - `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, + `description` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `ppe_fk1_idx` (`workerFk`), KEY `ppe_fk2_idx` (`planFk`), @@ -32998,7 +33206,7 @@ CREATE TABLE `ppe` ( CONSTRAINT `ppe_fk5` FOREIGN KEY (`account`) REFERENCES `pgcMaster` (`code`) ON UPDATE CASCADE, CONSTRAINT `ppe_fk6` FOREIGN KEY (`endowment`) REFERENCES `pgcMaster` (`code`) ON UPDATE CASCADE, CONSTRAINT `ppe_fk7` FOREIGN KEY (`elementAccount`) REFERENCES `pgcMaster` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Property, plant & equipment\nInmvolizado, en español'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Property, plant & equipment\nInmvolizado, en español'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33012,13 +33220,13 @@ CREATE TABLE `ppeComponent` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ppeFk` int(11) NOT NULL, `invoiceInFk` mediumint(8) unsigned NOT NULL, - `amount` decimal(10,2) NOT NULL DEFAULT '0.00', + `amount` decimal(10,2) NOT NULL DEFAULT 0.00, PRIMARY KEY (`id`), KEY `ppeComponent_fk1_idx` (`ppeFk`), KEY `ppeComponent_fk2_idx` (`invoiceInFk`), CONSTRAINT `ppeComponent_fk1` FOREIGN KEY (`ppeFk`) REFERENCES `ppe` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ppeComponent_fk2` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33037,7 +33245,7 @@ CREATE TABLE `ppeDMS` ( KEY `ppeDMS_fk2_idx` (`ppeFk`), CONSTRAINT `ppeDMS_fk1` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ppeDMS_fk2` FOREIGN KEY (`ppeFk`) REFERENCES `ppe` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33049,9 +33257,9 @@ DROP TABLE IF EXISTS `ppeGroup`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ppeGroup` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tipo de inmovilizado'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tipo de inmovilizado'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33062,10 +33270,10 @@ DROP TABLE IF EXISTS `ppeLocation`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ppeLocation` ( - `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `description` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '', + `description` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33077,10 +33285,10 @@ DROP TABLE IF EXISTS `ppePlan`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ppePlan` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `rate` decimal(3,2) NOT NULL DEFAULT '1.00', - `days` int(11) NOT NULL DEFAULT '365', + `rate` decimal(3,2) NOT NULL DEFAULT 1.00, + `days` int(11) NOT NULL DEFAULT 365, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Plan de amortizacion para la tabla ppe'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Plan de amortizacion para la tabla ppe'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33098,9 +33306,9 @@ CREATE TABLE `priceFixed` ( `rate3` double NOT NULL, `started` date NOT NULL, `ended` date NOT NULL, - `bonus` double NOT NULL DEFAULT '0', - `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT '0', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `bonus` double NOT NULL DEFAULT 0, + `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT 0, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `id` int(11) NOT NULL AUTO_INCREMENT, `grouping` smallint(5) DEFAULT NULL, `packing` int(11) DEFAULT NULL, @@ -33113,7 +33321,7 @@ CREATE TABLE `priceFixed` ( KEY `warehouse_id` (`warehouseFk`), CONSTRAINT `priceFixed_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `priceFixed_ibfk_2` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -33176,15 +33384,15 @@ DROP TABLE IF EXISTS `printQueue`; CREATE TABLE `printQueue` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `printerFk` tinyint(3) unsigned DEFAULT NULL, - `priorityFk` tinyint(3) unsigned NOT NULL DEFAULT '3' COMMENT '1 - high, 2 - normal, 3 - low', + `priorityFk` tinyint(3) unsigned NOT NULL DEFAULT 3 COMMENT '1 - high, 2 - normal, 3 - low', `reportFk` tinyint(3) unsigned DEFAULT NULL, - `statusCode` enum('queued','error','printing') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'queued', + `statusCode` enum('queued','error','printing') COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'queued', `started` datetime DEFAULT NULL, `finished` datetime DEFAULT NULL, `workerFk` int(11) DEFAULT NULL, - `error` text COLLATE utf8_unicode_ci, + `error` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `errorNumber` int(11) DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `statusCode` (`statusCode`), KEY `printerFk` (`printerFk`), @@ -33194,7 +33402,7 @@ CREATE TABLE `printQueue` ( CONSTRAINT `printQueue_printerFk` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`) ON UPDATE CASCADE, CONSTRAINT `printQueue_priorityFk` FOREIGN KEY (`priorityFk`) REFERENCES `queuePriority` (`id`) ON UPDATE CASCADE, CONSTRAINT `printQueue_report` FOREIGN KEY (`reportFk`) REFERENCES `report` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33206,11 +33414,12 @@ DROP TABLE IF EXISTS `printQueueArgs`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `printQueueArgs` ( `printQueueFk` int(10) unsigned NOT NULL, - `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `value` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `value` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + PRIMARY KEY (`printQueueFk`,`name`), KEY `printQueueArgs_printQueueFk_idx` (`printQueueFk`), CONSTRAINT `printQueueArgs_printQueueFk` FOREIGN KEY (`printQueueFk`) REFERENCES `printQueue` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Argumentos que se pasarán al informe para generarlos'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Argumentos que se pasarán al informe para generarlos'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33221,10 +33430,10 @@ DROP TABLE IF EXISTS `printQueueConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `printQueueConfig` ( - `networkDrive` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'X:\\', - `dmsPath` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT ' \\\\server\\dms', - `printQueueLimit` int(11) NOT NULL DEFAULT '30' COMMENT 'Número máximo de filas de la cola de impresión a mostrar al enviar correo a través del evento vn.printQueue_check' -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + `networkDrive` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'X:\\', + `dmsPath` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT ' \\\\server\\dms', + `printQueueLimit` int(11) NOT NULL DEFAULT 30 COMMENT 'Número máximo de filas de la cola de impresión a mostrar al enviar correo a través del evento vn.printQueue_check' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33238,15 +33447,15 @@ CREATE TABLE `printServerQueue2__` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `printerFk` tinyint(3) unsigned DEFAULT NULL, `priorityFk` tinyint(3) unsigned DEFAULT NULL, - `reportFk` tinyint(3) unsigned DEFAULT '0', - `statusFk` tinyint(3) unsigned DEFAULT '1', + `reportFk` tinyint(3) unsigned DEFAULT 0, + `statusFk` tinyint(3) unsigned DEFAULT 1, `started` datetime DEFAULT NULL, `finished` datetime DEFAULT NULL, - `param1` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `param1` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `workerFk` int(11) DEFAULT NULL, - `param2` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `param3` text COLLATE utf8_unicode_ci, - `error` text COLLATE utf8_unicode_ci, + `param2` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `param3` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `error` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `Id_Impresora_2` (`printerFk`,`priorityFk`,`reportFk`,`statusFk`,`param1`,`workerFk`,`param2`), KEY `Id_estado` (`statusFk`), @@ -33256,7 +33465,7 @@ CREATE TABLE `printServerQueue2__` ( KEY `Id_Trabajador` (`workerFk`), CONSTRAINT `printServerQueue2_FK_1` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`), CONSTRAINT `printServerQueue2_FK_2` FOREIGN KEY (`priorityFk`) REFERENCES `queuePriority` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33268,13 +33477,13 @@ DROP TABLE IF EXISTS `printer`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `printer` ( `id` tinyint(3) unsigned NOT NULL, - `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `path` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `modelFk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `macWifi` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `ipAddress` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `reference` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `isLabeler` tinyint(1) DEFAULT '0' COMMENT 'Indica si es impresora de etiquetas', + `name` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `path` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `modelFk` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `macWifi` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `ipAddress` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `reference` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isLabeler` tinyint(1) DEFAULT 0 COMMENT 'Indica si es impresora de etiquetas', `sectorFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `printer_UN` (`reference`), @@ -33285,7 +33494,7 @@ CREATE TABLE `printer` ( KEY `printer_sectorFk` (`sectorFk`), CONSTRAINT `printer_FK` FOREIGN KEY (`modelFk`) REFERENCES `printerModel` (`code`) ON UPDATE CASCADE, CONSTRAINT `printer_sectorFk` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33296,9 +33505,9 @@ DROP TABLE IF EXISTS `printerModel`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `printerModel` ( - `code` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33309,11 +33518,11 @@ DROP TABLE IF EXISTS `printingQueueCheck`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `printingQueueCheck` ( - `lastCount` int(11) unsigned NOT NULL DEFAULT '0', - `lastCheckSum` int(11) unsigned NOT NULL DEFAULT '0', - `isAlreadyNotified` tinyint(2) NOT NULL DEFAULT '0', + `lastCount` int(11) unsigned NOT NULL DEFAULT 0, + `lastCheckSum` int(11) unsigned NOT NULL DEFAULT 0, + `isAlreadyNotified` tinyint(2) NOT NULL DEFAULT 0, PRIMARY KEY (`lastCount`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Comprueba que el servidor de impresion no esta parado'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Comprueba que el servidor de impresion no esta parado'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33325,53 +33534,13 @@ DROP TABLE IF EXISTS `producer`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `producer` ( `id` mediumint(3) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `isVisible` tinyint(1) NOT NULL DEFAULT '1', - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `name` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isVisible` tinyint(1) NOT NULL DEFAULT 1, + `created` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 = 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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`producer_afterInsert` - AFTER INSERT ON `producer` - FOR EACH ROW -BEGIN - CALL util.debugAdd('producer_insert',CONCAT(NEW.name, NEW.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 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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER producer_beforeDelete -BEFORE DELETE -ON producer FOR EACH ROW -BEGIN - CALL util.debugAdd('producer_delete',CONCAT(OLD.name, OLD.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 */ ; -- -- Table structure for table `productionConfig` @@ -33381,20 +33550,24 @@ DROP TABLE IF EXISTS `productionConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `productionConfig` ( - `isPreviousPreparationRequired` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Impide que los sacadores reciban tickets que tengan productos de prep previa', - `ticketPrintedMax` int(10) unsigned NOT NULL DEFAULT '8' COMMENT 'numero máxido de tickets por carro que se ponen en impreso al pedir colección', - `ticketTrolleyMax` int(10) unsigned NOT NULL DEFAULT '4' COMMENT 'numero máximo de tickets por carro para asignar baldas en una colección', - `rookieDays` int(11) NOT NULL DEFAULT '3' COMMENT 'dias en que se cuida con especial cuidado los pedidos de un cliente por ser nuevo o recuperado', - `notBuyingMonths` int(11) NOT NULL DEFAULT '3' COMMENT 'numero de meses que han de pasar desde su ultima compra para considerar nueva la siguiente compra', - `id` int(11) NOT NULL DEFAULT '1', - `isZoneClosedByExpeditionActivated` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'activa el procedimiento vn.zone_getClosed', - `maxNotReadyCollections` int(11) NOT NULL DEFAULT '5', - `minTicketsToCloseZone` int(11) DEFAULT '15' COMMENT 'mínimo numero de tickets que deben de tener expediciones para cerrar una zona', - `movingTicketDelRoute` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Si está activo, al cambiar la fecha de un ticket desde el F11, le quita la ruta', - `defaultZone` int(11) NOT NULL DEFAULT '697', - `defautlAgencyMode` int(11) NOT NULL DEFAULT '1328' COMMENT 'SENDING', + `isPreviousPreparationRequired` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Impide que los sacadores reciban tickets que tengan productos de prep previa', + `ticketPrintedMax` int(10) unsigned NOT NULL DEFAULT 8 COMMENT 'numero máxido de tickets por carro que se ponen en impreso al pedir colección', + `ticketTrolleyMax` int(10) unsigned NOT NULL DEFAULT 4 COMMENT 'numero máximo de tickets por carro para asignar baldas en una colección', + `rookieDays` int(11) NOT NULL DEFAULT 3 COMMENT 'dias en que se cuida con especial cuidado los pedidos de un cliente por ser nuevo o recuperado', + `notBuyingMonths` int(11) NOT NULL DEFAULT 3 COMMENT 'numero de meses que han de pasar desde su ultima compra para considerar nueva la siguiente compra', + `id` int(11) NOT NULL DEFAULT 1, + `isZoneClosedByExpeditionActivated` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'activa el procedimiento vn.zone_getClosed', + `maxNotReadyCollections` int(11) NOT NULL DEFAULT 5, + `minTicketsToCloseZone` int(11) DEFAULT 15 COMMENT 'mínimo numero de tickets que deben de tener expediciones para cerrar una zona', + `movingTicketDelRoute` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Si está activo, al cambiar la fecha de un ticket desde el F11, le quita la ruta', + `defaultZone` int(11) NOT NULL DEFAULT 697, + `defautlAgencyMode` int(11) NOT NULL DEFAULT 1328 COMMENT 'SENDING', + `hasUniqueCollectionTime` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Determina si los tickets de una colección deben de tener la misma hora y minuto', + `maxCollectionWithoutUser` int(11) NOT NULL DEFAULT 1 COMMENT 'Número máximo de colecciones que pueden estar sin usuario, haciendo de caché....', + `pendingCollectionsOrder` tinyint(3) unsigned DEFAULT 8, + `pendingCollectionsAge` tinyint(3) unsigned DEFAULT 6, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Recoge los parámetros que condicionan la producción'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Recoge los parámetros que condicionan la producción'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33437,31 +33610,12 @@ DROP TABLE IF EXISTS `professionalCategory`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `professionalCategory` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `salary` decimal(10,2) DEFAULT NULL, `salaryorSeniority` decimal(10,2) DEFAULT NULL, `year` int(2) 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 `profile` --- - -DROP TABLE IF EXISTS `profile`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `profile` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `personFk` int(11) DEFAULT NULL, - `profileTypeFk` int(11) NOT NULL DEFAULT '1', - PRIMARY KEY (`id`), - KEY `personFk` (`personFk`), - 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=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33473,9 +33627,9 @@ DROP TABLE IF EXISTS `profileType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `profileType` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(15) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33487,15 +33641,15 @@ DROP TABLE IF EXISTS `project`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `project` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, - `photo` blob, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `name` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, + `photo` blob DEFAULT NULL, `started` date DEFAULT NULL, `finished` date DEFAULT NULL, `userFk` int(11) unsigned NOT NULL, `departmentFk` int(11) DEFAULT NULL, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', - `location` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, + `location` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `amount` decimal(15,2) DEFAULT NULL, PRIMARY KEY (`id`), KEY `project_FK` (`userFk`), @@ -33504,7 +33658,7 @@ CREATE TABLE `project` ( CONSTRAINT `project_FK` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `project_FK_1` FOREIGN KEY (`departmentFk`) REFERENCES `department` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `project_FK_2` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla master de proyectos'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla master de proyectos'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33516,8 +33670,8 @@ DROP TABLE IF EXISTS `projectNotes`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `projectNotes` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `txt` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `txt` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, `userFk` int(10) unsigned DEFAULT NULL, `projectFk` int(11) NOT NULL, PRIMARY KEY (`id`), @@ -33525,7 +33679,7 @@ CREATE TABLE `projectNotes` ( KEY `projectNotes_FK_1` (`userFk`), CONSTRAINT `projectNotes_FK` FOREIGN KEY (`projectFk`) REFERENCES `project` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `projectNotes_FK_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Historico de notas para project'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Historico de notas para project'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -33540,11 +33694,11 @@ DELIMITER ;; BEFORE INSERT ON projectNotes FOR EACH ROW BEGIN - + IF ISNULL(NEW.userFk) THEN - + SET NEW.userFk = account.myUser_getId(); - + END IF; END */;; @@ -33563,12 +33717,12 @@ DROP TABLE IF EXISTS `property`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `property` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(250) COLLATE utf8_unicode_ci NOT NULL, - `cadaster` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(250) COLLATE utf8mb3_unicode_ci NOT NULL, + `cadaster` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `smallholding` int(11) DEFAULT NULL, - `area` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `area` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `townFk` int(11) NOT NULL, - `registry` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, + `registry` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `volume` int(11) DEFAULT NULL, `book` int(11) DEFAULT NULL, `page` int(11) DEFAULT NULL, @@ -33577,12 +33731,12 @@ CREATE TABLE `property` ( `value` int(11) DEFAULT NULL, `propertyGroupFk` int(11) NOT NULL, `companyFk` smallint(5) unsigned NOT NULL, - `photo` blob, - `allocation` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, + `photo` blob DEFAULT NULL, + `allocation` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `m2` decimal(10,2) DEFAULT NULL, `tome` int(11) DEFAULT NULL, - `url` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL, - `protocol` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'numero de protocolo notarial de la escritura de compra venta', + `url` varchar(250) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `protocol` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'numero de protocolo notarial de la escritura de compra venta', PRIMARY KEY (`id`), KEY `property_FK` (`propertyGroupFk`), KEY `property_FK_1` (`townFk`), @@ -33590,7 +33744,7 @@ CREATE TABLE `property` ( CONSTRAINT `property_FK` FOREIGN KEY (`propertyGroupFk`) REFERENCES `propertyGroup` (`id`) ON UPDATE CASCADE, CONSTRAINT `property_FK_1` FOREIGN KEY (`townFk`) REFERENCES `town` (`id`) ON UPDATE CASCADE, CONSTRAINT `property_company` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33609,7 +33763,7 @@ CREATE TABLE `propertyDms` ( KEY `propertyDms_FK_1` (`propertyFk`), CONSTRAINT `propertyDms_FK` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `propertyDms_FK_1` FOREIGN KEY (`propertyFk`) REFERENCES `property` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33621,9 +33775,9 @@ DROP TABLE IF EXISTS `propertyGroup`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `propertyGroup` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33636,15 +33790,15 @@ DROP TABLE IF EXISTS `propertyNotes`; CREATE TABLE `propertyNotes` ( `id` int(11) NOT NULL AUTO_INCREMENT, `propertyFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `note` text COLLATE utf8_unicode_ci NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `note` text COLLATE utf8mb3_unicode_ci NOT NULL, `userFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `propertyNotes_FK_1` (`userFk`), KEY `propertyNotes_FK` (`propertyFk`), CONSTRAINT `propertyNotes_FK` FOREIGN KEY (`propertyFk`) REFERENCES `property` (`id`), CONSTRAINT `propertyNotes_FK_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33656,7 +33810,7 @@ DROP TABLE IF EXISTS `province`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `province` ( `id` smallint(6) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(30) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL, `countryFk` mediumint(8) unsigned NOT NULL, `warehouseFk` smallint(6) unsigned DEFAULT NULL COMMENT 'warehouse responsable de las rutas', `zoneFk` tinyint(4) DEFAULT NULL, @@ -33671,7 +33825,7 @@ CREATE TABLE `province` ( CONSTRAINT `province_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, CONSTRAINT `province_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `vn2008`.`zones` (`zone_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `warehouse_Id` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -33686,10 +33840,10 @@ DELIMITER ;; BEFORE INSERT ON `province` FOR EACH ROW BEGIN - + SET NEW.geoFk = zoneGeo_new('province', NEW.`name`, (SELECT geoFk FROM autonomy WHERE id = NEW.autonomyFk)); - + SET NEW.countryFk = (SELECT a.countryFk FROM vn.autonomy a WHERE a.id = NEW.autonomyFk); END */;; @@ -33710,14 +33864,14 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`province_beforeUpdate` BEFORE UPDATE ON `province` FOR EACH ROW -BEGIN - +BEGIN + IF !(OLD.autonomyFk <=> NEW.autonomyFk) THEN - + SET NEW.countryFk = (SELECT a.countryFk FROM vn.autonomy a WHERE a.id = NEW.autonomyFk); END IF; - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -33765,7 +33919,7 @@ DELIMITER ;; AFTER DELETE ON `province` FOR EACH ROW BEGIN - CALL zoneGeo_delete(OLD.geoFk); + CALL zoneGeo_delete(OLD.geoFk); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -33782,10 +33936,10 @@ DROP TABLE IF EXISTS `punchState`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `punchState` ( `workerFk` int(11) NOT NULL, - `state` tinyint(4) DEFAULT '1', + `state` tinyint(4) DEFAULT 1, `created` datetime DEFAULT NULL, PRIMARY KEY (`workerFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Table for storing punches that have cars with errors'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Table for storing punches that have cars with errors'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33796,11 +33950,11 @@ DROP TABLE IF EXISTS `queuePriority`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `queuePriority` ( - `id` tinyint(3) unsigned NOT NULL DEFAULT '0', - `priority` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `code` varchar(6) COLLATE utf8_unicode_ci DEFAULT NULL, + `id` tinyint(3) unsigned NOT NULL DEFAULT 0, + `priority` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `code` varchar(6) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33813,7 +33967,7 @@ DROP TABLE IF EXISTS `rankBonus`; CREATE TABLE `rankBonus` ( `rank` int(11) DEFAULT NULL, `bonus` int(11) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33834,7 +33988,7 @@ CREATE TABLE `rate` ( PRIMARY KEY (`id`), KEY `tarifa_warehouse` (`warehouseFk`), CONSTRAINT `tarifa_warehouse` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33851,7 +34005,7 @@ CREATE TABLE `rateConfig` ( `rate2` int(11) DEFAULT NULL, `rate3` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33863,16 +34017,16 @@ DROP TABLE IF EXISTS `receipt`; /*!40101 SET character_set_client = utf8 */; 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', + `invoiceFk` varchar(50) COLLATE utf8mb3_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, `payed` datetime DEFAULT NULL, `workerFk` int(10) unsigned DEFAULT NULL, - `bankFk` int(11) DEFAULT '0', - `clientFk` int(11) DEFAULT '0', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', - `isConciliate` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0', + `bankFk` int(11) DEFAULT 0, + `clientFk` int(11) DEFAULT 0, + `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, + `isConciliate` tinyint(1) unsigned zerofill NOT NULL DEFAULT 0, PRIMARY KEY (`Id`), KEY `Id_Banco` (`bankFk`), KEY `Id_Trabajador` (`workerFk`), @@ -33884,7 +34038,7 @@ CREATE TABLE `receipt` ( CONSTRAINT `receipt_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, CONSTRAINT `receipt_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE, CONSTRAINT `recibo_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -33906,7 +34060,7 @@ BEGIN FROM accounting a JOIN accountingType at2 ON at2.id = a.accountingTypeFk WHERE a.id = NEW.bankFk; - + SET NEW.isConciliate = vIsAutoConciliated; END IF; END */;; @@ -34011,20 +34165,20 @@ DROP TABLE IF EXISTS `recipe`; CREATE TABLE `recipe` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemFk` int(11) NOT NULL COMMENT 'bouquet al que hace referencia la receta', - `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `size` int(10) unsigned DEFAULT NULL, `originFk` tinyint(2) unsigned DEFAULT NULL, `typeFk` smallint(5) unsigned DEFAULT NULL, - `longName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `quantity` int(11) NOT NULL DEFAULT '1', - `element` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `inkFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, + `longName` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `quantity` int(11) NOT NULL DEFAULT 1, + `element` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `inkFk` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `recipe_ix_1` (`element`), KEY `recipe_ix_2` (`itemFk`), KEY `recipe_FK` (`inkFk`), CONSTRAINT `recipe_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34037,7 +34191,7 @@ DROP TABLE IF EXISTS `recipe_log`; CREATE TABLE `recipe_log` ( `id` int(11) NOT NULL AUTO_INCREMENT, `recipe_ItemFk` int(11) NOT NULL, - `element` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `element` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `selected_ItemFk` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `recipe_log_ix1` (`recipe_ItemFk`), @@ -34045,7 +34199,7 @@ CREATE TABLE `recipe_log` ( KEY `recipe_log_ix3` (`selected_ItemFk`), CONSTRAINT `recipe_log_FK` FOREIGN KEY (`recipe_ItemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE, CONSTRAINT `recipe_log_FK_1` FOREIGN KEY (`selected_ItemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena las decisiones tomadas al generar recetas'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Almacena las decisiones tomadas al generar recetas'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34057,16 +34211,16 @@ DROP TABLE IF EXISTS `recovery`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `recovery` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `clientFk` int(11) NOT NULL DEFAULT '0', + `clientFk` int(11) NOT NULL DEFAULT 0, `started` date NOT NULL COMMENT 'Fecha a partir de la que comienza el recobro', `finished` date DEFAULT NULL COMMENT 'Fecha en la que acaba', `amount` double NOT NULL, - `period` tinyint(3) unsigned NOT NULL DEFAULT '7' COMMENT 'numero de dias que indica cada cuanto hare el recobro', + `period` tinyint(3) unsigned NOT NULL DEFAULT 7 COMMENT 'numero de dias que indica cada cuanto hare el recobro', PRIMARY KEY (`id`), KEY `cliente_idx` (`clientFk`), CONSTRAINT `cliente333` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, CONSTRAINT `cliente_cliente` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntaremos los acuerdos de recobro semanal a '; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='En esta tabla apuntaremos los acuerdos de recobro semanal a '; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34083,7 +34237,7 @@ CREATE TABLE `referenceCurrent` ( PRIMARY KEY (`dated`,`currencyFk`), KEY `referenceCurrent_currencyFk _idx` (`currencyFk`), CONSTRAINT `referenceCurrent_currencyFk ` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34099,7 +34253,7 @@ CREATE TABLE `referenceRate` ( `value` float unsigned NOT NULL, PRIMARY KEY (`currencyFk`,`dated`), KEY `date` (`dated`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34110,9 +34264,9 @@ DROP TABLE IF EXISTS `referenceRateConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `referenceRateConfig` ( - `simulatedValue` float unsigned NOT NULL DEFAULT '1.2309', + `simulatedValue` float unsigned NOT NULL DEFAULT 1.2309, PRIMARY KEY (`simulatedValue`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34124,26 +34278,26 @@ DROP TABLE IF EXISTS `report`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `report` ( `id` tinyint(3) unsigned NOT NULL, - `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `returnBuckets` +-- Table structure for table `returnBuckets` -- -DROP TABLE IF EXISTS `returnBuckets`; -/*!50001 DROP VIEW IF EXISTS `returnBuckets`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `returnBuckets` ( - `id` tinyint NOT NULL, - `freightContainerType` tinyint NOT NULL, - `freightPackagingEmpty` tinyint NOT NULL, - `freightPackagingFull` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; +DROP TABLE IF EXISTS `returnBuckets`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `returnBuckets` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `freightContainerType` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL, + `freightPackagingEmpty` double NOT NULL DEFAULT 0, + `freightPackagingFull` double NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Temporary table structure for view `role` @@ -34175,7 +34329,7 @@ CREATE TABLE `route` ( `vehicleFk` int(10) unsigned DEFAULT NULL, `agencyModeFk` int(11) DEFAULT NULL, `time` datetime DEFAULT NULL, - `isOk` tinyint(1) unsigned NOT NULL DEFAULT '0', + `isOk` tinyint(1) unsigned NOT NULL DEFAULT 0, `kmStart` mediumint(9) DEFAULT NULL, `kmEnd` mediumint(9) DEFAULT NULL, `started` datetime NOT NULL, @@ -34183,9 +34337,9 @@ CREATE TABLE `route` ( `gestdocFk` int(11) DEFAULT NULL, `cost` double unsigned DEFAULT NULL, `m3` decimal(10,1) unsigned DEFAULT NULL, - `description` text COLLATE utf8_unicode_ci, + `description` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `zoneFk` int(11) DEFAULT NULL, - `priority` int(11) NOT NULL DEFAULT '0', + `priority` int(11) NOT NULL DEFAULT 0, `invoiceInFk` mediumint(8) unsigned DEFAULT NULL, `beachFk` int(11) DEFAULT NULL, `commissionWorkCenterFk` int(11) DEFAULT NULL COMMENT 'WorkerCenter que gestiona la ruta', @@ -34204,7 +34358,7 @@ CREATE TABLE `route` ( CONSTRAINT `route_ibfk_1` FOREIGN KEY (`gestdocFk`) REFERENCES `dms` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `route_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `route_invoiceInFk` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -34220,10 +34374,10 @@ DELIMITER ;; FOR EACH ROW BEGIN SET NEW.commissionWorkCenterFk = ( - SELECT IFNULL(wl.workCenterFK, r.defaultWorkCenterFk) + SELECT IFNULL(b.workCenterFK, r.defaultWorkCenterFk) FROM vn.routeConfig r - LEFT JOIN vn.workerLabour wl ON wl.workerFk = account.myUser_getId() - AND NEW.created BETWEEN wl.started AND IFNULL(wl.ended, NEW.created)); + LEFT JOIN vn.business b ON b.workerFk = account.myUser_getId() + AND NEW.created BETWEEN b.started AND IFNULL(b.ended, NEW.created)); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -34244,14 +34398,14 @@ DELIMITER ;; FOR EACH ROW BEGIN DECLARE vKmMax INT; - + IF NEW.isOk <> FALSE AND OLD.isOk = FALSE THEN - SET NEW.m3 = ( SELECT SUM(litros)/1000 - FROM vn.saleVolume s - JOIN vn.ticket t ON s.ticketFk = t.id + SET NEW.m3 = ( SELECT SUM(litros)/1000 + FROM vn.saleVolume s + JOIN vn.ticket t ON s.ticketFk = t.id WHERE t.routeFk = NEW.id); END IF; - + IF NEW.kmEnd < NEW.kmStart AND NEW.kmEnd <> 0 THEN CALL util.throw ('KmEnd menor que kmStart'); END IF; @@ -34285,15 +34439,15 @@ BEGIN IF IFNULL(NEW.gestdocFk,0) <> IFNULL(OLD.gestdocFk,0) AND NEW.gestdocFk > 0 THEN -- JGF 09/09/14 cuando se añade un gestdoc a una ruta, se le asigna automagicamente a todos sus Tickets - + -- Inserta el gestdoc en todos los tickets de la ruta INSERT INTO ticketDms(ticketFk,dmsFk) SELECT id, NEW.gestdocFk FROM ticket WHERE routeFk = NEW.id ON DUPLICATE KEY UPDATE dmsFk = NEW.gestdocFk; - -- Update del firmado - UPDATE ticket t - JOIN ticketDms tg ON t.id = tg.ticketFk + -- Update del firmado + UPDATE ticket t + JOIN ticketDms tg ON t.id = tg.ticketFk SET isSigned = 1 WHERE t.routeFk = NEW.id; END IF; @@ -34321,10 +34475,10 @@ DROP TABLE IF EXISTS `routeAction`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `routeAction` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `price` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34350,7 +34504,7 @@ CREATE TABLE `routeCommission` ( KEY `routeCommission_workCenterFk_idx` (`workCenterFk`), CONSTRAINT `routeCommission_routeFk` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON UPDATE CASCADE, CONSTRAINT `routeCommission_workCenterFk` FOREIGN KEY (`workCenterFk`) REFERENCES `workCenter` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34371,7 +34525,7 @@ CREATE TABLE `routeComplement` ( KEY `fgn_routeActionFk_idx` (`routeActionFk`), CONSTRAINT `fgn_routeActionFk` FOREIGN KEY (`routeActionFk`) REFERENCES `routeAction` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fgn_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34401,9 +34555,9 @@ CREATE TABLE `routeConfig` ( `maxSalaryCategory2` decimal(6,2) DEFAULT NULL, `distributionM3Category1` decimal(5,2) DEFAULT NULL, `distributionM3Category2` decimal(5,2) DEFAULT NULL, - `plusCategory1Concept` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `plusCategory2Concept` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `defaultCompanyFk` smallint(5) unsigned DEFAULT '442', + `plusCategory1Concept` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `plusCategory2Concept` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `defaultCompanyFk` smallint(5) unsigned DEFAULT 442, `kmHeavy` decimal(5,2) DEFAULT NULL COMMENT 'Comisión por kilometro vehículo pesado', `kmLight` decimal(5,2) DEFAULT NULL COMMENT 'Comisión por kilometro vehículo ligero', `kmYearly` decimal(5,2) DEFAULT NULL COMMENT 'Comisión por kilometro objetivo anual', @@ -34422,12 +34576,12 @@ CREATE TABLE `routeConfig` ( `freelanceMinM3` decimal(5,2) DEFAULT NULL COMMENT 'Metros mínimos para considerar las rutas de autónomos', `mainlineDelivered` decimal(5,2) DEFAULT NULL COMMENT 'Comisión para entregas troncales', `cutoffDated` date DEFAULT NULL COMMENT 'Fecha a partir de la cual se autoriza calcular la comisión', - `defaultWorkCenterFk` int(11) DEFAULT '9' COMMENT 'Para el cálculo de las comisiones, en caso de el creador de la ruta no tenga workCenter', - `kmMax` int(11) DEFAULT '4000' COMMENT 'Máximo número de km validos para una ruta', + `defaultWorkCenterFk` int(11) DEFAULT 9 COMMENT 'Para el cálculo de las comisiones, en caso de el creador de la ruta no tenga workCenter', + `kmMax` int(11) DEFAULT 4000 COMMENT 'Máximo número de km validos para una ruta', PRIMARY KEY (`id`), KEY `routeConfig_FK` (`defaultCompanyFk`), CONSTRAINT `routeConfig_FK` FOREIGN KEY (`defaultCompanyFk`) REFERENCES `company` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34438,23 +34592,23 @@ DROP TABLE IF EXISTS `routeGate__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `routeGate__` ( - `deviceId` varchar(30) CHARACTER SET utf8 NOT NULL, - `displayText` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `status` set('idle','doing','done','') CHARACTER SET utf8 DEFAULT 'idle', - `gateAreaFk` int(11) NOT NULL DEFAULT '1', + `deviceId` varchar(30) CHARACTER SET utf8mb3 NOT NULL, + `displayText` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `status` set('idle','doing','done','') CHARACTER SET utf8mb3 DEFAULT 'idle', + `gateAreaFk` int(11) NOT NULL DEFAULT 1, `routeFk` int(11) NOT NULL, `freeTickets` int(11) DEFAULT NULL, `expeditions` int(11) DEFAULT NULL, `scanned` int(11) DEFAULT NULL, - `flag` blob, + `flag` blob DEFAULT NULL, `pallets` int(11) DEFAULT NULL, `lastScanned` datetime DEFAULT NULL, - `ready` tinyint(4) NOT NULL DEFAULT '0', + `ready` tinyint(4) NOT NULL DEFAULT 0, `id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`), UNIQUE KEY `routeFk_UNIQUE` (`routeFk`), KEY `routeGate_fk1_idx` (`gateAreaFk`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -34503,7 +34657,7 @@ CREATE TABLE `routeLoadWorker` ( KEY `frmWorker_idx` (`workerFk`), CONSTRAINT `frmRutas` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `frmWorker` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34517,20 +34671,20 @@ CREATE TABLE `routeLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `originFk` int(10) 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, - `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8_unicode_ci, - `newInstance` text COLLATE utf8_unicode_ci, + `action` set('insert','update','delete') COLLATE utf8mb3_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 DEFAULT NULL, + `changedModel` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `originFk` (`originFk`), KEY `userFk` (`userFk`), CONSTRAINT `routeLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `route` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `routeLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34543,7 +34697,7 @@ DROP TABLE IF EXISTS `routeRecalc`; CREATE TABLE `routeRecalc` ( `routeFk` int(11) NOT NULL, PRIMARY KEY (`routeFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Queue of changed volume to recalc route volumen'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin COMMENT='Queue of changed volume to recalc route volumen'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34561,7 +34715,7 @@ CREATE TABLE `routeUserPercentage` ( PRIMARY KEY (`id`), KEY `routeUserPercentageFk_idx` (`workerFk`), CONSTRAINT `routeUserPercentageFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34573,22 +34727,22 @@ DROP TABLE IF EXISTS `routesMonitor`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `routesMonitor` ( `routeFk` int(10) unsigned NOT NULL, - `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `beachFk` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `beachFk` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `ticketPacked` int(11) DEFAULT NULL, `ticketFree` int(11) DEFAULT NULL, `ticketProduction` int(11) DEFAULT NULL, `packages` int(11) DEFAULT NULL, - `note` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `note` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `dated` date DEFAULT NULL, - `dockFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `dockFk` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `m3` decimal(10,1) DEFAULT NULL, - `priority` int(11) NOT NULL DEFAULT '0', + `priority` int(11) NOT NULL DEFAULT 0, `etd` time DEFAULT NULL, `expeditionTruckFk` int(11) DEFAULT NULL, `m3boxes` decimal(10,1) DEFAULT NULL, `bufferFk` int(11) DEFAULT NULL COMMENT 'Buffer del sorter por el que se quiere sacar esa ruta', - `isPickingAllowed` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Los tickets de esta ruta se pueden preparar', + `isPickingAllowed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Los tickets de esta ruta se pueden preparar', PRIMARY KEY (`routeFk`), KEY `routesMonitor_FK` (`bufferFk`), KEY `routesMonitor_FK_2` (`beachFk`), @@ -34596,7 +34750,7 @@ CREATE TABLE `routesMonitor` ( CONSTRAINT `routesMonitor_FK` FOREIGN KEY (`bufferFk`) REFERENCES `srt`.`buffer` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `routesMonitor_FK_1` FOREIGN KEY (`dockFk`) REFERENCES `dock` (`code`) ON UPDATE CASCADE, CONSTRAINT `routesMonitor_FK_2` FOREIGN KEY (`beachFk`) REFERENCES `beach` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34629,23 +34783,23 @@ CREATE TABLE `sale` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemFk` int(11) NOT NULL, `ticketFk` int(11) NOT NULL, - `concept` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `quantity` decimal(10,2) NOT NULL DEFAULT '0.00', + `concept` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `quantity` decimal(10,2) NOT NULL DEFAULT 0.00, `originalQuantity` double(9,1) DEFAULT NULL, - `price` decimal(10,2) DEFAULT '0.00', - `discount` tinyint(2) unsigned NOT NULL DEFAULT '0', - `priceFixed` decimal(10,2) NOT NULL DEFAULT '0.00', - `reserved` tinyint(1) NOT NULL DEFAULT '0', - `isPicked` tinyint(1) NOT NULL DEFAULT '0', - `isPriceFixed` tinyint(1) NOT NULL DEFAULT '0', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `isAdded` tinyint(1) NOT NULL DEFAULT '0', + `price` decimal(10,2) DEFAULT 0.00, + `discount` tinyint(2) unsigned NOT NULL DEFAULT 0, + `priceFixed` decimal(10,2) NOT NULL DEFAULT 0.00, + `reserved` tinyint(1) NOT NULL DEFAULT 0, + `isPicked` tinyint(1) NOT NULL DEFAULT 0, + `isPriceFixed` tinyint(1) NOT NULL DEFAULT 0, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `isAdded` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `Id_Ticket` (`ticketFk`), KEY `itemFk_ticketFk` (`itemFk`,`ticketFk`), CONSTRAINT `movement_ticket_id` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `sale_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -34660,7 +34814,7 @@ DELIMITER ;; AFTER INSERT ON `sale` FOR EACH ROW BEGIN - + IF (SELECT COUNT(*) from item i WHERE id = NEW.itemFk AND family = 'SER') THEN CALL util.throw('Cannot insert a service item into a ticket'); END IF; @@ -34669,22 +34823,22 @@ BEGIN CALL ticket_requestRecalc(NEW.ticketFk); IF NEW.quantity > 0 THEN - + 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 - AND (c.itemPackingTypeFk = i.itemPackingTypeFk + JOIN vn.item i ON i.id = NEW.itemFk + AND (c.itemPackingTypeFk = i.itemPackingTypeFk OR ISNULL(c.itemPackingTypeFk)) SET c.saleTotalCount = c.saleTotalCount + 1; - + INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) - SELECT r.id + SELECT r.id FROM vn.sale s JOIN vn.ticket t ON t.id = s.ticketFk JOIN vn.route r ON r.id = t.routeFk - WHERE r.isOk = FALSE + WHERE r.isOk = FALSE AND s.id = NEW.id - AND r.created >= CURDATE() + AND r.created >= util.VN_CURDATE() GROUP BY r.id; END IF; @@ -34707,7 +34861,7 @@ DELIMITER ;; BEFORE UPDATE ON `sale` FOR EACH ROW BEGIN -/* +/* IF (SELECT COUNT(*) from item i WHERE id = NEW.itemFk AND family = 'SER') THEN CALL util.throw('Cannot insert a service item into a ticket'); END IF; @@ -34718,7 +34872,7 @@ BEGIN IF old.discount > 0 AND NEW.discount = 0 THEN INSERT INTO ticketLog - SET originFk = NEW.ticketFk, userFk = account.myUser_getId(), `action` = 'insert', + SET originFk = NEW.ticketFk, userFk = account.myUser_getId(), `action` = 'insert', description = CONCAT('Cambio de descuento del item :', ' ', new.itemFk, ' de ', old.discount ,' a 0 '); END IF; END */;; @@ -34744,7 +34898,7 @@ BEGIN DECLARE vPickedLines INT; DECLARE vCollectionFk INT; DECLARE vUserRole VARCHAR(255); - + IF !(NEW.id <=> OLD.id) OR !(NEW.ticketFk <=> OLD.ticketFk) OR !(NEW.itemFk <=> OLD.itemFk) @@ -34767,68 +34921,68 @@ BEGIN UPDATE ticketRequest SET ticketFk = NEW.ticketFk WHERE saleFk = NEW.id; END IF; - + SELECT account.myUser_getName() INTO vUserRole; SELECT account.user_getMysqlRole(vUserRole) INTO vUserRole; IF !(OLD.quantity <=> NEW.quantity) THEN - SELECT COUNT(*) INTO vIsToSendMail + SELECT COUNT(*) INTO vIsToSendMail FROM vncontrol.inter i JOIN vn.state s ON s.id = i.state_id - WHERE s.code='PACKED' + WHERE s.code='PACKED' AND i.Id_Ticket = OLD.ticketFk AND vUserRole IN ('salesPerson', 'salesBoss') LIMIT 1; - - IF vIsToSendMail THEN + + IF vIsToSendMail THEN CALL vn.mail_insert('jefesventas@verdnatura.es', 'noreply@verdnatura.es', CONCAT('Ticket ', OLD.ticketFk ,' modificada cantidad tras encajado'), CONCAT('Ticket ', OLD.ticketFk ,'.
', - 'Modificada la catidad de ', OLD.quantity, ' a ' , NEW.quantity, + 'Modificada la catidad de ', OLD.quantity, ' a ' , NEW.quantity, ' del artículo ', OLD.itemFk, ' tras estado encajado del ticket.
', 'Este email se ha generado automáticamente' ) ); - END IF; + END IF; IF (OLD.quantity > NEW.quantity) THEN INSERT INTO saleComponent(saleFk, componentFk, value) - SELECT NEW.id, cm.id, sc.value + SELECT NEW.id, cm.id, sc.value FROM saleComponent sc JOIN component cd ON cd.id = sc.componentFk JOIN component cm ON cm.code = 'mana' WHERE saleFk = NEW.id AND cd.code = 'lastUnitsDiscount' ON DUPLICATE KEY UPDATE value = sc.value + VALUES(value); - - DELETE sc.* + + DELETE sc.* FROM vn.saleComponent sc JOIN component c ON c.id = sc.componentFk WHERE saleFk = NEW.id AND c.code = 'lastUnitsDiscount'; - END IF; + END IF; INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) - SELECT r.id + SELECT r.id FROM vn.sale s JOIN vn.ticket t ON t.id = s.ticketFk JOIN vn.route r ON r.id = t.routeFk - WHERE r.isOk = FALSE + WHERE r.isOk = FALSE AND s.id = NEW.id - AND r.created >= CURDATE() + AND r.created >= util.VN_CURDATE() GROUP BY r.id; END IF; IF !(ABS(NEW.isPicked) <=> ABS(OLD.isPicked)) AND NEW.quantity > 0 THEN - + UPDATE vn.collection c JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk SET c.salePickedCount = c.salePickedCount + IF(NEW.isPicked != 0, 1, -1); - + END IF; IF !(NEW.quantity <=> OLD.quantity) AND (NEW.quantity = 0 OR OLD.quantity = 0) THEN - + UPDATE vn.collection c JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk SET c.saleTotalCount = c.saleTotalCount + IF(OLD.quantity = 0, 1, -1); - + END IF; END */;; DELIMITER ; @@ -34851,13 +35005,13 @@ DELIMITER ;; BEGIN IF OLD.quantity > 0 THEN INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) - SELECT r.id + SELECT r.id FROM vn.sale s JOIN vn.ticket t ON t.id = s.ticketFk JOIN vn.route r ON r.id = t.routeFk - WHERE r.isOk = FALSE + WHERE r.isOk = FALSE AND s.id = OLD.id - AND r.created >= CURDATE() + AND r.created >= util.VN_CURDATE() GROUP BY r.id; END IF; END */;; @@ -34878,43 +35032,43 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_afterDelete` AFTER DELETE ON `sale` FOR EACH ROW -BEGIN +BEGIN DECLARE vIsToSendMail BOOL; DECLARE vUserRole VARCHAR(255); - + CALL stock.log_add('sale', NULL, OLD.id); CALL ticket_requestRecalc(OLD.ticketFk); SELECT account.myUser_getName() INTO vUserRole; SELECT account.user_getMysqlRole(vUserRole) INTO vUserRole; - SELECT COUNT(*) INTO vIsToSendMail + SELECT COUNT(*) INTO vIsToSendMail FROM vncontrol.inter i JOIN vn.state s ON s.id = i.state_id - WHERE s.code='PACKED' + WHERE s.code='PACKED' AND i.Id_Ticket = OLD.ticketFk AND vUserRole IN ('salesPerson', 'salesBoss') LIMIT 1; - IF vIsToSendMail THEN + IF vIsToSendMail THEN CALL vn.mail_insert('jefesventas@verdnatura.es', 'noreply@verdnatura.es', CONCAT('Ticket ', OLD.ticketFk ,' eliminado artículo tras encajado' ), CONCAT('Ticket ', OLD.ticketFk ,'.
', 'Eliminado artículo ', OLD.itemFk, ' tras estado encajado del ticket.
Este email se ha generado automáticamente' ) ); - END IF; - + END IF; + IF OLD.quantity > 0 THEN - + UPDATE vn.collection c JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = OLD.ticketFk - JOIN vn.item i ON i.id = OLD.itemFk - AND (c.itemPackingTypeFk = i.itemPackingTypeFk + JOIN vn.item i ON i.id = OLD.itemFk + AND (c.itemPackingTypeFk = i.itemPackingTypeFk OR ISNULL(c.itemPackingTypeFk)) SET c.saleTotalCount = c.saleTotalCount - 1, c.salePickedCount = c.salePickedCount - ABS(OLD.isPicked); - + END IF; END */;; DELIMITER ; @@ -34933,13 +35087,13 @@ DROP TABLE IF EXISTS `saleBuy`; CREATE TABLE `saleBuy` ( `saleFk` int(11) NOT NULL, `buyFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `workerFk` int(11) DEFAULT NULL, PRIMARY KEY (`saleFk`), KEY `saleBuy_FK` (`buyFk`), CONSTRAINT `saleBuy_FK` FOREIGN KEY (`buyFk`) REFERENCES `buy` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `saleBuy_FK_1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -34953,10 +35107,10 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`BEFORE_INSERT` BEFORE INSERT ON `saleBuy` FOR EACH ROW -BEGIN - +BEGIN + SET NEW.workerFk = vn.getUser(); - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -34975,13 +35129,13 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleBuy_AI` AFTER INSERT ON `saleBuy` FOR EACH ROW -BEGIN +BEGIN /* Activar de nuevo cuando volvamos a vender fruta y verdura - * + * UPDATE vn.sale s SET s.concept = CONCAT(s.concept, ' Lote: ', NEW.buyFk) WHERE s.id = NEW.saleFk; -*/ +*/ END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -34998,10 +35152,10 @@ DROP TABLE IF EXISTS `saleChecked`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `saleChecked` ( `saleFk` int(11) NOT NULL, - `isChecked` int(11) NOT NULL DEFAULT '0', + `isChecked` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`saleFk`), CONSTRAINT `fk_Movimientos_checked_1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35018,7 +35172,7 @@ CREATE TABLE `saleCloned` ( KEY `saleOriginalFk_idx` (`saleOriginalFk`), CONSTRAINT `saleClonedFk_fk2` FOREIGN KEY (`saleClonedFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `saleOriginalFk_fk1` FOREIGN KEY (`saleOriginalFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35032,13 +35186,13 @@ CREATE TABLE `saleComponent` ( `saleFk` int(11) NOT NULL, `componentFk` int(11) NOT NULL, `value` double NOT NULL, - `isGreuge` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Indica si ya se ha tenido en cuenta para calcular el greuge', - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `isGreuge` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Indica si ya se ha tenido en cuenta para calcular el greuge', + `created` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), PRIMARY KEY (`saleFk`,`componentFk`), KEY `fk_mov_comp_idx` (`componentFk`), CONSTRAINT `mc_fk1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `mc_fk2` FOREIGN KEY (`componentFk`) REFERENCES `component` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35078,7 +35232,7 @@ CREATE TABLE `saleGoal` ( `goal` decimal(10,2) DEFAULT NULL, `goalType` smallint(6) DEFAULT NULL COMMENT 'grado', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35090,12 +35244,12 @@ DROP TABLE IF EXISTS `saleGroup`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `saleGroup` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `userFk` int(11) DEFAULT NULL, `parkingFk` int(11) DEFAULT NULL, `sectorFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='agrupa lineas de venta'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='agrupa lineas de venta'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35107,7 +35261,7 @@ DROP TABLE IF EXISTS `saleGroupDetail`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `saleGroupDetail` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `saleFk` int(11) NOT NULL, `saleGroupFk` int(11) NOT NULL, PRIMARY KEY (`id`), @@ -35115,7 +35269,7 @@ CREATE TABLE `saleGroupDetail` ( KEY `saleGroupDetail_FK_1` (`saleGroupFk`), CONSTRAINT `saleGroupDetail_FK` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `saleGroupDetail_FK_1` FOREIGN KEY (`saleGroupFk`) REFERENCES `saleGroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='relaciona sale y saleGroup'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='relaciona sale y saleGroup'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35129,30 +35283,14 @@ CREATE TABLE `saleItemShelving__` ( `id` int(11) NOT NULL AUTO_INCREMENT, `saleFk` int(11) NOT NULL, `itemShelvingFk` int(10) unsigned NOT NULL, - `quantity` int(11) NOT NULL DEFAULT '0', - `isPicked` tinyint(4) NOT NULL DEFAULT '0', - `ubication` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `quantity` int(11) NOT NULL DEFAULT 0, + `isPicked` tinyint(4) NOT NULL DEFAULT 0, + `ubication` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `saleItemShelving_fk1_idx` (`itemShelvingFk`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Temporary table structure for view `saleLabel` --- - -DROP TABLE IF EXISTS `saleLabel`; -/*!50001 DROP VIEW IF EXISTS `saleLabel`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `saleLabel` ( - `saleFk` tinyint NOT NULL, - `label` tinyint NOT NULL, - `stem` tinyint NOT NULL, - `created` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `saleMistake` -- @@ -35165,7 +35303,7 @@ CREATE TABLE `saleMistake` ( `saleFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL COMMENT 'Controlador', `typeFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `saleMistake_fk1_idx` (`saleFk`), KEY `saleMistake_fk2_idx` (`userFk`), @@ -35173,7 +35311,7 @@ CREATE TABLE `saleMistake` ( CONSTRAINT `saleMistake_fk1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `saleMistake_fk2` FOREIGN KEY (`userFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `saleMistake_fk3` FOREIGN KEY (`typeFk`) REFERENCES `mistakeType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35225,14 +35363,14 @@ CREATE TABLE `saleParking__` ( `id` int(11) NOT NULL AUTO_INCREMENT, `saleFk` int(11) NOT NULL, `parkingFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `userFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `saleParking_FK` (`saleFk`), KEY `saleParking_FK_1` (`parkingFk`), CONSTRAINT `saleParking_FK` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `saleParking_FK_1` FOREIGN KEY (`parkingFk`) REFERENCES `parking` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='ubica las lineas de venta preparadas previamente'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='ubica las lineas de venta preparadas previamente'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35262,7 +35400,7 @@ CREATE TABLE `saleState` ( KEY `saleState_fk2_idx` (`stateFk`), CONSTRAINT `saleState_fk1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `saleState_fk2` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='cahce para el estado de la linea'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='cahce para el estado de la linea'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35274,8 +35412,8 @@ DROP TABLE IF EXISTS `saleTracking`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `saleTracking` ( `saleFk` int(11) NOT NULL, - `isChecked` tinyint(3) unsigned NOT NULL DEFAULT '0', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `isChecked` tinyint(3) unsigned NOT NULL DEFAULT 0, + `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `originalQuantity` double DEFAULT NULL, `workerFk` int(11) NOT NULL, `actionFk` int(11) DEFAULT NULL, @@ -35290,7 +35428,7 @@ CREATE TABLE `saleTracking` ( CONSTRAINT `fgnStateFk` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE, CONSTRAINT `saleTracking_FK` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `saleTracking_FK_1` FOREIGN KEY (`actionFk`) REFERENCES `vncontrol`.`accion` (`accion_id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -35332,14 +35470,14 @@ DELIMITER ;; AFTER INSERT ON `saleTracking` FOR EACH ROW BEGIN - - IF NEW.isChecked THEN - + + IF NEW.isChecked THEN + UPDATE vn.sale s - SET s.isPicked = TRUE + SET s.isPicked = TRUE WHERE s.id = NEW.saleFk AND s.isPicked = 0; - + END IF; END */;; @@ -35441,12 +35579,12 @@ DROP TABLE IF EXISTS `salesPersonGoal`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `salesPersonGoal` ( - `salesPersonName` varchar(100) CHARACTER SET utf8 NOT NULL DEFAULT '', + `salesPersonName` varchar(100) CHARACTER SET utf8mb3 NOT NULL DEFAULT '', `month` int(11) DEFAULT NULL, `year` int(11) DEFAULT NULL, `goal` int(11) DEFAULT NULL, PRIMARY KEY (`salesPersonName`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35510,14 +35648,14 @@ DROP TABLE IF EXISTS `sample`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sample` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `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', + `code` varchar(25) CHARACTER SET utf8mb3 NOT NULL, + `description` varchar(105) COLLATE utf8mb3_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; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35529,23 +35667,23 @@ DROP TABLE IF EXISTS `sector`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sector` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', - `isPreviousPreparedByPacking` tinyint(4) NOT NULL DEFAULT '1', - `code` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `pickingPlacement__` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 1, + `isPreviousPreparedByPacking` tinyint(4) NOT NULL DEFAULT 1, + `code` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `pickingPlacement__` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `path__` int(11) DEFAULT NULL, - `isPreviousPrepared` tinyint(1) NOT NULL DEFAULT '0', - `isPackagingArea` tinyint(1) NOT NULL DEFAULT '0', + `isPreviousPrepared` tinyint(1) NOT NULL DEFAULT 0, + `isPackagingArea` tinyint(1) NOT NULL DEFAULT 0, `reportFk` tinyint(3) unsigned DEFAULT NULL, `sonFk` int(11) DEFAULT NULL, - `isMain` tinyint(1) NOT NULL DEFAULT '0', - `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `isMain` tinyint(1) NOT NULL DEFAULT 0, + `itemPackingTypeFk` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `workerFk` int(11) DEFAULT NULL, `labelReport__` tinyint(3) DEFAULT NULL, `printerFk` tinyint(3) unsigned DEFAULT NULL, - `isHideForPickers` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'sector a ocultar a los sacadores', - `isReserve` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Sectores de reserva, como Albenfruit o Fuentes', + `isHideForPickers` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'sector a ocultar a los sacadores', + `isReserve` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Sectores de reserva, como Albenfruit o Fuentes', PRIMARY KEY (`id`,`warehouseFk`), UNIQUE KEY `code_UNIQUE` (`code`), KEY `sector_fk1_idx` (`warehouseFk`), @@ -35554,7 +35692,7 @@ CREATE TABLE `sector` ( CONSTRAINT `sector_FK` FOREIGN KEY (`sonFk`, `warehouseFk`) REFERENCES `sector` (`id`, `warehouseFk`) ON UPDATE CASCADE, CONSTRAINT `sector_fk1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `sector_report` FOREIGN KEY (`reportFk`) REFERENCES `report` (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35566,7 +35704,7 @@ DROP TABLE IF EXISTS `sectorCollection`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sectorCollection` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `userFk` int(10) unsigned NOT NULL, `sectorFk` int(11) NOT NULL, PRIMARY KEY (`id`), @@ -35574,7 +35712,7 @@ CREATE TABLE `sectorCollection` ( KEY `sectorCollection_FK_2` (`sectorFk`), CONSTRAINT `sectorCollection_FK` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `sectorCollection_FK_1` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Las lineas de preparacion de pedidos por sectores se agrupan bajo el identificador de esta tabla'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Las lineas de preparacion de pedidos por sectores se agrupan bajo el identificador de esta tabla'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35586,7 +35724,7 @@ DROP TABLE IF EXISTS `sectorCollectionSaleGroup`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sectorCollectionSaleGroup` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `sectorCollectionFk` int(11) NOT NULL, `saleGroupFk` int(11) NOT NULL, PRIMARY KEY (`id`), @@ -35594,7 +35732,7 @@ CREATE TABLE `sectorCollectionSaleGroup` ( KEY `sectorCollectionSaleGroup_FK_1` (`saleGroupFk`), CONSTRAINT `sectorCollectionSaleGroup_FK` FOREIGN KEY (`sectorCollectionFk`) REFERENCES `sectorCollection` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `sectorCollectionSaleGroup_FK_1` FOREIGN KEY (`saleGroupFk`) REFERENCES `saleGroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las lineas de venta con la coleccion del sector'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Relaciona las lineas de venta con la coleccion del sector'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35607,9 +35745,9 @@ DROP TABLE IF EXISTS `sectorProductivity`; CREATE TABLE `sectorProductivity` ( `id` int(11) NOT NULL AUTO_INCREMENT, `workerFk` int(11) DEFAULT NULL, - `firstName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `lastName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `sector` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `firstName` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `lastName` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `sector` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `ticketCount` int(11) DEFAULT NULL, `saleCount` int(11) DEFAULT NULL, `error` int(11) DEFAULT NULL, @@ -35617,7 +35755,7 @@ CREATE TABLE `sectorProductivity` ( `hourWorked` decimal(10,2) DEFAULT NULL, `dated` date DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35633,13 +35771,13 @@ CREATE TABLE `sharingCart` ( `started` date NOT NULL, `ended` date NOT NULL, `workerSubstitute` int(10) unsigned NOT NULL, - `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `created` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), PRIMARY KEY (`id`), UNIQUE KEY `workerFk_UNIQUE` (`workerFk`,`started`,`ended`,`workerSubstitute`), 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=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -35657,9 +35795,9 @@ BEGIN IF NEW.workerFk = NEW.workerSubstitute THEN CALL util.throw ('worker and workerSubstitute must be different'); ELSE - INSERT IGNORE INTO sharingCartDaily (ownerFk, substituteFk, dated) - SELECT NEW.workerFk, NEW.workerSubstitute, dated - FROM time + INSERT IGNORE INTO sharingCartDaily (ownerFk, substituteFk, dated) + SELECT NEW.workerFk, NEW.workerSubstitute, dated + FROM time WHERE dated BETWEEN NEW.started AND NEW.ended; END IF; END */;; @@ -35684,14 +35822,14 @@ BEGIN IF NEW.workerFk = NEW.workerSubstitute THEN CALL util.throw ('worker and workerSubstitute must be different'); ELSE - DELETE sc FROM sharingCartDaily sc - WHERE sc.dated BETWEEN OLD.started AND OLD.ended AND - sc.ownerFk = OLD.workerFk AND + DELETE sc FROM sharingCartDaily sc + WHERE sc.dated BETWEEN OLD.started AND OLD.ended AND + sc.ownerFk = OLD.workerFk AND sc.substituteFk = OLD.workerSubstitute; - - INSERT IGNORE INTO sharingCartDaily (ownerFk, substituteFk, dated) - SELECT NEW.workerFk, NEW.workerSubstitute, dated - FROM time + + INSERT IGNORE INTO sharingCartDaily (ownerFk, substituteFk, dated) + SELECT NEW.workerFk, NEW.workerSubstitute, dated + FROM time WHERE dated BETWEEN NEW.started AND NEW.ended; END IF; @@ -35714,9 +35852,9 @@ DELIMITER ;; BEFORE DELETE ON `sharingCart` FOR EACH ROW BEGIN - DELETE sc FROM sharingCartDaily sc - WHERE sc.dated BETWEEN OLD.started AND OLD.ended AND - sc.ownerFk = OLD.workerFk AND + DELETE sc FROM sharingCartDaily sc + WHERE sc.dated BETWEEN OLD.started AND OLD.ended AND + sc.ownerFk = OLD.workerFk AND sc.substituteFk = OLD.workerSubstitute; END */;; DELIMITER ; @@ -35737,13 +35875,13 @@ CREATE TABLE `sharingCartDaily` ( `ownerFk` int(10) unsigned NOT NULL, `substituteFk` int(10) unsigned NOT NULL, `dated` date NOT NULL, - `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `created` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), PRIMARY KEY (`id`), UNIQUE KEY `sharingCartDailyWorker_idx` (`ownerFk`,`dated`), KEY `sharingCartDailySubstitute_idx` (`substituteFk`), CONSTRAINT `sharingCartDailySubstitute` FOREIGN KEY (`substituteFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `sharingCartDailyWorker` FOREIGN KEY (`ownerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='para calcular las comisiones de las sustituciones de los comerciales'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='para calcular las comisiones de las sustituciones de los comerciales'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35764,7 +35902,7 @@ CREATE TABLE `sharingClient` ( KEY `Client` (`clientFk`), CONSTRAINT `Clients_key` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, CONSTRAINT `Trabajadores_key` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -35779,8 +35917,8 @@ DELIMITER ;; BEFORE INSERT ON `sharingClient` FOR EACH ROW BEGIN - SET NEW.ended = GREATEST(CURDATE(),NEW.ended); - SET NEW.started = GREATEST(CURDATE(),NEW.started); + SET NEW.ended = GREATEST(util.VN_CURDATE(),NEW.ended); + SET NEW.started = GREATEST(util.VN_CURDATE(),NEW.started); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -35800,8 +35938,8 @@ DELIMITER ;; BEFORE UPDATE ON `sharingClient` FOR EACH ROW BEGIN - SET NEW.ended = GREATEST(CURDATE(),NEW.ended); - SET NEW.started = GREATEST(CURDATE(),NEW.started); + SET NEW.ended = GREATEST(util.VN_CURDATE(),NEW.ended); + SET NEW.started = GREATEST(util.VN_CURDATE(),NEW.started); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -35817,20 +35955,22 @@ DROP TABLE IF EXISTS `shelving`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `shelving` ( - `code` varchar(10) CHARACTER SET utf8 NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + `code` varchar(10) CHARACTER SET utf8mb3 NOT NULL, `parkingFk` int(11) DEFAULT NULL, - `isPrinted` tinyint(4) NOT NULL DEFAULT '0', - `priority` int(11) NOT NULL DEFAULT '0', - `parked` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `isPrinted` tinyint(4) NOT NULL DEFAULT 0, + `priority` int(11) NOT NULL DEFAULT 0, + `parked` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `userFk` int(10) unsigned DEFAULT NULL, - `isSpam` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'señala las matrículas con producto que se puede llevar a la reserva', - `isRecyclable` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'las matrículas marcadas como reciclables se liberan cada noche desde vn.shelving_clean para poder volver a utilizarlas', - PRIMARY KEY (`code`), + `isSpam` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'señala las matrículas con producto que se puede llevar a la reserva', + `isRecyclable` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'las matrículas marcadas como reciclables se liberan cada noche desde vn.shelving_clean para poder volver a utilizarlas', + PRIMARY KEY (`id`), + UNIQUE KEY `shelving_UN` (`code`), KEY `shelving_fk1_idx` (`parkingFk`), KEY `shelving_fk2_idx` (`userFk`), CONSTRAINT `shelving_fk1` FOREIGN KEY (`parkingFk`) REFERENCES `parking` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `shelving_fk2` FOREIGN KEY (`userFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla usada para localizar el carro en el parking del altillo'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla usada para localizar el carro en el parking del altillo'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -35847,9 +35987,9 @@ DELIMITER ;; BEGIN IF NEW.code = "" THEN - + CALL util.throw('NOT_EMPTY_CODE_ALLOWED'); - + END IF; END */;; @@ -35871,13 +36011,13 @@ DELIMITER ;; BEFORE UPDATE ON `shelving` FOR EACH ROW BEGIN - + IF NEW.code = "" THEN - + CALL util.throw('NOT_EMPTY_CODE_ALLOWED'); - + END IF; - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -35894,22 +36034,21 @@ DROP TABLE IF EXISTS `shelvingLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `shelvingLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `originFk` varchar(10) CHARACTER SET utf8 NOT NULL, + `originFk` int(11) 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, - `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8_unicode_ci, - `newInstance` text COLLATE utf8_unicode_ci, + `action` set('insert','update','delete') COLLATE utf8mb3_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 DEFAULT NULL, + `changedModel` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `originFk` (`originFk`), - CONSTRAINT `shelvingLog_FK_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `shelving` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `shelvingLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35926,7 +36065,7 @@ CREATE TABLE `silexACL` ( `role` varchar(20) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `module_UNIQUE` (`module`,`method`) USING BTREE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35941,9 +36080,9 @@ CREATE TABLE `sinister` ( `supplierFk` int(11) NOT NULL, `clientFk` int(11) NOT NULL, `amount` decimal(10,2) NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `insureRate` decimal(3,2) NOT NULL DEFAULT '0.75', - `isBooked` tinyint(4) NOT NULL DEFAULT '0', + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `insureRate` decimal(3,2) NOT NULL DEFAULT 0.75, + `isBooked` tinyint(4) NOT NULL DEFAULT 0, `workerFk` int(10) unsigned NOT NULL, `companyFk` smallint(5) unsigned NOT NULL, PRIMARY KEY (`id`), @@ -35955,7 +36094,7 @@ CREATE TABLE `sinister` ( CONSTRAINT `sinister_fk2` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `sinister_fk3` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `sinister_fk4` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Impago de cliente asegurado'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Impago de cliente asegurado'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35968,10 +36107,10 @@ DROP TABLE IF EXISTS `sinisterDetail`; CREATE TABLE `sinisterDetail` ( `id` int(11) NOT NULL, `sinisterFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `amountIn` decimal(10,2) DEFAULT NULL, `amountOut` decimal(10,2) DEFAULT NULL, - `isConciliated` tinyint(1) NOT NULL DEFAULT '0', + `isConciliated` tinyint(1) NOT NULL DEFAULT 0, `workerFk` int(10) unsigned NOT NULL, `bankFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), @@ -35981,7 +36120,7 @@ CREATE TABLE `sinisterDetail` ( CONSTRAINT `sinisterDetail_fk1` FOREIGN KEY (`sinisterFk`) REFERENCES `sinister` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `sinisterDetail_fk2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `sinisterDetail_fk3` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35992,13 +36131,13 @@ DROP TABLE IF EXISTS `smartTag`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `smartTag` ( - `code` varchar(12) CHARACTER SET utf8 NOT NULL, - `shelvingFk` varchar(10) CHARACTER SET utf8 DEFAULT NULL, + `code` varchar(12) CHARACTER SET utf8mb3 NOT NULL, + `shelvingFk` varchar(10) CHARACTER SET utf8mb3 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; + CONSTRAINT `smartTag_FK` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36012,16 +36151,16 @@ CREATE TABLE `sms` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `senderFk` int(10) unsigned NOT NULL, `destinationFk__` int(11) DEFAULT NULL, - `sender` varchar(15) CHARACTER SET utf8 NOT NULL DEFAULT '693474205', - `destination` varchar(15) CHARACTER SET utf8 NOT NULL, - `message` varchar(160) COLLATE utf8_unicode_ci NOT NULL, - `statusCode` smallint(9) DEFAULT '0', - `status` varchar(255) COLLATE utf8_unicode_ci DEFAULT 'OK', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `sender` varchar(15) CHARACTER SET utf8mb3 NOT NULL DEFAULT '693474205', + `destination` varchar(15) CHARACTER SET utf8mb3 NOT NULL, + `message` varchar(160) COLLATE utf8mb3_unicode_ci NOT NULL, + `statusCode` smallint(9) DEFAULT 0, + `status` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT 'OK', + `created` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `sms_FK` (`senderFk`), CONSTRAINT `sms_FK` FOREIGN KEY (`senderFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36033,13 +36172,13 @@ DROP TABLE IF EXISTS `smsConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `smsConfig` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `uri` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `user__` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `password__` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `title` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `apiKey` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `uri` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `user__` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `password__` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `title` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, + `apiKey` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='SMS configuration parameters'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='SMS configuration parameters'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36057,7 +36196,7 @@ CREATE TABLE `solunionCAP` ( PRIMARY KEY (`creditInsurance`,`dateStart`), KEY `solunionCAPdateLeavingIdx` (`dateLeaving`), CONSTRAINT `solunionCAP` FOREIGN KEY (`creditInsurance`) REFERENCES `creditInsurance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -36073,7 +36212,7 @@ DELIMITER ;; FOR EACH ROW BEGIN UPDATE vn2008.Clientes c - JOIN creditClassification cc ON c.Id_Cliente = cc.client + JOIN creditClassification cc ON c.Id_Cliente = cc.client JOIN creditInsurance ci ON ci.creditClassification = cc.id SET creditInsurance = ci.credit * 2 WHERE ci.id = NEW.creditInsurance; END */;; @@ -36097,12 +36236,12 @@ DELIMITER ;; BEGIN IF NEW.dateLeaving IS NOT NULL THEN UPDATE vn2008.Clientes c - JOIN creditClassification cc ON c.Id_Cliente = cc.client + JOIN creditClassification cc ON c.Id_Cliente = cc.client JOIN creditInsurance ci ON ci.creditClassification = cc.id SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; ELSE UPDATE vn2008.Clientes c - JOIN creditClassification cc ON c.Id_Cliente = cc.client + JOIN creditClassification cc ON c.Id_Cliente = cc.client JOIN creditInsurance ci ON ci.creditClassification = cc.id SET creditInsurance = ci.credit * 2 WHERE ci.id = OLD.creditInsurance; END IF; @@ -36126,7 +36265,7 @@ DELIMITER ;; FOR EACH ROW BEGIN UPDATE vn2008.Clientes c - JOIN creditClassification cc ON c.Id_Cliente = cc.client + JOIN creditClassification cc ON c.Id_Cliente = cc.client JOIN creditInsurance ci ON ci.creditClassification = cc.id SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; END */;; @@ -36144,23 +36283,23 @@ DROP TABLE IF EXISTS `sorter`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sorter` ( - `id` int(11) NOT NULL DEFAULT '0', + `id` int(11) NOT NULL DEFAULT 0, `created` datetime NOT NULL, `routeFk` int(10) unsigned NOT NULL, `ticketFk` int(10) NOT NULL, - `isBox` int(11) DEFAULT '1', + `isBox` int(11) DEFAULT 1, `itemFk` int(11) DEFAULT NULL, - `width` decimal(10,2) DEFAULT '0.00', - `depth` decimal(10,2) DEFAULT '0.00', - `height` decimal(10,2) DEFAULT '0.00', - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', - `weight` decimal(5,2) NOT NULL DEFAULT '0.00', - `buildingOrder` int(5) NOT NULL DEFAULT '0', + `width` decimal(10,2) DEFAULT 0.00, + `depth` decimal(10,2) DEFAULT 0.00, + `height` decimal(10,2) DEFAULT 0.00, + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 1, + `weight` decimal(5,2) NOT NULL DEFAULT 0.00, + `buildingOrder` int(5) NOT NULL DEFAULT 0, `ETD` time NOT NULL DEFAULT '23:59:00', `palletOrder` int(5) DEFAULT NULL, - `lungGrow` int(11) DEFAULT '0', + `lungGrow` int(11) DEFAULT 0, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36172,12 +36311,12 @@ DROP TABLE IF EXISTS `specialLabels`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `specialLabels` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, - `reportName` varchar(100) COLLATE utf8_unicode_ci NOT NULL, - `isVisible` tinyint(1) NOT NULL DEFAULT '0', - `image` blob, + `description` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, + `reportName` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, + `isVisible` tinyint(1) NOT NULL DEFAULT 0, + `image` blob DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36189,16 +36328,16 @@ DROP TABLE IF EXISTS `specialPrice`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `specialPrice` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `clientFk` int(11) NOT NULL DEFAULT '0', - `itemFk` int(11) NOT NULL DEFAULT '0', - `value` double NOT NULL DEFAULT '0', + `clientFk` int(11) NOT NULL DEFAULT 0, + `itemFk` int(11) NOT NULL DEFAULT 0, + `value` double NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `Id_Cliente_2` (`clientFk`,`itemFk`), KEY `Id_Article` (`itemFk`), KEY `Id_Cliente` (`clientFk`), CONSTRAINT `sp_article_id` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE, CONSTRAINT `sp_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36210,10 +36349,10 @@ DROP TABLE IF EXISTS `specie`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `specie` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `specie_UN` (`name`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -36268,7 +36407,7 @@ CREATE TABLE `specieGeoInvasive` ( `genusFk` int(11) NOT NULL, `specieFk` int(11) NOT NULL, `zoneGeofk` int(11) NOT NULL, - `isForbidden` tinyint(1) NOT NULL DEFAULT '1', + `isForbidden` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY (`id`), KEY `specieGeoInvasive_FK` (`genusFk`), KEY `specieGeoInvasive_FK_1` (`specieFk`), @@ -36276,7 +36415,7 @@ CREATE TABLE `specieGeoInvasive` ( CONSTRAINT `specieGeoInvasive_FK` FOREIGN KEY (`genusFk`) REFERENCES `genus` (`id`) ON UPDATE CASCADE, CONSTRAINT `specieGeoInvasive_FK_1` FOREIGN KEY (`specieFk`) REFERENCES `specie` (`id`) ON UPDATE CASCADE, CONSTRAINT `specieGeoInvasive_FK_2` FOREIGN KEY (`zoneGeofk`) REFERENCES `zoneGeo` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Esta tabla recoge las prohibiciones de comerciar con especies invasoras de acuerdo con el Catálogo de Especies Exóticas Invasoras publicado por el Estado Español'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Esta tabla recoge las prohibiciones de comerciar con especies invasoras de acuerdo con el Catálogo de Especies Exóticas Invasoras publicado por el Estado Español'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36290,7 +36429,7 @@ CREATE TABLE `splitFilter` ( `id` int(11) NOT NULL AUTO_INCREMENT, `autonomyFk` int(11) DEFAULT NULL, `clientFk` int(11) DEFAULT NULL, - `nickname` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `nickname` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `splitFilter_UN` (`autonomyFk`), UNIQUE KEY `splitFilter_UN1` (`clientFk`), @@ -36298,7 +36437,7 @@ CREATE TABLE `splitFilter` ( KEY `splitFilter_FK_1` (`clientFk`), CONSTRAINT `splitFilter_FK` FOREIGN KEY (`autonomyFk`) REFERENCES `autonomy` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `splitFilter_FK_1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='define los clientes que tienen split y el nombre a mostrar en la etiqueta'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='define los clientes que tienen split y el nombre a mostrar en la etiqueta'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36311,14 +36450,14 @@ DROP TABLE IF EXISTS `starredModule`; CREATE TABLE `starredModule` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `workerFk` int(10) unsigned NOT NULL, - `moduleFk` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `moduleFk` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `position` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `starred_workerFk` (`workerFk`), KEY `starred_moduleFk` (`moduleFk`), CONSTRAINT `starred_moduleFk` FOREIGN KEY (`moduleFk`) REFERENCES `salix`.`module` (`code`) ON UPDATE CASCADE, CONSTRAINT `starred_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36330,21 +36469,21 @@ DROP TABLE IF EXISTS `state`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `state` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(20) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL, `order` tinyint(3) unsigned DEFAULT NULL, - `alertLevel` int(11) NOT NULL DEFAULT '0', - `code` varchar(45) CHARACTER SET utf8 NOT NULL, + `alertLevel` int(11) NOT NULL DEFAULT 0, + `code` varchar(45) CHARACTER SET utf8mb3 NOT NULL, `sectorProdPriority` tinyint(3) DEFAULT NULL, `nextStateFk` tinyint(3) unsigned NOT NULL COMMENT 'Estado al que tiene que cambiar el ticket despues de preparacion previa', - `isPreviousPreparable` tinyint(1) NOT NULL DEFAULT '0', - `isPicked` tinyint(1) NOT NULL DEFAULT '0', - `isPreparable` tinyint(1) NOT NULL DEFAULT '0', - `semaphore` int(11) NOT NULL DEFAULT '0', - `isPrintable` tinyint(4) NOT NULL DEFAULT '0', - `isOK` tinyint(4) NOT NULL DEFAULT '0', - `graphCategory` int(11) NOT NULL DEFAULT '0', - `isNotValidated` tinyint(1) DEFAULT '0' COMMENT 'Los tienen que ser validados por un comercial para prepararse', - `classColor` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, + `isPreviousPreparable` tinyint(1) NOT NULL DEFAULT 0, + `isPicked` tinyint(1) NOT NULL DEFAULT 0, + `isPreparable` tinyint(1) NOT NULL DEFAULT 0, + `semaphore` int(11) NOT NULL DEFAULT 0, + `isPrintable` tinyint(4) NOT NULL DEFAULT 0, + `isOK` tinyint(4) NOT NULL DEFAULT 0, + `graphCategory` int(11) NOT NULL DEFAULT 0, + `isNotValidated` tinyint(1) DEFAULT 0 COMMENT 'Los tienen que ser validados por un comercial para prepararse', + `classColor` varchar(12) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`), KEY `state_id3` (`semaphore`), @@ -36352,7 +36491,7 @@ CREATE TABLE `state` ( KEY `state_FK` (`nextStateFk`), CONSTRAINT `state_FK` FOREIGN KEY (`nextStateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE, CONSTRAINT `state_ibfk_1` FOREIGN KEY (`alertLevel`) REFERENCES `alertLevel` (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36367,14 +36506,14 @@ CREATE TABLE `stockBuyed` ( `user` int(10) unsigned DEFAULT NULL, `buyed` decimal(10,2) DEFAULT NULL, `date` date DEFAULT NULL, - `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `creationDate` timestamp NULL DEFAULT current_timestamp(), `reserved` decimal(10,2) DEFAULT NULL, `requested` decimal(10,2) DEFAULT NULL, - `description` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `description` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `stockBuyed_user_idx` (`user`), CONSTRAINT `stockBuyedUserFk` FOREIGN KEY (`user`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36387,9 +36526,9 @@ DROP TABLE IF EXISTS `stowaway`; CREATE TABLE `stowaway` ( `id` int(11) NOT NULL COMMENT 'ticket pequeño', `shipFk` int(11) NOT NULL COMMENT 'ticket grande', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tickets polizones y sus naves de embarque'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tickets polizones y sus naves de embarque'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36401,37 +36540,37 @@ DROP TABLE IF EXISTS `supplier`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `supplier` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, `account` varchar(10) DEFAULT NULL, - `street` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `city` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `street` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `city` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, `provinceFk` smallint(5) unsigned DEFAULT NULL, `countryFk` mediumint(8) unsigned DEFAULT NULL, - `nif` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `isOfficial` tinyint(1) NOT NULL DEFAULT '1', - `isFarmer` tinyint(1) NOT NULL DEFAULT '0', - `retAccount` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `phone` varchar(16) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `Fax__` varchar(16) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `commission` float NOT NULL DEFAULT '0', - `nickname` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `nif` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isOfficial` tinyint(1) NOT NULL DEFAULT 1, + `isFarmer` tinyint(1) NOT NULL DEFAULT 0, + `retAccount` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `phone` varchar(16) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `Fax__` varchar(16) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `commission` float NOT NULL DEFAULT 0, + `nickname` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, `payMethodFk` tinyint(3) unsigned NOT NULL, `payDay` tinyint(4) unsigned DEFAULT NULL, - `payDemFk` tinyint(3) unsigned NOT NULL DEFAULT '7', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `isSerious` tinyint(1) unsigned NOT NULL DEFAULT '1', - `note` text CHARACTER SET utf8 COLLATE utf8_unicode_ci, + `payDemFk` tinyint(3) unsigned NOT NULL DEFAULT 7, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `isSerious` tinyint(1) unsigned NOT NULL DEFAULT 1, + `note` text CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, `postcodeFk` int(11) unsigned DEFAULT NULL, - `postCode` char(8) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `isActive` tinyint(4) DEFAULT '1', + `postCode` char(8) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isActive` tinyint(4) NOT NULL DEFAULT 1, `taxTypeSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipo de IVA SAGE', `withholdingSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipos de retención SAGE', `transactionTypeSageFk` tinyint(4) DEFAULT NULL COMMENT 'Ti po de transacción SAGE', - `isTrucker` tinyint(1) NOT NULL DEFAULT '0', + `isTrucker` tinyint(1) NOT NULL DEFAULT 0, `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', + `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`), @@ -36454,7 +36593,7 @@ CREATE TABLE `supplier` ( CONSTRAINT `supplier_withholdingFk` FOREIGN KEY (`withholdingSageFk`) REFERENCES `sage`.`TiposRetencion` (`CodigoRetencion`) ON UPDATE CASCADE, CONSTRAINT `supplier_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `suppplier_supplierActivityFk` FOREIGN KEY (`supplierActivityFk`) REFERENCES `supplierActivity` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -36481,7 +36620,7 @@ BEGIN IF vPayMethodHasVerified AND !vHasChange THEN SET vHasChange = (NEW.payMethodFk <> OLD.payMethodFk); END IF; - + IF vHasChange THEN SET NEW.isPayMethodChecked = FALSE; END IF; @@ -36503,22 +36642,22 @@ DROP TABLE IF EXISTS `supplierAccount`; CREATE TABLE `supplierAccount` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `supplierFk` int(11) DEFAULT NULL, - `iban` varchar(30) CHARACTER SET utf8 DEFAULT NULL, - `office` varchar(4) CHARACTER SET utf8 DEFAULT NULL, - `DC` varchar(2) CHARACTER SET utf8 DEFAULT NULL, - `number` varchar(10) CHARACTER SET utf8 DEFAULT NULL, - `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta(comprobar)', - `bicSufix` varchar(3) CHARACTER SET utf8 NOT NULL DEFAULT '', + `iban` varchar(30) CHARACTER SET utf8mb3 DEFAULT NULL, + `office` varchar(4) CHARACTER SET utf8mb3 DEFAULT NULL, + `DC` varchar(2) CHARACTER SET utf8mb3 DEFAULT NULL, + `number` varchar(10) CHARACTER SET utf8mb3 DEFAULT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'obsoleta(comprobar)', + `bicSufix` varchar(3) CHARACTER SET utf8mb3 NOT NULL DEFAULT '', `bankEntityFk` int(10) unsigned DEFAULT NULL, `bankFk` int(11) DEFAULT NULL COMMENT 'obsoleta(comprobar)', - `beneficiary` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `beneficiary` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_proveedores_proveedores_account_idx` (`supplierFk`), KEY `fk_Proveedores_account_entity1_idx` (`bankEntityFk`), KEY `fk_banco_prov_account_idx` (`bankFk`), CONSTRAINT `supplierAccount_FK` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `supplierAccount_FK_1` FOREIGN KEY (`bankEntityFk`) REFERENCES `bankEntity` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -36539,7 +36678,7 @@ BEGIN FROM vn.supplier s JOIN vn.payMethod pm ON pm.id = s.payMethodFk WHERE s.id = OLD.supplierFk; - + IF OLD.iban <> NEW.iban OR OLD.bankEntityFk <> NEW.bankEntityFk AND vPayMethodHasVerified THEN UPDATE vn.supplier SET isPayMethodChecked = FALSE @@ -36561,10 +36700,10 @@ DROP TABLE IF EXISTS `supplierActivity`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `supplierActivity` ( - `code` varchar(45) CHARACTER SET utf8 NOT NULL, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(45) CHARACTER SET utf8mb3 NOT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36577,17 +36716,17 @@ DROP TABLE IF EXISTS `supplierAddress`; CREATE TABLE `supplierAddress` ( `id` int(11) NOT NULL AUTO_INCREMENT, `supplierFk` int(11) DEFAULT NULL, - `nickname` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, - `street` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `nickname` varchar(40) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `street` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `provinceFk` smallint(6) unsigned DEFAULT NULL, - `postalCode` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `city` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `phone` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `mobile` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `postalCode` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `city` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `phone` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `mobile` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `supplierAddress_province_fk` (`provinceFk`), CONSTRAINT `supplierAddress_province_fk` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36600,18 +36739,18 @@ DROP TABLE IF EXISTS `supplierAgencyTerm`; CREATE TABLE `supplierAgencyTerm` ( `agencyFk` smallint(5) unsigned NOT NULL, `supplierFk` int(11) DEFAULT NULL, - `minimumPackages` int(11) NOT NULL DEFAULT '0' COMMENT 'numero minimo de bultos', - `kmPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'precio extra por km', - `packagePrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'precio extra por bulto', + `minimumPackages` int(11) NOT NULL DEFAULT 0 COMMENT 'numero minimo de bultos', + `kmPrice` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT 'precio extra por km', + `packagePrice` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT 'precio extra por bulto', `routePrice` decimal(10,2) DEFAULT NULL COMMENT 'precio fijo por ruta', - `minimumKm` int(11) NOT NULL DEFAULT '0', - `minimumM3` decimal(10,2) NOT NULL DEFAULT '0.00', - `m3Price` decimal(10,2) NOT NULL DEFAULT '0.00', + `minimumKm` int(11) NOT NULL DEFAULT 0, + `minimumM3` decimal(10,2) NOT NULL DEFAULT 0.00, + `m3Price` decimal(10,2) NOT NULL DEFAULT 0.00, PRIMARY KEY (`agencyFk`), KEY `agencyTerm_FK_1` (`supplierFk`), CONSTRAINT `agencyTerm_FK` FOREIGN KEY (`agencyFk`) REFERENCES `agency` (`id`) ON UPDATE CASCADE, CONSTRAINT `agencyTerm_FK_1` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36624,15 +36763,15 @@ DROP TABLE IF EXISTS `supplierContact`; CREATE TABLE `supplierContact` ( `id` int(11) NOT NULL AUTO_INCREMENT, `supplierFk` int(11) DEFAULT NULL, - `phone` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL, - `mobile` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL, - `email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `observation` text COLLATE utf8_unicode_ci, - `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `phone` varchar(16) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `mobile` varchar(16) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `email` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `observation` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `name` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `supplier_id` (`supplierFk`), CONSTRAINT `supplier_id` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36646,13 +36785,13 @@ CREATE TABLE `supplierExpense` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `dated` date NOT NULL, `supplierFk` int(11) NOT NULL, - `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT '2', - `amount` decimal(10,2) NOT NULL DEFAULT '0.00', - `description` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', + `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT 2, + `amount` decimal(10,2) NOT NULL DEFAULT 0.00, + `description` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, `dmsFk` int(11) DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `isConciliated` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0', + `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `isConciliated` tinyint(1) unsigned zerofill NOT NULL DEFAULT 0, `dueDated` date NOT NULL, PRIMARY KEY (`id`), KEY `empresa_id` (`companyFk`), @@ -36665,7 +36804,7 @@ CREATE TABLE `supplierExpense` ( CONSTRAINT `pago_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, CONSTRAINT `pago_moneda` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`) ON UPDATE CASCADE, CONSTRAINT `proveedor_pago` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36679,20 +36818,20 @@ CREATE TABLE `supplierLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `originFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, - `action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL, - `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `description` text CHARACTER SET utf8, - `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8_unicode_ci, - `newInstance` text COLLATE utf8_unicode_ci, + `action` set('insert','update','delete') COLLATE utf8mb3_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 DEFAULT NULL, + `changedModel` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `logSupplier_ibfk_1` (`originFk`), KEY `supplierLog_ibfk_2` (`userFk`), CONSTRAINT `supplierLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `supplier` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `supplierLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36725,12 +36864,12 @@ DROP TABLE IF EXISTS `tablet`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tablet` ( - `uuid` varchar(100) COLLATE utf8_unicode_ci NOT NULL, - `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `place` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `macwifi` varchar(45) COLLATE utf8_unicode_ci DEFAULT '0', + `uuid` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `place` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `macwifi` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT '0', PRIMARY KEY (`uuid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36741,13 +36880,13 @@ DROP TABLE IF EXISTS `tabletDepartment`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tabletDepartment` ( - `tabletFk` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `tabletFk` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, `departmentFk` int(11) NOT NULL, PRIMARY KEY (`tabletFk`,`departmentFk`), KEY `departmentFk_idx` (`departmentFk`), CONSTRAINT `departmentFk` FOREIGN KEY (`departmentFk`) REFERENCES `department` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `tablet_uuid` FOREIGN KEY (`tabletFk`) REFERENCES `tablet` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36759,19 +36898,19 @@ DROP TABLE IF EXISTS `tag`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tag` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(45) CHARACTER SET utf8 DEFAULT NULL, - `name` varchar(25) COLLATE utf8_unicode_ci NOT NULL, - `isFree` tinyint(1) NOT NULL DEFAULT '1', - `isQuantitatif` tinyint(4) NOT NULL DEFAULT '0', - `sourceTable` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `unit` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `ediTypeFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `overwrite` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'nombre del campo de item a sobreescribir con el valor del tag, hay que añadir el código correspondiente en item_refreshTags', + `code` varchar(45) CHARACTER SET utf8mb3 DEFAULT NULL, + `name` varchar(25) COLLATE utf8mb3_unicode_ci NOT NULL, + `isFree` tinyint(1) NOT NULL DEFAULT 1, + `isQuantitatif` tinyint(4) NOT NULL DEFAULT 0, + `sourceTable` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `unit` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `ediTypeFk` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `overwrite` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'nombre del campo de item a sobreescribir con el valor del tag, hay que añadir el código correspondiente en item_refreshTags', PRIMARY KEY (`id`), UNIQUE KEY `tagNameIdx` (`name`,`ediTypeFk`), UNIQUE KEY `tagEdiTypeFkIdx` (`ediTypeFk`), CONSTRAINT `fgnTag` FOREIGN KEY (`ediTypeFk`) REFERENCES `edi`.`type` (`type_id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Categorias para etiquetar los productos'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Categorias para etiquetar los productos'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -36804,13 +36943,13 @@ DROP TABLE IF EXISTS `tagAbbreviation`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tagAbbreviation` ( - `value` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `abbreviation` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `value` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL, + `abbreviation` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, `tagFk` int(11) DEFAULT NULL, PRIMARY KEY (`value`), KEY `tagAbbreviation_FK` (`tagFk`), CONSTRAINT `tagAbbreviation_FK` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36822,10 +36961,10 @@ DROP TABLE IF EXISTS `tagI18n`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tagI18n` ( `tagFk` int(10) unsigned NOT NULL, - `lang` char(2) CHARACTER SET utf8 NOT NULL, - `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `lang` char(2) CHARACTER SET utf8mb3 NOT NULL, + `name` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`tagFk`,`lang`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36850,11 +36989,11 @@ DROP TABLE IF EXISTS `taxArea`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `taxArea` ( - `code` varchar(15) CHARACTER SET utf8 NOT NULL, - `ClaveOperacionFactura` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(15) CHARACTER SET utf8mb3 NOT NULL, + `ClaveOperacionFactura` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `CodigoTransaccion` int(2) DEFAULT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36866,11 +37005,11 @@ DROP TABLE IF EXISTS `taxClass`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `taxClass` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `description` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `code` varchar(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'R', + `description` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL, + `code` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'R', PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36888,7 +37027,7 @@ CREATE TABLE `taxClassCode` ( KEY `iva_codigo_id` (`taxCodeFk`), CONSTRAINT `taxClassCode_ibfk_1` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE, CONSTRAINT `taxClassCode_ibfk_2` FOREIGN KEY (`taxCodeFk`) REFERENCES `taxCode` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36901,25 +37040,25 @@ DROP TABLE IF EXISTS `taxCode`; CREATE TABLE `taxCode` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `dated` date NOT NULL, - `code` varchar(10) CHARACTER SET utf8 NOT NULL, + `code` varchar(10) CHARACTER SET utf8mb3 NOT NULL, `taxTypeFk` tinyint(2) NOT NULL, - `rate` decimal(4,1) NOT NULL DEFAULT '0.0', - `equalizationTax` decimal(4,1) NOT NULL DEFAULT '0.0', - `type` char(1) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Solo rellenar si en el asiento ira en el DEBE', - `link` tinyint(4) unsigned DEFAULT '0' COMMENT 'las que tienen el mismo valor se contabilizan emparejadas', - `isActive` tinyint(2) NOT NULL DEFAULT '1', - `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `transactionCode` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Código de Transacción de SAGE', - `operationCode` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Código de operaciones de SAGE', + `rate` decimal(4,1) NOT NULL DEFAULT 0.0, + `equalizationTax` decimal(4,1) NOT NULL DEFAULT 0.0, + `type` char(1) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'Solo rellenar si en el asiento ira en el DEBE', + `link` tinyint(4) unsigned DEFAULT 0 COMMENT 'las que tienen el mismo valor se contabilizan emparejadas', + `isActive` tinyint(2) NOT NULL DEFAULT 1, + `updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `transactionCode` varchar(2) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'Código de Transacción de SAGE', + `operationCode` varchar(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'Código de operaciones de SAGE', `taxCode` int(4) DEFAULT NULL COMMENT 'Código de IVA SAGE', - `isIntracommunity` tinyint(2) DEFAULT '0', + `isIntracommunity` tinyint(2) DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `taxCode_dated_IDX` (`dated`,`taxTypeFk`,`type`,`link`) USING BTREE, KEY `iva_tipo_id` (`taxTypeFk`), KEY `codigo` (`code`), KEY `tipo_index` (`type`), CONSTRAINT `taxCode_ibfk_1` FOREIGN KEY (`taxTypeFk`) REFERENCES `taxType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36931,17 +37070,17 @@ DROP TABLE IF EXISTS `taxType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `taxType` ( `id` tinyint(2) NOT NULL AUTO_INCREMENT, - `nickname` varchar(6) COLLATE utf8_unicode_ci NOT NULL, - `isAccrued` tinyint(4) NOT NULL DEFAULT '0', - `serial` char(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `TIPOOPE` varchar(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT ' ' COMMENT 'respetar el nombre de la columna, se utiliza en contaplus', - `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `nickname` varchar(6) COLLATE utf8mb3_unicode_ci NOT NULL, + `isAccrued` tinyint(4) NOT NULL DEFAULT 0, + `serial` char(1) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `TIPOOPE` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT ' ' COMMENT 'respetar el nombre de la columna, se utiliza en contaplus', + `description` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, `countryFk` mediumint(8) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `serie_id` (`serial`), KEY `Id_Pais` (`countryFk`), CONSTRAINT `taxType_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36952,11 +37091,11 @@ DROP TABLE IF EXISTS `temperature`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `temperature` ( - `code` varchar(10) CHARACTER SET utf8 NOT NULL, - `description` text COLLATE utf8_unicode_ci, - `name` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(10) CHARACTER SET utf8mb3 NOT NULL, + `description` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `name` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36967,10 +37106,10 @@ DROP TABLE IF EXISTS `thermograph`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `thermograph` ( - `id` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `model` enum('TL30','SENSITECH','TREKVIEW1','TREKVIEW2','DISPOSABLE','TEMPMATE') COLLATE utf8_unicode_ci NOT NULL, + `id` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `model` enum('TL30','SENSITECH','TREKVIEW1','TREKVIEW2','DISPOSABLE','TEMPMATE') COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -36982,34 +37121,34 @@ DROP TABLE IF EXISTS `ticket`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticket` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `clientFk` int(11) NOT NULL DEFAULT '0', - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', + `clientFk` int(11) NOT NULL DEFAULT 0, + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 1, `shipped` datetime NOT NULL, - `nickname` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `notes__` longtext COLLATE utf8_unicode_ci, - `refFk` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `nickname` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `notes__` longtext COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `refFk` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `invoiceOutFk__` int(10) unsigned DEFAULT NULL COMMENT 'eliminar', - `isBooked__` tinyint(1) NOT NULL DEFAULT '0', - `addressFk` int(11) NOT NULL DEFAULT '0', + `isBooked__` tinyint(1) NOT NULL DEFAULT 0, + `addressFk` int(11) NOT NULL DEFAULT 0, `workerFk` int(11) DEFAULT NULL, - `observations` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'eliminar', - `isSigned` tinyint(1) NOT NULL DEFAULT '0', - `isLabeled` tinyint(1) NOT NULL DEFAULT '0', - `isPrinted` tinyint(1) NOT NULL DEFAULT '0', - `packages` smallint(10) unsigned DEFAULT '0', - `location` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `hour` int(11) DEFAULT '0', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `isBlocked` tinyint(1) NOT NULL DEFAULT '1', - `solution` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, + `observations` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'eliminar', + `isSigned` tinyint(1) NOT NULL DEFAULT 0, + `isLabeled` tinyint(1) NOT NULL DEFAULT 0, + `isPrinted` tinyint(1) NOT NULL DEFAULT 0, + `packages` smallint(10) unsigned DEFAULT 0, + `location` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `hour` int(11) DEFAULT 0, + `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `isBlocked` tinyint(1) NOT NULL DEFAULT 1, + `solution` varchar(5) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `routeFk` int(10) unsigned DEFAULT NULL, `priority` tinyint(3) unsigned DEFAULT NULL, - `hasPriority` tinyint(1) unsigned NOT NULL DEFAULT '1', - `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', + `hasPriority` tinyint(1) unsigned NOT NULL DEFAULT 1, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, `agencyModeFk` int(11) DEFAULT NULL, `landed` date DEFAULT NULL, - `isBoxed` tinyint(2) NOT NULL DEFAULT '0', - `isDeleted` tinyint(2) NOT NULL DEFAULT '0', + `isBoxed` tinyint(2) NOT NULL DEFAULT 0, + `isDeleted` tinyint(2) NOT NULL DEFAULT 0, `zoneFk` int(11) DEFAULT NULL, `collectionFk__` int(11) DEFAULT NULL, `zonePrice` decimal(10,2) DEFAULT NULL, @@ -37039,14 +37178,14 @@ CREATE TABLE `ticket` ( CONSTRAINT `ticket_ibfk_9` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `tickets_fk11` FOREIGN KEY (`collectionFk__`) REFERENCES `collection` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `tickets_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -37054,11 +37193,11 @@ DELIMITER ;; AFTER INSERT ON `ticket` FOR EACH ROW BEGIN - + DECLARE vClientType VARCHAR(255); DECLARE vStateCode VARCHAR(255); DECLARE vTransferorFirstShipped DATE; - + -- Borrar cuando se cambie el insert ticket en la APP móvil SELECT typeFk INTO vClientType @@ -37071,8 +37210,8 @@ BEGIN END IF; INSERT INTO vncontrol.inter(Id_Ticket, state_id, Id_Trabajador) - SELECT NEW.id, id, account.myUser_getId() - FROM state + SELECT NEW.id, id, account.myUser_getId() + FROM state WHERE `code` = vStateCode COLLATE utf8_general_ci; IF YEAR(NEW.shipped) > 2000 THEN @@ -37083,9 +37222,9 @@ BEGIN WHERE c.id = NEW.clientFk; INSERT INTO bs.clientNewBorn(clientFk, firstShipped, lastShipped) - VALUES(NEW.clientFk, IFNULL(vTransferorFirstShipped, CURDATE()), CURDATE()) - ON DUPLICATE KEY UPDATE lastShipped = CURDATE(); - + VALUES(NEW.clientFk, IFNULL(vTransferorFirstShipped, util.VN_CURDATE()), util.VN_CURDATE()) + ON DUPLICATE KEY UPDATE lastShipped = util.VN_CURDATE(); + END IF; END */;; @@ -37108,18 +37247,18 @@ DELIMITER ;; FOR EACH ROW BEGIN DECLARE vNewTime TIME; - + IF !(NEW.routeFk <=> OLD.routeFk) THEN - INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) - SELECT r.id + INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) + SELECT r.id FROM vn.route r - WHERE r.isOk = FALSE + WHERE r.isOk = FALSE AND r.id IN (OLD.routeFk,NEW.routeFk) - AND r.created >= CURDATE() + AND r.created >= util.VN_CURDATE() GROUP BY r.id; call util.debugAdd(NEW.id,CONCAT(OLD.routeFk,' ',NEW.routeFk)); END IF; - + IF !(DATE(NEW.shipped) <=> DATE(OLD.shipped)) THEN IF YEAR(NEW.shipped) < 2000 THEN SIGNAL SQLSTATE '46000' @@ -37131,15 +37270,15 @@ BEGIN END IF; END IF; - + IF !(NEW.isDeleted <=> OLD.isDeleted) AND NEW.isDeleted THEN - INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) - SELECT r.id + INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) + SELECT r.id FROM vn.ticket t JOIN vn.route r ON r.id = t.routeFk - WHERE r.isOk = FALSE + WHERE r.isOk = FALSE AND t.id = NEW.id - AND r.created >= CURDATE() + AND r.created >= util.VN_CURDATE() GROUP BY r.id; SET NEW.shipped = DATE_FORMAT(NEW.shipped, '2000-%m-%d %T'); SET NEW.landed = DATE_FORMAT(NEW.landed, '2000-%m-%d %T'); @@ -37147,7 +37286,7 @@ BEGIN SET NEW.zoneFk = NULL; END IF; - IF NEW.routeFk AND NEW.isDeleted THEN + IF NEW.routeFk AND NEW.isDeleted THEN CALL util.throw ('This ticket is deleted'); END IF; @@ -37156,22 +37295,22 @@ BEGIN FROM vn.ticket WHERE routeFk = NEW.routeFk HAVING MAX(TIME(shipped)) > TIME(NEW.shipped); - + IF vNewTime THEN SET NEW.shipped = TIMESTAMP(DATE(NEW.shipped), vNewTime); INSERT INTO vn.ticketLog - SET originFk = NEW.id, - userFk = account.myUser_getId(), - `action` = 'update', + SET originFk = NEW.id, + userFk = account.myUser_getId(), + `action` = 'update', description = CONCAT('Cambia la hora por cambio de ruta de ', TIME(OLD.shipped), ' a ', TIME(NEW.shipped)); END IF; INSERT IGNORE INTO zoneAgencyMode (agencyModeFk,zoneFk) - SELECT r.agencyModeFk, NEW.zoneFk FROM route r + SELECT r.agencyModeFk, NEW.zoneFk FROM route r WHERE r.id = NEW.routeFk; - + CALL vn.routeUpdateM3(NEW.routeFk); END IF; END */;; @@ -37205,7 +37344,7 @@ BEGIN 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 CALL mail_insert( @@ -37215,10 +37354,10 @@ BEGIN CONCAT(account.myUser_getName(), ' ha modificado el ticket ',NEW.id) ); END IF; - + IF NEW.routeFk <> OLD.routeFk THEN - UPDATE expedition + UPDATE expedition SET hasNewRoute = TRUE WHERE ticketFk = NEW.id; @@ -37242,13 +37381,13 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_beforeDelete` BEFORE DELETE ON `ticket` FOR EACH ROW -BEGIN - INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) - SELECT r.id +BEGIN + INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) + SELECT r.id FROM vn.route r - WHERE r.isOk = FALSE + WHERE r.isOk = FALSE AND r.id = OLD.routeFk - AND r.created >= CURDATE() + AND r.created >= util.VN_CURDATE() GROUP BY r.id; DELETE FROM sale WHERE ticketFk = OLD.id; @@ -37272,10 +37411,10 @@ CREATE TABLE `ticketCollection` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ticketFk` int(11) NOT NULL, `collectionFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `level` int(11) DEFAULT NULL, - `wagon` int(11) NOT NULL DEFAULT '0', - `smartTagFk` varchar(12) CHARACTER SET utf8 DEFAULT NULL, + `wagon` int(11) NOT NULL DEFAULT 0, + `smartTagFk` varchar(12) CHARACTER SET utf8mb3 DEFAULT NULL, `usedShelves` int(11) DEFAULT NULL COMMENT 'número de bandejas que ocupa un ticket en el carro', `itemCount` int(11) DEFAULT NULL COMMENT 'número de productos distintos en el pedido', `liters` int(11) DEFAULT NULL COMMENT 'volumen del pedido en litros', @@ -37288,42 +37427,42 @@ CREATE TABLE `ticketCollection` ( CONSTRAINT `ticketCollection_FK` FOREIGN KEY (`smartTagFk`) REFERENCES `smartTag` (`code`) ON UPDATE CASCADE, 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; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER ticketCollection_afterDelete AFTER DELETE ON ticketCollection FOR EACH ROW -BEGIN - +BEGIN + DECLARE vSalesRemaining INT; SELECT count(*) INTO vSalesRemaining FROM vn.ticketCollection tc - JOIN sale s ON s.ticketFk = tc.ticketFk + JOIN sale s ON s.ticketFk = tc.ticketFk WHERE collectionFk = OLD.collectionFk AND tc.id != OLD.id; - + IF NOT vSalesRemaining THEN - + DELETE FROM vn.collection WHERE id = OLD.collectionFk; - + ELSE - - UPDATE vn.collection + + UPDATE vn.collection SET saleTotalCount = vSalesRemaining WHERE id = OLD.collectionFk; - + END IF; - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -37341,9 +37480,9 @@ DROP TABLE IF EXISTS `ticketConfig`; CREATE TABLE `ticketConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, `scopeDays` tinyint(3) DEFAULT NULL, - `pickingDelay` int(11) NOT NULL DEFAULT '10' COMMENT 'minutos de cortesia desde que se crea un ticket hasta que se puede preparar', + `pickingDelay` int(11) NOT NULL DEFAULT 10 COMMENT 'minutos de cortesia desde que se crea un ticket hasta que se puede preparar', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -37360,7 +37499,7 @@ CREATE TABLE `ticketDms` ( KEY `gestdoc_id` (`dmsFk`), CONSTRAINT `ticketDms_dmsFk` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketDms_ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -37375,13 +37514,13 @@ DELIMITER ;; BEFORE DELETE ON `ticketDms` FOR EACH ROW BEGIN - UPDATE dms - SET dmsTypeFk = (SELECT id - FROM dmsType + UPDATE dms + SET dmsTypeFk = (SELECT id + FROM dmsType WHERE `code` = 'trash' ) - WHERE id = OLD.dmsFk AND ( SELECT IF(COUNT(*) > 0, FALSE, TRUE) - FROM ticketDms + WHERE id = OLD.dmsFk AND ( SELECT IF(COUNT(*) > 0, FALSE, TRUE) + FROM ticketDms WHERE dmsFk = OLD.dmsFk ) ; END */;; @@ -37401,7 +37540,7 @@ DROP TABLE IF EXISTS `ticketDocumentation`; CREATE TABLE `ticketDocumentation` ( `ticketFk` int(11) NOT NULL, PRIMARY KEY (`ticketFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Marca si se ha revisado el ticket para aportar la documentación CRM/DUA (relativa al trasporte internacional de mercancias)'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Marca si se ha revisado el ticket para aportar la documentación CRM/DUA (relativa al trasporte internacional de mercancias)'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -37413,8 +37552,8 @@ DROP TABLE IF EXISTS `ticketDown`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticketDown` ( `ticketFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `selected` int(11) NOT NULL DEFAULT '0', + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `selected` int(11) NOT NULL DEFAULT 0, `collectionFk` int(11) NOT NULL, `id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`), @@ -37423,7 +37562,7 @@ CREATE TABLE `ticketDown` ( KEY `ticketDown_FK` (`collectionFk`), CONSTRAINT `ticketDown_FK` FOREIGN KEY (`collectionFk`) REFERENCES `collection` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketDown_fk1` FOREIGN KEY (`selected`) REFERENCES `ticketDown_SelectionType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Cola de impresion para los tickets que se van a solicitar al altillo'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Cola de impresion para los tickets que se van a solicitar al altillo'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -37435,10 +37574,10 @@ DROP TABLE IF EXISTS `ticketDown_SelectionType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticketDown_SelectionType` ( `id` int(11) NOT NULL, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `description_UNIQUE` (`description`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -37449,14 +37588,14 @@ DROP TABLE IF EXISTS `ticketLastState`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticketLastState` ( - `ticketFk` int(11) NOT NULL DEFAULT '0', + `ticketFk` int(11) NOT NULL DEFAULT 0, `ticketTrackingFk` int(11) NOT NULL, - `name` varchar(15) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`ticketFk`), KEY `double_foreign` (`ticketFk`,`ticketTrackingFk`), CONSTRAINT `Id_Ticket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `double_foreign` FOREIGN KEY (`ticketFk`, `ticketTrackingFk`) REFERENCES `vncontrol`.`inter` (`Id_Ticket`, `inter_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -37487,21 +37626,6 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `ticketLocation` --- - -DROP TABLE IF EXISTS `ticketLocation`; -/*!50001 DROP VIEW IF EXISTS `ticketLocation`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `ticketLocation` ( - `ticketFk` tinyint NOT NULL, - `longitude` tinyint NOT NULL, - `latitude` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `ticketLog` -- @@ -37513,50 +37637,22 @@ CREATE TABLE `ticketLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `originFk` int(11) NOT NULL, `userFk` int(10) unsigned DEFAULT NULL, - `action` set('insert','update','delete','select') COLLATE utf8_unicode_ci NOT NULL, - `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `description` text CHARACTER SET utf8, - `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8_unicode_ci, - `newInstance` text COLLATE utf8_unicode_ci, + `action` set('insert','update','delete','select') COLLATE utf8mb3_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 DEFAULT NULL, + `changedModel` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `logTicketoriginFk` (`originFk`), KEY `logTicketuserFk` (`userFk`), CONSTRAINT `ticketLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketLog_user` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Temporary table structure for view `ticketMRW` --- - -DROP TABLE IF EXISTS `ticketMRW`; -/*!50001 DROP VIEW IF EXISTS `ticketMRW`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `ticketMRW` ( - `id_Agencia` tinyint NOT NULL, - `empresa_id` tinyint NOT NULL, - `Consignatario` tinyint NOT NULL, - `DOMICILIO` tinyint NOT NULL, - `POBLACION` tinyint NOT NULL, - `CODPOSTAL` tinyint NOT NULL, - `telefono` tinyint NOT NULL, - `movil` tinyint NOT NULL, - `IF` tinyint NOT NULL, - `Id_Ticket` tinyint NOT NULL, - `warehouse_id` tinyint NOT NULL, - `Id_Consigna` tinyint NOT NULL, - `CodigoPais` tinyint NOT NULL, - `Fecha` tinyint NOT NULL, - `province_id` tinyint NOT NULL, - `landing` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `ticketNotInvoiced` -- @@ -37586,13 +37682,13 @@ CREATE TABLE `ticketObservation` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `ticketFk` int(11) NOT NULL, `observationTypeFk` tinyint(3) unsigned NOT NULL, - `description` text COLLATE utf8_unicode_ci NOT NULL, + `description` text COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `Id_Ticket` (`ticketFk`,`observationTypeFk`), KEY `observation_type_id` (`observationTypeFk`), CONSTRAINT `ticketObservation_ibfk_1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketObservation_ibfk_2` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -37604,10 +37700,10 @@ DROP TABLE IF EXISTS `ticketPackage`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticketPackage` ( `ticket` int(11) NOT NULL, - `counter` int(10) unsigned NOT NULL DEFAULT '0', + `counter` int(10) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`ticket`), CONSTRAINT `ticketPackage_ticketFk` FOREIGN KEY (`ticket`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -37620,9 +37716,9 @@ DROP TABLE IF EXISTS `ticketPackaging`; CREATE TABLE `ticketPackaging` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ticketFk` int(11) NOT NULL, - `packagingFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `quantity` int(10) DEFAULT '0', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `packagingFk` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, + `quantity` int(10) DEFAULT 0, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `pvp` double DEFAULT NULL, `workerFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), @@ -37632,7 +37728,7 @@ CREATE TABLE `ticketPackaging` ( CONSTRAINT `ticketPackaging_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk3` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -37666,18 +37762,18 @@ DROP TABLE IF EXISTS `ticketPackagingStartingStock`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticketPackagingStartingStock` ( `clientFk` int(11) NOT NULL, - `packagingFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `packagingFk` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, `itemFk` int(11) NOT NULL, `sent` int(11) DEFAULT NULL, `returned` int(11) DEFAULT NULL, - `isForgetable` tinyint(1) NOT NULL DEFAULT '0', + `isForgetable` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`clientFk`,`packagingFk`), KEY `ticketPackagingStartingStock_fk2_idx` (`packagingFk`), KEY `ticketPackagingStartingStock_fk3_idx` (`itemFk`), CONSTRAINT `ticketPackagingStartingStock_fk1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketPackagingStartingStock_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketPackagingStartingStock_fk3` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -37713,7 +37809,7 @@ CREATE TABLE `ticketParking` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ticketFk` int(11) NOT NULL, `parkingFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `workerFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `ticketParking_idx1` (`ticketFk`,`parkingFk`), @@ -37721,7 +37817,7 @@ CREATE TABLE `ticketParking` ( KEY `ticketParking_fk1_idx` (`parkingFk`), CONSTRAINT `ticketParking_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketParking_fk2` FOREIGN KEY (`parkingFk`) REFERENCES `parking` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los distintos lugares donde puede estar aparcado cada uno de los prepedidos'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Almacena los distintos lugares donde puede estar aparcado cada uno de los prepedidos'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -37738,7 +37834,7 @@ DELIMITER ;; BEGIN SET NEW.workerFk = vn.getUser(); - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -37778,9 +37874,8 @@ CREATE TABLE `ticketRecalc` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ticketFk` int(11) NOT NULL, PRIMARY KEY (`id`), - KEY `ticketRecalc_ibfk_1` (`ticketFk`), - CONSTRAINT `ticketRecalc_ibfk_1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Queue of changed tickets to recalc its total'; + KEY `ticketRecalc_ibfk_1` (`ticketFk`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Queue of changed tickets to recalc its total'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -37799,7 +37894,7 @@ CREATE TABLE `ticketRefund` ( KEY `ticketRefund_FK_1` (`originalTicketFk`), CONSTRAINT `ticketRefund_FK` FOREIGN KEY (`refundTicketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticketRefund_FK_1` FOREIGN KEY (`originalTicketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -37851,23 +37946,23 @@ DROP TABLE IF EXISTS `ticketRequest`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticketRequest` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `description` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `ordered` datetime DEFAULT NULL, `shipped` datetime DEFAULT NULL, - `salesPersonCode` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `buyerCode` varchar(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'NOE', + `salesPersonCode` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `buyerCode` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'NOE', `quantity` int(11) DEFAULT NULL, `price` double DEFAULT NULL, `price__` double DEFAULT NULL, `itemFk` double DEFAULT NULL, `clientFk` int(11) DEFAULT NULL, - `response` longtext COLLATE utf8_unicode_ci, - `ok__` tinyint(1) NOT NULL DEFAULT '0', + `response` longtext COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `ok__` tinyint(1) NOT NULL DEFAULT 0, `total` int(11) DEFAULT NULL, `buyed` datetime DEFAULT NULL, - `ko__` tinyint(1) NOT NULL DEFAULT '0', + `ko__` tinyint(1) NOT NULL DEFAULT 0, `saleFk` int(11) DEFAULT NULL, - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NULL DEFAULT current_timestamp(), `isOk` tinyint(1) DEFAULT NULL, `requesterFk` int(10) unsigned DEFAULT NULL, `attenderFk` int(10) unsigned DEFAULT NULL, @@ -37886,7 +37981,7 @@ CREATE TABLE `ticketRequest` ( CONSTRAINT `fgnAtender` FOREIGN KEY (`attenderFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `fgnRequester` FOREIGN KEY (`requesterFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `fgnTicket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -37958,10 +38053,10 @@ DROP TABLE IF EXISTS `ticketService`; /*!40101 SET character_set_client = utf8 */; 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) NOT NULL DEFAULT '0.00', - `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT '2', + `description` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `quantity` int(11) NOT NULL DEFAULT 0, + `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, PRIMARY KEY (`id`), @@ -37971,7 +38066,7 @@ CREATE TABLE `ticketService` ( CONSTRAINT `fgn_ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketServiceIvaGroup` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticketService_ticketServiceType` FOREIGN KEY (`ticketServiceTypeFk`) REFERENCES `ticketServiceType` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Servicios asociadas a un ticket'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Servicios asociadas a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -37988,7 +38083,7 @@ DELIMITER ;; BEGIN CALL ticket_requestRecalc(NEW.ticketFk); - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -38052,12 +38147,12 @@ DROP TABLE IF EXISTS `ticketServiceType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticketServiceType` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL, `expenceFk` varchar(10) NOT NULL DEFAULT '7050000000', PRIMARY KEY (`id`), KEY `ticketServiceType_expenceFk_idx` (`expenceFk`), CONSTRAINT `ticketServiceType_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COMMENT='Lista de los posibles servicios a elegir'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COMMENT='Lista de los posibles servicios a elegir'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38130,10 +38225,10 @@ DROP TABLE IF EXISTS `ticketTrolley`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticketTrolley` ( `ticket` int(11) NOT NULL, - `labelCount` int(11) NOT NULL DEFAULT '0', + `labelCount` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`ticket`), CONSTRAINT `fk_ticketTrolley_vs_ticket` FOREIGN KEY (`ticket`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38145,10 +38240,10 @@ DROP TABLE IF EXISTS `ticketUpdateAction`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticketUpdateAction` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `code` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla pondremos las distintas opciones que se ofrecen al comecial o al cliente al cambiar alguno de los parametros básicos de un ticket'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='En esta tabla pondremos las distintas opciones que se ofrecen al comecial o al cliente al cambiar alguno de los parametros básicos de un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38166,7 +38261,7 @@ CREATE TABLE `ticketWeekly` ( KEY `agencyModeFk_idx` (`agencyModeFk`), CONSTRAINT `Id_Ticket_fk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `agencyModeFk` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38179,22 +38274,22 @@ DROP TABLE IF EXISTS `till`; CREATE TABLE `till` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dated` date NOT NULL, - `isAccountable` tinyint(1) NOT NULL DEFAULT '0', - `serie` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, + `isAccountable` tinyint(1) NOT NULL DEFAULT 0, + `serie` varchar(2) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `number` int(11) DEFAULT NULL, - `concept` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + `concept` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, `in` decimal(10,2) DEFAULT NULL, `out` decimal(10,2) DEFAULT NULL, - `bankFk` int(11) DEFAULT '1', + `bankFk` int(11) DEFAULT 1, `workerFk` int(10) unsigned DEFAULT NULL, - `companyFk` smallint(5) unsigned DEFAULT '442' COMMENT 'kakear', - `isLinked` tinyint(4) DEFAULT '0', - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `isOk` tinyint(4) NOT NULL DEFAULT '0', - `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT 'to kak\\n', - `isConciliate` tinyint(4) NOT NULL DEFAULT '0', + `companyFk` smallint(5) unsigned DEFAULT 442 COMMENT 'kakear', + `isLinked` tinyint(4) DEFAULT 0, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `isOk` tinyint(4) NOT NULL DEFAULT 0, + `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT 1 COMMENT 'to kak\\n', + `isConciliate` tinyint(4) NOT NULL DEFAULT 0, `supplierAccountFk` mediumint(8) unsigned NOT NULL, - `calculatedCode` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `calculatedCode` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `InForeignValue` decimal(10,2) DEFAULT NULL, `OutForeignValue` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`id`), @@ -38207,7 +38302,7 @@ CREATE TABLE `till` ( KEY `fk_Cajas_Proveedores_account1_idx` (`supplierAccountFk`), CONSTRAINT `till_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE, CONSTRAINT `till_ibfk_3` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -38242,9 +38337,9 @@ DROP TABLE IF EXISTS `tillConfig`; CREATE TABLE `tillConfig` ( `id` int(11) NOT NULL, `openingBalance` decimal(10,2) NOT NULL, - `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38270,7 +38365,7 @@ CREATE TABLE `time` ( KEY `month_index` (`month`) USING HASH, KEY `periodo` (`period`) USING HASH, KEY `yearMonth` (`yearMonth`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla de referencia para las semanas, años y meses'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla de referencia para las semanas, años y meses'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -38307,14 +38402,14 @@ DROP TABLE IF EXISTS `town`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `town` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, `provinceFk` smallint(6) unsigned NOT NULL, `geoFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `name_idx` (`name`), KEY `townProvinceFk` (`provinceFk`), CONSTRAINT `townProvinceFk` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -38481,9 +38576,9 @@ DROP TABLE IF EXISTS `train`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `train` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la configuración de los carros que se utilizan para sacar pedidos'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Define la configuración de los carros que se utilizan para sacar pedidos'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38495,9 +38590,9 @@ DROP TABLE IF EXISTS `trainingCenter`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `trainingCenter` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38514,11 +38609,11 @@ CREATE TABLE `trainingCourse` ( `centerFk` int(11) DEFAULT NULL, `started` datetime NOT NULL, `ended` datetime NOT NULL, - `invoice` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `invoice` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `amount` double DEFAULT NULL, - `remark` longtext COLLATE utf8_unicode_ci, - `hasDiscount` tinyint(1) NOT NULL DEFAULT '0', - `hasDiploma` tinyint(1) NOT NULL DEFAULT '0', + `remark` longtext COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `hasDiscount` tinyint(1) NOT NULL DEFAULT 0, + `hasDiploma` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `frgnWorker_idx` (`workerFk`), KEY `frgnCenter_idx` (`centerFk`), @@ -38526,7 +38621,7 @@ CREATE TABLE `trainingCourse` ( CONSTRAINT `frgnCenter` FOREIGN KEY (`centerFk`) REFERENCES `trainingCenter` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `frgnTrainingCourseType` FOREIGN KEY (`trainingCourseTypeFk`) REFERENCES `trainingCourseType` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `frgnWorker` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de trabajadores que han realizado una formación'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Lista de trabajadores que han realizado una formación'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38538,9 +38633,9 @@ DROP TABLE IF EXISTS `trainingCourseType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `trainingCourseType` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de las formaciones'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Lista de las formaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38559,13 +38654,13 @@ CREATE TABLE `travel` ( `warehouseInFk` smallint(6) unsigned DEFAULT NULL, `warehouseOutFk` smallint(6) unsigned DEFAULT NULL, `agencyFk` int(11) DEFAULT NULL, - `ref` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `isDelivered` tinyint(1) NOT NULL DEFAULT '0', - `isReceived` tinyint(1) NOT NULL DEFAULT '0', + `ref` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isDelivered` tinyint(1) NOT NULL DEFAULT 0, + `isReceived` tinyint(1) NOT NULL DEFAULT 0, `m3` decimal(10,2) unsigned DEFAULT NULL, `kg` decimal(10,0) unsigned DEFAULT NULL, `cargoSupplierFk` int(11) DEFAULT NULL, - `totalEntries` tinyint(4) unsigned DEFAULT '0', + `totalEntries` tinyint(4) unsigned DEFAULT 0, `appointment` datetime DEFAULT NULL, `agencyModeFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), @@ -38581,7 +38676,7 @@ CREATE TABLE `travel` ( CONSTRAINT `travel_ibfk_1` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_2` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_3` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -38660,7 +38755,7 @@ BEGIN CALL stock.log_add('travel', NEW.id, OLD.id); IF !(NEW.shipped <=> OLD.shipped) THEN - UPDATE entry + UPDATE entry SET commission = entry_getCommission(travelFk, currencyFk,supplierFk) WHERE travelFk = NEW.id; END IF; @@ -38697,7 +38792,7 @@ CREATE TABLE `travelClonedWeekly` ( `agencyModeFk` int(11) NOT NULL, `weekDay` tinyint(3) unsigned NOT NULL, `duration` tinyint(3) unsigned NOT NULL, - `ref` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + `ref` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL, `supplierFk` int(11) DEFAULT NULL, `kg` decimal(10,0) unsigned DEFAULT NULL, `travelFk` int(11) unsigned DEFAULT NULL COMMENT 'Travel origen para clonar ademas sus entradas', @@ -38712,7 +38807,7 @@ CREATE TABLE `travelClonedWeekly` ( CONSTRAINT `travelClonedWeekly_FK_2` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `travelClonedWeekly_FK_3` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `travelClonedWeekly_FK_4` FOREIGN KEY (`travelFk`) REFERENCES `travel` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38726,20 +38821,20 @@ CREATE TABLE `travelLog` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `originFk` int(10) 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, - `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8_unicode_ci, - `newInstance` text COLLATE utf8_unicode_ci, + `action` set('insert','update','delete') COLLATE utf8mb3_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 DEFAULT NULL, + `changedModel` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `originFk` (`originFk`), KEY `userFk` (`userFk`), CONSTRAINT `travelLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `travel` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `travelLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38753,10 +38848,10 @@ CREATE TABLE `travelObservation` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `originFk` int(11) NOT NULL, `userFk` int(11) NOT NULL, - `description` text COLLATE utf8_unicode_ci NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `description` text COLLATE utf8mb3_unicode_ci NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de travel'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Observaciones de travel'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38769,7 +38864,7 @@ DROP TABLE IF EXISTS `travelRecalc`; CREATE TABLE `travelRecalc` ( `travelFk` int(10) unsigned NOT NULL, PRIMARY KEY (`travelFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Travels to recalc it''s entry count'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Travels to recalc it''s entry count'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38781,14 +38876,14 @@ DROP TABLE IF EXISTS `travelThermograph`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `travelThermograph` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `thermographFk` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `thermographFk` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `created` date NOT NULL, `warehouseFk` smallint(6) unsigned NOT NULL, `travelFk` int(10) unsigned DEFAULT NULL, - `temperature__` enum('COOL','WARM','DRY') COLLATE utf8_unicode_ci DEFAULT NULL, - `result` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `temperature__` enum('COOL','WARM','DRY') COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `result` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `dmsFk` int(11) DEFAULT NULL, - `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.', + `temperatureFk` varchar(10) CHARACTER SET utf8mb3 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`), @@ -38800,7 +38895,7 @@ CREATE TABLE `travelThermograph` ( CONSTRAINT `travelThermographThermographFgn` FOREIGN KEY (`thermographFk`) REFERENCES `thermograph` (`id`) ON UPDATE CASCADE, CONSTRAINT `travelThermographTravelFgn` FOREIGN KEY (`travelFk`) REFERENCES `travel` (`id`), 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'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Registra cada termografo que se ha introducido en cada travel'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38813,11 +38908,11 @@ DROP TABLE IF EXISTS `trolley`; CREATE TABLE `trolley` ( `id` int(11) NOT NULL AUTO_INCREMENT, `workerFk` int(10) unsigned DEFAULT NULL, - `coupled` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `coupled` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `trolley_FK` (`workerFk`), CONSTRAINT `trolley_FK` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38850,11 +38945,11 @@ CREATE TABLE `userConfig` ( `userFk` int(10) unsigned NOT NULL, `warehouseFk` smallint(6) DEFAULT NULL, `companyFk` smallint(5) unsigned DEFAULT NULL, - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `darkMode` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Salix interface dark mode', + `created` timestamp NULL DEFAULT current_timestamp(), + `updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `darkMode` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Salix interface dark mode', PRIMARY KEY (`userFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Configuración de usuario en Salix'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Configuración de usuario en Salix'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38868,20 +38963,20 @@ CREATE TABLE `userLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `originFk` int(10) 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, - `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8_unicode_ci, - `newInstance` text COLLATE utf8_unicode_ci, + `action` set('insert','update','delete') COLLATE utf8mb3_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 DEFAULT NULL, + `changedModel` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `originFk` (`originFk`), KEY `userFk` (`userFk`), CONSTRAINT `userLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `userLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38894,14 +38989,14 @@ DROP TABLE IF EXISTS `userPhone`; CREATE TABLE `userPhone` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userFk` int(10) unsigned NOT NULL, - `typeFk` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `phone` varchar(25) COLLATE utf8_unicode_ci NOT NULL, + `typeFk` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `phone` varchar(25) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `UserFk_Phone` (`userFk`,`typeFk`,`phone`), KEY `fgnTypeFk` (`typeFk`), CONSTRAINT `fgnTypeFk` FOREIGN KEY (`typeFk`) REFERENCES `userPhoneType` (`code`) ON UPDATE CASCADE, CONSTRAINT `fgnUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38912,10 +39007,10 @@ DROP TABLE IF EXISTS `userPhoneType`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `userPhoneType` ( - `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, + `description` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38927,18 +39022,18 @@ DROP TABLE IF EXISTS `vehicle`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `vehicle` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `numberPlate` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `model` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `tradeMark` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', + `numberPlate` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, + `model` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL, + `tradeMark` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, `m3` double DEFAULT NULL, - `isActive` tinyint(4) NOT NULL DEFAULT '1', + `isActive` tinyint(4) NOT NULL DEFAULT 1, `warehouseFk` smallint(6) unsigned DEFAULT NULL, - `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `deliveryPointFk` int(11) DEFAULT '6' COMMENT 'Direccion para Buscaman', - `isKmTruckRate` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Computar km como camión en el cálculo de salario de reparto', - `photo` blob, - `chassis` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'numero de bastidor', + `description` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `deliveryPointFk` int(11) DEFAULT 6 COMMENT 'Direccion para Buscaman', + `isKmTruckRate` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Computar km como camión en el cálculo de salario de reparto', + `photo` blob DEFAULT NULL, + `chassis` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'numero de bastidor', `fuelTypeFk` int(11) DEFAULT NULL, `ppeFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), @@ -38952,7 +39047,7 @@ CREATE TABLE `vehicle` ( CONSTRAINT `vehicle_FK_1` FOREIGN KEY (`ppeFk`) REFERENCES `ppe` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `vehicle_deliveryPointFk` FOREIGN KEY (`deliveryPointFk`) REFERENCES `deliveryPoint` (`id`) ON UPDATE CASCADE, CONSTRAINT `vehicle_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38971,7 +39066,7 @@ CREATE TABLE `vehicleDms` ( KEY `vehicleDms_FK_1` (`dmsFk`), CONSTRAINT `vehicleDms_FK` FOREIGN KEY (`vehicleFk`) REFERENCES `vehicle` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `vehicleDms_FK_1` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Gestion documental de vehicle'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Gestion documental de vehicle'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38986,7 +39081,7 @@ CREATE TABLE `vehicleEvent` ( `started` date DEFAULT NULL, `finished` date DEFAULT NULL, `vehicleStateFk` int(11) DEFAULT NULL, - `description` varchar(250) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(250) COLLATE utf8mb3_unicode_ci NOT NULL, `vehicleFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), @@ -38994,7 +39089,7 @@ CREATE TABLE `vehicleEvent` ( KEY `vehicleEvent_FK_1` (`userFk`), CONSTRAINT `vehicleEvent_FK` FOREIGN KEY (`vehicleStateFk`) REFERENCES `vehicleState` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `vehicleEvent_FK_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39014,7 +39109,7 @@ CREATE TABLE `vehicleInvoiceIn` ( KEY `vehicleInvoiceIn_FK_1` (`invoiceInFk`), CONSTRAINT `vehicleInvoiceIn_FK` FOREIGN KEY (`vehicleFk`) REFERENCES `vehicle` (`id`), CONSTRAINT `vehicleInvoiceIn_FK_1` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39027,15 +39122,15 @@ DROP TABLE IF EXISTS `vehicleNotes`; CREATE TABLE `vehicleNotes` ( `id` int(11) NOT NULL AUTO_INCREMENT, `vehicleFk` int(10) unsigned NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `note` text COLLATE utf8_unicode_ci NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `note` text COLLATE utf8mb3_unicode_ci NOT NULL, `userFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `vehicleNotes_FK_1` (`userFk`), KEY `vehicleNotes_FK` (`vehicleFk`), CONSTRAINT `vehicleNotes_FK` FOREIGN KEY (`vehicleFk`) REFERENCES `vehicle` (`id`), CONSTRAINT `vehicleNotes_FK_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39047,9 +39142,9 @@ DROP TABLE IF EXISTS `vehicleState`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `vehicleState` ( `id` int(11) NOT NULL, - `state` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `state` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39062,16 +39157,17 @@ DROP TABLE IF EXISTS `volumeConfig`; CREATE TABLE `volumeConfig` ( `palletM3` decimal(10,2) DEFAULT NULL COMMENT 'metros cúbicos', `trolleyM3` decimal(10,2) DEFAULT NULL COMMENT 'metros cúbicos', - `dutchCompressionRate` double NOT NULL DEFAULT '1', + `dutchCompressionRate` double NOT NULL DEFAULT 1, `standardFlowerBox` int(11) NOT NULL COMMENT 'en litros', - `minCompressionRate` decimal(10,2) DEFAULT '0.30' COMMENT 'minimo permitido por la empresa', - `ccLength` int(11) NOT NULL DEFAULT '130' COMMENT 'longitud útil para la carga de un CC, en cm', - `ccWidth` int(11) NOT NULL DEFAULT '60' COMMENT 'ancho útil para la carga en un CC, en cm', - `sorterPallet_m3` decimal(5,1) NOT NULL DEFAULT '2.0' COMMENT 'volumen minimo para extraer pallet del sorter', - `minTicketVolume` int(11) NOT NULL DEFAULT '75' COMMENT 'volumen mínimo, en litros, para que un pedido sea preparable', - `shelveVolume` int(11) DEFAULT '200' COMMENT 'volumen en litros de una bandeja standard, a efectos de los sacadores', - `minTicketValue` int(11) NOT NULL DEFAULT '50' -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='almacena el valor standard para volumenes convencionales de Verdnatura, en metros cúbicos'; + `minCompressionRate` decimal(10,2) DEFAULT 0.30 COMMENT 'minimo permitido por la empresa', + `ccLength` int(11) NOT NULL DEFAULT 130 COMMENT 'longitud útil para la carga de un CC, en cm', + `ccWidth` int(11) NOT NULL DEFAULT 60 COMMENT 'ancho útil para la carga en un CC, en cm', + `sorterPallet_m3` decimal(5,1) NOT NULL DEFAULT 2.0 COMMENT 'volumen minimo para extraer pallet del sorter', + `minTicketVolume` int(11) NOT NULL DEFAULT 75 COMMENT 'volumen mínimo, en litros, para que un pedido sea preparable', + `shelveVolume` int(11) DEFAULT 200 COMMENT 'volumen en litros de una bandeja standard, a efectos de los sacadores', + `minTicketValue` int(11) NOT NULL DEFAULT 50, + `aerealVolumetricDensity` decimal(10,1) DEFAULT 167.0 COMMENT 'factor de conversión para calcular el peso tasable aereo' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='almacena el valor standard para volumenes convencionales de Verdnatura, en metros cúbicos'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39083,10 +39179,10 @@ DROP TABLE IF EXISTS `wagon`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `wagon` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `volume` int(11) NOT NULL DEFAULT '150' COMMENT 'Volumen en litros', - `plate` varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Matrícula', + `volume` int(11) NOT NULL DEFAULT 150 COMMENT 'Volumen en litros', + `plate` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL COMMENT 'Matrícula', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39098,15 +39194,15 @@ DROP TABLE IF EXISTS `wagonVolumetry`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `wagonVolumetry` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `level` int(10) unsigned NOT NULL DEFAULT '0', - `lines` int(10) unsigned NOT NULL DEFAULT '1', - `liters` int(10) unsigned NOT NULL DEFAULT '0', - `height` int(10) unsigned NOT NULL DEFAULT '20', + `level` int(10) unsigned NOT NULL DEFAULT 0, + `lines` int(10) unsigned NOT NULL DEFAULT 1, + `liters` int(10) unsigned NOT NULL DEFAULT 0, + `height` int(10) unsigned NOT NULL DEFAULT 20, `wagonFk` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `wagonVolumetry_FK` (`wagonFk`), CONSTRAINT `wagonVolumetry_FK` FOREIGN KEY (`wagonFk`) REFERENCES `wagon` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39118,33 +39214,33 @@ DROP TABLE IF EXISTS `warehouse`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `warehouse` ( `id` smallint(6) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `code` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `isFeedStock` tinyint(1) unsigned NOT NULL DEFAULT '0', - `addressName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `delay` double NOT NULL DEFAULT '0.004', - `hasAvailable` tinyint(4) NOT NULL DEFAULT '0', - `isForTicket` tinyint(2) unsigned zerofill NOT NULL DEFAULT '00', - `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', - `labelZone` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'almacenes donde hay produccion', - `hasComission` tinyint(4) NOT NULL DEFAULT '0', - `isInventory` tinyint(2) NOT NULL DEFAULT '0', - `isComparative` tinyint(2) NOT NULL DEFAULT '0' COMMENT 'Si esta a true,en la comparativa muestra el stock de este almacen, cuando no se especifica almacen.', - `valuatedInventory` tinyint(2) NOT NULL DEFAULT '0' COMMENT 'Determina si se incluye en el informe de inventario valorado', - `isManaged` tinyint(2) NOT NULL DEFAULT '0' COMMENT 'Se añaden los cubos de expedition a la tabla ticketPackaging', - `hasConfectionTeam` tinyint(1) unsigned NOT NULL DEFAULT '0', - `hasStowaway` tinyint(1) NOT NULL DEFAULT '0', - `hasDms` tinyint(1) NOT NULL DEFAULT '0', + `name` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL, + `code` varchar(3) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isFeedStock` tinyint(1) unsigned NOT NULL DEFAULT 0, + `addressName` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `delay` double NOT NULL DEFAULT 0.004, + `hasAvailable` tinyint(4) NOT NULL DEFAULT 0, + `isForTicket` tinyint(2) unsigned zerofill NOT NULL DEFAULT 00, + `countryFk` mediumint(8) unsigned NOT NULL DEFAULT 1, + `labelZone` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'almacenes donde hay produccion', + `hasComission` tinyint(4) NOT NULL DEFAULT 0, + `isInventory` tinyint(2) NOT NULL DEFAULT 0, + `isComparative` tinyint(2) NOT NULL DEFAULT 0 COMMENT 'Si esta a true,en la comparativa muestra el stock de este almacen, cuando no se especifica almacen.', + `valuatedInventory` tinyint(2) NOT NULL DEFAULT 0 COMMENT 'Determina si se incluye en el informe de inventario valorado', + `isManaged` tinyint(2) NOT NULL DEFAULT 0 COMMENT 'Se añaden los cubos de expedition a la tabla ticketPackaging', + `hasConfectionTeam` tinyint(1) unsigned NOT NULL DEFAULT 0, + `hasStowaway` tinyint(1) NOT NULL DEFAULT 0, + `hasDms` tinyint(1) NOT NULL DEFAULT 0, `pickUpAgencyModeFk` int(11) DEFAULT NULL, - `isBuyerToBeEmailed` tinyint(2) NOT NULL DEFAULT '0', + `isBuyerToBeEmailed` tinyint(2) NOT NULL DEFAULT 0, `aliasFk` smallint(5) unsigned DEFAULT NULL, `labelReport` int(11) DEFAULT NULL, - `hasUbications` tinyint(1) NOT NULL DEFAULT '1', - `hasProduction` tinyint(1) NOT NULL DEFAULT '0', + `hasUbications` tinyint(1) NOT NULL DEFAULT 1, + `hasProduction` tinyint(1) NOT NULL DEFAULT 0, `addressFk` int(11) DEFAULT NULL, - `hasMachine` tinyint(1) NOT NULL DEFAULT '0', - `isLogiflora` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Este almacén acepta productos de Logiflora', - `isBionic` tinyint(1) NOT NULL DEFAULT '1', + `hasMachine` tinyint(1) NOT NULL DEFAULT 0, + `isLogiflora` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Este almacén acepta productos de Logiflora', + `isBionic` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`), KEY `Id_Paises` (`countryFk`), @@ -39156,7 +39252,7 @@ CREATE TABLE `warehouse` ( CONSTRAINT `warehouse_FK_1` FOREIGN KEY (`pickUpAgencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `warehouse_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`), CONSTRAINT `warehouse_ibfk_2` FOREIGN KEY (`aliasFk`) REFERENCES `warehouseAlias` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -39173,7 +39269,7 @@ DELIMITER ;; BEGIN IF NEW.isFeedStock THEN INSERT INTO warehouseAlias(`name`) VALUES(NEW.`name`); - INSERT INTO warehouseJoined(warehouseFk, warehouseAliasFk) + INSERT INTO warehouseJoined(warehouseFk, warehouseAliasFk) VALUES(NEW.id,LAST_INSERT_ID()); END IF; END */;; @@ -39197,7 +39293,7 @@ DELIMITER ;; BEGIN IF NEW.isFeedStock IS TRUE and OLD.isFeedStock IS FALSE then INSERT INTO warehouseAlias(`name`) VALUES(NEW.`name`); - INSERT INTO warehouseJoined(warehouseFk, warehouseAliasFk) + INSERT INTO warehouseJoined(warehouseFk, warehouseAliasFk) VALUES(NEW.id,LAST_INSERT_ID()); END IF; END */;; @@ -39216,10 +39312,10 @@ DROP TABLE IF EXISTS `warehouseAlias`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `warehouseAlias` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(15) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39230,7 +39326,7 @@ DROP TABLE IF EXISTS `workCenter`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workCenter` ( - `id` int(11) NOT NULL DEFAULT '0', + `id` int(11) NOT NULL DEFAULT 0, `name` varchar(255) DEFAULT NULL, `payrollCenterFk` int(11) DEFAULT NULL COMMENT 'Campo workcenter en A3', `counter` bigint(20) DEFAULT NULL, @@ -39240,7 +39336,7 @@ CREATE TABLE `workCenter` ( PRIMARY KEY (`id`), KEY `workCenter_geoFk_idx` (`geoFk`), CONSTRAINT `workCenter_geoFk` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39255,7 +39351,7 @@ CREATE TABLE `workCenterHoliday` ( `days` double NOT NULL, `year` smallint(6) NOT NULL, PRIMARY KEY (`workCenterFk`,`year`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39267,35 +39363,37 @@ DROP TABLE IF EXISTS `worker`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `worker` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `code` varchar(3) COLLATE utf8_unicode_ci NOT NULL, - `firstName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `lastName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL, + `firstName` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `lastName` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `sub` int(11) unsigned DEFAULT NULL, - `photo` blob, - `phone` varchar(9) COLLATE utf8_unicode_ci DEFAULT NULL, + `photo` blob DEFAULT NULL, + `phone` varchar(9) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `mobileExtension` int(4) DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, - `bossFk` int(11) NOT NULL DEFAULT '103', + `bossFk` int(11) NOT NULL DEFAULT 103, `fiDueDate` datetime DEFAULT NULL, - `hasMachineryAuthorized` tinyint(2) DEFAULT '0', + `hasMachineryAuthorized` tinyint(2) DEFAULT 0, `seniority` date DEFAULT NULL, - `isTodayRelative` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Para el F11. Calcula los problemas de visiblidad en funcion del dia actual', - `isF11Allowed` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Usuario autorizado para abrir el F11', + `isTodayRelative` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Para el F11. Calcula los problemas de visiblidad en funcion del dia actual', + `isF11Allowed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Usuario autorizado para abrir el F11', `sectorFk` int(11) DEFAULT NULL COMMENT 'Sector que tiene asociado el trabajador.', - `maritalStatus` enum('S','M') COLLATE utf8_unicode_ci NOT NULL, + `maritalStatus` enum('S','M') COLLATE utf8mb3_unicode_ci NOT NULL, `labelerFk` tinyint(3) unsigned DEFAULT NULL, `originCountryFk` mediumint(8) unsigned DEFAULT NULL COMMENT 'País de origen', `educationLevelFk` smallint(6) DEFAULT NULL, - `SSN` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `fi` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `SSN` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `fi` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `birth` date DEFAULT NULL, - `isDisable` tinyint(1) NOT NULL DEFAULT '0', - `isFreelance` tinyint(1) NOT NULL DEFAULT '0', - `isSsDiscounted` tinyint(1) NOT NULL DEFAULT '0', - `sex` enum('M','F') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'F' COMMENT 'M Masculino F Femenino', + `isDisable` tinyint(1) NOT NULL DEFAULT 0, + `isFreelance` tinyint(1) NOT NULL DEFAULT 0, + `isSsDiscounted` tinyint(1) NOT NULL DEFAULT 0, + `sex` enum('M','F') COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'F' COMMENT 'M Masculino F Femenino', + `businessFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `CodigoTrabajador_UNIQUE` (`code`), UNIQUE KEY `user_id_UNIQUE` (`userFk`), + UNIQUE KEY `worker_business` (`businessFk`), KEY `sub` (`sub`), KEY `boss_idx` (`bossFk`), KEY `worker_FK` (`labelerFk`), @@ -39304,8 +39402,9 @@ CREATE TABLE `worker` ( CONSTRAINT `worker_FK` FOREIGN KEY (`labelerFk`) REFERENCES `printer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `worker_FK_1` FOREIGN KEY (`originCountryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, CONSTRAINT `worker_FK_2` FOREIGN KEY (`educationLevelFk`) REFERENCES `educationLevel` (`id`) ON UPDATE CASCADE, + CONSTRAINT `worker_businessFk` FOREIGN KEY (`businessFk`) REFERENCES `business` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `worker_ibfk_1` FOREIGN KEY (`id`) REFERENCES `account`.`user` (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39320,7 +39419,7 @@ CREATE TABLE `workerAppTester` ( PRIMARY KEY (`workerFk`), KEY `workerAppTester_FK` (`workerFk`), CONSTRAINT `workerAppTester_FK_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='La tabla incluye usuarios testers que actualizarán a una versión diferente que el resto para testear los cambios nuevos en las app'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='La tabla incluye usuarios testers que actualizarán a una versión diferente que el resto para testear los cambios nuevos en las app'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39340,7 +39439,7 @@ CREATE TABLE `workerBosses` ( KEY `fg_bossFk_worker_idx` (`bossFk`), CONSTRAINT `fg_bossFk_worker` FOREIGN KEY (`bossFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fg_workerFk_worker` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39353,7 +39452,7 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `workerBusinessDated` ( `dated` tinyint NOT NULL, - `business_id` tinyint NOT NULL, + `businessFk` tinyint NOT NULL, `workerFk` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; @@ -39367,12 +39466,12 @@ DROP TABLE IF EXISTS `workerBusinessType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerBusinessType` ( `id` int(11) NOT NULL, - `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `isFullTime` tinyint(1) NOT NULL DEFAULT '1', - `isPermanent` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Contrato fijo', - `hasHolidayEntitlement` tinyint(1) DEFAULT '1' COMMENT 'Tiene derecho a vacaciones', + `name` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, + `isFullTime` tinyint(1) NOT NULL DEFAULT 1, + `isPermanent` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Contrato fijo', + `hasHolidayEntitlement` tinyint(1) DEFAULT 1 COMMENT 'Tiene derecho a vacaciones', PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39402,13 +39501,13 @@ CREATE TABLE `workerClockLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `originFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, - `action` set('insert','update','delete','select') COLLATE utf8_unicode_ci NOT NULL, - `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `description` text COLLATE utf8_unicode_ci NOT NULL, + `action` set('insert','update','delete','select') COLLATE utf8mb3_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), KEY `logWorkerClockoriginFk` (`originFk`), KEY `logWorkerClockuserFk` (`userFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39424,7 +39523,7 @@ CREATE TABLE `workerConfig__` ( PRIMARY KEY (`id`), KEY `defaultWorkerFk` (`defaultWorkerFk`), CONSTRAINT `workerConfig___ibfk_1` FOREIGN KEY (`defaultWorkerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39453,7 +39552,7 @@ CREATE TABLE `workerDisableExcluded` ( `dated` date DEFAULT NULL, PRIMARY KEY (`workerFk`), CONSTRAINT `workerDisableExcludedFk1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='No se deshabilitan hasta la fecha especificada'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='No se deshabilitan hasta la fecha especificada'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39470,7 +39569,7 @@ CREATE TABLE `workerDistributionCategory` ( PRIMARY KEY (`id`), KEY `workerDistributionCategory_workerFk_idx` (`workerFk`), CONSTRAINT `workerDistributionCategory_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39484,13 +39583,13 @@ CREATE TABLE `workerDocument` ( `id` int(11) NOT NULL AUTO_INCREMENT, `worker` int(10) unsigned DEFAULT NULL, `document` int(11) DEFAULT NULL, - `isReadableByWorker` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indica si el empleado tiene permiso para acceder al documento', + `isReadableByWorker` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si el empleado tiene permiso para acceder al documento', PRIMARY KEY (`id`), KEY `workerDocument_ibfk_1` (`worker`), KEY `workerDocument_ibfk_2` (`document`), CONSTRAINT `workerDocument_ibfk_1` FOREIGN KEY (`worker`) REFERENCES `worker` (`userFk`) ON UPDATE CASCADE, CONSTRAINT `workerDocument_ibfk_2` FOREIGN KEY (`document`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39502,10 +39601,10 @@ DROP TABLE IF EXISTS `workerEmergencyBoss`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerEmergencyBoss` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `value` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Table to save all responsible people phones', + `name` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `value` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL COMMENT 'Table to save all responsible people phones', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39522,7 +39621,7 @@ CREATE TABLE `workerHourPrice` ( `nightInc` decimal(4,2) DEFAULT NULL, `extraInc` decimal(4,2) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Recoge los acuerdos de los distintos convenios'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Recoge los acuerdos de los distintos convenios'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39534,22 +39633,22 @@ DROP TABLE IF EXISTS `workerIrpf`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerIrpf` ( `workerFk` int(10) unsigned NOT NULL, - `spouseNif` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `spouseNif` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `geographicMobilityDate` date DEFAULT NULL, `disabilityGradeFk` int(11) DEFAULT NULL, - `isDependend` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Acredita la necesidad de ayuda de terceras personas o movilidad reducida', - `familySituation` enum('1','2','3') COLLATE utf8_unicode_ci DEFAULT '1', + `isDependend` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Acredita la necesidad de ayuda de terceras personas o movilidad reducida', + `familySituation` enum('1','2','3') COLLATE utf8mb3_unicode_ci DEFAULT '1', `spousePension` decimal(10,2) DEFAULT NULL COMMENT 'Apartado 4 - Pensión compensatoria en favor del conyuge ', `childPension` decimal(10,2) DEFAULT NULL COMMENT 'Apartado 4 - Anualidades por alimentos en favor de los hijos', - `hasHousingPaymentBefore` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Apartado 5 - Pagos por adquisición o rehabilitación de la vivienda habitual utilizando financiación ajena, con derecho a deducción del IRPF', - `hasHousingPaymentAfter` tinyint(1) NOT NULL DEFAULT '0', - `hasExtendedWorking` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Aprtado 1 - prolongar la actividad laboral', - `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `hasHousingPaymentBefore` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Apartado 5 - Pagos por adquisición o rehabilitación de la vivienda habitual utilizando financiación ajena, con derecho a deducción del IRPF', + `hasHousingPaymentAfter` tinyint(1) NOT NULL DEFAULT 0, + `hasExtendedWorking` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Aprtado 1 - prolongar la actividad laboral', + `updated` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`workerFk`), KEY `workerIrpf_disabilityGradeFk` (`disabilityGradeFk`), CONSTRAINT `workerIrpf_disabilityGradeFk` FOREIGN KEY (`disabilityGradeFk`) REFERENCES `disabilityGrade` (`id`) ON UPDATE CASCADE, CONSTRAINT `workerIrpf_wokerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Modelo 145 IRPF apartado 1 - 4 y 5 '; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Modelo 145 IRPF apartado 1 - 4 y 5 '; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39563,29 +39662,29 @@ CREATE TABLE `workerJourney` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userFk` int(10) unsigned NOT NULL, `dated` date NOT NULL, - `total` decimal(5,2) NOT NULL DEFAULT '0.00', - `priceOrdinaryHour` decimal(5,2) NOT NULL DEFAULT '0.00', - `nocturn` decimal(5,2) NOT NULL DEFAULT '0.00', - `priceNocturnHour` decimal(5,2) NOT NULL DEFAULT '0.00', - `holiday` decimal(5,2) NOT NULL DEFAULT '0.00', - `priceHolidayHour` decimal(5,2) NOT NULL DEFAULT '0.00', - `lunch` decimal(5,2) NOT NULL DEFAULT '0.00', - `priceExtraHour` decimal(5,2) NOT NULL DEFAULT '0.00', - `extra` decimal(5,2) NOT NULL DEFAULT '0.00', - `contractJourney` decimal(5,2) NOT NULL DEFAULT '0.00', - `priceExtraHoliday` decimal(5,2) NOT NULL DEFAULT '0.00', + `total` decimal(5,2) NOT NULL DEFAULT 0.00, + `priceOrdinaryHour` decimal(5,2) NOT NULL DEFAULT 0.00, + `nocturn` decimal(5,2) NOT NULL DEFAULT 0.00, + `priceNocturnHour` decimal(5,2) NOT NULL DEFAULT 0.00, + `holiday` decimal(5,2) NOT NULL DEFAULT 0.00, + `priceHolidayHour` decimal(5,2) NOT NULL DEFAULT 0.00, + `lunch` decimal(5,2) NOT NULL DEFAULT 0.00, + `priceExtraHour` decimal(5,2) NOT NULL DEFAULT 0.00, + `extra` decimal(5,2) NOT NULL DEFAULT 0.00, + `contractJourney` decimal(5,2) NOT NULL DEFAULT 0.00, + `priceExtraHoliday` decimal(5,2) NOT NULL DEFAULT 0.00, `businessFk` int(11) DEFAULT NULL, - `isPaid` tinyint(1) NOT NULL DEFAULT '0', - `isUpdated` tinyint(1) NOT NULL DEFAULT '0', - `permission` decimal(5,2) NOT NULL DEFAULT '0.00', + `isPaid` tinyint(1) NOT NULL DEFAULT 0, + `isUpdated` tinyint(1) NOT NULL DEFAULT 0, + `permission` decimal(5,2) NOT NULL DEFAULT 0.00, PRIMARY KEY (`id`), UNIQUE KEY `userFk_UNIQUE` (`userFk`,`dated`), KEY `fk_workerJourney_user_idx` (`userFk`), - KEY `workerJourney_businessFk_idx` (`businessFk`), KEY `workerJourney_dated_idx` (`dated`), + KEY `workerJourney_businessFk` (`businessFk`), CONSTRAINT `fk_workerJourney_user` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE, - CONSTRAINT `workerJourney_businessFk` FOREIGN KEY (`businessFk`) REFERENCES `postgresql`.`business` (`business_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `workerJourney_businessFk` FOREIGN KEY (`businessFk`) REFERENCES `business` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39618,20 +39717,20 @@ CREATE TABLE `workerLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `originFk` int(10) unsigned NOT NULL, `userFk` int(10) unsigned NOT NULL, - `action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL, - `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `description` text COLLATE utf8_unicode_ci NOT NULL, - `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8_unicode_ci, - `newInstance` text COLLATE utf8_unicode_ci, + `action` set('insert','update','delete') COLLATE utf8mb3_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text COLLATE utf8mb3_unicode_ci NOT NULL, + `changedModel` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `workerFk_idx` (`originFk`), KEY `userFk_idx` (`userFk`), CONSTRAINT `userFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `workerFk` FOREIGN KEY (`originFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39643,16 +39742,16 @@ DROP TABLE IF EXISTS `workerMana`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerMana` ( `workerFk` int(10) unsigned NOT NULL, - `size` int(11) NOT NULL DEFAULT '300', - `amount` int(11) NOT NULL DEFAULT '0', - `pricesModifierRate` double NOT NULL DEFAULT '0', - `isPricesModifierActivated` tinyint(1) NOT NULL DEFAULT '1', - `minRate` decimal(3,2) NOT NULL DEFAULT '-0.05', - `maxRate` decimal(3,2) NOT NULL DEFAULT '0.05', + `size` int(11) NOT NULL DEFAULT 300, + `amount` int(11) NOT NULL DEFAULT 0, + `pricesModifierRate` double NOT NULL DEFAULT 0, + `isPricesModifierActivated` tinyint(1) NOT NULL DEFAULT 1, + `minRate` decimal(3,2) NOT NULL DEFAULT -0.05, + `maxRate` decimal(3,2) NOT NULL DEFAULT 0.05, PRIMARY KEY (`workerFk`), KEY `fk_mana_spellers_Trabajadores_idx` (`workerFk`), CONSTRAINT `fk_mana_spellers_Trabajadores` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39666,7 +39765,7 @@ CREATE TABLE `workerManaExcluded` ( `workerFk` int(10) unsigned NOT NULL, PRIMARY KEY (`workerFk`), CONSTRAINT `mana_spellers_excluded_fk1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Usuarios que tienen que estar excluidos del cálculo del maná'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Usuarios que tienen que estar excluidos del cálculo del maná'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39693,14 +39792,14 @@ DROP TABLE IF EXISTS `workerMistake`; CREATE TABLE `workerMistake` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userFk` int(10) unsigned NOT NULL, - `workerMistakeTypeFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `workerMistakeTypeFk` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `workerMistake_fk1_idx` (`userFk`), KEY `workerMistake_fk2_idx` (`workerMistakeTypeFk`), CONSTRAINT `workerMistake_fk1` FOREIGN KEY (`userFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `workerMistake_fk2` FOREIGN KEY (`workerMistakeTypeFk`) REFERENCES `workerMistakeType` (`code`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39711,10 +39810,10 @@ DROP TABLE IF EXISTS `workerMistakeType`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerMistakeType` ( - `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL, + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39727,19 +39826,19 @@ DROP TABLE IF EXISTS `workerRelatives`; CREATE TABLE `workerRelatives` ( `id` int(11) NOT NULL AUTO_INCREMENT, `workerFk` int(10) unsigned NOT NULL, - `isDescendant` tinyint(1) DEFAULT '1' COMMENT 'Descendientes - Ascendientes', + `isDescendant` tinyint(1) DEFAULT 1 COMMENT 'Descendientes - Ascendientes', `disabilityGradeFk` int(11) DEFAULT NULL, `birthed` int(4) NOT NULL, `adoptionYear` int(4) DEFAULT NULL COMMENT 'Solo en el caso de descendientes', - `isDependend` tinyint(1) DEFAULT '0', - `isJointCustody` tinyint(1) DEFAULT '0' COMMENT 'Solo en el caso de descendientes', - `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `isDependend` tinyint(1) DEFAULT 0, + `isJointCustody` tinyint(1) DEFAULT 0 COMMENT 'Solo en el caso de descendientes', + `updated` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `workerRelatives_disabilityGradeFk` (`disabilityGradeFk`), KEY `workerRelatives_workerFk` (`workerFk`), CONSTRAINT `workerRelatives_disabilityGradeFk` FOREIGN KEY (`disabilityGradeFk`) REFERENCES `disabilityGrade` (`id`) ON UPDATE CASCADE, CONSTRAINT `workerRelatives_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `workerIrpf` (`workerFk`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Modelo 145 IRPF apartado 2 y 3'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Modelo 145 IRPF apartado 2 y 3'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39752,17 +39851,17 @@ DROP TABLE IF EXISTS `workerShelving`; CREATE TABLE `workerShelving` ( `id` int(11) NOT NULL AUTO_INCREMENT, `workerFk` int(10) unsigned NOT NULL, - `shelvingFk` varchar(10) CHARACTER SET utf8 NOT NULL, + `shelvingFk` varchar(10) CHARACTER SET utf8mb3 NOT NULL, `collectionFk` int(11) DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `workerShelving_shelving_fk` (`shelvingFk`), KEY `workerShelving_FK` (`workerFk`), KEY `workerShelving_FK_1` (`collectionFk`), CONSTRAINT `workerShelving_FK` FOREIGN KEY (`collectionFk`) REFERENCES `collection` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `workerShelving_shelving_fk` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON UPDATE CASCADE, + CONSTRAINT `workerShelving_FK_1` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON UPDATE CASCADE, CONSTRAINT `workerShelving_worker_fk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='utilizaremos el id para establecer la prioridad de los carros a asignar'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='utilizaremos el id para establecer la prioridad de los carros a asignar'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39820,7 +39919,7 @@ CREATE TABLE `workerTeam` ( KEY `user_idx` (`workerFk`), KEY `team_idx` (`team`), CONSTRAINT `user_team` FOREIGN KEY (`workerFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39848,25 +39947,25 @@ CREATE TABLE `workerTimeControl` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userFk` int(10) unsigned NOT NULL, `timed` datetime NOT NULL, - `manual` tinyint(4) NOT NULL DEFAULT '0', + `manual` tinyint(4) NOT NULL DEFAULT 0, `order` int(11) DEFAULT NULL, `warehouseFk` smallint(6) unsigned DEFAULT NULL, - `direction` enum('in','out','middle') COLLATE utf8_unicode_ci DEFAULT 'middle', - `isSendMail` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Fichadas generadas autómaticamente con el procedimiento vn.workerTimeControl_sendMail', + `direction` enum('in','out','middle') COLLATE utf8mb3_unicode_ci DEFAULT 'middle', + `isSendMail` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Fichadas generadas autómaticamente con el procedimiento vn.workerTimeControl_sendMail', PRIMARY KEY (`id`), UNIQUE KEY `userFk_Timed_uniq` (`userFk`,`timed`), KEY `warehouseFkfk1_idx` (`warehouseFk`), KEY `timed_idx` (`timed`), CONSTRAINT `warehouseFk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `workerTimeControl_fk1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -39874,9 +39973,9 @@ DELIMITER ;; AFTER INSERT ON `workerTimeControl` FOR EACH ROW BEGIN - IF NEW.timed > DATE_ADD(NOW(), INTERVAL 1 DAY) THEN + IF NEW.timed > DATE_ADD(util.VN_NOW(), INTERVAL 1 DAY) THEN CALL util.throw('date in the future'); - END IF; + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -39898,11 +39997,11 @@ CREATE TABLE `workerTimeControlConfig` ( `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, + `mailPass` varchar(45) COLLATE utf8mb3_bin NOT NULL, + `mailHost` varchar(45) COLLATE utf8mb3_bin NOT NULL, + `mailSuccessFolder` varchar(45) COLLATE utf8mb3_bin NOT NULL, + `mailErrorFolder` varchar(45) COLLATE utf8mb3_bin NOT NULL, + `mailUser` varchar(45) COLLATE utf8mb3_bin NOT NULL, `minHoursToBreak` decimal(5,2) unsigned NOT NULL COMMENT 'Horas mínimas que se deben trabajar para añadir descanso remunerado', `breakHours` decimal(5,2) unsigned NOT NULL COMMENT 'Descanso remunerado', `hoursCompleteWeek` int(10) unsigned NOT NULL COMMENT 'Horas a realizar por semana para que se considere jornada completa', @@ -39915,7 +40014,7 @@ CREATE TABLE `workerTimeControlConfig` ( `shortWeekDays` int(11) DEFAULT NULL COMMENT 'Días a tener en cuenta para calcular el descanso corto', `longWeekDays` int(11) DEFAULT NULL COMMENT 'Días a tener en cuenta para calcular el descanso largo', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='All values in seconds'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin COMMENT='All values in seconds'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39928,11 +40027,11 @@ DROP TABLE IF EXISTS `workerTimeControlConfig_`; CREATE TABLE `workerTimeControlConfig_` ( `id` int(11) NOT NULL AUTO_INCREMENT, `warehouseFk` smallint(6) unsigned NOT NULL, - `host` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `host` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`), KEY `warehouseFk_1_idx` (`warehouseFk`), CONSTRAINT `warehouseFk_2` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39945,10 +40044,10 @@ DROP TABLE IF EXISTS `workerTimeControlLog`; CREATE TABLE `workerTimeControlLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userFk` int(10) NOT NULL, - `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `created` datetime NOT NULL DEFAULT current_timestamp(), + `description` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Log de fichadas, se rellena cuando el fichador(tablet) no autoriza el fichaje (PROC:vn.workerTimeControl_check)'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Log de fichadas, se rellena cuando el fichador(tablet) no autoriza el fichaje (PROC:vn.workerTimeControl_check)'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39963,15 +40062,15 @@ CREATE TABLE `workerTimeControlMail` ( `workerFk` int(10) unsigned NOT NULL, `year` int(4) NOT NULL, `week` int(2) NOT NULL, - `state` enum('SENDED','CONFIRMED','REVISE') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'SENDED', - `updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Fecha/hora último cambio de estado', - `sendedCounter` int(3) NOT NULL DEFAULT '1' COMMENT 'Número de veces que se ha enviado el correo', - `emailResponse` text COLLATE utf8_unicode_ci, + `state` enum('SENDED','CONFIRMED','REVISE') COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'SENDED', + `updated` datetime NOT NULL DEFAULT current_timestamp() COMMENT 'Fecha/hora último cambio de estado', + `sendedCounter` int(3) NOT NULL DEFAULT 1 COMMENT 'Número de veces que se ha enviado el correo', + `emailResponse` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `workerFk_UNIQUE` (`workerFk`,`year`,`week`), KEY `workerFk_idx` (`workerFk`), CONSTRAINT `workerTimeControlMail_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Guarda las respuestas de mail de los correos generados automáticamente por la procedimiento workerTimeControl_sendMail'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Guarda las respuestas de mail de los correos generados automáticamente por la procedimiento workerTimeControl_sendMail'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -39991,13 +40090,13 @@ CREATE TABLE `workerTimeControlParams` ( `weekMaxBreak` int(11) NOT NULL, `weekMaxScope` int(11) NOT NULL, `askInOut` int(11) NOT NULL COMMENT 'Tiempo desde la última fichada que determinará si se pregunta al usuario por la dirección de la fichada', - `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, + `mailPass` varchar(45) COLLATE utf8mb3_bin NOT NULL, + `mailHost` varchar(45) COLLATE utf8mb3_bin NOT NULL, + `mailSuccessFolder` varchar(45) COLLATE utf8mb3_bin NOT NULL, + `mailErrorFolder` varchar(45) COLLATE utf8mb3_bin NOT NULL, + `mailUser` varchar(45) COLLATE utf8mb3_bin NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='All values in seconds'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin COMMENT='All values in seconds'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40009,10 +40108,10 @@ DROP TABLE IF EXISTS `workerTimeControlPin`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerTimeControlPin` ( `workerFk` int(10) unsigned NOT NULL, - `pin` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `pin` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`workerFk`), CONSTRAINT `workerFk_.1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40027,7 +40126,7 @@ CREATE TABLE `workerTimeControlSchedule` ( `time` time DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `punique_trhf` (`time`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40050,27 +40149,6 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `workerTimeControlWorking` --- - -DROP TABLE IF EXISTS `workerTimeControlWorking`; -/*!50001 DROP VIEW IF EXISTS `workerTimeControlWorking`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `workerTimeControlWorking` ( - `userFk` tinyint NOT NULL, - `timed` tinyint NOT NULL, - `name` tinyint NOT NULL, - `surname` tinyint NOT NULL, - `phone` tinyint NOT NULL, - `workerPhone` tinyint NOT NULL, - `department` tinyint NOT NULL, - `workerCenter` tinyint NOT NULL, - `maxOrder` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `workerTimeJourneyNG` -- @@ -40113,21 +40191,21 @@ DROP TABLE IF EXISTS `workers20190711`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workers20190711` ( - `person_id` int(11) NOT NULL DEFAULT '0', - `business_id` int(11) NOT NULL DEFAULT '0', - `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, - `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, - `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, + `person_id` int(11) NOT NULL DEFAULT 0, + `business_id` int(11) NOT NULL DEFAULT 0, + `Apellidos` varchar(60) CHARACTER SET utf8mb3 NOT NULL, + `Nombre` varchar(20) CHARACTER SET utf8mb3 DEFAULT NULL, + `nif` varchar(15) CHARACTER SET utf8mb3 DEFAULT NULL, `Fecha_Inicio` date DEFAULT NULL, `Fecha_Fin` date DEFAULT NULL, - `departamento` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `departamento` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL, `Jornada_Semanal` smallint(6) DEFAULT NULL, `Codigo_Contrato` int(11) DEFAULT NULL, `userFk` int(11) NOT NULL, PRIMARY KEY (`person_id`), UNIQUE KEY `userFk_UNIQUE` (`userFk`), UNIQUE KEY `nif_UNIQUE` (`nif`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40139,17 +40217,17 @@ DROP TABLE IF EXISTS `workers20190711_FichadasAbril`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workers20190711_FichadasAbril` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT '0', - `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, - `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, - `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, + `person_id` int(11) NOT NULL DEFAULT 0, + `nif` varchar(15) CHARACTER SET utf8mb3 DEFAULT NULL, + `Apellidos` varchar(60) CHARACTER SET utf8mb3 NOT NULL, + `Nombre` varchar(20) CHARACTER SET utf8mb3 DEFAULT NULL, `Fecha` date DEFAULT NULL, `Hora` int(2) DEFAULT NULL, `Minuto` int(2) DEFAULT NULL, `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT '8.00', + `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40161,17 +40239,17 @@ DROP TABLE IF EXISTS `workers20190711_FichadasJulio11`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workers20190711_FichadasJulio11` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT '0', - `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, - `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, - `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, + `person_id` int(11) NOT NULL DEFAULT 0, + `nif` varchar(15) CHARACTER SET utf8mb3 DEFAULT NULL, + `Apellidos` varchar(60) CHARACTER SET utf8mb3 NOT NULL, + `Nombre` varchar(20) CHARACTER SET utf8mb3 DEFAULT NULL, `Fecha` date DEFAULT NULL, `Hora` int(2) DEFAULT NULL, `Minuto` int(2) DEFAULT NULL, `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT '8.00', + `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40183,17 +40261,17 @@ DROP TABLE IF EXISTS `workers20190711_FichadasJunio`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workers20190711_FichadasJunio` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT '0', - `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, - `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, - `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, + `person_id` int(11) NOT NULL DEFAULT 0, + `nif` varchar(15) CHARACTER SET utf8mb3 DEFAULT NULL, + `Apellidos` varchar(60) CHARACTER SET utf8mb3 NOT NULL, + `Nombre` varchar(20) CHARACTER SET utf8mb3 DEFAULT NULL, `Fecha` date DEFAULT NULL, `Hora` int(2) DEFAULT NULL, `Minuto` int(2) DEFAULT NULL, `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT '8.00', + `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40205,17 +40283,17 @@ DROP TABLE IF EXISTS `workers20190711_FichadasMayo`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workers20190711_FichadasMayo` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT '0', - `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, - `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, - `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, + `person_id` int(11) NOT NULL DEFAULT 0, + `nif` varchar(15) CHARACTER SET utf8mb3 DEFAULT NULL, + `Apellidos` varchar(60) CHARACTER SET utf8mb3 NOT NULL, + `Nombre` varchar(20) CHARACTER SET utf8mb3 DEFAULT NULL, `Fecha` date DEFAULT NULL, `Hora` int(2) DEFAULT NULL, `Minuto` int(2) DEFAULT NULL, `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT '8.00', + `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40227,17 +40305,17 @@ DROP TABLE IF EXISTS `workers20190711_FichadasOctubre`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workers20190711_FichadasOctubre` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT '0', - `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, - `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, - `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, + `person_id` int(11) NOT NULL DEFAULT 0, + `nif` varchar(15) CHARACTER SET utf8mb3 DEFAULT NULL, + `Apellidos` varchar(60) CHARACTER SET utf8mb3 NOT NULL, + `Nombre` varchar(20) CHARACTER SET utf8mb3 DEFAULT NULL, `Fecha` date DEFAULT NULL, `Hora` int(2) DEFAULT NULL, `Minuto` int(2) DEFAULT NULL, `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT '8.00', + `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40249,17 +40327,17 @@ DROP TABLE IF EXISTS `workers20190711_Garrote`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workers20190711_Garrote` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT '0', - `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, - `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, - `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, + `person_id` int(11) NOT NULL DEFAULT 0, + `nif` varchar(15) CHARACTER SET utf8mb3 DEFAULT NULL, + `Apellidos` varchar(60) CHARACTER SET utf8mb3 NOT NULL, + `Nombre` varchar(20) CHARACTER SET utf8mb3 DEFAULT NULL, `Fecha` date DEFAULT NULL, `Hora` int(2) DEFAULT NULL, `Minuto` int(2) DEFAULT NULL, `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT '8.00', + `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40277,7 +40355,7 @@ CREATE TABLE `workingHours` ( PRIMARY KEY (`id`), KEY `user_working_hour_idx` (`userId`), CONSTRAINT `user_working_hour` FOREIGN KEY (`userId`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena horas de Entrada y de Salida del personal'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Almacena horas de Entrada y de Salida del personal'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -40292,7 +40370,7 @@ DELIMITER ;; BEFORE INSERT ON `workingHours` FOR EACH ROW BEGIN - IF (SELECT COUNT(*) FROM workingHours WHERE userId = NEW.userId AND DATE(timeIn) = CURDATE()) > 0 THEN + IF (SELECT COUNT(*) FROM workingHours WHERE userId = NEW.userId AND DATE(timeIn) = util.VN_CURDATE()) > 0 THEN CALL util.throw ('ALREADY_LOGGED'); END IF; END */;; @@ -40311,15 +40389,15 @@ DROP TABLE IF EXISTS `zone`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `zone` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL, `hour` datetime NOT NULL, `warehouseFk__` smallint(6) unsigned DEFAULT NULL, `agencyModeFk` int(11) NOT NULL, - `travelingDays` int(11) NOT NULL DEFAULT '1', - `price` double NOT NULL DEFAULT '0', - `bonus` double NOT NULL DEFAULT '0', - `isVolumetric` tinyint(1) NOT NULL DEFAULT '0', - `inflation` decimal(5,2) NOT NULL DEFAULT '1.00', + `travelingDays` int(11) NOT NULL DEFAULT 1, + `price` double NOT NULL DEFAULT 0, + `bonus` double NOT NULL DEFAULT 0, + `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', `code` varchar(45) DEFAULT NULL, @@ -40329,7 +40407,7 @@ CREATE TABLE `zone` ( KEY `zone_name_idx` (`name`), CONSTRAINT `fk_zone_1` FOREIGN KEY (`warehouseFk__`) REFERENCES `warehouse` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `fk_zone_2` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40348,7 +40426,7 @@ CREATE TABLE `zoneAgencyMode` ( KEY `zoneAgencyMode_FK_1` (`zoneFk`), CONSTRAINT `zoneAgencyMode_FK` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `zoneAgencyMode_FK_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='junta agencias con zonas para que al enrutar se puedan proponer tickets.'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='junta agencias con zonas para que al enrutar se puedan proponer tickets.'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40363,7 +40441,7 @@ CREATE TABLE `zoneClosure` ( `dated` date NOT NULL, `hour` time NOT NULL, PRIMARY KEY (`zoneFk`,`dated`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40376,9 +40454,9 @@ DROP TABLE IF EXISTS `zoneConfig`; CREATE TABLE `zoneConfig` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `scope` int(10) unsigned NOT NULL, - `forwardDays` int(10) NOT NULL DEFAULT '7' COMMENT 'days forward to show zone_upcomingDeliveries', + `forwardDays` int(10) NOT NULL DEFAULT 7 COMMENT 'days forward to show zone_upcomingDeliveries', PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40424,7 +40502,7 @@ CREATE TABLE `zoneEvent` ( PRIMARY KEY (`id`), UNIQUE KEY `zoneFk` (`zoneFk`,`type`,`dated`), CONSTRAINT `zoneEvent_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40438,13 +40516,13 @@ CREATE TABLE `zoneExclusion` ( `id` int(11) NOT NULL AUTO_INCREMENT, `zoneFk` int(11) NOT NULL, `dated` date NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `userFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `zoneFk_2` (`zoneFk`,`dated`), KEY `zoneFk` (`zoneFk`), CONSTRAINT `zoneExclusion_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -40458,10 +40536,10 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneExclusion_BI` BEFORE INSERT ON `zoneExclusion` FOR EACH ROW -BEGIN - +BEGIN + SET NEW.userFk = account.myUser_getId(); - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -40480,10 +40558,10 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneExclusion_BU` BEFORE UPDATE ON `zoneExclusion` FOR EACH ROW -BEGIN - +BEGIN + SET NEW.userFk = account.myUser_getId(); - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -40507,7 +40585,7 @@ CREATE TABLE `zoneExclusionGeo` ( KEY `zoneExclusionGeo2_FK_1` (`geoFk`), CONSTRAINT `zoneExclusionGeo_FK` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON UPDATE CASCADE, CONSTRAINT `zoneExclusionGeo_FK_1` FOREIGN KEY (`zoneExclusionFk`) REFERENCES `zoneExclusion` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40527,7 +40605,7 @@ CREATE TABLE `zoneFilter` ( KEY `zoneFilter_FK_1` (`itemTypeFk`), CONSTRAINT `zoneFilter_FK` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `zoneFilter_FK_1` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='recoge los parámetros para filtrar determinados productos según la zona'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='recoge los parámetros para filtrar determinados productos según la zona'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40539,20 +40617,20 @@ DROP TABLE IF EXISTS `zoneGeo`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `zoneGeo` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `type` set('country','province','town','postCode','autonomy') CHARACTER SET utf8 NOT NULL, - `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `type` set('country','province','town','postCode','autonomy') CHARACTER SET utf8mb3 NOT NULL, + `name` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `parentFk` int(10) unsigned DEFAULT NULL, - `path` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `path` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `lft` int(11) DEFAULT NULL, `rgt` int(11) DEFAULT NULL, - `depth` bigint(22) NOT NULL DEFAULT '0', + `depth` bigint(22) NOT NULL DEFAULT 0, `sons` decimal(10,0) DEFAULT NULL, PRIMARY KEY (`id`), KEY `lft_rgt_depth_idx` (`lft`,`rgt`,`depth`), KEY `name_idx` (`name`), KEY `parentFk` (`parentFk`), KEY `path` (`path`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -40608,7 +40686,7 @@ CREATE TABLE `zoneGeoRecalc` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `isChanged` tinyint(4) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40626,7 +40704,7 @@ CREATE TABLE `zoneIncluded` ( KEY `geoFk_idx` (`geoFk`), CONSTRAINT `zoneFk2` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `zoneGeoFk2` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40640,20 +40718,20 @@ CREATE TABLE `zoneLog` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `originFk` int(10) 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, - `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8_unicode_ci, - `newInstance` text COLLATE utf8_unicode_ci, + `action` set('insert','update','delete') COLLATE utf8mb3_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 DEFAULT NULL, + `changedModel` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `originFk` (`originFk`), KEY `userFk` (`userFk`), CONSTRAINT `zoneLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `zoneLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40668,11 +40746,11 @@ CREATE TABLE `zonePromo__` ( `zoneFk` int(11) NOT NULL, `dated` date NOT NULL, `amount` decimal(10,2) NOT NULL, - `isDone` tinyint(4) NOT NULL DEFAULT '0', + `isDone` tinyint(4) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `zonePromo_fk1_idx` (`zoneFk`), CONSTRAINT `zonePromo_fk1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40691,7 +40769,7 @@ CREATE TABLE `zoneWarehouse` ( KEY `warehouseFk` (`warehouseFk`), CONSTRAINT `zoneWarehouse_fk_warehouse` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `zoneWarehouse_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40734,28 +40812,28 @@ DELIMITER ;; DECLARE vIsAlreadyNotified BOOLEAN; DECLARE vNotificationThrehold INT; - SELECT actualNumber, endRange, isAlreadyNotified, notificationThrehold + SELECT actualNumber, endRange, isAlreadyNotified, notificationThrehold INTO vActualNumber, vEndRange, vIsAlreadyNotified, vNotificationThrehold FROM envialiaConfig; - + IF (vActualNumber+vNotificationThrehold) >= vEndRange AND vIsAlreadyNotified = FALSE THEN - CALL mail_insert( + 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; - + IF (vActualNumber+vNotificationThrehold) < vEndRange AND vIsAlreadyNotified = TRUE THEN UPDATE envialiaConfig SET isAlreadyNotified = FALSE; END IF; - + END */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; @@ -40802,7 +40880,7 @@ DELIMITER ;; DECLARE vDone BOOL DEFAULT FALSE; DECLARE vPrintQueueLimit INT; - DECLARE vCur CURSOR FOR + DECLARE vCur CURSOR FOR SELECT CONCAT(' ', IFNULL(pq.id, ''), ' ', IFNULL(p.path, ''),' @@ -40815,21 +40893,21 @@ DELIMITER ;; LEFT JOIN worker w ON w.id = pq.workerFk LEFT JOIN printer p ON p.id = pq.printerFk LEFT JOIN report r ON r.id = pq.reportFk - JOIN printQueueConfig + JOIN printQueueConfig LIMIT vPrintQueueLimit; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - SELECT printQueueLimit INTO vPrintQueueLimit + SELECT printQueueLimit INTO vPrintQueueLimit FROM printQueueConfig; SELECT COUNT(*), IFNULL(SUM(id),0) INTO vCurrentCount, vCheckSum FROM printQueue WHERE statusCode = 'queued'; - SELECT isAlreadyNotified INTO vIsAlreadyNotified + SELECT isAlreadyNotified INTO vIsAlreadyNotified FROM printingQueueCheck; - + IF (SELECT lastCount FROM printingQueueCheck) = vCurrentCount AND (SELECT lastCheckSum FROM printingQueueCheck) = vCheckSum AND vIsAlreadyNotified = FALSE AND vCurrentCount > 0 @@ -40844,11 +40922,11 @@ DELIMITER ;; Trabajador Error ' INTO vTableQueue; - + OPEN vCur; l: LOOP - + SET vDone = FALSE; FETCH vCur INTO vLineQueue; @@ -40858,7 +40936,7 @@ DELIMITER ;; END IF; SELECT CONCAT(vTableQueue, vLineQueue) INTO vTableQueue; - + END LOOP; CLOSE vCur; @@ -40866,11 +40944,11 @@ DELIMITER ;; CALL mail_insert( 'cau@verdnatura.es', NULL, - 'Servidor de impresion parado', + 'Servidor de impresion parado', CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas', vTableQueue, '') ); - UPDATE printingQueueCheck SET isAlreadyNotified = TRUE; + UPDATE printingQueueCheck SET isAlreadyNotified = TRUE; END IF; IF (SELECT lastCount FROM printingQueueCheck) > vCurrentCount AND @@ -40882,7 +40960,7 @@ DELIMITER ;; UPDATE printingQueueCheck SET lastCount = vCurrentCount, lastCheckSum = vCheckSum; - + END */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; @@ -40919,7 +40997,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `sale_checkWithoutComponents` ON SCHEDULE EVERY 10 MINUTE STARTS '2020-05-04 11:56:23' ON COMPLETION PRESERVE DISABLE DO call sale_checkNoComponents(DATE_ADD(NOW(), INTERVAL -10 MINUTE),DATE_ADD(NOW(), INTERVAL -1 MINUTE)) */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `sale_checkWithoutComponents` ON SCHEDULE EVERY 10 MINUTE STARTS '2020-05-04 11:56:23' ON COMPLETION PRESERVE DISABLE DO call sale_checkNoComponents(DATE_ADD(util.VN_NOW(), INTERVAL -10 MINUTE),DATE_ADD(util.VN_NOW(), INTERVAL -1 MINUTE)) */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -40937,7 +41015,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `ticketClosure` ON SCHEDULE EVERY 1 DAY STARTS '2017-09-18 00:30:00' ON COMPLETION NOT PRESERVE DISABLE COMMENT 'Realiza el cierre de todos los almacenes del dia actual' DO CALL ticketClosureMultiWarehouse(DATE_ADD(CURDATE(), INTERVAL -1 DAY)) */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `ticketClosure` ON SCHEDULE EVERY 1 DAY STARTS '2017-09-18 00:30:00' ON COMPLETION NOT PRESERVE DISABLE COMMENT 'Realiza el cierre de todos los almacenes del dia actual' DO CALL ticketClosureMultiWarehouse(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 DAY)) */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -40995,11 +41073,11 @@ DELIMITER ;; 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)) + FROM vn.time + WHERE dated IN (DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL -4 DAY)) GROUP BY year,week LIMIT 1; - + CALL vn.workerTimeControl_sendMail(vWeek, vYear, NULL); END */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; @@ -41007,6 +41085,24 @@ 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 `worker_updateChangedBusiness` */;; +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_unicode_ci */ ;; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ;; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `worker_updateChangedBusiness` ON SCHEDULE EVERY 1 DAY STARTS '2000-01-01 00:00:05' ON COMPLETION NOT PRESERVE ENABLE DO CALL worker_updateChangedBusiness */ ;; +/*!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 */ ;; @@ -41031,8 +41127,6 @@ DELIMITER ; -- -- Dumping routines for database 'vn' -- -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `addressTaxArea` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41040,40 +41134,40 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `addressTaxArea`(vAddresId INT, vCompanyId INT) RETURNS varchar(25) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `addressTaxArea`(vAddresId INT, vCompanyId INT) RETURNS varchar(25) CHARSET utf8mb3 DETERMINISTIC BEGIN /** - * Devuelve el area de un Consignatario, + * Devuelve el area de un Consignatario, * intracomunitario, extracomunitario, nacional o recargo de equivalencia. - * Asumimos que no tenemos ninguna empresa + * Asumimos que no tenemos ninguna empresa * * @param vAddresId Id del Consignatario * @param vCompanyId Compañia desde la que se factura * @return Código de area */ - DECLARE vTaxArea VARCHAR(25); + DECLARE vTaxArea VARCHAR(25); - DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; - CREATE TEMPORARY TABLE tmp.addressCompany - SELECT vAddresId addressFk, vCompanyId companyFk; + DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; + CREATE TEMPORARY TABLE tmp.addressCompany + SELECT vAddresId addressFk, vCompanyId companyFk; - CALL vn.addressTaxArea(); - SELECT areaFk INTO vTaxArea FROM tmp.addressTaxArea; - DROP TEMPORARY TABLE - tmp.addressCompany, - tmp.addressTaxArea; + CALL vn.addressTaxArea(); + SELECT areaFk INTO vTaxArea FROM tmp.addressTaxArea; + DROP TEMPORARY TABLE + tmp.addressCompany, + tmp.addressTaxArea; - RETURN vTaxArea; + RETURN vTaxArea; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `address_getGeo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41081,6 +41175,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `address_getGeo`(vSelf INT) RETURNS int(11) DETERMINISTIC @@ -41094,7 +41190,7 @@ BEGIN DECLARE vGeoFk INT; SELECT p.geoFk INTO vGeoFk - FROM address a + FROM address a JOIN town t ON t.provinceFk = a.provinceFk JOIN postCode p ON p.townFk = t.id AND p.`code` = a.postalCode WHERE a.id = vSelf @@ -41108,8 +41204,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `barcodeToItem` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41117,16 +41211,18 @@ DELIMITER ; /*!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`@`localhost` FUNCTION `barcodeToItem`(vBarcode VARCHAR(22)) RETURNS int(11) DETERMINISTIC BEGIN - + /** * Obtiene el id del artículo * * @param vBarcode código de barras - * + * * return id del item */ @@ -41136,43 +41232,41 @@ BEGIN FROM vn.item WHERE id = vBarcode OR comment = vBarcode LIMIT 1; - - IF vItemFk THEN + + IF vItemFk THEN RETURN vItemFk; END IF; - SELECT itemFk INTO vItemFk - FROM buy + SELECT itemFk INTO vItemFk + FROM buy WHERE id = vBarcode; - - IF vItemFk THEN - RETURN vItemFk; - END IF; - - SELECT itemFk INTO vItemFk - FROM itemBarcode - WHERE code = vBarcode; - - IF vItemFk THEN + + IF vItemFk THEN RETURN vItemFk; END IF; - SELECT i.id INTO vItemFk + SELECT itemFk INTO vItemFk + FROM itemBarcode + WHERE code = vBarcode; + + IF vItemFk THEN + RETURN vItemFk; + END IF; + + SELECT i.id INTO vItemFk FROM vn.item i WHERE i.name LIKE CONCAT('%',vBarcode,'%') ORDER BY i.id ASC LIMIT 1; - + RETURN vItemFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `botanicExport_isUpdatable` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41180,15 +41274,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `botanicExport_isUpdatable`(vEdiGenusFk MEDIUMINT,vEdiSpecieFk MEDIUMINT, vCountryFk MEDIUMINT,vRestriction MEDIUMINT) RETURNS int(11) DETERMINISTIC BEGIN DECLARE vIsUpdatable INTEGER; - SELECT COUNT(*) INTO vIsUpdatable - FROM botanicExport - WHERE ediGenusFk = vEdiGenusFk + SELECT COUNT(*) INTO vIsUpdatable + FROM botanicExport + WHERE ediGenusFk = vEdiGenusFk AND (vEdiSpecieFk = ediSpecieFk OR IFNULL(vEdiSpecieFk,ediSpecieFk) IS NULL) AND (vCountryFk = countryFk OR IFNULL(vCountryFk,countryFk) IS NULL) AND vRestriction = restriction; @@ -41199,8 +41295,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `buy_getUnitVolume` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41208,6 +41302,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `buy_getUnitVolume`(vSelf INT) RETURNS int(11) DETERMINISTIC @@ -41234,8 +41330,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `buy_getVolume` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41243,6 +41337,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `buy_getVolume`(vSelf INT) RETURNS int(11) DETERMINISTIC @@ -41267,8 +41363,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `catalog_componentReverse` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41276,6 +41370,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `catalog_componentReverse`(vWarehouse INT, vCost DECIMAL(10,3), @@ -41285,16 +41381,16 @@ CREATE DEFINER=`root`@`localhost` FUNCTION `catalog_componentReverse`(vWarehouse DETERMINISTIC BEGIN /* Calcula los componentes para un cliente a partir de un coste y volumen - * @param vWarehouse + * @param vWarehouse * @param vCost Valor de coste del articulo * @param vM3 m3 del articulo - * @param vAddressFk + * @param vAddressFk * @param vZoneFk - * @return vRetailedPrice precio de venta sin iva + * @return vRetailedPrice precio de venta sin iva * @return tmp.catalog_component (warehouseFk, itemFk, componentFk, cost) */ - - DECLARE vBoxVolume BIGINT; + + DECLARE vBoxVolume BIGINT; DECLARE vCustomer INT; DECLARE vComponentRecovery INT DEFAULT 17; DECLARE vComponentMana INT DEFAULT 39; @@ -41303,11 +41399,11 @@ BEGIN DECLARE vComponentCost INT DEFAULT 28; DECLARE vRetailedPrice DECIMAL(10,2); DECLARE vItem INT DEFAULT 98; - + SELECT volume INTO vBoxVolume FROM vn.packaging WHERE id = '94'; - + SELECT clientFk INTO vCustomer FROM address WHERE id = vAddressFk; DROP TEMPORARY TABLE IF EXISTS tmp.catalog_component; @@ -41323,7 +41419,7 @@ BEGIN INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost) SELECT vWarehouse, vItem, vComponentCost, vCost FROM vn.rate - WHERE dated <= CURDATE() + WHERE dated <= util.VN_CURDATE() AND warehouseFk = vWarehouse ORDER BY dated DESC LIMIT 1; @@ -41331,16 +41427,16 @@ BEGIN -- Margen -- No se aplica margen, cau 12589 /* INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost) - SELECT vWarehouse, vItem, vComponentMargin, (vCost / ((100 - rate2) / 100)) - vCost + SELECT vWarehouse, vItem, vComponentMargin, (vCost / ((100 - rate2) / 100)) - vCost FROM vn.rate - WHERE dated <= CURDATE() + WHERE dated <= util.VN_CURDATE() AND warehouseFk = vWarehouse ORDER BY dated DESC LIMIT 1; */ -- Recobro INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost) - SELECT vWarehouse, vItem, vComponentRecovery, ROUND(LEAST(recobro,0.25), 3) + SELECT vWarehouse, vItem, vComponentRecovery, ROUND(LEAST(recobro,0.25), 3) FROM bi.claims_ratio WHERE Id_Cliente = vCustomer AND recobro > 0.009; @@ -41357,7 +41453,7 @@ BEGIN ROUND( vM3 * (z.price - z.bonus) - * z.inflation + * z.inflation / vBoxVolume, 4 ) FROM zone z @@ -41374,8 +41470,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `clientGetDebt` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41383,6 +41477,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `clientGetDebt`(`vClient` INT, `vDate` DATE) RETURNS decimal(10,2) READS SQL DATA @@ -41402,31 +41498,31 @@ BEGIN 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 vDate = IFNULL(vDate, util.VN_CURDATE()); + + SET vDateIni = TIMESTAMPADD(MONTH, -2, util.VN_CURDATE()); SET vDateEnd = TIMESTAMP(vDate, '23:59:59'); SELECT IFNULL(SUM(t.amount), 0) INTO vDebt - FROM ( + FROM ( SELECT SUM(IFNULL(totalWithVat,0)) amount FROM ticket WHERE clientFk = vClient AND refFk IS NULL AND shipped BETWEEN vDateIni AND vDateEnd - UNION ALL + UNION ALL SELECT SUM(amountPaid) amount FROM receipt WHERE clientFk = vClient AND payed > vDateEnd UNION ALL SELECT SUM(amount) - FROM clientRisk + FROM clientRisk WHERE clientFk = vClient UNION ALL SELECT CAST(-SUM(amount) / 100 AS DECIMAL(10,2)) @@ -41443,8 +41539,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `clientGetMana` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41452,6 +41546,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `clientGetMana`(vClient INT) RETURNS decimal(10,2) DETERMINISTIC @@ -41469,30 +41565,30 @@ BEGIN DECLARE vAutoManaComponent INT; DECLARE vManaBank INT; DECLARE vManaGreugeType INT; - + SELECT id INTO vManaGreugeType FROM greugeType WHERE code = 'mana'; SELECT id INTO vManaBank FROM bank WHERE code = 'mana'; SELECT id INTO vManaComponent FROM component WHERE code = 'mana'; SELECT id INTO vAutoManaComponent FROM component WHERE code = 'autoMana'; - + SELECT COUNT(*) INTO vHasMana FROM `client` c WHERE c.id = vClient AND c.typeFk = 'normal'; - + IF NOT vHasMana THEN RETURN 0; END IF; - + SELECT max(dated) INTO vFromDated FROM clientManaCache; SELECT sum(mana) INTO vMana - FROM + FROM ( SELECT mana FROM clientManaCache WHERE clientFk = vClient - AND dated = vFromDated + AND dated = vFromDated UNION ALL SELECT s.quantity * value FROM ticket t @@ -41500,8 +41596,8 @@ BEGIN JOIN sale s on s.ticketFk = t.id JOIN saleComponent sc on sc.saleFk = s.id WHERE sc.componentFk IN (vManaComponent, vAutoManaComponent) - AND t.shipped > vFromDated - AND t.shipped < TIMESTAMPADD(DAY,1,CURDATE()) + AND t.shipped > vFromDated + AND t.shipped < TIMESTAMPADD(DAY,1,util.VN_CURDATE()) AND a.clientFk = vClient UNION ALL SELECT - amountPaid @@ -41509,7 +41605,7 @@ BEGIN JOIN `client` c ON c.id = r.clientFk WHERE r.bankFk = vManaBank AND r.payed > vFromDated - AND r.payed <= CURDATE() + AND r.payed <= util.VN_CURDATE() AND c.id = vClient UNION ALL SELECT g.amount @@ -41517,7 +41613,7 @@ BEGIN JOIN `client` c ON c.id = g.clientFk WHERE g.greugeTypeFk = vManaGreugeType AND g.shipped > vFromDated - AND g.shipped <= CURDATE() + AND g.shipped <= util.VN_CURDATE() AND c.id = vClient ) sub; RETURN IFNULL(vMana,0); @@ -41527,8 +41623,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `clientGetSalesPerson` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41536,6 +41630,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `clientGetSalesPerson`(vClientFk INT, vDated DATE) RETURNS int(11) DETERMINISTIC @@ -41550,8 +41646,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `clientTaxArea` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41559,12 +41653,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `clientTaxArea`(vClientId INT, vCompanyId INT) RETURNS varchar(25) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `clientTaxArea`(vClientId INT, vCompanyId INT) RETURNS varchar(25) CHARSET utf8mb3 READS SQL DATA BEGIN /** - * Devuelve el area de un cliente, + * Devuelve el area de un cliente, * intracomunitario, extracomunitario o nacional. * * @param vClient Id del cliente @@ -41585,8 +41681,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `client_getFromPhone` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41594,6 +41688,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `client_getFromPhone`(vPhone VARCHAR(255)) RETURNS int(11) DETERMINISTIC @@ -41640,8 +41736,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `client_getSalesPerson` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41649,13 +41743,15 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPerson`(vClientFk INT, vDated DATE) RETURNS int(11) DETERMINISTIC BEGIN /** - * Dado un id cliente y una fecha, devuelve su comercial para ese dia, teniendo - * en cuenta la jerarquía de las tablas: 1º la de sharingclient, 2º la de + * Dado un id cliente y una fecha, devuelve su comercial para ese dia, teniendo + * en cuenta la jerarquía de las tablas: 1º la de sharingclient, 2º la de * sharingcart y tercero la de clientes. * * @param vClientFk El id del cliente @@ -41693,29 +41789,29 @@ BEGIN l: LOOP SELECT workerSubstitute INTO vWorkerSubstituteFk - FROM sharingCart - WHERE curdate() BETWEEN started AND ended + FROM sharingCart + WHERE util.VN_CURDATE() BETWEEN started AND ended AND workerFk = vSalesPersonFk ORDER BY id LIMIT 1; - + IF vWorkerSubstituteFk IS NULL THEN LEAVE l; END IF; - + SELECT COUNT(*) > 0 INTO vLoop FROM tmp.stack WHERE substitute = vWorkerSubstituteFk; IF vLoop THEN LEAVE l; END IF; - + INSERT INTO tmp.stack SET substitute = vWorkerSubstituteFk; - + SET vSalesPersonFk = vWorkerSubstituteFk; END LOOP; - + DROP TEMPORARY TABLE tmp.stack; END IF; @@ -41726,8 +41822,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `client_getSalesPersonByTicket` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41735,6 +41829,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPersonByTicket`(vTicketFk INT) RETURNS int(11) DETERMINISTIC @@ -41749,11 +41845,11 @@ BEGIN **/ DECLARE vClientFk INT; DECLARE vDated DATE; - + SELECT clientFk, shipped INTO vClientFk, vDated FROM ticket WHERE id = vTicketFk; - + RETURN client_getSalesPerson(vClientFk, vDated); END ;; DELIMITER ; @@ -41761,8 +41857,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `client_getSalesPersonCode` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41770,8 +41864,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPersonCode`(vClientFk INT, vDated DATE) RETURNS varchar(3) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPersonCode`(vClientFk INT, vDated DATE) RETURNS varchar(3) CHARSET utf8mb3 DETERMINISTIC BEGIN /** @@ -41784,12 +41880,12 @@ BEGIN **/ DECLARE vWorkerCode CHAR(3); DECLARE vSalesPersonFk INT; - + SET vSalesPersonFk = client_getSalesPerson(vClientFk, vDated); SELECT code INTO vWorkerCode - FROM worker + FROM worker WHERE id = vSalesPersonFk; RETURN vWorkerCode; @@ -41799,8 +41895,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `client_getSalesPersonCodeByTicket` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41808,8 +41902,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPersonCodeByTicket`(vTicketFk INT) RETURNS varchar(3) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPersonCodeByTicket`(vTicketFk INT) RETURNS varchar(3) CHARSET utf8mb3 DETERMINISTIC BEGIN /** @@ -41822,11 +41918,11 @@ BEGIN **/ DECLARE vClientFk INT; DECLARE vDated DATE; - + SELECT clientFk, shipped INTO vClientFk, vDated FROM ticket WHERE id = vTicketFk; - + RETURN client_getSalesPersonCode(vClientFk, vDated); END ;; DELIMITER ; @@ -41834,8 +41930,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `collectionExpeditionLacks` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41843,8 +41937,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `collectionExpeditionLacks`(vCollectionFk INT) RETURNS varchar(100) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `collectionExpeditionLacks`(vCollectionFk INT) RETURNS varchar(100) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN /** @@ -41870,8 +41966,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `collection_isPacked` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41879,6 +41973,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `collection_isPacked`(vSelf INT) RETURNS tinyint(1) DETERMINISTIC @@ -41904,8 +42000,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `currentRate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41913,13 +42007,15 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `currentRate`(vCurrencyFk INT, vDated DATE) RETURNS decimal(10,4) READS SQL DATA BEGIN DECLARE curRate DECIMAL(10,4); - + SELECT value INTO curRate FROM referenceRate WHERE dated <= vDated @@ -41935,8 +42031,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `deviceProductionUser_accessGranted` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41944,29 +42038,31 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `deviceProductionUser_accessGranted`(vUserFK INT(10) , android_id VARCHAR(50)) RETURNS tinyint(1) DETERMINISTIC BEGIN /* * Comprueba si el usuario puede entrar en la aplicacion de almacen con ese movil - * + * * */ - + /*DECLARE vIsGranted BOOLEAN; DECLARE vDeviceProductionFk INT(11) DEFAULT NULL; - SELECT dp.id INTO vDeviceProductionFk - FROM vn.deviceProduction dp + SELECT dp.id INTO vDeviceProductionFk + FROM vn.deviceProduction dp WHERE dp.android_id = android_id; IF vDeviceProductionFk THEN - - SELECT COUNT(*) INTO vIsGranted - FROM vn.deviceProductionUser dpu - WHERE dpu.userFk = vUserFK + + SELECT COUNT(*) INTO vIsGranted + FROM vn.deviceProductionUser dpu + WHERE dpu.userFk = vUserFK AND dpu.deviceProductionFk = vDeviceProductionFk; - + RETURN vIsGranted; END IF;*/ RETURN TRUE; @@ -41976,8 +42072,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `duaTax_getRate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -41985,22 +42079,24 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `duaTax_getRate`(vDua INT, vTaxClass INT) RETURNS decimal(5,2) DETERMINISTIC BEGIN DECLARE vCountryFk INTEGER; - + SELECT s.countryFk INTO vCountryFk FROM dua d JOIN supplier s ON s.id = d.companyFk WHERE d.id = vDua; - + RETURN (SELECT rate FROM (SELECT taxClassFk, rate - FROM invoiceInTaxBookingAccount - WHERE effectived <= CURDATE() + FROM invoiceInTaxBookingAccount + WHERE effectived <= util.VN_CURDATE() AND countryFk = vCountryFk AND taxClassFk = vTaxClass ORDER BY effectived DESC @@ -42013,8 +42109,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `ekt_getEntry` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42022,29 +42116,31 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `ekt_getEntry`(vEktFk INT) RETURNS int(11) READS SQL DATA BEGIN /** - * Devuelve el numero de entrada para el ekt - * + * Devuelve el numero de entrada para el ekt + * * @param vEktFk Identificador de edi.ekt - */ + */ DECLARE vTravelFk INT; DECLARE vEntryFk INT DEFAULT 0; DECLARE vEntryAssignFk INT; - SELECT ea.id + SELECT ea.id INTO vEntryAssignFk FROM edi.ekt e - JOIN vn.ektEntryAssign ea ON + JOIN vn.ektEntryAssign ea ON IFNULL(ea.sub, e.sub) <=> e.sub AND IFNULL(ea.kop, e.kop) <=> e.kop AND IFNULL(ea.pro, e.pro) <=> e.pro AND IFNULL(ea.auction, e.auction) <=> e.auction WHERE e.id = vEktFk - ORDER BY + ORDER BY IF(ea.sub,1,0) * 1000 + IF(ea.kop,1,0) * 100 + IF(ea.pro,1,0) * 10 + @@ -42055,7 +42151,7 @@ BEGIN IF vTravelFk THEN - SELECT MAX(e.id) + SELECT MAX(e.id) INTO vEntryFk FROM vn.entry e JOIN vn.ektEntryAssign ea ON ea.id = vEntryAssignFk @@ -42063,20 +42159,20 @@ BEGIN AND e.sub <=> ea.sub AND e.kop <=> ea.kop AND e.pro <=> ea.pro - AND e.auction <=> ea.auction; + AND e.auction <=> ea.auction + AND e.companyFk <=> ea.companyFk; IF vEntryFk IS NULL THEN - INSERT INTO vn.entry(travelFk, supplierFk, companyFk, currencyFk, kop, sub, ref, pro) - SELECT vTravelFk, ea.supplierFk, c.id, cu.id, ea.kop, ea.sub, ea.ref, ea.pro + INSERT INTO vn.entry(travelFk, supplierFk, companyFk, currencyFk, kop, sub, ref, pro, auction) + SELECT vTravelFk, ea.supplierFk, ea.companyFk, cu.id, ea.kop, ea.sub, ea.ref, ea.pro, ea.auction FROM vn.ektEntryAssign ea - JOIN vn.company c ON c.code = 'VNL' - JOIN vn.currency cu ON cu.code = 'EUR' + JOIN vn.currency cu ON cu.code = 'EUR' WHERE ea.id = vEntryAssignFk; SET vEntryFk = LAST_INSERT_ID(); END IF; - UPDATE vn.ektEntryAssign + UPDATE vn.ektEntryAssign SET entryFk = vEntryFk WHERE id = vEntryAssignFk; @@ -42095,8 +42191,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `ekt_getTravel` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42104,42 +42198,46 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `ekt_getTravel`(vEntryAssignFk INT, vEktFk INT) RETURNS int(11) READS SQL DATA BEGIN /** * Devuelve un vn.travel.id - * + * * @param vEntryAssignFk Identificador de vn.entryAssign */ DECLARE vTravelFk INT; - SELECT MAX(tr.id) INTO vTravelFk - FROM vn.travel tr - JOIN vn.ektEntryAssign ea ON ea.id = vEntryAssignFk - JOIN edi.ekt e ON e.id = vEktFk - WHERE ea.warehouseOutFk = tr.warehouseOutFk - AND ea.warehouseInFk = tr.warehouseInFk - AND ea.agencyModeFk = tr.agencyModeFk - AND tr.landed = e.fec; + IF vEntryAssignFk IS NOT NULL THEN + SELECT MAX(tr.id) INTO vTravelFk + FROM vn.travel tr + JOIN vn.ektEntryAssign ea ON ea.id = vEntryAssignFk + JOIN edi.ekt e ON e.id = vEktFk + WHERE ea.warehouseOutFk = tr.warehouseOutFk + AND ea.warehouseInFk = tr.warehouseInFk + AND ea.agencyModeFk = tr.agencyModeFk + AND tr.landed = e.fec; - IF vTravelFk IS NULL THEN + IF vTravelFk IS NULL THEN - INSERT INTO vn.travel(landed, shipped, warehouseInFk, warehouseOutFk, agencyModeFk) - SELECT e.fec, e.fec, ea.warehouseInFk, ea.warehouseOutFk, ea.agencyModeFk - FROM edi.ekt e - JOIN vn.ektEntryAssign ea ON ea.kop = e.kop - WHERE e.id = vEktFk - ORDER BY - IF(ea.sub,1,0) * 1000 + - IF(ea.kop,1,0) * 100 + - IF(ea.pro,1,0) * 10 + - IF(ea.auction,1,0) DESC - LIMIT 1; + INSERT INTO vn.travel(landed, shipped, warehouseInFk, warehouseOutFk, agencyModeFk) + SELECT e.fec, e.fec, ea.warehouseInFk, ea.warehouseOutFk, ea.agencyModeFk + FROM edi.ekt e + JOIN vn.ektEntryAssign ea ON ea.kop = e.kop + WHERE e.id = vEktFk + ORDER BY + IF(ea.sub,1,0) * 1000 + + IF(ea.kop,1,0) * 100 + + IF(ea.pro,1,0) * 10 + + IF(ea.auction,1,0) DESC + LIMIT 1; - SET vTravelFk = LAST_INSERT_ID(); + SET vTravelFk = LAST_INSERT_ID(); + END IF; END IF; RETURN vTravelFk; @@ -42149,8 +42247,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `entry_getCommission` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42158,9 +42254,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `entry_getCommission`( - vTravelFk INT, +CREATE DEFINER=`root`@`localhost` FUNCTION `entry_getCommission`(vTravelFk INT, vCurrencyFk INT, vSupplierFk INT ) RETURNS int(11) @@ -42170,36 +42267,36 @@ BEGIN DECLARE vCurrentCommission INT; DECLARE vIsCurrencyUsd INT; DECLARE vLastEntryFk INT; - + SELECT count(*) INTO vIsCurrencyUsd FROM currency c WHERE c.code = 'USD' AND id = vCurrencyFk; - + IF NOT vIsCurrencyUsd THEN - + SELECT e.id INTO vLastEntryFk FROM vn.entry e JOIN vn.travel tr ON tr.id = e.travelFk WHERE e.supplierFk = vSupplierFk ORDER BY tr.landed DESC LIMIT 1; - + IF vLastEntryFk THEN - + SELECT commission INTO vCurrentCommission FROM vn.entry WHERE id = vLastEntryFk; - + ELSE - + SELECT commission INTO vCurrentCommission FROM supplier s WHERE s.id = vSupplierFk; - + END IF; - + RETURN vCurrentCommission; - + ELSE SELECT ROUND(-100 * (1 - (1 / r.value))) INTO vCommission @@ -42208,19 +42305,17 @@ BEGIN WHERE t.id = vTravelFk ORDER BY r.`dated` DESC LIMIT 1; - + RETURN IFNULL(vCommission, 0); - + END IF; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `entry_getCurrency` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42228,9 +42323,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `entry_getCurrency`( - vCurrency INT, +CREATE DEFINER=`root`@`localhost` FUNCTION `entry_getCurrency`(vCurrency INT, vSupplierFk INT ) RETURNS int(11) READS SQL DATA @@ -42251,8 +42347,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `entry_getForLogiflora` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42260,14 +42354,16 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `entry_getForLogiflora`(vLanded DATE, vWarehouseFk INT) RETURNS int(11) READS SQL DATA BEGIN - + /** * Devuelve una entrada para Logiflora. Si no existe la crea. - * + * * @param vLanded Fecha de llegada al almacén * @param vWarehouseFk Identificador de vn.warehouse */ @@ -42275,55 +42371,57 @@ BEGIN DECLARE vTravelFk INT; DECLARE vEntryFk INT; DECLARE previousEntryFk INT; - + SET vTravelFk = vn.travel_getForLogiflora(vLanded, vWarehouseFk); - + IF vLanded THEN - - SELECT IFNULL(MAX(id),0) INTO vEntryFk + + SELECT IFNULL(MAX(id),0) INTO vEntryFk FROM vn.entry - WHERE travelFk = vTravelFk + WHERE travelFk = vTravelFk AND isRaid; IF NOT vEntryFk THEN - + INSERT INTO vn.entry(travelFk, supplierFk, commission, companyFk, currencyFk, isRaid) SELECT vTravelFk, s.id, 4, c.id, cu.id, TRUE FROM vn.supplier s JOIN vn.company c ON c.code = 'VNL' JOIN vn.currency cu ON cu.code = 'EUR' WHERE s.name = 'KONINKLIJE COOPERATIEVE BLOEMENVEILING FLORAHOLLAN'; - - SELECT MAX(id) INTO vEntryFk + + SELECT MAX(id) INTO vEntryFk FROM vn.entry WHERE travelFk = vTravelFk; - - END IF; - - END IF; - SELECT entryFk INTO previousEntryFk + END IF; + + END IF; + + SELECT entryFk INTO previousEntryFk FROM edi.warehouseFloramondo wf WHERE wf.warehouseFk = vWarehouseFk; - + IF IFNULL(previousEntryFk,0) != vEntryFk THEN - + + UPDATE buy b + SET b.printedStickers = 0 + WHERE entryFk = previousEntryFk; + DELETE FROM buy WHERE entryFk = previousEntryFk; - + DELETE FROM entry WHERE id = previousEntryFk; - + END IF; - + RETURN vEntryFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `entry_isInventoryOrPrevious` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42331,6 +42429,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `entry_isInventoryOrPrevious`(vSelf INT) RETURNS int(11) DETERMINISTIC @@ -42352,8 +42452,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `expedition_checkRoute` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42361,6 +42459,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `expedition_checkRoute`(vPalletFk INT,vExpeditionFk INT) RETURNS tinyint(1) DETERMINISTIC @@ -42377,17 +42477,17 @@ BEGIN DECLARE vHasDistinctRoutes BOOL; SELECT t.routeFk INTO vRouteFk - FROM vn.expedition e + FROM vn.expedition e JOIN vn.ticket t ON e.ticketFk = t.id WHERE e.id = vExpeditionFk; - + SELECT COUNT(*) > 0 INTO vHasDistinctRoutes FROM vn.expeditionScan es JOIN vn.expedition e ON es.expeditionFk = e.id JOIN vn.ticket t ON e.ticketFk = t.id WHERE es.palletFk = vPalletFk AND t.routeFk <> vRouteFk; - + RETURN vHasDistinctRoutes; END ;; @@ -42396,8 +42496,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `firstDayOfWeek` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42405,6 +42503,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `firstDayOfWeek`(vYear INT, vWeek INT) RETURNS date DETERMINISTIC @@ -42432,8 +42532,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `getAlert3State` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42441,34 +42539,36 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `getAlert3State`(vTicket INT) RETURNS varchar(45) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `getAlert3State`(vTicket INT) RETURNS varchar(45) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci READS SQL DATA BEGIN DECLARE vDeliveryType INTEGER DEFAULT 0; DECLARE isWaitingForPickUp BOOLEAN DEFAULT FALSE; DECLARE vCode VARCHAR(45); - + SELECT am.deliveryMethodFk - INTO vDeliveryType + INTO vDeliveryType FROM ticket t JOIN agencyMode am ON am.id = t.agencyModeFk WHERE t.id = vTicket; - + CASE vDeliveryType WHEN 1 THEN -- AGENCIAS SET vCode = 'DELIVERED'; - + WHEN 2 THEN -- REPARTO SET vCode = 'ON_DELIVERY'; - + ELSE -- MERCADO, OTROS SELECT MIN(t.warehouseFk <> w.id) INTO isWaitingForPickUp - FROM ticket t + FROM ticket t LEFT JOIN warehouse w ON w.pickUpagencyModeFk = t.agencyModeFk WHERE t.id = vTicket; - + IF isWaitingForPickUp THEN SET vCode = 'WAITING_FOR_PICKUP'; ELSE @@ -42482,8 +42582,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `getAlert3StateTest` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42491,6 +42589,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `getAlert3StateTest`(vTicket INT) RETURNS varchar(45) CHARSET latin1 READS SQL DATA @@ -42498,28 +42598,28 @@ BEGIN DECLARE vDeliveryType INTEGER DEFAULT 0; DECLARE isWaitingForPickUp BOOLEAN DEFAULT FALSE; DECLARE vCode VARCHAR(45); - - SELECT + + SELECT a.Vista - INTO vDeliveryType + INTO vDeliveryType FROM vn2008.Tickets t JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia WHERE Id_Ticket = vTicket; - + CASE vDeliveryType WHEN 1 THEN -- AGENCIAS SET vCode = 'DELIVERED'; - + WHEN 2 THEN -- REPARTO SET vCode = 'ON_DELIVERY'; - + ELSE -- MERCADO, OTROS SELECT t.warehouse_id <> w.warehouse_id INTO isWaitingForPickUp - FROM vn2008.Tickets t - LEFT JOIN vn2008.warehouse_pickup w + FROM vn2008.Tickets t + LEFT JOIN vn2008.warehouse_pickup w ON w.agency_id = t.Id_Agencia AND w.warehouse_id = t.warehouse_id WHERE t.Id_Ticket = vTicket; - + IF isWaitingForPickUp THEN SET vCode = 'WAITING_FOR_PICKUP'; ELSE @@ -42533,8 +42633,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `getDueDate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42542,6 +42640,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `getDueDate`(vDated DATE, vDayToPay INT) RETURNS date NO SQL @@ -42561,8 +42661,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `getInventoryDate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42570,6 +42668,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `getInventoryDate`() RETURNS date DETERMINISTIC @@ -42581,8 +42681,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `getNewItemId` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42590,6 +42688,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `getNewItemId`() RETURNS int(11) READS SQL DATA @@ -42610,8 +42710,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `getNextDueDate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42619,6 +42717,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `getNextDueDate`(vDated DATE, vGapDays INT, vPayDay INT) RETURNS date NO SQL @@ -42627,16 +42727,16 @@ BEGIN DECLARE vReturn DATE; DECLARE vDuaDate DATE; DECLARE vDuaDateDay INT; - + SELECT TIMESTAMPADD(DAY, vGapDays, vDated) INTO vDuaDate; IF vDuaDate = CONCAT(YEAR(vDuaDate), '-03-01') THEN - SET vDuaDate = TIMESTAMPADD (DAY , -1, vDuaDate); + SET vDuaDate = TIMESTAMPADD (DAY , -1, vDuaDate); ELSEIF vDuaDate = CONCAT(YEAR(vDuaDate), '-02-29') THEN - SET vDuaDate = TIMESTAMPADD (DAY , -2, vDuaDate); + SET vDuaDate = TIMESTAMPADD (DAY , -2, vDuaDate); END IF; - IF MONTH(vDuaDate) = 2 AND vPayDay = 30 THEN + IF MONTH(vDuaDate) = 2 AND vPayDay = 30 THEN IF util.isLeapYear(YEAR(vDuaDate)) THEN SET vPayDay = 29; ELSE @@ -42644,7 +42744,7 @@ BEGIN END IF; END IF; - SELECT DAY(vDuaDate) INTO vDuaDateDay; + SELECT DAY(vDuaDate) INTO vDuaDateDay; RETURN TIMESTAMPADD(MONTH, (vDuaDateDay > vPayDay), DATE_FORMAT(vDuaDate, CONCAT('%y/%m/', vPayDay))); END ;; DELIMITER ; @@ -42652,8 +42752,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `getShipmentHour` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42661,16 +42759,18 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `getShipmentHour`(vTicket INT) RETURNS int(11) READS SQL DATA BEGIN DECLARE vShipmentHour INT; - + SELECT HOUR(shipped) INTO vShipmentHour FROM ticket WHERE id = vTicket; - + IF vShipmentHour = 0 THEN DROP TEMPORARY TABLE IF EXISTS tmp.production_buffer; @@ -42685,11 +42785,11 @@ BEGIN JOIN agencyMode am on am.id = t.agencyModeFk JOIN address a on a.id = t.addressFk WHERE t.id = vTicket; - - SELECT Hora INTO vShipmentHour + + SELECT Hora INTO vShipmentHour FROM tmp.production_buffer; END IF; - + RETURN vShipmentHour; END ;; DELIMITER ; @@ -42697,8 +42797,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `getSpecialPrice` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42706,6 +42804,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `getSpecialPrice`(vItemFk int(11),vClientFk int(11)) RETURNS decimal(10,2) READS SQL DATA @@ -42714,12 +42814,12 @@ BEGIN SELECT rate3 INTO price FROM vn.priceFixed - WHERE itemFk = vItemFk - AND CURDATE() BETWEEN started AND ended ORDER BY created DESC LIMIT 1; + WHERE itemFk = vItemFk + AND util.VN_CURDATE() BETWEEN started AND ended ORDER BY created DESC LIMIT 1; - SELECT `value` INTO price + SELECT `value` INTO price FROM vn.specialPrice - WHERE itemFk = vItemFk + WHERE itemFk = vItemFk AND clientFk = vClientFk ; RETURN price; END ;; @@ -42728,8 +42828,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `getTicketToPrepare` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42737,6 +42835,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `getTicketToPrepare`(`vWorker` INT, `vWarehouse` INT) RETURNS int(11) READS SQL DATA @@ -42744,23 +42844,23 @@ BEGIN /** * Devuelve el ticket que debe de preparar el trabajador * - * @param vWorker Id del trabajador + * @param vWorker Id del trabajador * @param vWarehouse Id del almacén * @return Id del ticket * * #UPDATED PAK 2019/08/16 * #PENDING REVIEW **/ - - DECLARE vToday DATETIME DEFAULT CURDATE(); + + DECLARE vToday DATETIME DEFAULT util.VN_CURDATE(); DECLARE vYesterday DATETIME; DECLARE vTodayvMidniight DATETIME DEFAULT midnight(vToday); DECLARE vTicket INT DEFAULT NULL; DECLARE PREVIOUS_PREPARATION INT; DECLARE vHasBeenPreviouslyPrepared INT DEFAULT 0; - + -- Si hay algun ticket previamente seleccionado, y se ha quedado sin empezar, lo recupera en primer lugar. - /* + /* SELECT i.Id_Ticket INTO vTicket FROM vncontrol.inter i JOIN vn.state s ON s.id = i.state_id @@ -42769,15 +42869,15 @@ BEGIN FROM vn.sale s JOIN vn.saleTracking st ON st.saleFk = s.id JOIN vn.ticketStateToday tst ON tst.ticket = s.ticketFk - WHERE st.created > CURDATE() + WHERE st.created > util.VN_CURDATE() -- AND tst.`code` = 'ON_PREPARATION' ) sub ON sub.ticketFk = i.Id_Ticket - WHERE odbc_date > CURDATE() + WHERE odbc_date > util.VN_CURDATE() AND s.`code` = 'ON_PREPARATION' AND i.Id_Trabajador = vWorker AND sub.ticketFk IS NULL LIMIT 1; - + IF vTicket IS NULL THEN */ SELECT id INTO PREVIOUS_PREPARATION @@ -42785,20 +42885,20 @@ BEGIN WHERE code LIKE 'PREVIOUS_PREPARATION'; SET vYesterday = TIMESTAMPADD(DAY,-1,vToday); - + DROP TEMPORARY TABLE IF EXISTS tmp.workerComercial; CREATE TEMPORARY TABLE tmp.workerComercial ENGINE = MEMORY - SELECT workerFk as worker FROM `grant` g - JOIN grantGroup gg ON g.`groupFk` = gg.id + SELECT workerFk as worker FROM `grant` g + JOIN grantGroup gg ON g.`groupFk` = gg.id WHERE gg.description = 'Comerciales'; - - DELETE wc.* + + DELETE wc.* FROM tmp.workerComercial wc JOIN `grant` g ON g.workerFk = wc.worker - JOIN grantGroup gg ON g.`groupFk` = gg.id - WHERE gg.description = 'Gerencia'; - + JOIN grantGroup gg ON g.`groupFk` = gg.id + WHERE gg.description = 'Gerencia'; + DROP TEMPORARY TABLE IF EXISTS tmp.production_buffer; CREATE TEMPORARY TABLE tmp.production_buffer ENGINE = MEMORY @@ -42819,18 +42919,18 @@ BEGIN LEFT JOIN vn.zone z ON z.id = t.zoneFk WHERE t.shipped BETWEEN vYesterday AND vTodayvMidniight AND t.warehouseFk = vWarehouse - AND + AND ( (tls.code = 'PRINTED' AND wc.worker IS NULL) - OR + OR (tls.code ='PICKER_DESIGNED' AND tls.worker = vWorker) - OR + OR (tls.code = 'PRINTED_BACK') - OR + OR (tls.code = 'PRINTED PREVIOUS') ); - - + + SELECT ticket INTO vTicket FROM tmp.production_buffer ORDER BY (code = 'PICKER_DESIGNED') DESC, (code = 'PRINTED PREVIOUS') DESC ,Hora, Minuto, loadingOrder @@ -42841,15 +42941,15 @@ BEGIN FROM vncontrol.inter WHERE Id_Ticket = vTicket AND state_id = PREVIOUS_PREPARATION; - - IF vHasBeenPreviouslyPrepared AND ticketWarehouseGet(vTicket) = 1 THEN - + + IF vHasBeenPreviouslyPrepared AND ticketWarehouseGet(vTicket) = 1 THEN + INSERT IGNORE INTO vn.ticketDown(ticketFk) VALUES(vTicket); - + END IF; -- END IF; - + RETURN vTicket; END ;; @@ -42858,8 +42958,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `getTicketTrolleyLabelCount` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42867,13 +42965,15 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `getTicketTrolleyLabelCount`(vTicket INT) RETURNS int(11) READS SQL DATA BEGIN DECLARE vLabelCount INT DEFAULT 0; - SELECT labelCount INTO vLabelCount + SELECT labelCount INTO vLabelCount FROM ticketTrolley WHERE ticket = vTicket; @@ -42889,8 +42989,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `getUser` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42898,6 +42996,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `getUser`() RETURNS int(11) DETERMINISTIC @@ -42912,8 +43012,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `getUserId` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42921,6 +43019,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `getUserId`(userName varchar(30)) RETURNS int(11) READS SQL DATA @@ -42939,8 +43039,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `getWorkerCode` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42948,8 +43046,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `getWorkerCode`() RETURNS varchar(3) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `getWorkerCode`() RETURNS varchar(3) CHARSET utf8mb3 READS SQL DATA BEGIN DECLARE vUserCode VARCHAR(3) CHARSET utf8 COLLATE utf8_unicode_ci; @@ -42965,8 +43065,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `hasAnyNegativeBase` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42974,10 +43072,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `hasAnyNegativeBase`() RETURNS tinyint(1) DETERMINISTIC -BEGIN +BEGIN /* Calcula si existe alguna base imponible negativa * Requiere la tabla temporal vn.ticketToInvoice(id) @@ -42985,14 +43085,14 @@ BEGIN * returns BOOLEAN */ DECLARE hasAnyNegativeBase BOOLEAN; - + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; CREATE TEMPORARY TABLE tmp.ticket (KEY (ticketFk)) ENGINE = MEMORY SELECT id ticketFk FROM ticketToInvoice; - + CALL ticket_getTax(NULL); SELECT COUNT(*) INTO hasAnyNegativeBase @@ -43005,17 +43105,15 @@ BEGIN DROP TEMPORARY TABLE tmp.ticketTax; DROP TEMPORARY TABLE tmp.ticket; - + RETURN hasAnyNegativeBase; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `hasItemsInSector` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43023,31 +43121,31 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `hasItemsInSector`(vTicketFk INT, vSectorFk INT) RETURNS tinyint(1) DETERMINISTIC BEGIN DECLARE vItemCount INT; - + SELECT count(*) INTO vItemCount - FROM vn.sale s + FROM vn.sale s JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk WHERE s.ticketFk = vTicketFk AND p.sectorFk = vSectorFk; - + RETURN vItemCount; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `hasSomeNegativeBase` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43055,6 +43153,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `hasSomeNegativeBase`(vTicket INT) RETURNS tinyint(1) READS SQL DATA @@ -43062,7 +43162,7 @@ BEGIN DECLARE vCountry INT; DECLARE hasSomeNegativeBase BOOLEAN; - SELECT s.countryFk + SELECT s.countryFk INTO vCountry FROM supplier s JOIN ticket t ON t.companyFk = s.id @@ -43071,9 +43171,9 @@ BEGIN SELECT COUNT(*) INTO hasSomeNegativeBase FROM ( SELECT SUM(ROUND(s.quantity * s.price * (100 - s.discount)/100,2)) taxableBase - FROM sale s + FROM sale s JOIN item i ON i.id = s.itemFk - JOIN itemTaxCountry itc + JOIN itemTaxCountry itc ON itc.itemFk = i.id AND itc.countryFk = vCountry WHERE s.ticketFk = vTicket GROUP BY itc.taxClassFk @@ -43087,8 +43187,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `invoiceOutAmount` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43096,6 +43194,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceOutAmount`(vInvoiceRef VARCHAR(15)) RETURNS decimal(10,2) READS SQL DATA @@ -43103,12 +43203,12 @@ BEGIN DECLARE totalAmount DECIMAL(10,2); SELECT SUM(vat) INTO totalAmount - FROM ( + FROM ( SELECT iot.vat FROM invoiceOutTax iot JOIN invoiceOut io ON io.id = iot.invoiceOutFk WHERE io.ref = vInvoiceRef - UNION ALL + UNION ALL SELECT ioe.amount FROM invoiceOutExpence ioe JOIN invoiceOut io ON io.id = ioe.invoiceOutFk @@ -43122,8 +43222,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `invoiceOut_getPath` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43131,14 +43229,16 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceOut_getPath`(vSelf INT) RETURNS varchar(255) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceOut_getPath`(vSelf INT) RETURNS varchar(255) CHARSET utf8mb3 DETERMINISTIC BEGIN DECLARE vIssued DATE; DECLARE vSerial VARCHAR(15); - SELECT issued, ref + SELECT issued, ref INTO vIssued, vSerial FROM invoiceOut WHERE id = vSelf; @@ -43155,8 +43255,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `invoiceOut_getWeight` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43164,6 +43262,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceOut_getWeight`(vInvoice VARCHAR(15)) RETURNS decimal(10,2) READS SQL DATA @@ -43195,8 +43295,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `invoiceSerial` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43204,14 +43302,16 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceSerial`(vClientFk INT, vCompanyFk INT, vType CHAR(1)) RETURNS char(1) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceSerial`(vClientFk INT, vCompanyFk INT, vType CHAR(1)) RETURNS char(1) CHARSET utf8mb3 DETERMINISTIC BEGIN /** - * Obtiene la serie de de una factura + * Obtiene la serie de de una factura * dependiendo del area del cliente. - * + * * @param vClientFk Id del cliente * @param vCompanyFk Id de la empresa * @param vType Tipo de factura ["R", "M", "G"] @@ -43233,8 +43333,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `invoiceSerialArea` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43242,32 +43340,33 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceSerialArea`(vType CHAR(1), vTaxArea VARCHAR(25)) RETURNS char(1) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceSerialArea`(vType CHAR(1), vTaxArea VARCHAR(25)) RETURNS char(1) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN - DECLARE vSerie CHAR(1); - + IF vType = 'R' THEN - SELECT - CASE vTaxArea + SELECT + CASE vTaxArea WHEN 'CEE' THEN 'H' WHEN 'WORLD' THEN 'E' - WHEN 'NATIONAL' THEN 'T' + ELSE 'T' END INTO vSerie; - -- Factura multiple + -- Factura multiple ELSEIF vType = 'M' THEN - SELECT - CASE vTaxArea + SELECT + CASE vTaxArea WHEN 'CEE' THEN 'H' WHEN 'WORLD' THEN 'E' - WHEN 'NATIONAL' THEN 'M' + ELSE 'M' END INTO vSerie; -- Factura global ELSEIF vType = 'G' THEN - SELECT - CASE vTaxArea + SELECT + CASE vTaxArea WHEN 'CEE' THEN 'V' WHEN 'WORLD' THEN 'X' ELSE 'A' @@ -43280,8 +43379,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `isDateRangeAccounting` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43289,22 +43386,24 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `isDateRangeAccounting`(vSelf DATE) RETURNS int(11) READS SQL DATA BEGIN /** -* Comprueba si la fecha pasada esta en el rango -* de fecha de contabilidad -* -* @param vSelf Fecha para comparar -* @return vReturn -* -**/ + * Comprueba si la fecha pasada esta en el rango + * de fecha de contabilidad + * + * @param vSelf Fecha para comparar + * @return vReturn + * + */ DECLARE vReturn BOOL; SELECT COUNT(*) INTO vReturn - FROM accountingConfig + FROM accountingConfig WHERE Vself BETWEEN minDate AND maxDate; RETURN vReturn; @@ -43314,8 +43413,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `isIntrastatEntry` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43323,6 +43420,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `isIntrastatEntry`(vEntryFk INT) RETURNS int(11) READS SQL DATA @@ -43345,7 +43444,7 @@ BEGIN JOIN vn.entry e ON e.companyFk = co.id WHERE e.id = vEntryFk AND c.isUeeMember = TRUE; - + IF vSupplierCountry != vClientCountry AND vSupplierCountry * vClientCountry > 0 THEN SET isIntrastatOperation = TRUE; END IF; @@ -43357,8 +43456,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `isLogifloraDay` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43366,30 +43463,30 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `isLogifloraDay`(vShipped DATE, vWarehouse INT) RETURNS tinyint(1) DETERMINISTIC BEGIN - + DECLARE vIsLogifloraDay BOOLEAN; SELECT COUNT(*) INTO vIsLogifloraDay FROM edi.warehouseFloramondo wf - JOIN vn.floramondoConfig fc + JOIN vn.floramondoConfig fc WHERE wf.warehouseFk = vWarehouse AND vShipped BETWEEN DATE(TIMESTAMPADD(DAY, wf.travellingDays , fc.nextLanded)) AND DATE(TIMESTAMPADD(DAY, wf.travellingDays + wf.dayRange , fc.nextLanded)); - + RETURN vIsLogifloraDay; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `isPalletHomogeneus` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43397,6 +43494,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `isPalletHomogeneus`(vExpedition INT) RETURNS tinyint(1) READS SQL DATA @@ -43418,7 +43517,7 @@ BEGIN WHERE sl.scan_id = vScanId AND t.Id_Ruta ) t1; - + RETURN vDistinctRoutesInThePallet = 1; END ;; DELIMITER ; @@ -43426,8 +43525,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `itemPacking` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43435,6 +43532,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `itemPacking`(vBarcode VARCHAR(22), vWarehouseFk INT) RETURNS int(11) DETERMINISTIC @@ -43442,20 +43541,20 @@ BEGIN DECLARE vPacking INTEGER DEFAULT 0; DECLARE vItemFk INTEGER; - + SELECT vn.barcodeToItem(vBarcode) INTO vItemFk; - - SELECT IFNULL(packing,0) INTO vPacking - FROM vn.buy + + SELECT IFNULL(packing,0) INTO vPacking + FROM vn.buy WHERE id = CAST(vBarcode AS DECIMAL(18,0)); - - - - + + + + IF NOT vPacking THEN CALL cache.last_buy_refresh(FALSE); SELECT IFNULL(packing,1) INTO vPacking - FROM + FROM (SELECT packing , created FROM vn.itemShelving WHERE itemFk = vItemFk @@ -43468,19 +43567,17 @@ BEGIN ) packings ORDER BY created desc LIMIT 1; - + END IF; - + RETURN vPacking; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `itemShelvingPlacementSupply_ClosestGet` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43488,6 +43585,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `itemShelvingPlacementSupply_ClosestGet`(vParkingFk INT) RETURNS int(11) READS SQL DATA @@ -43497,11 +43596,11 @@ BEGIN DECLARE vColumn INT; DECLARE vClosestParkingFk INT; DECLARE vSectorFk INT; - + SELECT p.column, sectorFk INTO vColumn, vSectorFk FROM vn.parking p WHERE p.id = vParkingFk; - + SELECT itemShelvingFk INTO vClosestParkingFk FROM ( @@ -43511,20 +43610,18 @@ BEGIN JOIN vn.itemPlacementSupplyList ipsl ON ipsl.sectorFk = ispss.sectorFk AND ipsl.itemFk = ispss.itemFk WHERE p.sectorFk = vSectorFk AND ipsl.saldo > 0 - ) sub + ) sub ORDER BY distance LIMIT 1; - + RETURN vClosestParkingFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `itemsInSector_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43532,31 +43629,31 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `itemsInSector_get`(vTicketFk INT, vSectorFk INT) RETURNS int(11) READS SQL DATA BEGIN DECLARE vItemCount INT; - + SELECT count(*) INTO vItemCount - FROM vn.sale s + FROM vn.sale s JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk WHERE s.ticketFk = vTicketFk AND p.sectorFk = vSectorFk; - + RETURN vItemCount; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `itemTag_getIntValue` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43564,6 +43661,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `itemTag_getIntValue`(vValue VARCHAR(255)) RETURNS int(11) DETERMINISTIC @@ -43579,8 +43678,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `item_getFhImage` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43588,8 +43685,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `item_getFhImage`(itemFk INT) RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `item_getFhImage`(itemFk INT) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN DECLARE vImageUrl VARCHAR(255); @@ -43608,8 +43707,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `item_getPackage` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43617,41 +43714,41 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `item_getPackage`(vItemFk INT) RETURNS varchar(50) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `item_getPackage`(vItemFk INT) RETURNS varchar(50) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN - + DECLARE vDiameter INT; DECLARE vPackageFk VARCHAR(50); DECLARE vCoeficient DOUBLE DEFAULT 1.08; - + SELECT MAX(LEFT(value,3)) INTO vDiameter - FROM vn.itemTag it + FROM vn.itemTag it JOIN vn.tag t ON t.id = it.tagFk WHERE it.itemFk = vItemFk AND t.overwrite = 'diameter'; - + SELECT 8000 + FLOOR(vc.ccLength * vc.ccWidth / (vCoeficient * PI() * (vDiameter / 2) * (vDiameter / 2))) INTO vPackageFk FROM vn.volumeConfig vc; - + INSERT IGNORE INTO vn.packaging(id, width, `depth`) - SELECT vPackageFk, - FLOOR(vc.ccWidth / FLOOR(vc.ccWidth / vDiameter)), + SELECT vPackageFk, + FLOOR(vc.ccWidth / FLOOR(vc.ccWidth / vDiameter)), FLOOR(vc.ccLength / FLOOR(vc.ccLength / vDiameter)) FROM vn.volumeConfig vc; - + RETURN vPackageFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `item_getVolume` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43659,6 +43756,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `item_getVolume`(vSelf INT, vPackaging VARCHAR(10)) RETURNS int(11) DETERMINISTIC @@ -43680,7 +43779,7 @@ BEGIN FROM packaging p JOIN item i ON i.id = vSelf WHERE p.id = vPackaging; - + RETURN vVolume; END ;; @@ -43689,8 +43788,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `lastDayOfWeek` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43698,10 +43795,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `lastDayOfWeek`(vYear INT, vWeek INT) RETURNS date DETERMINISTIC -BEGIN +BEGIN /** * Returns the date of the last day of the week * @@ -43725,8 +43824,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `machine_checkPlate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43734,22 +43831,24 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `machine_checkPlate`(vPlate VARCHAR(10)) RETURNS tinyint(1) READS SQL DATA BEGIN /** * Comprueba si existe matrícula - * + * * @param vPlate matrícula del vehículo * @return Devuelve TRUE en caso de que exista - * + * */ - + IF (SELECT COUNT(*) - FROM machine m + FROM machine m WHERE m.plate = vPlate - ) THEN + ) THEN RETURN TRUE; ELSE RETURN FALSE; @@ -43760,8 +43859,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `messageSend` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43769,6 +43866,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `messageSend`(vRecipient VARCHAR(255) CHARSET utf8, vMessage TEXT CHARSET utf8) RETURNS int(11) READS SQL DATA @@ -43776,9 +43875,9 @@ BEGIN DECLARE result INT; DECLARE vSenderFk INT; - SELECT id INTO vSenderFk + SELECT id INTO vSenderFk FROM account.user WHERE `name` = account.myUser_getName(); - + RETURN (SELECT messageSendWithUser(vSenderFk, vRecipient, vMessage)); END ;; DELIMITER ; @@ -43786,8 +43885,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `messageSendWithUser` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43795,6 +43892,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `messageSendWithUser`(vSenderFK INT, vRecipient VARCHAR(255) CHARSET utf8, vMessage TEXT CHARSET utf8) RETURNS int(11) DETERMINISTIC @@ -43802,12 +43901,12 @@ BEGIN DECLARE vCount INT; DECLARE vUuid VARCHAR(255); - DECLARE vSendDate DATETIME DEFAULT NOW(); + DECLARE vSendDate DATETIME DEFAULT util.VN_NOW(); DECLARE vSender VARCHAR(255) CHARSET utf8; - SELECT `name` INTO vSender + SELECT `name` INTO vSender FROM account.user WHERE id = vSenderFK; - + SET vRecipient = LOWER(vRecipient); DROP TEMPORARY TABLE IF EXISTS tRecipients; @@ -43828,7 +43927,7 @@ BEGIN IF vCount = 0 THEN RETURN vCount; - END IF; + END IF; SET vUuid = UUID(); @@ -43839,7 +43938,7 @@ BEGIN message = vMessage, sendDate = vSendDate; - INSERT INTO messageInbox (uuid, sender, recipient, finalRecipient, message, sendDate) + INSERT INTO messageInbox (uuid, sender, recipient, finalRecipient, message, sendDate) SELECT vUuid, vSender, vRecipient, finalRecipient, vMessage, vSendDate FROM tRecipients; @@ -43851,8 +43950,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `MIDNIGHT` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43860,6 +43957,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `MIDNIGHT`(vDate DATE) RETURNS datetime DETERMINISTIC @@ -43871,8 +43970,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `nz` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43880,6 +43977,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `nz`(vQuantity DOUBLE) RETURNS double DETERMINISTIC @@ -43897,8 +43996,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `orderTotalVolume` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43906,6 +44003,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `orderTotalVolume`(vOrderId INT) RETURNS decimal(10,3) READS SQL DATA @@ -43913,7 +44012,7 @@ BEGIN -- Devuelte el volumen total de la orden sumada DECLARE vWarehouseId INTEGER; DECLARE vVolume DECIMAL(10,3); - + SELECT IFNULL(SUM(o.amount * ic.cm3delivery)/1000000,0) INTO vVolume FROM hedera.orderRow o JOIN item i ON i.id = o.itemFk @@ -43928,8 +44027,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `orderTotalVolumeBoxes` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43937,6 +44034,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `orderTotalVolumeBoxes`(vOrderId INT) RETURNS decimal(10,3) READS SQL DATA @@ -43964,8 +44063,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `phytoPassport` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43973,12 +44070,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `phytoPassport`(vRef VARCHAR(15)) RETURNS text CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `phytoPassport`(vRef VARCHAR(15)) RETURNS text CHARSET utf8mb3 DETERMINISTIC BEGIN DECLARE vPhyto TEXT CHARSET utf8 COLLATE utf8_unicode_ci; -SELECT +SELECT GROUP_CONCAT(i.id, ':', ppa.denomination, @@ -44019,8 +44118,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `routeProposal` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44028,6 +44125,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `routeProposal`(vTicketFk INT) RETURNS int(11) READS SQL DATA @@ -44035,20 +44134,20 @@ BEGIN DECLARE vRouteFk INT; DECLARE vAddressFk INT; - + DECLARE vLanded DATE; DECLARE vZoneFk INT; DECLARE vSignificativeFriendship INT DEFAULT 6; DECLARE vVolumeMax DECIMAL(5,1) DEFAULT 10; - + SELECT addressFk, zoneFk, landed INTO vAddressFk, vZoneFk, vLanded - FROM vn.ticket + FROM vn.ticket WHERE id = vTicketFk; - + -- Se inicia la selección de rutas posibles con aquellas cuyas agencias alguna vez han estado asociadas con nuestra zona DROP TEMPORARY TABLE IF EXISTS tmp.route; CREATE TEMPORARY TABLE tmp.route - SELECT r.id routeFk, + SELECT r.id routeFk, zf.friendship zoneFriendship FROM vn.route r JOIN cache.zoneAgencyFriendship zf ON zf.agencyModeFk = r.agencyModeFk @@ -44056,16 +44155,16 @@ BEGIN AND zf.zoneFk = vZoneFk AND r.created = vLanded ORDER BY friendship; - + -- Se eliminan aquellas que superan el volumen máximo DELETE r.* - FROM tmp.route r + FROM tmp.route r JOIN (SELECT routeFk, sum(volume) volume FROM vn.saleVolume WHERE landed = vLanded GROUP BY routeFk) sub ON sub.routeFk = r.routeFk WHERE sub.volume > vVolumeMax; - + -- Se ordenan las que quedan en función con la afinidad del resto de consignatarios de cada ruta SELECT routeFk INTO vRouteFk FROM @@ -44077,7 +44176,7 @@ BEGIN ORDER BY zoneFriendship DESC, friendshipSum DESC ) sub LIMIT 1; - + RETURN vRouteFk; END ;; DELIMITER ; @@ -44085,8 +44184,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `routeProposal_` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44094,6 +44191,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `routeProposal_`(vTicketFk INT) RETURNS int(11) READS SQL DATA @@ -44102,9 +44201,9 @@ BEGIN DECLARE vRouteFk INT; DECLARE vAddressFk INT; DECLARE vShipped DATETIME; - + SELECT addressFk, date(shipped) INTO vAddressFk, vShipped - FROM vn.ticket + FROM vn.ticket WHERE id = vTicketFk; SELECT routeFk INTO vRouteFk @@ -44118,7 +44217,7 @@ BEGIN ORDER BY friendshipSum DESC ) sub LIMIT 1; - + RETURN vRouteFk; END ;; DELIMITER ; @@ -44126,8 +44225,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `routeProposal_beta` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44135,6 +44232,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `routeProposal_beta`(vTicketFk INT) RETURNS int(11) READS SQL DATA @@ -44142,20 +44241,20 @@ BEGIN DECLARE vRouteFk INT; DECLARE vAddressFk INT; - + DECLARE vLanded DATE; DECLARE vZoneFk INT; DECLARE vSignificativeFriendship INT DEFAULT 6; DECLARE vVolumeMax DECIMAL(5,1) DEFAULT 10; - + SELECT addressFk, zoneFk, landed INTO vAddressFk, vZoneFk, vLanded - FROM vn.ticket + FROM vn.ticket WHERE id = vTicketFk; - + -- Se inicia la selección de rutas posibles con aquellas cuyas agencias alguna vez han estado asociadas con nuestra zona DROP TEMPORARY TABLE IF EXISTS tmp.route; CREATE TEMPORARY TABLE tmp.route - SELECT r.id routeFk, + SELECT r.id routeFk, zf.friendship zoneFriendship FROM vn.route r JOIN cache.zoneAgencyFriendship zf ON zf.agencyModeFk = r.agencyModeFk @@ -44163,16 +44262,16 @@ BEGIN AND zf.zoneFk = vZoneFk AND r.created = vLanded ORDER BY friendship; - + -- Se eliminan aquellas que superan el volumen máximo DELETE r.* - FROM tmp.route r + FROM tmp.route r JOIN (SELECT routeFk, sum(volume) volume FROM vn.saleVolume WHERE landed = vLanded GROUP BY routeFk) sub ON sub.routeFk = r.routeFk WHERE sub.volume > vVolumeMax; - + -- Se ordenan las que quedan en función con la afinidad del resto de consignatarios de cada ruta SELECT routeFk INTO vRouteFk FROM @@ -44184,7 +44283,7 @@ BEGIN ORDER BY zoneFriendship DESC, friendshipSum DESC ) sub LIMIT 1; - + RETURN vRouteFk; END ;; DELIMITER ; @@ -44192,8 +44291,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `specie_IsForbidden` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44201,38 +44298,38 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `specie_IsForbidden`(vItemFk INT, vAddressFk INT) RETURNS tinyint(1) READS SQL DATA BEGIN - + DECLARE vIsForbbiden BOOL; DECLARE vLeft INT; SELECT zg.lft INTO vLeft - FROM vn.address a - JOIN vn.zoneGeo zg ON zg.name = a.postalCode + FROM vn.address a + JOIN vn.zoneGeo zg ON zg.name = a.postalCode WHERE a.id = vAddressFk; - + SELECT sgi.isForbidden INTO vIsForbbiden - FROM vn.specieGeoInvasive sgi - JOIN vn.zoneGeo zg ON zg.id = sgi.zoneGeofk + FROM vn.specieGeoInvasive sgi + JOIN vn.zoneGeo zg ON zg.id = sgi.zoneGeofk JOIN vn.itemBotanical ib ON ib.genusFk = sgi.genusFk AND sgi.specieFk IN ('sp.',ib.specieFk) WHERE vLeft BETWEEN zg.lft AND zg.rgt AND ib.itemFk = vItemFk - ORDER BY zg.`depth` DESC + ORDER BY zg.`depth` DESC LIMIT 1; RETURN IFNULL(vIsForbbiden, FALSE); - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `testCIF` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44240,11 +44337,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `testCIF`(vCIF VARCHAR(9)) RETURNS varchar(10) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `testCIF`(vCIF VARCHAR(9)) RETURNS varchar(10) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN - + DECLARE vLetraInicial VARCHAR(1); DECLARE vLetraFinal VARCHAR(1); DECLARE vParteNumerica VARCHAR(7); @@ -44256,68 +44355,66 @@ BEGIN SET vLetraInicial = SUBSTR(vCIF, 1, 1); SET vLetraFinal = SUBSTR(vCIF, 9, 1); SET vParteNumerica = SUBSTR(vCIF, 2, 7); - - WHILE i < 7 DO - + + WHILE i < 7 DO + SET i = i + 1; - + SET vNumero = CAST(SUBSTR(vParteNumerica, i, 1) AS DECIMAL(1,0)); - + IF i MOD 2 THEN - + SET vNumero = vNumero * 2; SET vNumero = vNumero MOD 10 + FLOOR(vNumero/10); - + END IF; - + SET vSuma = vSuma + vNumero; - + END WHILE; - + SET vSuma = vSuma MOD 10; - + IF vSuma > 0 THEN - + SET vSuma = 10 - vSuma; - + END IF; - + -- Comprobación de dígito de control IF CAST(vLetraFinal AS DECIMAL(1,0)) = vSuma THEN - + SET vResult = TRUE; - + END IF; - + IF vSuma = 0 THEN - + SET vSuma = 10; - + END IF; - + IF CHAR(64 + vSuma) = vLetraFinal THEN - + SET vResult = TRUE; - + END IF; - + -- Sólo se aceptan letras como caracter inicial IF ASCII(vLetraInicial) < 65 OR ASCII(vLetraInicial) > 87 THEN -- Ha de ser entre la A y la W - + SET vResult = FALSE; - + END IF; - + RETURN vResult; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `testNIE` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44325,11 +44422,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `testNIE`(vNIE VARCHAR(9)) RETURNS tinyint(1) DETERMINISTIC BEGIN - + DECLARE vIndice INT; DECLARE vNumero VARCHAR(7); DECLARE vOperador VARCHAR(9); @@ -44338,53 +44437,51 @@ BEGIN DECLARE vLetraFinal VARCHAR(1); DECLARE vLetrasFinalesPosibles VARCHAR(24) DEFAULT "TRWAGMYFPDXBNJZSQVHLCKE"; DECLARE vLetraInicialEsIncorrecta BOOL DEFAULT FALSE; - + SET vLetraInicial = SUBSTR(vNIE, 1, 1); SET vLetraFinal = SUBSTR(vNIE, 9, 1); SET vNumero = SUBSTR(vNIE, 2, 7); CASE vLetraInicial - + WHEN 'X' THEN - + SET vOperador = "0"; - + WHEN 'Y' THEN - + SET vOperador = "1"; - + WHEN 'Z' THEN - + SET vOperador = "2"; - + ELSE - + SET vLetraInicialEsIncorrecta = TRUE; - + END CASE; - + SET vOperador = CONCAT(vOperador, vNumero); SET vParteNumerica = CAST(vOperador AS DECIMAL(8,0)); SET vIndice = Round(vParteNumerica Mod 23, 0) + 1; IF SUBSTR(vLetrasFinalesPosibles, vIndice, 1) = vLetraFinal AND vLetraInicialEsIncorrecta = FALSE 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `testNIF` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44392,6 +44489,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `testNIF`(vNIF VARCHAR(9)) RETURNS tinyint(1) DETERMINISTIC @@ -44401,31 +44500,29 @@ BEGIN DECLARE vParteNumerica DECIMAL(8,0); DECLARE vLetra VARCHAR(1); DECLARE vLetrasPosibles VARCHAR(24) DEFAULT "TRWAGMYFPDXBNJZSQVHLCKE"; - + SET vLetra = SUBSTRING(vNIF, 9, 1); - + SET vParteNumerica = CAST(SUBSTRING(vNIF, 1, 8) AS DECIMAL(8,0)); - + SET vIndice = Round(vParteNumerica MOD 23, 0) + 1; - + If SUBSTRING(vLetrasPosibles, vIndice, 1) = vLetra 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `ticketCollection_getNoPacked` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44433,25 +44530,27 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticketCollection_getNoPacked`(vCollectionFk INT) RETURNS varchar(100) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `ticketCollection_getNoPacked`(vCollectionFk INT) RETURNS varchar(100) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN - + /* * return message with tickets and collection if there is tickets of a collection without expeditions - * + * * @param vCollectionFk the collection to check * @return an array with collection and tickets without expeditions - * + * */ - + DECLARE vAnswer VARCHAR(100) DEFAULT ''; IF collection_isPacked(vCollectionFk) = FALSE THEN SELECT CONCAT('Colección: ',tc.collectionFk,' Tickets: ' , GROUP_CONCAT(tc.ticketFk) ) INTO vAnswer FROM vn.ticketCollection tc - LEFT JOIN vn.expedition e ON e.ticketFk = tc.ticketFk + LEFT JOIN vn.expedition e ON e.ticketFk = tc.ticketFk WHERE tc.collectionFk = vCollectionFk AND ISNULL(e.id); END IF; @@ -44463,8 +44562,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `ticketGetTotal` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44472,6 +44569,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `ticketGetTotal`(vTicketId INT) RETURNS decimal(10,2) READS SQL DATA @@ -44497,17 +44596,15 @@ BEGIN DROP TEMPORARY TABLE tmp.ticket, tmp.ticketTotal; - + RETURN vTotal; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `ticketPositionInPath` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44515,11 +44612,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticketPositionInPath`(vTicketId INT) RETURNS varchar(10) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `ticketPositionInPath`(vTicketId INT) RETURNS varchar(10) CHARSET utf8mb3 DETERMINISTIC BEGIN - + DECLARE vRestTicketsMaxOrder INT; DECLARE vRestTicketsMinOrder INT; DECLARE vRestTicketsPacking INT; @@ -44531,7 +44630,7 @@ BEGIN DECLARE vExpeditionsCount INT; DECLARE vIsValenciaPath BOOLEAN DEFAULT FALSE; -SELECT `order` +SELECT `order` INTO PACKING_ORDER FROM state WHERE code = 'PACKING'; @@ -44542,7 +44641,7 @@ SELECT t.routeFk, t.warehouseFk, IFNULL(ts.productionOrder,0) LEFT JOIN ticketState ts on ts.ticket = t.id WHERE t.id = vTicketId; -SELECT (ag.`name` = 'VN_VALENCIA') +SELECT (ag.`name` = 'VN_VALENCIA') INTO vIsValenciaPath FROM vn2008.Rutas r JOIN vn2008.Agencias a on a.Id_Agencia = r.Id_Agencia @@ -44556,7 +44655,7 @@ IF vIsValenciaPath THEN -- Rutas Valencia FROM expedition e JOIN ticket t ON t.id = e.ticketFk WHERE t.routeFk = vMyPath; - + SELECT MAX(ts.productionOrder), MIN(ts.productionOrder) INTO vRestTicketsMaxOrder, vRestTicketsMinOrder FROM ticket t @@ -44565,7 +44664,7 @@ IF vIsValenciaPath THEN -- Rutas Valencia AND t.warehouseFk = vMyWarehouse AND t.id != vTicketid; - SELECT COUNT(*) + SELECT COUNT(*) INTO vRestTicketsPacking FROM ticket t LEFT JOIN ticketState ts on t.id = ts.ticket @@ -44597,8 +44696,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `ticketSplitCounter` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44606,8 +44703,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticketSplitCounter`(vTicketFk INT) RETURNS varchar(15) CHARSET utf8 +CREATE DEFINER=`root`@`localhost` FUNCTION `ticketSplitCounter`(vTicketFk INT) RETURNS varchar(15) CHARSET utf8mb3 READS SQL DATA BEGIN DECLARE vSplitCounter VARCHAR(15); @@ -44620,17 +44719,15 @@ BEGIN LEFT JOIN vn2008.movement_label l ON l.Id_Movimiento = s.id WHERE ticketFk = vTicketFk ) sub; - + RETURN IFNULL(vSplitCounter,'--'); - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `ticketTotalVolume` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44638,6 +44735,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `ticketTotalVolume`(vTicketId INT) RETURNS decimal(10,3) READS SQL DATA @@ -44657,8 +44756,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `ticketTotalVolumeBoxes` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44666,26 +44763,28 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `ticketTotalVolumeBoxes`(vTicketId INT) RETURNS decimal(10,1) DETERMINISTIC BEGIN -/* +/* * Devuelve el volumen estimado del ticket sumado, en cajas * * vTicketId Numero de ticket - * + * */ DECLARE vVolumeBoxM3 DOUBLE; DECLARE vTicketTotalVolumeBoxes DECIMAL(10,1); DECLARE vVnBoxId VARCHAR(10) DEFAULT '94'; - + SELECT volume / 1000000 INTO vVolumeBoxM3 FROM packaging WHERE id = vVnBoxId; - + SET vTicketTotalVolumeBoxes = ticketTotalVolume(vTicketId) / vVolumeBoxM3; - + RETURN vTicketTotalVolumeBoxes; END ;; @@ -44694,8 +44793,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `ticketWarehouseGet` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44703,6 +44800,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `ticketWarehouseGet`(vTicketFk INT) RETURNS int(11) READS SQL DATA @@ -44710,7 +44809,7 @@ BEGIN DECLARE vWarehouseFk INT; SELECT warehouseFk INTO vWarehouseFk - FROM ticket + FROM ticket WHERE id = vTicketFk; RETURN vWarehouseFk; @@ -44720,8 +44819,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `ticket_CC_volume` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44729,22 +44826,24 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_CC_volume`(vTicketFk INT) RETURNS decimal(10,1) READS SQL DATA BEGIN - + DECLARE vCC DECIMAL(10,1); SELECT sum(sv.volume * IF(i.itemPackingTypeFk = 'H', vc.dutchCompressionRate, 1)) / (p.volume / 1000000) INTO vCC - FROM vn.saleVolume sv - JOIN vn.sale s ON s.id = sv.saleFk - JOIN vn.item i ON i.id = s.itemFk + FROM vn.saleVolume sv + JOIN vn.sale s ON s.id = sv.saleFk + JOIN vn.item i ON i.id = s.itemFk JOIN vn.packaging p ON p.id = 'CC' - JOIN vn.volumeConfig vc + JOIN vn.volumeConfig vc WHERE sv.ticketFk = vTicketFk; - + RETURN vCC; END ;; @@ -44753,8 +44852,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `ticket_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44762,74 +44859,74 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_get`(vParamFk INT) RETURNS int(11) READS SQL DATA proc:BEGIN - + /* Devuelve el número de ticket o collection consultando en varias tablas posibles - * + * * @param vParamFk Número a validar * @return vValidFk Identificador validado */ - + DECLARE vValidFk INT; -- Tabla vn.saleGroup SELECT s.ticketFk INTO vValidFk FROM vn.sale s JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id - JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk + JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk WHERE sg.id = vParamFk - AND sg.created > TIMESTAMPADD(WEEK,-1, CURDATE()) + AND sg.created > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE()) LIMIT 1; - + IF vValidFk THEN - + RETURN vValidFk; - + LEAVE proc; - + END IF; -- Tabla vn.collection SELECT c.id INTO vValidFk - FROM vn.collection c + FROM vn.collection c WHERE c.id = vParamFk - AND c.created > TIMESTAMPADD(WEEK,-1, CURDATE()); - + AND c.created > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE()); + IF vValidFk THEN - + RETURN vValidFk; - + LEAVE proc; - + END IF; -- Tabla vn.ticket SELECT t.id INTO vValidFk FROM vn.ticket t WHERE t.id = vParamFk - AND t.shipped > TIMESTAMPADD(WEEK,-1, CURDATE()); - + AND t.shipped > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE()); + IF vValidFk THEN - + RETURN vValidFk; - + LEAVE proc; - + END IF; RETURN 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `ticket_getFreightCost` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44837,6 +44934,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_getFreightCost`(vTicketFk INT) RETURNS decimal(10,2) DETERMINISTIC @@ -44847,8 +44946,8 @@ BEGIN * @vTicketFk Id del ticket a calcular */ DECLARE deliveryPrice DECIMAL (10,2); - - IF (SELECT isVolumetric FROM ticket t JOIN zone z ON t.zoneFk = z.id + + IF (SELECT isVolumetric FROM ticket t JOIN zone z ON t.zoneFk = z.id WHERE t.id = vTicketFk) THEN SELECT SUM(sv.freight) INTO deliveryPrice FROM vn.saleVolume sv @@ -44859,7 +44958,7 @@ BEGIN LEFT JOIN expedition e ON e.ticketFk = t.id JOIN expeditionBoxVol ebv ON ebv.boxFk = e.isBox WHERE t.id = vTicketFk; - + END IF; RETURN deliveryPrice; END ;; @@ -44868,8 +44967,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `ticket_getWeight` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44877,22 +44974,24 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` 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 ;; @@ -44901,8 +45000,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `ticket_getWithParameters` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44910,6 +45007,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_getWithParameters`(vClientFk INT, vWarehouseFk INT, vShipped DATE, vAddressFk INT, vCompanyFk INT, vAgencyModeFk INT) RETURNS int(11) DETERMINISTIC @@ -44923,10 +45022,10 @@ BEGIN * @param vAddressFk Consignatario * @param vCompanyFk Empresa * @param vAgencyModeFk agencia - */ - + */ + DECLARE vTicket INT; - + SELECT t.id INTO vTicket FROM vn.ticket t WHERE (t.clientFk <=> vClientFk OR vClientFk IS NULL) @@ -44936,11 +45035,11 @@ BEGIN AND (t.companyFk <=> vCompanyFk OR vCompanyFk IS NULL) AND (t.agencyModeFk <=> vAgencyModeFk OR vAgencyModeFk IS NULL) LIMIT 1; - + IF vTicket IS NULL THEN CALL vn.ticket_add( vClientFk, - IFNULL(vShipped, CURDATE()), + IFNULL(vShipped, util.VN_CURDATE()), vWarehouseFk, vCompanyFk, vAddressFk, @@ -44952,7 +45051,7 @@ BEGIN vTicket ); END IF; - + RETURN vTicket; END ;; DELIMITER ; @@ -44960,8 +45059,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `ticket_HasUbication` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44969,19 +45066,21 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_HasUbication`(vTicketFk INT) RETURNS tinyint(1) READS SQL DATA BEGIN - + DECLARE hasUbication BOOL; SELECT COUNT(*) INTO hasUbication FROM vn.ticket t JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk - WHERE rm.beachFk + WHERE rm.beachFk AND t.id = vTicketFk; - + RETURN hasUbication; END ;; @@ -44990,8 +45089,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `till_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44999,9 +45096,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `till_new`( - vClient INT +CREATE DEFINER=`root`@`localhost` FUNCTION `till_new`(vClient INT ,vBank INT ,vAmount DOUBLE ,vConcept VARCHAR(25) @@ -45082,8 +45180,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `timeWorkerControl_getDirection` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45091,12 +45187,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `timeWorkerControl_getDirection`(vUserFk INT, vTimed DATETIME) RETURNS varchar(6) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`localhost` FUNCTION `timeWorkerControl_getDirection`(vUserFk INT, vTimed DATETIME) RETURNS varchar(6) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci READS SQL DATA BEGIN /** - * Verifica la dirección de la fichada + * Verifica la dirección de la fichada * @param vUserFk Identificador del trabajador * @param vTimed Hora de la fichada * @return Retorna sentido de la fichada 'in, out, middle' @@ -45109,40 +45207,40 @@ BEGIN DECLARE vDayStayMax INT; DECLARE vTimedSeconds INT; DECLARE vLastTimeIn INT; - + SELECT UNIX_TIMESTAMP(vTimed) INTO vTimedSeconds; - + SELECT dayStayMax INTO vDayStayMax FROM vn.workerTimeControlParams; SELECT timed, direction INTO vNext,vNextDirection - FROM vn.workerTimeControl - WHERE userFk = vUserFk + FROM vn.workerTimeControl + WHERE userFk = vUserFk AND direction IN ('in','out') AND timed > vTimed ORDER BY timed ASC LIMIT 1; - + SELECT timed, direction INTO vPrevious, vPreviousDirection - FROM vn.workerTimeControl - WHERE userFk = vUserFk + FROM vn.workerTimeControl + WHERE userFk = vUserFk AND direction IN ('in','out') AND timed < vTimed ORDER BY timed DESC - LIMIT 1; - - IF (vTimedSeconds - UNIX_TIMESTAMP(vPrevious) + UNIX_TIMESTAMP(vNext) - vTimedSeconds)<= vDayStayMax AND vPreviousDirection = 'in' AND vNextDirection = 'out' THEN + LIMIT 1; + + IF (vTimedSeconds - UNIX_TIMESTAMP(vPrevious) + UNIX_TIMESTAMP(vNext) - vTimedSeconds)<= vDayStayMax AND vPreviousDirection = 'in' AND vNextDirection = 'out' THEN RETURN 'middle'; END IF; - - + + IF (vTimedSeconds> UNIX_TIMESTAMP(vPrevious)) THEN - IF vPreviousDirection = 'in' THEN + IF vPreviousDirection = 'in' THEN RETURN 'out'; ELSE SELECT UNIX_TIMESTAMP(MAX(timed)) INTO vLastTimeIn - FROM vn.workerTimeControl - WHERE userFk = vUserFk + FROM vn.workerTimeControl + WHERE userFk = vUserFk AND direction ='in' AND timed < vPrevious; IF vTimedSeconds - vLastTimeIn <= vDayStayMax THEN @@ -45158,8 +45256,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `time_getSalesYear` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45167,6 +45263,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `time_getSalesYear`(vMonth INT, vYear INT) RETURNS int(11) DETERMINISTIC @@ -45183,8 +45281,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `travel_getForLogiflora` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45192,15 +45288,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `travel_getForLogiflora`(vLanded DATE, vWarehouseFk INT) RETURNS int(11) READS SQL DATA BEGIN - + /** * Devuelve un número de travel para compras de Logiflora a partir de la fecha de llegada y del almacén. * Si no existe lo genera. - * + * * @param vLanded Fecha de llegada al almacén * @param vWarehouseFk Identificador de vn.warehouse */ @@ -45208,8 +45306,8 @@ BEGIN DECLARE vTravelFk INT; IF vLanded THEN - - SELECT IFNULL(MAX(tr.id),0) INTO vTravelFk + + 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 @@ -45220,14 +45318,14 @@ BEGIN AND landed = vLanded; IF NOT vTravelFk THEN - + INSERT INTO vn.travel(landed, shipped, warehouseInFk, warehouseOutFk, agencyModeFk) - SELECT vLanded, curdate(), vWarehouseFk, wOut.id, am.id - FROM vn.warehouse wOut + SELECT vLanded, util.VN_CURDATE(), vWarehouseFk, wOut.id, am.id + FROM vn.warehouse wOut JOIN vn.agencyMode am ON am.name = 'LOGIFLORA' WHERE wOut.name = 'Holanda'; - - SELECT MAX(tr.id) INTO vTravelFk + + 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 @@ -45235,19 +45333,17 @@ BEGIN AND wOut.name = 'Holanda' AND landed = vLanded; END IF; - + END IF; - + 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `validationCode` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45255,6 +45351,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `validationCode`(vString VARCHAR(255)) RETURNS int(11) DETERMINISTIC @@ -45266,29 +45364,27 @@ BEGIN DECLARE vChar INT; SET vLength = length(vString); - + WHILE vLength > 0 DO - + SET vChar = MID(vString,vLength,1); - + SET vSeed = vSeed + ASCII(vChar); - + SET vLength = vLength - 1; - + END WHILE; SET vCode = FLOOR(SQRT(vSeed)*1000000) mod 1000; RETURN vCode; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `validationCode_beta` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45296,6 +45392,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `validationCode_beta`(vString VARCHAR(255)) RETURNS int(11) DETERMINISTIC @@ -45307,29 +45405,27 @@ BEGIN DECLARE vChar INT; SET vLength = length(vString); - + WHILE vLength > 0 DO - + SET vChar = MID(vString,vLength,1); - + SET vSeed = vSeed + ASCII(vChar); - + SET vLength = vLength - 1; - + END WHILE; SET vCode = FLOOR(SQRT(vSeed)*1000000) mod 1000; RETURN vCode; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `workerIsBoss` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45337,6 +45433,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `workerIsBoss`(vUserId INT) RETURNS int(11) DETERMINISTIC @@ -45387,8 +45485,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `workerMachinery_isRegistered` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45396,22 +45492,24 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` 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(*) + + 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 + AND m.inTimed >= TIMESTAMPADD(HOUR , -(SELECT maxHours from machineWorkerConfig), util.VN_NOW()) AND ISNULL(m.outTimed)) + THEN RETURN TRUE; ELSE RETURN FALSE; @@ -45423,8 +45521,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `workerNigthlyHours_calculate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45432,6 +45528,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `workerNigthlyHours_calculate`(vTimeIn DATETIME, vTimeOut DATETIME) RETURNS decimal(5,2) READS SQL DATA @@ -45443,15 +45541,15 @@ BEGIN * @param vTimeOut * @return vNigthlyHours */ - DECLARE vNigthlyHours DECIMAL(5,2); + DECLARE vNigthlyHours DECIMAL(5,2); DECLARE vSecondsPerHour INT(4) DEFAULT 3600; - + SELECT GREATEST(0, TIMESTAMPDIFF(SECOND, - IF(TIME(vTimeIn) BETWEEN endNightlyHours AND startNightlyHours, - CONCAT(DATE(vTimeIn), ' ', startNightlyHours), + IF(TIME(vTimeIn) BETWEEN endNightlyHours AND startNightlyHours, + CONCAT(DATE(vTimeIn), ' ', startNightlyHours), vTimeIn), - IF(TIME(vTimeOut) BETWEEN endNightlyHours AND startNightlyHours, - CONCAT(DATE(vTimeOut), ' ', endNightlyHours), + IF(TIME(vTimeOut) BETWEEN endNightlyHours AND startNightlyHours, + CONCAT(DATE(vTimeOut), ' ', endNightlyHours), vTimeOut))) / vSecondsPerHour INTO vNigthlyHours FROM vn.workerTimeControlConfig; @@ -45462,8 +45560,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `workerTimeControl_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45471,8 +45567,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `workerTimeControl_add`( vUserFk INT, vWarehouseFk INT, vTimed DATETIME, vIsManual BOOL) RETURNS int(11) +CREATE DEFINER=`root`@`localhost` FUNCTION `workerTimeControl_add`(vUserFk INT, vWarehouseFk INT, vTimed DATETIME, vIsManual BOOL) RETURNS int(11) DETERMINISTIC BEGIN DECLARE vDirection VARCHAR(6); @@ -45483,47 +45581,47 @@ BEGIN SELECT dayStayMax INTO vDayStayMax FROM workerTimeControlParams; - + SELECT timeWorkerControl_getDirection(vUserFk,vTimed) INTO vDirection; IF vDirection = 'out' THEN - + SELECT MAX(timed) INTO vLastIn - FROM workerTimeControl - WHERE userFk = vUserFk + FROM workerTimeControl + WHERE userFk = vUserFk AND direction = 'in' AND timed < vTimed; - + UPDATE workerTimeControl wtc SET wtc.direction = 'middle' WHERE userFk = vUserFk AND direction = 'out' AND timed BETWEEN vLastIn AND vTimed; - + ELSE IF vDirection = 'in' THEN - - SELECT COUNT(*) INTO vHasDirectionOut + + SELECT COUNT(*) INTO vHasDirectionOut FROM workerTimeControl wtc - WHERE userFk = vUserFk + WHERE userFk = vUserFk AND direction = 'out' - AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed); + AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed); UPDATE workerTimeControl wtc SET wtc.direction = IF (vHasDirectionOut,'middle','out') WHERE userFk = vUserFk AND direction = 'in' - AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed); + AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed); END IF; END IF; - + INSERT INTO workerTimeControl(userFk, timed, warehouseFk, direction, manual) VALUES(vUserFk, vTimed, vWarehouseFk, vDirection, vIsManual); - + SET vLastInsertedId = LAST_INSERT_ID(); - + CALL workerTimeControlSOWP(vUserFk, vTimed); - + RETURN vLastInsertedId; END ;; DELIMITER ; @@ -45531,8 +45629,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `workerTimeControl_addDirection` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45540,8 +45636,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `workerTimeControl_addDirection`( vUserFk INT, vWarehouseFk INT, vTimed DATETIME, vIsManual BOOL) RETURNS int(11) +CREATE DEFINER=`root`@`localhost` FUNCTION `workerTimeControl_addDirection`(vUserFk INT, vWarehouseFk INT, vTimed DATETIME, vIsManual BOOL) RETURNS int(11) DETERMINISTIC BEGIN DECLARE vDirection VARCHAR(6); @@ -45552,47 +45650,47 @@ BEGIN SELECT dayStayMax INTO vDayStayMax FROM workerTimeControlParams; - + SELECT timeWorkerControl_getDirection(vUserFk,vTimed) INTO vDirection; IF vDirection = 'out' THEN - + SELECT MAX(timed) INTO vLastIn - FROM workerTimeControl - WHERE userFk = vUserFk + FROM workerTimeControl + WHERE userFk = vUserFk AND direction = 'in' AND timed < vTimed; - + UPDATE workerTimeControl wtc SET wtc.direction = 'middle' WHERE userFk = vUserFk AND direction = 'out' AND timed BETWEEN vLastIn AND vTimed; - + ELSE IF vDirection = 'in' THEN - - SELECT COUNT(*) INTO vHasDirectionOut + + SELECT COUNT(*) INTO vHasDirectionOut FROM workerTimeControl wtc - WHERE userFk = vUserFk + WHERE userFk = vUserFk AND direction = 'out' - AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed); + AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed); UPDATE workerTimeControl wtc SET wtc.direction = IF (vHasDirectionOut,'middle','out') WHERE userFk = vUserFk AND direction = 'in' - AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed); + AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed); END IF; END IF; - + INSERT INTO workerTimeControl(userFk, timed, warehouseFk, direction, manual) VALUES(vUserFk, vTimed, vWarehouseFk, vDirection, vIsManual); - + SET vLastInsertedId = LAST_INSERT_ID(); - + CALL workerTimeControlSOWP(vUserFk, vTimed); - + RETURN vLastInsertedId; END ;; DELIMITER ; @@ -45600,8 +45698,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `worker_isWorking` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45609,6 +45705,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `worker_isWorking`(vWorkerFk INT) RETURNS tinyint(1) READS SQL DATA @@ -45618,17 +45716,17 @@ BEGIN * @return Devuelve TRUE en caso de que este trabajando. Si se encuentra en un descanso devolverá FALSE */ DECLARE vLastIn DATETIME ; - + SELECT MAX(timed) INTO vLastIn - FROM vn.workerTimeControl + FROM vn.workerTimeControl WHERE userFk = vWorkerFk AND direction = 'in'; - IF (SELECT MOD(COUNT(*),2) - FROM vn.workerTimeControl - WHERE userFk = vWorkerFk AND + IF (SELECT MOD(COUNT(*),2) + FROM vn.workerTimeControl + WHERE userFk = vWorkerFk AND timed >= vLastIn - ) THEN + ) THEN RETURN TRUE; ELSE RETURN FALSE; @@ -45639,8 +45737,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `xdiario_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45648,9 +45744,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `xdiario_new`( - vAsiento INT, +CREATE DEFINER=`root`@`localhost` FUNCTION `xdiario_new`(vAsiento INT, vDated DATE, vSubaccount VARCHAR(12), vAccount VARCHAR(12), @@ -45695,8 +45792,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `zoneGeo_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45704,6 +45799,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `zoneGeo_new`(vType VARCHAR(255), vName VARCHAR(255), vParentFk INT) RETURNS int(11) NO SQL @@ -45723,7 +45820,7 @@ BEGIN SET `type` = vType, `name` = vName, parentFk = vParentFk; - + SET vSelf = LAST_INSERT_ID(); UPDATE zoneGeoRecalc SET isChanged = TRUE; @@ -45735,8 +45832,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `addNoteFromDelivery` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45744,10 +45839,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `addNoteFromDelivery`(idTicket INT,nota TEXT) BEGIN - + DECLARE observationTypeFk INT DEFAULT 3; /*3 = REPARTIDOR*/ INSERT INTO ticketObservation(ticketFk,observationTypeFk,description) @@ -45761,8 +45858,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `addressTaxArea` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45770,29 +45865,31 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `addressTaxArea`() READS SQL DATA BEGIN /** - * Devuelve el taxArea para un conjunto de Consignatarios y empresas, + * Devuelve el taxArea para un conjunto de Consignatarios y empresas, * * @table tmp.addressCompany(addressFk, companyFk) valores a calcular * @return tmp.addressTaxArea(addressFk,companyFk) */ DECLARE vSpainCountryCode INT DEFAULT 1; - + DROP TEMPORARY TABLE IF EXISTS tmp.addressTaxArea; CREATE TEMPORARY TABLE tmp.addressTaxArea (PRIMARY KEY (addressFk, companyFk)) ENGINE = MEMORY - SELECT CASE - WHEN (NOT cClient.isUeeMember OR NOT cSupplier.isUeeMember) AND s.countryFk != c.countryFk THEN + SELECT CASE + WHEN (NOT cClient.isUeeMember OR NOT cSupplier.isUeeMember) AND s.countryFk != c.countryFk THEN 'WORLD' - WHEN cClient.isUeeMember AND cSupplier.isUeeMember AND c.countryFk != s.countryFk AND c.isVies THEN + WHEN cClient.isUeeMember AND cSupplier.isUeeMember AND c.countryFk != s.countryFk AND c.isVies THEN 'CEE' - WHEN a.isEqualizated AND c.countryFk = vSpainCountryCode THEN + WHEN a.isEqualizated AND c.countryFk = vSpainCountryCode THEN 'EQU' ELSE 'NATIONAL' @@ -45809,8 +45906,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `agencyHourGetFirstShipped` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45818,6 +45913,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyHourGetFirstShipped`(vAgencyMode INT, vAddress INT, vWarehouse INT) BEGIN @@ -45829,27 +45926,27 @@ BEGIN * @param vAddress id de la direccion * @param vWarehouse id del warehouse * @return vShipped la primera fecha disponible y vLanded la fecha de llegada/recojida -*/ +*/ DECLARE vAgency INT; DECLARE vShipped DATE; -DECLARE vLanded DATE DEFAULT CURDATE(); +DECLARE vLanded DATE DEFAULT util.VN_CURDATE(); SELECT agencyFk INTO vAgency FROM agencyMode WHERE id= vAgencyMode; l: LOOP - + CALL agencyHourGetShipped(vLanded,vAddress,vAgency); - SELECT shipped INTO vShipped + SELECT shipped INTO vShipped FROM tmp.agencyHourGetShipped WHERE warehouseFk = vWarehouse LIMIT 1; - + IF vShipped THEN LEAVE l; END IF; - + SET vLanded = DATE_ADD(vLanded, INTERVAL +1 DAY); - + END LOOP; - + SELECT vShipped,vLanded; END ;; DELIMITER ; @@ -45857,8 +45954,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `agencyHourGetLanded` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45866,6 +45961,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyHourGetLanded`(vDated DATE, vAddress INT, vAgency INT, vWarehouse INT) BEGIN @@ -45899,16 +45996,14 @@ BEGIN ) t LIMIT 1 ) t - WHERE IF(vDated = CURDATE(), t.maxHour > HOUR(NOW()), TRUE) AND t.substractDay < 225; - + WHERE IF(vDated = util.VN_CURDATE(), t.maxHour > HOUR(util.VN_NOW()), TRUE) AND t.substractDay < 225; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `agencyHourGetWarehouse` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45916,6 +46011,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyHourGetWarehouse`(vAddress INT, vDate DATE, vWarehouse INT) BEGIN @@ -45923,14 +46020,14 @@ BEGIN * DEPRECATED usar zoneGetWarehouse * Devuelve el listado de agencias disponibles para la fecha, * dirección y warehouuse pasadas - * + * * @param vAddress no puede ser NULL * @param vWarehouse warehouse donde comprobaremos las agencias y fecha * @param vDate Fecha de recogida * @table agencyModeWarehouseList Listado de agencias disponibles */ DECLARE vAgency INT; - DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vDone BOOL DEFAULT FALSE; DECLARE vCur CURSOR FOR SELECT DISTINCT a.id FROM agency a @@ -45954,13 +46051,13 @@ BEGIN PRIMARY KEY(id) ) ENGINE = MEMORY; - + OPEN vCur; FETCH vCur INTO vAgency; WHILE NOT vDone DO - + INSERT INTO tmp.agencyModeWarehouseList SELECT am.id, am.name, am.description,am.deliveryMethodFk, TIMESTAMPADD(DAY, -ah.substractDay, vDate), w.name FROM agencyHour ah @@ -45975,8 +46072,8 @@ BEGIN AND (ah.provinceFk = a.provinceFk OR ah.provinceFk IS NULL OR vAddress IS NULL) - AND TIMESTAMPADD(DAY, -ah.substractDay, vDate) >= CURDATE() - AND IF(TIMESTAMPADD(DAY, -ah.substractDay, vDate) = CURDATE(), ah.maxHour > HOUR(NOW()), TRUE) + AND TIMESTAMPADD(DAY, -ah.substractDay, vDate) >= util.VN_CURDATE() + AND IF(TIMESTAMPADD(DAY, -ah.substractDay, vDate) = util.VN_CURDATE(), ah.maxHour > HOUR(util.VN_NOW()), TRUE) ORDER BY ( (ah.weekDay IS NOT NULL) + (ah.agencyFk IS NOT NULL) + @@ -45989,7 +46086,7 @@ BEGIN END WHILE; CLOSE vCur; - + SELECT * FROM tmp.agencyModeWarehouseList; DROP TEMPORARY TABLE tmp.agencyModeWarehouseList; END ;; @@ -45998,8 +46095,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `agencyHourListGetShipped` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46007,6 +46102,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyHourListGetShipped`(vDate DATE, vAddress INT, vAgency INT) BEGIN @@ -46015,17 +46112,15 @@ BEGIN CALL vn.agencyHourGetShipped(vDate, vAddress, vAgency); SELECT * FROM tmp.agencyHourGetShipped; - + DROP TEMPORARY TABLE IF EXISTS tmp.agencyHourGetShipped; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `available_calc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46033,6 +46128,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `available_calc`( vDate DATE, @@ -46055,7 +46152,7 @@ BEGIN DECLARE cWarehouses CURSOR FOR SELECT warehouseFk, shipped FROM tmp.zoneGetShipped; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -46064,7 +46161,7 @@ BEGIN CALL vn.zone_getShipped (vDate, vAddress, vAgencyMode, FALSE); DROP TEMPORARY TABLE IF EXISTS tmp.availableCalc; - CREATE TEMPORARY TABLE tmp.availableCalc( + CREATE TEMPORARY TABLE tmp.availableCalc( calcFk INT UNSIGNED, PRIMARY KEY (calcFk) ) @@ -46075,7 +46172,7 @@ BEGIN l: LOOP SET vDone = FALSE; FETCH cWarehouses INTO vWarehouse, vShipment; - + IF vDone THEN LEAVE l; END IF; @@ -46094,8 +46191,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `bankEntity_checkBic` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46103,12 +46198,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `bankEntity_checkBic`(vBic VARCHAR(255)) BEGIN /** * If the bic length is Incorrect throw exception - * + * * @param vBic bic code */ @@ -46116,7 +46213,7 @@ BEGIN SELECT bicLength INTO vConfigBicLenght FROM vn.bankEntityConfig bec; - + IF LENGTH(vBic) <> vConfigBicLenght THEN CALL util.throw(CONCAT('bic must be of length ', vConfigBicLenght )); END IF; @@ -46126,8 +46223,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `bankPolicy_notifyExpired` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46135,6 +46230,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `bankPolicy_notifyExpired`() BEGIN @@ -46143,26 +46240,24 @@ BEGIN * Manda correo cuando caduca un seguro * de los leasing * -*/ +*/ INSERT INTO mail (receiver,replyTo,subject,body) SELECT 'administracion@verdnatura.es' receiver, '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 - FROM vn.bankPolicy bp - LEFT JOIN vn.supplier s + 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(); + WHERE bp.insuranceExpired = util.VN_CURDATE(); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `buyUltimate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46170,6 +46265,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `buyUltimate`(vWarehouseFk SMALLINT, vDated DATE) BEGIN @@ -46191,7 +46288,7 @@ BEGIN FROM cache.last_buy WHERE warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL; - CALL buyUltimateFromInterval(vWarehouseFk, CURDATE(), vDated); + CALL buyUltimateFromInterval(vWarehouseFk, util.VN_CURDATE(), vDated); REPLACE INTO tmp.buyUltimate SELECT itemFk, buyFk, warehouseFk, landed landing @@ -46211,8 +46308,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `buyUltimateFromInterval` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46220,11 +46315,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `buyUltimateFromInterval`(vWarehouseFk SMALLINT, vStarted DATE, vEnded DATE) BEGIN /** - * Calcula las últimas compras realizadas + * Calcula las últimas compras realizadas * desde un rango de fechas. * * @param vWarehouseFk Id del almacén si es NULL se actualizan todos @@ -46235,21 +46332,21 @@ BEGIN IF vEnded IS NULL THEN SET vEnded = vStarted; END IF; - + IF vEnded < vStarted THEN SET vStarted = TIMESTAMPADD(MONTH, -1, vEnded); END IF; -- Item - + DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval (PRIMARY KEY (itemFk, warehouseFk), INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) ENGINE = MEMORY - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - MULTIMAX(t.landed, b.id) buyFk, + SELECT + b.itemFk, + t.warehouseInFk warehouseFk, + MULTIMAX(t.landed, b.id) buyFk, MAX(t.landed) landed FROM buy b JOIN entry e ON e.id = b.entryFk @@ -46260,12 +46357,12 @@ BEGIN AND NOT b.isIgnored AND b.quantity > 0 GROUP BY itemFk, warehouseInFk; - + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, + SELECT + b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, t.landed FROM buy b JOIN entry e ON e.id = b.entryFk @@ -46275,12 +46372,12 @@ BEGIN AND b.price2 > 0 AND NOT b.isIgnored GROUP BY itemFk, warehouseInFk; - + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, + SELECT + b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, t.landed FROM buy b JOIN entry e ON e.id = b.entryFk @@ -46289,16 +46386,16 @@ BEGIN AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) AND b.quantity = 0 GROUP BY itemFk, warehouseInFk; - - - + + + -- ItemOriginal - + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - MULTIMAX(t.landed, b.id) buyFk, + SELECT + b.itemFk, + t.warehouseInFk warehouseFk, + MULTIMAX(t.landed, b.id) buyFk, MAX(t.landed) landed FROM buy b JOIN entry e ON e.id = b.entryFk @@ -46310,12 +46407,12 @@ BEGIN AND b.quantity > 0 AND itemOriginalFk GROUP BY itemOriginalFk, warehouseInFk; - + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, + SELECT + b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, t.landed FROM buy b JOIN entry e ON e.id = b.entryFk @@ -46326,12 +46423,12 @@ BEGIN AND NOT b.isIgnored AND itemOriginalFk GROUP BY itemOriginalFk, warehouseInFk; - + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, + SELECT + b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, t.landed FROM buy b JOIN entry e ON e.id = b.entryFk @@ -46341,15 +46438,13 @@ BEGIN AND b.quantity = 0 AND itemOriginalFk GROUP BY itemOriginalFk, warehouseInFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `buy_afterUpsert` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46357,6 +46452,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_afterUpsert`(vSelf INT) BEGIN @@ -46373,14 +46470,29 @@ BEGIN DECLARE vWarehouseOut INT; DECLARE vIsMerchandise BOOL; DECLARE vIsFeedStock BOOL; - - SELECT b.entryFk, b.itemFk, i.packingOut, ic.merchandise, vc.standardFlowerBox - INTO vEntryFk, vItemFk, vPackingOut, vIsMerchandise, vStandardFlowerBox + DECLARE vWeight DECIMAL(10,2); + DECLARE vPacking INT; + + SELECT b.entryFk, + b.itemFk, + i.packingOut, + ic.merchandise, + vc.standardFlowerBox, + b.weight, + b.packing + INTO + vEntryFk, + vItemFk, + vPackingOut, + vIsMerchandise, + vStandardFlowerBox, + vWeight, + vPacking FROM buy b LEFT JOIN item i ON i.id = b.itemFk LEFT JOIN itemType it ON it.id = i.typeFk LEFT JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN packaging p ON p.id = b.packageFk AND NOT p.isBox + LEFT JOIN packaging p ON p.id = b.packageFk AND NOT p.isBox JOIN volumeConfig vc ON TRUE WHERE b.id = vSelf; @@ -46398,17 +46510,16 @@ BEGIN 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 - SET ic.grams = b.weight * 1000 / b.packing - WHERE ic.itemFk = vItemFk AND - ic.warehouseFk = vWarehouse; - + IF vWeight AND vPacking THEN + UPDATE itemCost SET + grams = vWeight * 1000 / vPacking + WHERE itemFk = vItemFk + AND warehouseFk = vWarehouse; + END IF; END IF; SELECT isFeedStock INTO vIsFeedStock - FROM warehouse WHERE id = vWarehouseOut AND id <> 13; + FROM warehouse WHERE id = vWarehouseOut; IF vIsFeedStock THEN INSERT IGNORE INTO producer(`name`) @@ -46419,15 +46530,13 @@ BEGIN WHERE b.id = vSelf; END IF; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `buy_checkGrouping` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46435,6 +46544,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_checkGrouping`(vGrouping INT) BEGIN @@ -46453,8 +46564,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `buy_getSplit` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46462,12 +46571,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_getSplit`(vSelf INT, vDated DATE) BEGIN /** * Devuelve las ventas de una compra - * + * * @param vSelf Identificador de vn.buy */ DECLARE vItemFk INT; @@ -46554,11 +46665,11 @@ BEGIN SELECT sp.labels, COALESCE(sfc.nickname, sfa.nickname, a.nickname) destination, - s.itemFk, - i.longName, - i.`size`, - vn.ticketSplitCounter(t.id) counter, - IF(sfa.id OR sfc.id, + s.itemFk, + i.longName, + i.`size`, + vn.ticketSplitCounter(t.id) counter, + IF(sfa.id OR sfc.id, a.nickname, CONCAT(a.id, ' ', p.`name`,' (', c.`code`,')')) destination2 FROM tmp.split sp @@ -46583,8 +46694,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `buy_getVolume` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46592,6 +46701,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_getVolume`() BEGIN @@ -46604,12 +46715,12 @@ BEGIN 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 ) * item_getVolume(b.itemFk, b.packageFk)) / vc.palletM3 / 1000000,1) AS DECIMAL(10,2)) espais - FROM buy b + FROM buy b JOIN tmp.buy tb ON tb.buyFk = b.id 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 + LEFT JOIN temperature t ON t.code = it.temperatureFk GROUP BY Temp; END ;; DELIMITER ; @@ -46617,8 +46728,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `buy_getVolumeByAgency` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46626,32 +46735,32 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_getVolumeByAgency`(vDated DATE, vAgencyFk INT) BEGIN - + DROP TEMPORARY TABLE IF EXISTS tmp.buy; CREATE TEMPORARY TABLE tmp.buy (buyFk INT NOT NULL, PRIMARY KEY (buyFk)) ENGINE = MEMORY; - INSERT INTO tmp.buy + INSERT INTO tmp.buy SELECT b.id - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk WHERE t.landed = vDated AND t.agencyModeFk IN (0, vAgencyFk); CALL buy_getVolume(); DROP TEMPORARY TABLE tmp.buy; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `buy_getVolumeByEntry` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46659,30 +46768,30 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_getVolumeByEntry`(vEntryFk INT) BEGIN - + DROP TEMPORARY TABLE IF EXISTS tmp.buy; CREATE TEMPORARY TABLE tmp.buy (buyFk INT NOT NULL, PRIMARY KEY (buyFk)) ENGINE = MEMORY; - - INSERT INTO tmp.buy + + INSERT INTO tmp.buy SELECT b.id - FROM buy b - JOIN entry e ON e.id = b.entryFk + FROM buy b + JOIN entry e ON e.id = b.entryFk WHERE e.id = vEntryFk; CALL buy_getVolume(); DROP TEMPORARY TABLE tmp.buy; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `buy_recalcPrices` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46690,31 +46799,34 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_recalcPrices`() BEGIN --- Preparar para que proveedores como el 4 no puedan ser recalculadas sus entradas /** * Recalcula los precios para las compras insertadas en tmp.buyRecalc * * @param tmp.buyRecalc (id) - */ + */ DECLARE vLanded DATE; - DECLARE vWarehouseFk INT; - DECLARE vFallo BOOL; - DECLARE vBuyingValue DECIMAL(10,3); - DECLARE vPackageFk VARCHAR(10); - - SELECT t.landed, t.warehouseInFk INTO vLanded, vWarehouseFk + DECLARE vWarehouseFk INT; + DECLARE vHasNotPrice BOOL; + DECLARE vBuyingValue DECIMAL(10,3); + DECLARE vPackageFk VARCHAR(10); + DECLARE vIsWarehouseFloramondo BOOL; + + SELECT t.landed, t.warehouseInFk, (w.`name` = 'Floramondo') + INTO vLanded, vWarehouseFk, vIsWarehouseFloramondo FROM tmp.buyRecalc br JOIN buy b ON b.id = br.id - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + JOIN warehouse w ON w.id = t.warehouseInFk LIMIT 1; - CALL vn.rate_getPrices(vLanded, vWarehouseFk); - - -- quitado los cubos a floramondo revisar en buy_tarifas_entry + CALL rate_getPrices(vLanded, vWarehouseFk); + UPDATE buy b JOIN tmp.buyRecalc br ON br.id = b.id AND (@buyId := b.id) LEFT JOIN packaging p ON p.id = b.packageFk @@ -46722,38 +46834,22 @@ BEGIN JOIN entry e ON e.id = b.entryFk JOIN itemType it ON it.id = i.typeFk JOIN travel tr ON tr.id = e.travelFk - JOIN agencyMode am ON am.id = tr.agencyModeFk + JOIN agencyMode am ON am.id = tr.agencyModeFk JOIN tmp.rate r - SET b.freightValue = @PF:= - ROUND(IFNULL(((am.m3 * @cm3:= item_getVolume(b.itemFk, b.packageFk)) / 1000000) / b.packing,0),3), + JOIN volumeConfig vc + SET b.freightValue = @PF:= IFNULL(((am.m3 * @m3:= item_getVolume(b.itemFk, b.packageFk) / 1000000) + / b.packing) * IF(am.hasWeightVolumetric, GREATEST(b.weight / @m3 / vc.aerealVolumetricDensity, 1), 1), 0), b.comissionValue = @CF:= ROUND(IFNULL(e.commission * b.buyingValue / 100, 0), 3), - b.packageValue = @EF:= IF(p.isPackageReturnable != 0, 0, ROUND(IFNULL(p.`value` / b.packing ,0),3)), + b.packageValue = @EF:= IF(vIsWarehouseFloramondo, 0, IFNULL(ROUND(IF(p.isPackageReturnable, p.returnCost / b.packing , p.`value` / b.packing), 3),0)), b.price3 = @t3:= IF(r.rate3 = 0, b.buyingValue,ROUND((b.buyingValue + @CF + @EF + @PF) / ((100 - r.rate3 - it.promo ) /100) ,2)), -- He añadido que el coste sea igual a tarifa3 si t3 = 0 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 vHasNotPrice, vBuyingValue, vPackageFk FROM vn.buy b WHERE b.id = @buyId AND b.buyingValue <> 0.01; - - IF vFallo THEN - - CALL `vn`.`mail_insert`('cau@verdnatura.es', - NULL, - CONCAT('Fallo en buy_recalcPrices buy.id = ', @buyId), - CONCAT( ' @t3 = ', @t3, - ' @t2 = ', @t2, - ' @PF = ', @PF, - ' @EF = ', @EF, - ' @CF = ', @CF, - ' buyingValue = ', vBuyingValue, - ' packageFk = ', vPackageFk - ) - ); - - END IF; - + DROP TEMPORARY TABLE tmp.rate; END ;; DELIMITER ; @@ -46761,8 +46857,107 @@ 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 `buy_recalcPricesByAwb` */; +/*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_recalcPricesByAwb`(IN awbFk varchar(18)) +BEGIN +/** + * inserta en tmp.buyRecalc las compras de un awb + * + * @param awbFk + */ + DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc; + + CREATE TEMPORARY TABLE tmp.buyRecalc + SELECT b.id + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN duaEntry de ON de.entryFk = e.id + JOIN dua d ON d.id = de.duaFk + JOIN awb a ON a.id = d.awbFk + WHERE a.code = awbFk; + + CALL buy_recalcPrices(); + + DROP TEMPORARY TABLE tmp.buyRecalc; +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_recalcPricesByBuy` */; +/*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_recalcPricesByBuy`(IN vBuyFk INT(11)) +BEGIN +/** + * Recalcula los precios de una compra + * + * @param vBuyFk + */ + DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc; + + CREATE TEMPORARY TABLE tmp.buyRecalc + SELECT vBuyFk id; + + CALL buy_recalcPrices(); + + DROP TEMPORARY TABLE tmp.buyRecalc; +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_recalcPricesByEntry` */; +/*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_recalcPricesByEntry`(IN vEntryFk INT(11)) +BEGIN +/** + * Recalcula los precios de una entrada + * + * @param vEntryFk + */ + DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc; + + CREATE TEMPORARY TABLE tmp.buyRecalc + SELECT b.id + FROM buy b + WHERE b.entryFk = vEntryFk; + + CALL buy_recalcPrices(); + + DROP TEMPORARY TABLE tmp.buyRecalc; +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_scan` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46770,84 +46965,51 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_scan`(vBarcode VARCHAR(255), vLabels INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_scan`(vBarcode VARCHAR(512)) BEGIN /** - * Marca una compra de subasta como escaneada. + * Busca compras a partir de un código de barras de subasta, las marca como + * escaneadas y como etiquetas impresas y las devuelve. * * @param vBarcode Código de compra de una etiqueta de subasta - * @param vLabels Cantidad escaneada + * @select (buy, do_photo) Identificadores de compra escaneados */ - DECLARE vEktFk INT; - DECLARE vBuyFk INT; - DECLARE vItemFk INT; - DECLARE vIsPhotoNeeded BOOL; + CALL edi.ekt_scan(vBarcode); - -- Aun no se sabe como obtener el número de serie de transacción de - -- las compras realizadas a través de un reloj, por lo que se establece - -- siempre a '01' + DROP TEMPORARY TABLE IF EXISTS tBuy; + CREATE TEMPORARY TABLE tBuy + SELECT id buyFk + FROM vn.buy b + LIMIT 0; - -- Campo ekt.barcode, el clásico - IF SUBSTR(vBarcode, 3, 2) != '99' THEN - SET vBarcode = CONCAT(LEFT(vBarcode, 12), '010'); - END IF; + INSERT INTO tBuy(buyFk) + SELECT b.id + FROM buy b + JOIN tmp.ekt t ON t.ektFk = b.ektFk + JOIN vn.entry en ON en.id = b.entryFk + JOIN vn.travel tr ON tr.id = en.travelFk + JOIN vn.warehouse w ON w.id = tr.warehouseInFk + JOIN vn.country c ON c.id = w.countryFk AND c.code = 'NL'; - SELECT e.id, b.id, b.itemFk, i.doPhoto - INTO vEktFk, vBuyFk, vItemFk, vIsPhotoNeeded - FROM edi.ekt e - JOIN vn.buy b ON b.ektFk = e.id - JOIN vn.item i ON i.id = b.itemFk - WHERE e.barcode = vBarcode - AND e.entryYear = YEAR(CURDATE()) - ORDER BY b.id - LIMIT 1; + SELECT b.id buy, i.doPhoto do_photo, b.stickers - b.printedStickers stickersToPrint + FROM tBuy tb + JOIN vn.buy b ON tb.buyFk = b.id + JOIN vn.item i ON i.id = b.itemFk; - -- Campo ekt.batchCode - IF ISNULL(vEktFk) THEN - SELECT e.id, b.id, b.itemFk, i.doPhoto - INTO vEktFk, vBuyFk, vItemFk, vIsPhotoNeeded - FROM edi.ekt e - JOIN vn.buy b ON b.ektFk = e.id - JOIN vn.item i ON i.id = b.itemFk - WHERE LEFT(@bc, 13) = e.batchNumber - AND e.entryYear = YEAR(CURDATE()) - ORDER BY b.id - LIMIT 1; - END IF; + UPDATE vn.buy b + JOIN tBuy tb ON tb.buyFk = b.id + SET b.printedStickers = b.stickers; - -- Campo ekt.deliveryNumber - IF ISNULL(vEktFk) THEN - SELECT e.id, b.id, b.itemFk, i.doPhoto - INTO vEktFk, vBuyFk, vItemFk, vIsPhotoNeeded - FROM edi.ekt e - JOIN vn.buy b ON b.ektFk = e.id - JOIN vn.item i ON i.id = b.itemFk - WHERE e.deliveryNumber = vBarcode - AND e.entryYear = YEAR(CURDATE()) - ORDER BY b.id - LIMIT 1; - END IF; - - IF NOT ISNULL(vEktFk) THEN - - UPDATE edi.ekt e SET e.scanned = TRUE WHERE id = vEktFk; - - UPDATE vn.buy b - SET b.printedStickers = b.printedStickers + IF(vLabels <> -1, vLabels, b.stickers) - WHERE b.id = vBuyFk; - - END IF; - - SELECT vBuyFk buy, vIsPhotoNeeded do_photo; + DROP TEMPORARY TABLE tmp.ekt, tBuy; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `buy_updateGrouping` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46855,6 +47017,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_updateGrouping`(vWarehouseFk INT, vItemFk INT, vGrouping INT) BEGIN @@ -46864,14 +47028,14 @@ BEGIN * @param vWarehouseFk Id del almacén * @param vItemFk Id del Artículo * @param vGrouping Cantidad de grouping - */ - - CALL vn.buyUltimate(vWarehouseFk, CURDATE()); + */ + + CALL vn.buyUltimate(vWarehouseFk, util.VN_CURDATE()); UPDATE vn.buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk - SET b.`grouping` = vGrouping - WHERE bu.warehouseFk = vWarehouseFk + SET b.`grouping` = vGrouping + WHERE bu.warehouseFk = vWarehouseFk AND bu.itemFk = vItemFk; DROP TEMPORARY TABLE tmp.buyUltimate; @@ -46881,8 +47045,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `buy_updatePacking` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46890,22 +47052,24 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_updatePacking`(vWarehouseFk INT, vItemFk INT, vPacking INT) BEGIN /** - * Actualiza packing + * Actualiza packing * * @param vWarehouseFk warehouse del item * @param vItemFk id del item * @param vPacking packing a actualizar */ - CALL buyUltimate(vWarehouseFk, CURDATE()); + CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); UPDATE buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk - SET b.packing = vPacking - WHERE bu.warehouseFk = vWarehouseFk + SET b.packing = vPacking + WHERE bu.warehouseFk = vWarehouseFk AND bu.itemFk = vItemFk; DROP TEMPORARY TABLE tmp.buyUltimate; @@ -46916,8 +47080,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `catalog_calcFromItem` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46925,6 +47087,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calcFromItem`( vLanded DATE, @@ -46944,7 +47108,7 @@ BEGIN */ DROP TEMPORARY TABLE IF EXISTS tmp.item; CREATE TEMPORARY TABLE tmp.item - ENGINE = MEMORY + ENGINE = MEMORY SELECT vItemFk itemFk; CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk); @@ -46955,8 +47119,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `catalog_calculate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46964,9 +47126,11 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calculate`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) -BEGIN +BEGIN /** * Calcula los articulos disponibles y sus precios * @@ -46974,7 +47138,7 @@ BEGIN * @param vLanded Fecha de recepcion de mercancia * @param vAddressFk Id del consignatario * @param vAgencyModeFk Id de la agencia - * @return tmp.ticketCalculateItem(itemFk, available, producer, + * @return tmp.ticketCalculateItem(itemFk, available, producer, * item, size, stems, category, inkFk, image, origin, price) * @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk) * @return tmp.ticketComponent @@ -47010,22 +47174,22 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticketCalculateItem; CREATE TEMPORARY TABLE tmp.ticketCalculateItem( - itemFk INT(11) NOT NULL, + 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), + 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), + origin VARCHAR(3), price DECIMAL(10,2), priceKg DECIMAL(10,2), `grouping` INT(10) UNSIGNED, PRIMARY KEY `itemFk` (`itemFk`) ) ENGINE = MEMORY DEFAULT CHARSET=utf8; - + OPEN cTravelTree; l: LOOP @@ -47047,20 +47211,20 @@ BEGIN bu.buyFk, vZoneFk FROM `cache`.available a - LEFT JOIN cache.availableNoRaids anr ON anr.item_id = a.item_id + LEFT JOIN cache.availableNoRaids anr ON anr.item_id = a.item_id AND anr.calc_id = vAvailableNoRaidsCalc JOIN tmp.item i ON i.itemFk = a.item_id JOIN vn.item it ON it.id = i.itemFk JOIN vn.`zone` z ON z.id = vZoneFk - LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id - LEFT JOIN edi.supplyResponse sr ON sr.ID = it.supplyResponseFk - LEFT JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID + LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id + LEFT JOIN edi.supplyResponse sr ON sr.ID = it.supplyResponseFk + LEFT JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID LEFT JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID LEFT JOIN (SELECT isVNHSupplier, isEarlyBird, TRUE AS itemAllowed FROM vn.addressFilter af - JOIN (SELECT ad.provinceFk, p.countryFk, ad.isLogifloraAllowed - FROM vn.address ad - JOIN vn.province p ON p.id = ad.provinceFk + JOIN (SELECT ad.provinceFk, p.countryFk, ad.isLogifloraAllowed + FROM vn.address ad + JOIN vn.province p ON p.id = ad.provinceFk WHERE ad.id = vAddressFk ) sub2 ON sub2.provinceFk <=> IFNULL(af.provinceFk, sub2.provinceFk) AND sub2.countryFk <=> IFNULL(af.countryFk, sub2.countryFk) @@ -47077,7 +47241,7 @@ BEGIN JOIN vn.itemType itt ON itt.id = it.typeFk JOIN vn.itemCategory itc on itc.id = itt.categoryFk JOIN vn.address ad ON ad.id = vAddressFk - LEFT JOIN vn.clientItemType cit + LEFT JOIN vn.clientItemType cit ON cit.clientFk = ad.clientFk AND cit.itemTypeFk = itt.id LEFT JOIN vn.clientItemCategory cic @@ -47090,7 +47254,7 @@ BEGIN AND (itc.isReclining OR ISNULL(it.`size`) OR it.`size` < z.itemMaxSize OR ISNULL(z.itemMaxSize)) AND NOT (cit.isAllowed <=> FALSE) AND (ISNULL(cic.itemCategoryFk) OR cit.isAllowed); - + DROP TEMPORARY TABLE tmp.buyUltimate; CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); @@ -47152,8 +47316,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `catalog_componentCalculate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -47161,6 +47323,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_componentCalculate`( vZoneFk INT, vAddressFk INT, @@ -47171,7 +47335,7 @@ BEGIN * Calcula los componentes de los articulos de tmp.ticketLot * * @param vZoneFk para calcular el transporte - * @param vAddressFk Consignatario + * @param vAddressFk Consignatario * @param vShipped dia de salida del pedido * @param vWarehouseFk warehouse de salida del pedido * @table tmp.ticketLot (warehouseFk, available, itemFk, buyFk, zoneFk) @@ -47179,15 +47343,15 @@ BEGIN * * @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg) */ - + DECLARE vClientFk INT; DECLARE vIsFrenchVNHBuyer BOOLEAN DEFAULT FALSE; DECLARE vVNHWarehouseFk INT DEFAULT 7; DECLARE vFrenchDiscount DECIMAL(3,2) DEFAULT 0.12; SELECT clientFk INTO vClientFK - FROM address - WHERE id = vAddressFk; + FROM address + WHERE id = vAddressFk; SELECT (c.country = 'FRANCIA' AND vWarehouseFk = vVNHWarehouseFk) INTO vIsFrenchVNHBuyer @@ -47201,16 +47365,16 @@ BEGIN CREATE TEMPORARY TABLE tmp.ticketComponentCalculate (PRIMARY KEY (itemFk, warehouseFk)) ENGINE = MEMORY - SELECT - tl.itemFk, - tl.warehouseFk, + SELECT + tl.itemFk, + tl.warehouseFk, tl.available, IF(i.hasMinPrice, GREATEST(i.minPrice,IFNULL(pf.rate2, b.price2)),IFNULL(pf.rate2, b.price2)) rate2, IF(i.hasMinPrice, GREATEST(i.minPrice,IFNULL(pf.rate3, b.price3)),IFNULL(pf.rate3, b.price3)) rate3, IFNULL(pf.packing, GREATEST(b.grouping, b.packing)) packing, IFNULL(pf.`grouping`, b.`grouping`) `grouping`, ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, - tl.buyFk, + tl.buyFk, i.typeFk, IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping FROM tmp.ticketLot tl @@ -47218,7 +47382,7 @@ BEGIN JOIN item i ON i.id = tl.itemFk JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN specialPrice sp ON sp.itemFk = i.id + LEFT JOIN specialPrice sp ON sp.itemFk = i.id AND sp.clientFk = vClientFk LEFT JOIN ( SELECT * FROM ( @@ -47230,55 +47394,55 @@ BEGIN pf.rate3, zw.warehouseFk FROM priceFixed pf - JOIN zoneWarehouse zw ON zw.zoneFk = vZoneFk + JOIN zoneWarehouse zw ON zw.zoneFk = vZoneFk AND zw.warehouseFk IN (pf.warehouseFk,0) WHERE vShipped BETWEEN pf.started AND pf.ended ORDER BY pf.itemFk, pf.warehouseFk DESC LIMIT 10000000000000000000 ) tpf GROUP BY tpf.itemFk, tpf.warehouseFk - ) pf ON pf.itemFk = tl.itemFk + ) pf ON pf.itemFk = tl.itemFk AND pf.warehouseFk = tl.warehouseFk - WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 + WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 AND ic.merchandise - AND tl.zoneFk = vZoneFk + AND tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk; -- Coste INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - c2.id, + SELECT + tcc.warehouseFk, + tcc.itemFk, + c2.id, b.buyingValue + b.freightValue + b.packageValue + b.comissionValue - FROM tmp.ticketComponentCalculate tcc + FROM tmp.ticketComponentCalculate tcc JOIN vn.component c2 ON c2.code = 'purchaseValue' JOIN buy b ON b.id = tcc.buyFk; -- Margen INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - c2.id, + SELECT + tcc.warehouseFk, + tcc.itemFk, + c2.id, tcc.rate3 - b.buyingValue - b.freightValue - b.packageValue - b.comissionValue - FROM tmp.ticketComponentCalculate tcc + FROM tmp.ticketComponentCalculate tcc JOIN vn.component c2 ON c2.code = 'margin' JOIN buy b ON b.id = tcc.buyFk; -- Promo Francia IF vIsFrenchVNHBuyer THEN - + INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - c2.id, + SELECT + tcc.warehouseFk, + tcc.itemFk, + c2.id, - vFrenchDiscount * (b.buyingValue + b.freightValue + b.packageValue + b.comissionValue) / ( 1 - vFrenchDiscount) - FROM tmp.ticketComponentCalculate tcc + FROM tmp.ticketComponentCalculate tcc JOIN vn.component c2 ON c2.code = 'frenchOffer' JOIN buy b ON b.id = tcc.buyFk; - + END IF; DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentBase; @@ -47287,17 +47451,17 @@ BEGIN FROM tmp.ticketComponent tc JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk GROUP BY tc.itemFk, warehouseFk; - + -- RECOBRO INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) - SELECT tcb.warehouseFk, tcb.itemFk, c2.id, - ROUND(tcb.base * + SELECT tcb.warehouseFk, tcb.itemFk, c2.id, + ROUND(tcb.base * LEAST( MAX(GREATEST(IFNULL(cr.priceIncreasing,0), IFNULL(cr1.priceIncreasing,0), IFNULL(cr2.priceIncreasing,0)) - ), - cc.maxPriceIncreasingRatio), + ), + cc.maxPriceIncreasingRatio), 3) FROM tmp.ticketComponentBase tcb JOIN vn.component c2 ON c2.code = 'debtCollection' @@ -47315,31 +47479,43 @@ BEGIN SELECT tcb.warehouseFk, tcb.itemFk, c2.id, ROUND(base * (0.01 + wm.pricesModifierRate), 3) as manaAuto FROM tmp.ticketComponentBase tcb JOIN `client` c on c.id = vClientFk - JOIN workerMana wm ON c.salesPersonFk = wm.workerFk + JOIN workerMana wm ON c.salesPersonFk = wm.workerFk JOIN vn.component c2 ON c2.code = 'autoMana' WHERE wm.isPricesModifierActivated HAVING manaAuto <> 0; - + -- Precios especiales INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) SELECT tcb.warehouseFk, tcb.itemFk, c2.id, GREATEST( - IFNULL(ROUND(tcb.base * c2.tax, 4), 0), + IFNULL(ROUND(tcb.base * c2.tax, 4), 0), IF(i.hasMinPrice, i.minPrice,0) - tcc.rate3 ) cost FROM tmp.ticketComponentBase tcb JOIN vn.component c2 ON c2.code = 'lastUnitsDiscount' - JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk + JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk JOIN vn.item i ON i.id = tcb.itemFk WHERE sp.value IS NULL AND i.supplyResponseFk IS NULL; - + + -- Individual + INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) + SELECT tcb.warehouseFk, + tcb.itemFk, + c2.id, + IFNULL(ROUND(tcb.base * c2.tax, 4), 0) cost + FROM tmp.ticketComponentBase tcb + JOIN vn.component c2 ON c2.code = 'individual' + JOIN vn.client c ON c.id = vClientFk + JOIN vn.businessType bt ON bt.code = c.businessTypeFk + WHERE bt.code = 'individual'; + -- Venta por paquetes INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) - SELECT tcc.warehouseFk, tcc.itemFk, c2.id, tcc.rate2 - tcc.rate3 + SELECT tcc.warehouseFk, tcc.itemFk, c2.id, tcc.rate2 - tcc.rate3 FROM tmp.ticketComponentCalculate tcc JOIN vn.component c2 ON c2.code = 'salePerPackage' JOIN buy b ON b.id = tcc.buyFk @@ -47352,12 +47528,12 @@ BEGIN SELECT vZoneFk id; CALL zone_getOptionsForShipment(vShipped, TRUE); - + -- Reparto INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFK, + SELECT tcc.warehouseFK, tcc.itemFk, - c2.id, + c2.id, z.inflation * ROUND(ic.cm3delivery * (IFNULL(zo.price,5000) - IFNULL(zo.bonus,0)) / (1000 * vc.standardFlowerBox) , 4) cost FROM tmp.ticketComponentCalculate tcc JOIN item i ON i.id = tcc.itemFk @@ -47366,21 +47542,21 @@ BEGIN JOIN agencyMode am ON am.id = z.agencyModeFk JOIN vn.volumeConfig vc JOIN vn.component c2 ON c2.code = 'delivery' - LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk + LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk AND ic.itemFk = tcc.itemFk - HAVING cost <> 0; + HAVING cost <> 0; DROP TEMPORARY TABLE tmp.zoneOption; - + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCopy; CREATE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY SELECT * FROM tmp.ticketComponent; -- Precio especial INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, - tcc.itemFk, - c2.id, + SELECT tcc.warehouseFk, + tcc.itemFk, + c2.id, sp.value - SUM(tcc.cost) sumCost FROM tmp.ticketComponentCopy tcc JOIN component c ON c.id = tcc.componentFk @@ -47391,11 +47567,11 @@ BEGIN GROUP BY tcc.itemFk, tcc.warehouseFk HAVING ABS(sumCost) > 0.001; - -- Rappel + -- Rappel INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, - tcc.itemFk, - IFNULL(c.componentFk ,c2.id), + SELECT tcc.warehouseFk, + tcc.itemFk, + IFNULL(c.componentFk ,c2.id), SUM(tcc.cost) * ((1/(1-c.rappel/100)) -1) sumCost FROM tmp.ticketComponentCopy tcc JOIN vn.clientChain cc ON cc.clientFk = vClientFk @@ -47416,16 +47592,16 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentRate; CREATE TEMPORARY TABLE tmp.ticketComponentRate ENGINE = MEMORY - SELECT tcc.warehouseFk, - tcc.itemFk, + SELECT tcc.warehouseFk, + tcc.itemFk, 1 rate, - IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`, + IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`, CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price, - CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg + CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk + JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 1) = 1 + WHERE IFNULL(tcs.classRate, 1) = 1 AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) GROUP BY tcs.warehouseFk, tcs.itemFk; @@ -47445,17 +47621,17 @@ BEGIN GROUP BY tcs.warehouseFk, tcs.itemFk; INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 3 rate, - tcc.available `grouping`, + SELECT + tcc.warehouseFk, + tcc.itemFk, + 3 rate, + tcc.available `grouping`, SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightGrouping priceKg + SUM(tcs.sumCost) / weightGrouping priceKg FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk + JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 3) = 3 + WHERE IFNULL(tcs.classRate, 3) = 3 GROUP BY tcs.warehouseFk, tcs.itemFk; INSERT INTO tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg) @@ -47463,22 +47639,20 @@ BEGIN SELECT * FROM tmp.ticketComponentRate ORDER BY price LIMIT 10000000000000000000 ) t GROUP BY itemFk, warehouseFk, `grouping`; - + DROP TEMPORARY TABLE tmp.ticketComponentCalculate, tmp.ticketComponentSum, tmp.ticketComponentBase, tmp.ticketComponentRate, tmp.ticketComponentCopy; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `catalog_componentPrepare` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -47486,10 +47660,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_componentPrepare`() BEGIN - + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; CREATE TEMPORARY TABLE tmp.ticketComponent ( `warehouseFk` INT UNSIGNED NOT NULL, @@ -47499,9 +47675,9 @@ BEGIN INDEX `itemWarehouse` USING BTREE (`itemFk` ASC, `warehouseFk` ASC), UNIQUE `fkItemWarehouseComponent` (`itemFk` ASC, `warehouseFk` ASC, `componentFk` ASC) )ENGINE=MEMORY DEFAULT CHARSET=utf8; - + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentPrice; - CREATE TEMPORARY TABLE tmp.ticketComponentPrice ( + CREATE TEMPORARY TABLE tmp.ticketComponentPrice ( `warehouseFk` INT UNSIGNED NOT NULL, `itemFk` INT NOT NULL, `rate` INT NOT NULL, @@ -47510,15 +47686,13 @@ BEGIN `priceKg` DECIMAL(10,4), INDEX `itemWarehouse` USING BTREE (`itemFk` ASC, `warehouseFk` ASC), UNIQUE `fkItemWarehouseRate` (`itemFk` ASC, `warehouseFk` ASC, `rate` ASC) - )ENGINE=MEMORY DEFAULT CHARSET=utf8; + )ENGINE=MEMORY DEFAULT CHARSET=utf8; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `catalog_componentPurge` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -47526,10 +47700,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_componentPurge`() BEGIN - DROP TEMPORARY TABLE + DROP TEMPORARY TABLE tmp.ticketComponentPrice, tmp.ticketComponent, tmp.ticketLot; @@ -47539,8 +47715,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `catalog_test` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -47548,24 +47722,26 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` 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, + * @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 vLanded DATE DEFAULT DATE_ADD(util.VN_CURDATE(),INTERVAL 2 DAY); DECLARE vAddressFk INT DEFAULT 24526; DECLARE vAgencyModeFk INT DEFAULT 639; DECLARE vAvailableCalc INT; @@ -47580,10 +47756,10 @@ proc: BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.item; CREATE TEMPORARY TABLE tmp.item - ENGINE = MEMORY + ENGINE = MEMORY SELECT 10 itemFk; -- Establece los almacenes y las fechas que van a entrar al disponible -SELECT 1; +SELECT 1; CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, FALSE); SELECT 2; DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; @@ -47598,25 +47774,25 @@ SELECT 2; 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, + 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), + 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), + origin VARCHAR(3), price DECIMAL(10,2), priceKg DECIMAL(10,2), PRIMARY KEY `itemFk` (`itemFk`) ) ENGINE = MEMORY DEFAULT CHARSET=utf8; - + OPEN cTravelTree; l: LOOP @@ -47643,35 +47819,35 @@ SELECT 5; 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, + itemFk, + available, + producer, + item, + size, + stems, + category, inkFk, image, origin, price, priceKg) - SELECT - tl.itemFk, + SELECT + tl.itemFk, SUM(tl.available) available, - p.name producer, - i.name item, - i.size size, - i.stems, - i.category, - i.inkFk, + p.name producer, + i.name item, + i.size size, + i.stems, + i.category, + i.inkFk, i.image, - o.code origin, + o.code origin, bl.price, bl.priceKg FROM tmp.ticketLot tl @@ -47679,11 +47855,11 @@ SELECT 6; LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible JOIN origin o ON o.id = i.originFk JOIN ( - SELECT * + SELECT * FROM (SELECT price, itemFk, priceKg FROM tmp.ticketComponentPrice WHERE warehouseFk = vWarehouseFk - ORDER BY (rate = 2) DESC + ORDER BY (rate = 2) DESC LIMIT 10000000000000000000) sub GROUP BY itemFk ) bl ON bl.itemFk = tl.itemFk @@ -47695,16 +47871,14 @@ SELECT 6; CLOSE cTravelTree; DROP TEMPORARY TABLE tmp.item; -SELECT 7; - +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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -47712,6 +47886,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`() BEGIN @@ -47723,12 +47899,12 @@ BEGIN DECLARE v3Month DATE; DECLARE vTrashId varchar(15); - SET vDateShort = TIMESTAMPADD(MONTH, -2, CURDATE()); - SET vOneYearAgo = TIMESTAMPADD(YEAR,-1,CURDATE()); - SET vFourYearsAgo = TIMESTAMPADD(YEAR,-4,CURDATE()); - SET v18Month = TIMESTAMPADD(MONTH, -18,CURDATE()); - SET v26Month = TIMESTAMPADD(MONTH, -26,CURDATE()); - SET v3Month = TIMESTAMPADD(MONTH, -3, CURDATE()); + SET vDateShort = TIMESTAMPADD(MONTH, -2, util.VN_CURDATE()); + SET vOneYearAgo = TIMESTAMPADD(YEAR,-1,util.VN_CURDATE()); + SET vFourYearsAgo = TIMESTAMPADD(YEAR,-4,util.VN_CURDATE()); + SET v18Month = TIMESTAMPADD(MONTH, -18,util.VN_CURDATE()); + SET v26Month = TIMESTAMPADD(MONTH, -26,util.VN_CURDATE()); + SET v3Month = TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()); DELETE FROM ticketParking WHERE created < vDateShort; DELETE FROM routesMonitor WHERE dated < vDateShort; @@ -47737,28 +47913,28 @@ BEGIN DELETE FROM messageInbox WHERE sendDate < vDateShort; DELETE FROM messageInbox WHERE sendDate < vDateShort; DELETE FROM workerTimeControl WHERE timed < vFourYearsAgo; - DELETE FROM itemShelving WHERE created < CURDATE() AND visible = 0; - DELETE FROM ticketDown WHERE created < TIMESTAMPADD(DAY,-1,CURDATE()); + DELETE FROM itemShelving WHERE created < util.VN_CURDATE() AND visible = 0; + DELETE FROM ticketDown WHERE created < TIMESTAMPADD(DAY,-1,util.VN_CURDATE()); DELETE FROM entryLog WHERE creationDate < vDateShort; DELETE IGNORE FROM expedition WHERE created < v26Month; DELETE FROM sms WHERE created < v18Month; DELETE FROM saleTracking WHERE created < vOneYearAgo; - DELETE tobs FROM ticketObservation tobs - JOIN ticket t ON tobs.ticketFk = t.id WHERE t.shipped < TIMESTAMPADD(YEAR,-2,CURDATE()); + DELETE tobs FROM ticketObservation tobs + JOIN ticket t ON tobs.ticketFk = t.id WHERE t.shipped < TIMESTAMPADD(YEAR,-2,util.VN_CURDATE()); DELETE sc.* FROM saleCloned sc JOIN sale s ON s.id = sc.saleClonedFk JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped < vOneYearAgo; DELETE FROM sharingCart where ended < vDateShort; DELETE FROM sharingClient where ended < vDateShort; - DELETE tw.* FROM ticketWeekly tw + DELETE tw.* FROM ticketWeekly tw LEFT JOIN sale s ON s.ticketFk = tw.ticketFk WHERE s.itemFk IS NULL; DELETE FROM claim WHERE ticketCreated < vFourYearsAgo; DELETE FROM message WHERE sendDate < vDateShort; -- Robert ubicacion anterior de trevelLog comentario para debug - DELETE sc FROM saleChecked sc + DELETE sc FROM saleChecked sc JOIN sale s ON sc.saleFk = s.id WHERE s.created < vDateShort; DELETE FROM zoneEvent WHERE `type` = 'day' AND dated < v3Month; DELETE bm - FROM buyMark bm - JOIN buy b ON b.id = bm.id + FROM buyMark bm + JOIN buy b ON b.id = bm.id JOIN entry e ON e.id = b.entryFk JOIN travel t ON t.id = e.travelFk WHERE t.landed <= vDateShort; @@ -47766,10 +47942,11 @@ BEGIN DELETE FROM vn.buy WHERE created < vDateShort AND entryFk = 9200; DELETE FROM vn.itemShelvingLog WHERE created < vDateShort; DELETE FROM vn.stockBuyed WHERE creationDate < vDateShort; + DELETE FROM vn.itemCleanLog WHERE created < util.VN_NOW() - INTERVAL 1 YEAR; -- Equipos duplicados - DELETE w.* + DELETE w.* FROM workerTeam w JOIN (SELECT id, team, workerFk, COUNT(*) - 1 as duplicated FROM workerTeam @@ -47777,13 +47954,13 @@ BEGIN HAVING duplicated ) d ON d.team = w.team AND d.workerFk = w.workerFk AND d.id != w.id; - DELETE sc + DELETE sc FROM saleComponent sc JOIN sale s ON s.id= sc.saleFk JOIN ticket t ON t.id= s.ticketFk WHERE t.shipped < v18Month; - DELETE c + DELETE c FROM vn.claim c JOIN vn.claimState cs ON cs.id = c.claimStateFk WHERE cs.description = "Anulado" AND @@ -47799,7 +47976,7 @@ BEGIN FROM vn.travel t LEFT JOIN vn.entry e ON e.travelFk = t.id JOIN vn.travelThermograph th ON th.travelFk = t.id - WHERE t.shipped < TIMESTAMPADD(MONTH, -3, CURDATE()) AND e.travelFk IS NULL; + WHERE t.shipped < TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()) AND e.travelFk IS NULL; SELECT dt.id into vTrashId FROM vn.dmsType dt @@ -47809,20 +47986,20 @@ BEGIN JOIN vn.dms d ON d.id = th.dmsFk SET d.dmsTypeFk = vTrashId; - DELETE th + DELETE th FROM tmp.thermographToDelete tmp JOIN vn.travelThermograph th ON th.id = tmp.id; DELETE t FROM vn.travel t LEFT JOIN vn.entry e ON e.travelFk = t.id - WHERE t.shipped < TIMESTAMPADD(MONTH, -3, CURDATE()) AND e.travelFk IS NULL; - + WHERE t.shipped < TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()) AND e.travelFk IS NULL; + UPDATE dms d - JOIN dmsType dt ON dt.id = d.dmsTypeFk - SET d.dmsTypeFk = vTrashId - WHERE created < TIMESTAMPADD(MONTH, -dt.monthToDelete, CURDATE()); - + JOIN dmsType dt ON dt.id = d.dmsTypeFk + SET d.dmsTypeFk = vTrashId + WHERE created < TIMESTAMPADD(MONTH, -dt.monthToDelete, util.VN_CURDATE()); + -- borrar entradas sin compras DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete; CREATE TEMPORARY TABLE tmp.entryToDelete @@ -47830,33 +48007,33 @@ BEGIN FROM vn.entry e LEFT JOIN vn.buy b ON b.entryFk = e.id JOIN vn.entryConfig ec ON e.id != ec.defaultEntry - WHERE e.dated < TIMESTAMPADD(MONTH, -3, CURDATE()) AND b.entryFK IS NULL; + WHERE e.dated < TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()) AND b.entryFK IS NULL; DELETE e FROM vn.entry e - JOIN tmp.entryToDelete tmp ON tmp.id = e.id; - + JOIN tmp.entryToDelete tmp ON tmp.id = e.id; + -- borrar de route registros menores a 4 años DROP TEMPORARY TABLE IF EXISTS tmp.routeToDelete; CREATE TEMPORARY TABLE tmp.routeToDelete SELECT * FROM vn.route r - WHERE created < TIMESTAMPADD(YEAR,-4,CURDATE()); + WHERE created < TIMESTAMPADD(YEAR,-4,util.VN_CURDATE()); UPDATE tmp.routeToDelete tmp JOIN vn.dms d ON d.id = tmp.gestdocFk SET d.dmsTypeFk = vTrashId; - DELETE r + DELETE r FROM tmp.routeToDelete tmp JOIN vn.route r ON r.id = tmp.id; -- borrar registros de dua y awb menores a 2 años DROP TEMPORARY TABLE IF EXISTS tmp.duaToDelete; CREATE TEMPORARY TABLE tmp.duaToDelete - SELECT * - FROM vn.dua - WHERE operated < TIMESTAMPADD(YEAR,-2,CURDATE()); + SELECT * + FROM vn.dua + WHERE operated < TIMESTAMPADD(YEAR,-2,util.VN_CURDATE()); UPDATE tmp.duaToDelete tm JOIN vn.dms d ON d.id = tm.gestdocFk @@ -47866,7 +48043,7 @@ BEGIN FROM tmp.duaToDelete tmp JOIN vn.dua d ON d.id = tmp.id; - DELETE FROM vn.awb WHERE created < TIMESTAMPADD(YEAR,-2,CURDATE()); + DELETE FROM vn.awb WHERE created < TIMESTAMPADD(YEAR,-2,util.VN_CURDATE()); -- Borra los registros de collection y ticketcollection DELETE FROM vn.collection WHERE created < vDateShort; @@ -47877,7 +48054,7 @@ BEGIN DELETE FROM travelLog WHERE creationDate < v3Month; - CALL shelving_clean; + CALL shelving_clean; END ;; DELIMITER ; @@ -47885,8 +48062,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clean_logiflora` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -47894,19 +48069,22 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clean_logiflora`() BEGIN - /* partir en 2 procedimientos, uno que borre compras y otro articulos - * item_clean, buy_clean - * */ - - DECLARE vMaxDated DATE DEFAULT TIMESTAMPADD(DAY, - 7, CURDATE()); +/** + * Partir en 2 procedimientos, uno que borre compras y otro articulos + * item_clean, buy_clean. + */ + + DECLARE vMaxDated DATE DEFAULT TIMESTAMPADD(DAY, - 7, util.VN_CURDATE()); DECLARE vDone INT DEFAULT FALSE; DECLARE vBuyFk INT; DECLARE cur1 CURSOR FOR SELECT id FROM tmp.buy; DECLARE cur2 CURSOR FOR SELECT id FROM tmp.item; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DROP TEMPORARY TABLE IF EXISTS tmp.buy; @@ -47916,33 +48094,33 @@ BEGIN SELECT b.id FROM vn.buy b JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.travel tr ON tr.id = e.travelFk - JOIN vn.agencyMode am ON am.id = tr.agencyModeFk + JOIN vn.travel tr ON tr.id = e.travelFk + JOIN vn.agencyMode am ON am.id = tr.agencyModeFk WHERE b.quantity = 0 AND am.name = 'LOGIFLORA' AND e.isRaid; OPEN cur1; - read_loop: LOOP - - SET vDone = FALSE; - - FETCH cur1 INTO vBuyFk; - - IF vDone THEN - LEAVE read_loop; - END IF; - - DELETE FROM vn.buy WHERE id = vBuyFk; - - END LOOP; + read_loop: LOOP - CLOSE cur1; - - DROP TEMPORARY TABLE tmp.buy; - - DROP TEMPORARY TABLE IF EXISTS tmp.item; + SET vDone = FALSE; + + FETCH cur1 INTO vBuyFk; + + IF vDone THEN + LEAVE read_loop; + END IF; + + DELETE FROM vn.buy WHERE id = vBuyFk; + + END LOOP; + + CLOSE cur1; + + DROP TEMPORARY TABLE tmp.buy; + + DROP TEMPORARY TABLE IF EXISTS tmp.item; CREATE TEMPORARY TABLE tmp.item ENGINE = MEMORY @@ -47950,43 +48128,40 @@ BEGIN FROM vn.item i LEFT JOIN hedera.orderRow o ON o.itemFk = i.id LEFT JOIN vn.sale s ON s.itemFk = i.id - LEFT JOIN vn.buy b ON b.itemFk = i.id + LEFT JOIN vn.buy b ON b.itemFk = i.id LEFT JOIN bs.waste w ON w.itemFk = i.id - WHERE i.supplyResponseFk + WHERE i.supplyResponseFk AND o.id IS NULL - AND b.id IS NULL + AND b.id IS NULL AND s.id IS NULL AND w.rate IS NULL AND i.created < vMaxDated; - + OPEN cur2; - read_loop: LOOP - - SET vDone = FALSE; - - FETCH cur2 INTO vBuyFk; - - IF vDone THEN - LEAVE read_loop; - END IF; - - DELETE FROM vn.item WHERE id = vBuyFk; - - END LOOP; + read_loop: LOOP - CLOSE cur2; - - DROP TEMPORARY TABLE tmp.item; - + SET vDone = FALSE; + + FETCH cur2 INTO vBuyFk; + + IF vDone THEN + LEAVE read_loop; + END IF; + + DELETE FROM vn.item WHERE id = vBuyFk; + + END LOOP; + + CLOSE cur2; + + DROP TEMPORARY TABLE tmp.item; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clearShelvingList` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -47994,6 +48169,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clearShelvingList`(vShelvingFk VARCHAR(8)) BEGIN @@ -48006,8 +48183,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientCreate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48015,12 +48190,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clientCreate`( vFirstname VARCHAR(50), - vSurnames VARCHAR(50), - vFi VARCHAR(9), - vAddress TEXT, + vSurnames VARCHAR(50), + vFi VARCHAR(9), + vAddress TEXT, vPostcode CHAR(5), vCity VARCHAR(25), vProvinceFk SMALLINT(5), @@ -48039,7 +48216,7 @@ BEGIN DECLARE vIsTaxDataChecked TINYINT(1) DEFAULT 1; DECLARE vHasCoreVnl BOOLEAN DEFAULT TRUE; DECLARE vMandateTypeFk INT DEFAULT 2; - + INSERT INTO `client` ( id, name, @@ -48067,21 +48244,21 @@ BEGIN vProvinceFk, vCity, vPostcode, - CONCAT(vSurnames, ' ', vFirstname), + CONCAT(vSurnames, ' ', vFirstname), vPayMethodFk, vDueDay, vDefaultCredit, vIsTaxDataChecked, vHasCoreVnl, FALSE - ) ON duplicate key update + ) ON duplicate key update payMethodFk = vPayMethodFk, dueDay = vDueDay, credit = vDefaultCredit, isTaxDataChecked = vIsTaxDataChecked, hasCoreVnl = vHasCoreVnl, isActive = TRUE; - + IF (SELECT COUNT(*) FROM mandate WHERE clientFk = vUserFk AND companyFk = vCompanyFk AND mandateTypeFk = vMandateTypeFk) = 0 THEN INSERT INTO mandate (clientFk, companyFk, mandateTypeFk) VALUES (vUserFk, vCompanyFk, vMandateTypeFk); @@ -48092,8 +48269,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientDebtSpray` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48101,6 +48276,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clientDebtSpray`(vClientFk INT) BEGIN @@ -48111,21 +48288,21 @@ BEGIN */ DECLARE vClientDebt DOUBLE; - - SELECT vn.clientGetDebt(vClientFk, CURDATE()) INTO vClientDebt; - + + SELECT vn.clientGetDebt(vClientFk, util.VN_CURDATE()) INTO vClientDebt; + INSERT INTO vn.greuge(clientFk, description, amount, shipped, greugeTypeFk) - VALUES (vClientFk, 'Saldo pendiente', vClientDebt, CURDATE(), 5); - + VALUES (vClientFk, 'Saldo pendiente', vClientDebt, util.VN_CURDATE(), 5); + CALL vn.clientGreugeSpray(vClientFk, TRUE, '', TRUE); - + INSERT INTO vn.greuge(clientFk, description, amount, shipped, greugeTypeFk) - SELECT vClientFk, 'Liquidación cliente', sum(amount), CURDATE(), 5 + SELECT vClientFk, 'Liquidación cliente', sum(amount), util.VN_CURDATE(), 5 FROM vn.greuge WHERE clientFk = vClientFk; - - UPDATE vn.client - SET salesPersonFk = NULL + + UPDATE vn.client + SET salesPersonFk = NULL WHERE id = vClientFk; END ;; @@ -48134,8 +48311,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientFreeze` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48143,42 +48318,44 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clientFreeze`() BEGIN /** -* Congela diariamente aquellos clientes que son morosos sin recobro, -* pero que no sean trabajadores, +* Congela diariamente aquellos clientes que son morosos sin recobro, +* pero que no sean trabajadores, * y que el riesgo no sea menor que cero * hasta que no se gire la remesa no se congelan a los clientes de giro */ DECLARE vIsRemittanced BOOLEAN; - SELECT id into vIsRemittanced - FROM receipt - WHERE invoiceFk LIKE 'REMESA%' - AND payed > util.firstDayOfMonth(CURDATE()) + SELECT id into vIsRemittanced + FROM receipt + WHERE invoiceFk LIKE 'REMESA%' + AND payed > util.firstDayOfMonth(util.VN_CURDATE()) LIMIT 1; DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; CREATE TEMPORARY TABLE tmp.clientGetDebt SELECT clientFk - FROM bs.defaulter - WHERE created = CURDATE() + FROM bs.defaulter + WHERE created = util.VN_CURDATE() AND amount; - CALL clientGetDebt(CURDATE()); + CALL clientGetDebt(util.VN_CURDATE()); UPDATE client c - JOIN bi.defaulters d ON d.client = c.id AND d.date = CURDATE() + JOIN bi.defaulters d ON d.client = c.id AND d.date = util.VN_CURDATE() JOIN config ON TRUE LEFT JOIN recovery r ON r.clientFk = c.id AND r.finished IS NULL - LEFT JOIN payMethod pm ON pm.id = c.payMethodFk + LEFT JOIN payMethod pm ON pm.id = c.payMethodFk LEFT JOIN tmp.risk rk ON rk.clientFk = c.id - SET c.isFreezed = TRUE, - d.frozened = CURDATE() - WHERE (d.amount > config.defaultersMaxAmount + SET c.isFreezed = TRUE, + d.frozened = util.VN_CURDATE() + WHERE (d.amount > config.defaultersMaxAmount AND rk.risk > 0) AND c.typeFk = 'normal' AND r.id IS NULL @@ -48191,15 +48368,15 @@ 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientGetDebt` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clientGetDebt`(vDate DATE) BEGIN @@ -48210,19 +48387,19 @@ BEGIN * @param vDate Fecha maxima de los registros * @return tmp.risk */ - DECLARE vStarted DATETIME DEFAULT TIMESTAMPADD(DAY, -35, CURDATE()); + DECLARE vStarted DATETIME DEFAULT TIMESTAMPADD(DAY, -35, util.VN_CURDATE()); DECLARE vEnded DATETIME; - SET vEnded = TIMESTAMP(IFNULL(vDate, CURDATE()), '23:59:59'); + SET vEnded = TIMESTAMP(IFNULL(vDate, util.VN_CURDATE()), '23:59:59'); DROP TEMPORARY TABLE IF EXISTS tClientRisk; - CREATE TEMPORARY TABLE tClientRisk + CREATE TEMPORARY TABLE tClientRisk ENGINE = MEMORY SELECT cr.clientFk, SUM(cr.amount) amount FROM clientRisk cr JOIN tmp.clientGetDebt c ON c.clientFk = cr.clientFk GROUP BY cr.clientFk; - + INSERT INTO tClientRisk SELECT c.clientFk, SUM(r.amountPaid) FROM receipt r @@ -48237,7 +48414,7 @@ BEGIN WHERE t.receiptFk IS NULL AND t.status = 'ok' GROUP BY t.clientFk; - + INSERT INTO tClientRisk SELECT t.clientFk, totalWithVat FROM ticket t @@ -48253,7 +48430,7 @@ BEGIN FROM client c JOIN tClientRisk cr ON cr.clientFk = c.id GROUP BY c.id; - + DROP TEMPORARY TABLE tClientRisk; END ;; DELIMITER ; @@ -48261,8 +48438,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientGetDebtDiary` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48270,6 +48445,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clientGetDebtDiary`(vClientFK INT, vCompanyFk INT) BEGIN @@ -48286,33 +48463,33 @@ BEGIN DECLARE vIssued DATETIME; DECLARE vBalance DOUBLE DEFAULT 0.00; DECLARE cur CURSOR FOR - SELECT - created, - issued, + SELECT + created, + issued, ROUND(amount, 2) AS balance FROM invoiceOut - WHERE clientFk = vClientFk AND companyFk = vCompanyFk - UNION ALL - SELECT - created, - payed, + WHERE clientFk = vClientFk AND companyFk = vCompanyFk + UNION ALL + SELECT + created, + payed, ROUND(-1 * amountPaid, 2) AS balance - FROM receipt + FROM receipt WHERE clientFk = vClientFk AND companyFk = vCompanyFk ORDER BY issued, created; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + OPEN cur; - + proc: LOOP SET vDone = FALSE; - + FETCH cur INTO vCreated, vIssued, vBalance; IF vDate IS NULL THEN SET vDate=vIssued; END IF; - + IF vDone THEN LEAVE proc; END IF; @@ -48324,66 +48501,66 @@ BEGIN SET vDone = TRUE; END IF; END LOOP; - + CLOSE cur; - - SELECT - issued, - CAST(debtOut AS DECIMAL(10,2)) debtOut, + + SELECT + issued, + CAST(debtOut AS DECIMAL(10,2)) debtOut, CAST(debtIn AS DECIMAL(10,2)) debtIn, - ref, - companyFk, + ref, + companyFk, priority FROM - (SELECT - NULL AS issued, - SUM(amountUnpaid) AS debtOut, - NULL AS debtIn, - 'Saldo Anterior' AS ref, + (SELECT + NULL AS issued, + SUM(amountUnpaid) AS debtOut, + NULL AS debtIn, + 'Saldo Anterior' AS ref, companyFk, - 0 as priority - FROM - (SELECT SUM(amount) AS amountUnpaid, companyFk, 0 + 0 as priority + FROM + (SELECT SUM(amount) AS amountUnpaid, companyFk, 0 FROM invoiceOut - WHERE clientFk = vClientFK - AND issued < vDate - GROUP BY companyFk - - UNION ALL - - SELECT SUM(-1 * amountPaid), companyFk, 0 - FROM receipt - WHERE clientFk = vClientFK - AND payed < vDate - GROUP BY companyFk) AS transactions - GROUP BY companyFk - - UNION ALL - - SELECT - issued, - amount as debtOut, - NULL AS debtIn, + WHERE clientFk = vClientFK + AND issued < vDate + GROUP BY companyFk + + UNION ALL + + SELECT SUM(-1 * amountPaid), companyFk, 0 + FROM receipt + WHERE clientFk = vClientFK + AND payed < vDate + GROUP BY companyFk) AS transactions + GROUP BY companyFk + + UNION ALL + + SELECT + issued, + amount as debtOut, + NULL AS debtIn, ref, companyFk, - 1 - FROM invoiceOut - WHERE clientFk = vClientFK + 1 + FROM invoiceOut + WHERE clientFk = vClientFK AND issued >= vDate - UNION ALL - - SELECT - r.payed, - NULL as debtOut, - r.amountPaid, - r.invoiceFk, + UNION ALL + + SELECT + r.payed, + NULL as debtOut, + r.amountPaid, + r.invoiceFk, r.companyFk, - 0 + 0 FROM receipt r - WHERE r.clientFk = vClientFK - AND r.payed >= vDate) t - INNER JOIN `client` c ON c.id = vClientFK - HAVING debtOut <> 0 OR debtIn <> 0 + WHERE r.clientFk = vClientFK + AND r.payed >= vDate) t + INNER JOIN `client` c ON c.id = vClientFK + HAVING debtOut <> 0 OR debtIn <> 0 ORDER BY issued, priority DESC, debtIn; END ;; DELIMITER ; @@ -48391,8 +48568,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientGreugeSpray` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48400,6 +48575,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clientGreugeSpray`(IN vClientFk INT, IN onlyForHisOwner BOOL, IN vWorkerCode VARCHAR(3), IN vWithMana BOOLEAN) BEGIN @@ -48423,7 +48600,7 @@ BEGIN VALUES( vClientFk, 'Desasignación', -1 * vMana, - CURDATE(), + util.VN_CURDATE(), vGreugeTypeMana); END IF; @@ -48441,13 +48618,13 @@ BEGIN WHERE id = vClientFk; ELSE - + SELECT id INTO vOwner FROM vn.worker WHERE code = vWorkerCode COLLATE utf8_general_ci; END IF; - + DROP TEMPORARY TABLE IF EXISTS tmp.clientList; CREATE TEMPORARY TABLE tmp.clientList SELECT DISTINCT t.clientFk, floor(cr.yearSale / 12) monthSale @@ -48456,29 +48633,27 @@ BEGIN JOIN vn.workerMana wm ON wm.workerFk = c.salesPersonFk JOIN vn.claimRatio cr ON cr.clientFk = c.id WHERE wm.workerFk = IF(onlyForHisOwner, vOwner, wm.workerFk) - AND t.shipped >= TIMESTAMPADD(MONTH,-1,CURDATE()) + AND t.shipped >= TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()) AND c.id != vClientFk HAVING monthSale > 100; - + SELECT SUM(monthSale) INTO vTotalSale FROM tmp.clientList; INSERT INTO vn.greuge(clientFk, description, amount, shipped, greugeTypeFk) - SELECT clientFk, CONCAT('Cliente: ',vClientFk), vGreuge * monthSale / vTotalSale, CURDATE(), vGreugeTypeFk + SELECT clientFk, CONCAT('Cliente: ',vClientFk), vGreuge * monthSale / vTotalSale, util.VN_CURDATE(), vGreugeTypeFk FROM tmp.clientList UNION ALL - SELECT vClientFk, 'Reparto greuge', -vGreuge, CURDATE(), vGreugeTypeFk; + SELECT vClientFk, 'Reparto greuge', -vGreuge, util.VN_CURDATE(), vGreugeTypeFk; END IF; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientPackagingOverstock` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48486,17 +48661,19 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clientPackagingOverstock`(vClientFk INT, vGraceDays INT ) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.clientPackagingOverstock; CREATE TEMPORARY TABLE tmp.clientPackagingOverstock - ENGINE = MEMORY - SELECT itemFk, - sum(GotfromClient) - sum(SenttoClient) as devueltos, + ENGINE = MEMORY + SELECT itemFk, + sum(GotfromClient) - sum(SenttoClient) as devueltos, sum(InvoicedtoClient) - sum(InvoicedfromClient) as facturados, - LEAST( - sum(GotfromClient) - sum(SenttoClient), + LEAST( + sum(GotfromClient) - sum(SenttoClient), sum(InvoicedtoClient) - sum(InvoicedfromClient) ) as abonables FROM @@ -48504,14 +48681,14 @@ BEGIN SELECT t.*, IF(@month = month, 0, 1) monthEnd, @month := month - FROM + FROM ( - SELECT x.id as ticketFk, - date(x.shipped) as shipped, - x.itemFk, - IFNULL(cast(sum(x.InvoicedtoClient) as DECIMAL(10,0)),0) InvoicedtoClient, - IFNULL(cast(sum(x.InvoicedfromClient) as DECIMAL(10,0)),0) InvoicedfromClient, - IFNULL(cast(sum(x.SenttoClient) as DECIMAL(10,0)),0) SenttoClient, + SELECT x.id as ticketFk, + date(x.shipped) as shipped, + x.itemFk, + IFNULL(cast(sum(x.InvoicedtoClient) as DECIMAL(10,0)),0) InvoicedtoClient, + IFNULL(cast(sum(x.InvoicedfromClient) as DECIMAL(10,0)),0) InvoicedfromClient, + IFNULL(cast(sum(x.SenttoClient) as DECIMAL(10,0)),0) SenttoClient, IFNULL(cast(sum(x.GotfromClient) as DECIMAL(10,0)),0) GotfromClient, i.name as concept, x.refFk as invoice, @@ -48530,11 +48707,11 @@ BEGIN @month := 0 month, t.companyFk FROM sale s - JOIN ticket t on t.id = s.ticketFk - JOIN packaging p ON p.itemFk = s.itemFk + JOIN ticket t on t.id = s.ticketFk + JOIN packaging p ON p.itemFk = s.itemFk LEFT JOIN packageEquivalentItem pe ON pe.itemFk = s.itemFk WHERE t.clientFk = vClientFk - AND t.shipped > '2017-11-30' + AND t.shipped > '2017-11-30' AND p.isPackageReturnable UNION ALL SELECT NULL, @@ -48547,7 +48724,7 @@ BEGIN 'Histórico', NULL, NULL - + FROM ticketPackagingStartingStock tps LEFT JOIN packageEquivalentItem pe ON pe.itemFk = tps.itemFk WHERE tps.clientFk = vClientFk @@ -48558,13 +48735,13 @@ BEGIN IFNULL(pe.equivalentFk, p.itemFk) itemFk, NULL, NULL, - IF(tp.quantity > 0 AND t.shipped <= TIMESTAMPADD(DAY, - vGraceDays, CURDATE()), tp.quantity, NULL) SenttoClient, + IF(tp.quantity > 0 AND t.shipped <= TIMESTAMPADD(DAY, - vGraceDays, util.VN_CURDATE()), tp.quantity, NULL) SenttoClient, IF(tp.quantity < 0, -tp.quantity, NULL) GotfromClient, NULL AS refFk, NULL, t.companyFk - FROM ticketPackaging tp - JOIN ticket t on t.id = tp.ticketFk + FROM ticketPackaging tp + JOIN ticket t on t.id = tp.ticketFk JOIN packaging p ON p.id = tp.packagingFk LEFT JOIN packageEquivalentItem pe ON pe.itemFk = p.itemFk WHERE t.clientFk = vClientFk @@ -48583,8 +48760,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientPackagingOverstockReturn` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48592,6 +48767,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clientPackagingOverstockReturn`(vClientFk INT, vGraceDays INT ) BEGIN @@ -48601,47 +48778,45 @@ BEGIN -- SET vGraceDays = GREATEST(vGraceDays, 90); CALL vn.clientPackagingOverstock(vClientFk,vGraceDays); - + SELECT id INTO vWarehouseFk FROM vn.warehouse WHERE hasConfectionTeam; - + CALL vn.ticket_add( vClientFk - ,CURDATE() + ,util.VN_CURDATE() ,vWarehouseFk -- Algemesi ,442 -- Verdnatura ,NULL -- address ,NULL -- agencia ,NULL -- route - ,CURDATE() + ,util.VN_CURDATE() ,account.myUser_getId() ,TRUE ,vNewTicket); - + INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price) SELECT vNewTicket, cpo.itemFk, - cpo.abonables, i.longName, p.price FROM tmp.clientPackagingOverstock cpo JOIN vn.item i ON i.id = cpo.itemFk JOIN vn.packaging p ON p.itemFk = cpo.itemFk WHERE cpo.abonables > 0; - + INSERT INTO vn.ticketPackaging(ticketFk, packagingFk, quantity) SELECT vNewTicket, p.id, cpo.abonables FROM tmp.clientPackagingOverstock cpo JOIN vn.packaging p ON p.itemFk = cpo.itemFk WHERE cpo.abonables > 0; - + SELECT vNewTicket; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientRemoveWorker` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48649,6 +48824,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clientRemoveWorker`() BEGIN @@ -48671,9 +48848,9 @@ BEGIN JOIN vn.client c ON c.id = cd.id JOIN vn.province p ON p.id = c.provinceFk JOIN vn.country co ON co.id = p.countryFk - WHERE cd.Aviso = 'TERCER AVISO' AND - cp.clientFk IS NULL AND - co.country NOT IN ('Portugal','Francia','España exento') AND + WHERE cd.Aviso = 'TERCER AVISO' AND + cp.clientFk IS NULL AND + co.country NOT IN ('Portugal','Francia','España exento') AND c.salesPersonFk IS NOT NULL; OPEN rs; @@ -48693,8 +48870,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientRisk_update` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48702,6 +48877,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clientRisk_update`(vClientId INT, vCompanyId INT, vAmount DECIMAL(10,2)) BEGIN @@ -48721,8 +48898,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `client_checkBalance` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48730,6 +48905,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `client_checkBalance`(IN vDateTo DATETIME, IN vIsConciliated BOOL) BEGIN @@ -48738,14 +48915,14 @@ BEGIN SET vDateTo = TIMESTAMP(vDateTo,'23:59:59'); SELECT util.firstDayOfYear(vDateTo) INTO vDateFrom; - SELECT s.nickname, c.id , c.accountingAccount , sub1.mysql , sub1.sage, sub1.mysql - sub1.sage diference, sub1.companyFk , c.name + SELECT s.nickname, c.id , c.accountingAccount , sub1.mysql , sub1.sage, sub1.mysql - sub1.sage diference, sub1.companyFk , c.name FROM client c JOIN payMethod pm ON pm.id = c.payMethodFk - JOIN( SELECT sub.companyFk, sub.clientFk, ROUND(SUM(sub.mysql),2) mysql, ROUND(SUM(sub.sage),2) sage + JOIN( SELECT sub.companyFk, sub.clientFk, ROUND(SUM(sub.mysql),2) mysql, ROUND(SUM(sub.sage),2) sage FROM( SELECT io.companyFk, io.clientFk, -io.amount mysql, 0 sage FROM invoiceOut io WHERE issued BETWEEN vDateFrom AND vDateTo - UNION ALL + UNION ALL SELECT r.companyFk, r.clientFk, r.amountPaid, 0 sage FROM receipt r WHERE payed BETWEEN vDateFrom AND vDateTo @@ -48756,23 +48933,21 @@ BEGIN JOIN client c ON c.accountingAccount = xd.SUBCTA WHERE xd.Fecha BETWEEN vDateFrom AND vDateTo )sub - GROUP BY companyFk, clientFk + GROUP BY companyFk, clientFk ) sub1 ON sub1.clientFk = c.id JOIN supplier s ON s.id = sub1.companyFk - JOIN company co ON co.id = sub1.companyFk - WHERE pm.outstandingDebt - AND co.code <> 'BLK' + JOIN company co ON co.id = sub1.companyFk + WHERE pm.outstandingDebt + AND co.code <> 'BLK' HAVING ABS(diference) > 0.05 ORDER BY c.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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `client_RandomList` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48780,6 +48955,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `client_RandomList`(vNumber INT) BEGIN @@ -48787,9 +48964,9 @@ BEGIN DECLARE i INT DEFAULT 0; DECLARE c INT DEFAULT 0; DECLARE maxClientFk INT; - + DROP TEMPORARY TABLE IF EXISTS tmp.client; - + CREATE TEMPORARY TABLE tmp.`client` (id INT AUTO_INCREMENT, clientFk INT, @@ -48797,40 +48974,40 @@ BEGIN PRIMARY KEY(id), UNIQUE KEY clientFk (clientFk)) ENGINE = MEMORY; - + INSERT INTO tmp.client(clientFk) SELECT DISTINCT clientFk FROM vn.invoiceOut - WHERE issued > TIMESTAMPADD(MONTH, -2, CURDATE()); - + WHERE issued > TIMESTAMPADD(MONTH, -2, util.VN_CURDATE()); + SELECT max(id) INTO maxClientFk FROM tmp.client; - - + + WHILE i < vNumber DO - + SET i = i + 1; - + WHILE c = 0 DO - + SELECT id INTO c FROM tmp.client WHERE id = floor(RAND() * maxClientFk) + 1 AND isSelected = FALSE LIMIT 1; - + END WHILE; - + -- SELECT i, maxClientFk, c; - - UPDATE tmp.client - SET isSelected = TRUE + + UPDATE tmp.client + SET isSelected = TRUE WHERE id = c; - + SET c = 0; - + END WHILE; - + SELECT c.id, c.name FROM tmp.client tc JOIN vn.client c ON c.id = tc.clientFk WHERE isSelected @@ -48843,8 +49020,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `cmr_getByTicket` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48852,40 +49027,42 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `cmr_getByTicket`(vTicketFk INT) BEGIN DECLARE vLanded DATE; - - SELECT DATE_ADD(CURDATE(), INTERVAL landingDays DAY) INTO vLanded + + SELECT DATE_ADD(util.VN_CURDATE(), INTERVAL landingDays DAY) INTO vLanded FROM vn.cmrConfig; IF vTicketFk THEN - + IF (SELECT count(ticketFk) FROM vn.cmr WHERE ticketFk = vTicketFk) THEN - + SELECT id FROM vn.cmr WHERE ticketFk = vTicketFk; - + ELSE - + INSERT INTO vn.cmr(ticketFk, companyFk, addressFromFk, addressToFk, ead) SELECT vTicketFk, t.companyFk, a.id, t.addressFk, vLanded FROM vn.ticket t - JOIN vn.warehouse w ON w.id = t.warehouseFk - JOIN vn.address a ON a.id = w.addressFk + JOIN vn.warehouse w ON w.id = t.warehouseFk + JOIN vn.address a ON a.id = w.addressFk WHERE t.id = vTicketFk; - + SELECT LAST_INSERT_ID(); - + END IF; - + ELSE - + INSERT INTO vn.cmr(ead) VALUES(vLanded); - + SELECT LAST_INSERT_ID(); - + END IF; END ;; DELIMITER ; @@ -48893,8 +49070,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `cmr_sendOverview` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48902,15 +49077,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `cmr_sendOverview`() BEGIN /** * Insert the monthly CMR summary in vn.mail on the 5th of each month. */ - + SET SESSION group_concat_max_len = 1000000; --- IF (DAY(CURDATE()) = 5) THEN +-- IF (DAY(util.VN_CURDATE()) = 5) THEN INSERT INTO vn.mail (receiver, replyTo, @@ -48927,7 +49104,7 @@ BEGIN Estimado cliente,
- A continuación le enviamos el resumen menual de CMR ',UPPER(MONTHNAME(CURDATE() - INTERVAL 1 MONTH)),' ', YEAR(CURDATE() - INTERVAL 1 MONTH), '.

+ A continuación le enviamos el resumen menual de CMR ',UPPER(MONTHNAME(util.VN_CURDATE() - INTERVAL 1 MONTH)),' ', YEAR(util.VN_CURDATE() - INTERVAL 1 MONTH), '.

Le rogamos que nos devuelva el resumen firmado a cmr@verdnatura.es


@@ -48936,7 +49113,7 @@ 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 '' ), '

@@ -48946,17 +49123,17 @@ BEGIN JOIN vn.address a ON c.addressToFk = a.id JOIN vn.client c2 ON a.clientFk = c2.id WHERE c.state = 'Pending' - AND MONTH(c.created) = MONTH(CURDATE() - INTERVAL 1 MONTH) - AND YEAR(c.created) = YEAR(CURDATE() - INTERVAL 1 MONTH) + AND MONTH(c.created) = MONTH(util.VN_CURDATE() - INTERVAL 1 MONTH) + AND YEAR(c.created) = YEAR(util.VN_CURDATE() - INTERVAL 1 MONTH) AND c2.email IS NOT NULL -- No cogemos los CMRs dirigidos a 'Verdnatura' GROUP BY c2.id; -- Actualizamos el estado a 'Enviado' UPDATE vn.cmr c SET c.state = 'Sent' - WHERE c.state = 'Pending' - AND MONTH(c.created) = MONTH(CURDATE() - INTERVAL 1 MONTH) - AND YEAR(c.created) = YEAR(CURDATE() - INTERVAL 1 MONTH); + WHERE c.state = 'Pending' + AND MONTH(c.created) = MONTH(util.VN_CURDATE() - INTERVAL 1 MONTH) + AND YEAR(c.created) = YEAR(util.VN_CURDATE() - INTERVAL 1 MONTH); -- END IF; END ;; DELIMITER ; @@ -48964,8 +49141,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `collectionPlacement_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48973,41 +49148,37 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `collectionPlacement_get`(vParamFk INT(11), vIsPicker bool) BEGIN /** Devuelve el listado de ubicaciones a las que hay que ir para preparar una colección o ticket - * + * * @param vParamFk Identificador de vn.collection o Identificador de vn.ticket * @param vIsPicker Booleano para distinguer el sacador del revisador */ DECLARE vCalcFk INT; DECLARE vWarehouseFk INT; - DECLARE vWarehouseAliasFk INT; - DECLARE vCurrentYear INT DEFAULT YEAR(NOW()); + DECLARE vCurrentYear INT DEFAULT YEAR(util.VN_NOW()); DROP TEMPORARY TABLE IF EXISTS tmp.sale; + CREATE TEMPORARY TABLE tmp.sale ENGINE = MEMORY - SELECT 00000000 as ticketFk, - 00000000 as saleFk, - 00000000 as itemFk, - 0 as quantity; - -- 0 AS visible; + SELECT s.ticketFk, s.id saleFk, s.itemFk, s.quantity + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + WHERE tc.collectionFk = vParamFk + UNION ALL + SELECT s.ticketFk, s.id, s.itemFk, s.quantity + FROM vn.sale s + WHERE s.ticketFk = vParamFk; - INSERT INTO tmp.sale(ticketFk, saleFk, itemFk, quantity) - SELECT s.ticketFk, s.id, s.itemFk, s.quantity - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vParamFk - UNION ALL - SELECT s.ticketFk, s.id, s.itemFk, s.quantity - FROM vn.sale s - WHERE s.ticketFk = vParamFk; - SELECT t.warehouseFk, w.aliasFk - INTO vWarehouseFk, vWarehouseAliasFk + SELECT t.warehouseFk + INTO vWarehouseFk FROM vn.ticket t JOIN tmp.sale ts ON ts.ticketFk = t.id JOIN vn.warehouse w ON w.id = t.warehouseFk @@ -49025,8 +49196,8 @@ BEGIN (INDEX(itemFk)) ENGINE = MEMORY SELECT b.itemFk, - CASE b.groupingMode - WHEN 0 THEN 1 + CASE b.groupingMode + WHEN 0 THEN 1 WHEN 2 THEN b.packing ELSE b.`grouping` END AS `grouping` @@ -49048,7 +49219,7 @@ BEGIN ts.itemFk, CAST(0 AS DECIMAL(10,0)) as saleOrder, IF(ish.visible > 0 OR iss.id, 1, 100000) * p.pickingOrder as `order`, - 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, + IF(iss.id, TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,iss.created)), TO_SECONDS(TIMESTAMPADD(YEAR,- year(ish.created),ish.created)) /* + TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,util.VN_NOW())) */ ) as priority, CONCAT( IF( iss.id, CONCAT('< ', IFNULL(wk.`code`, '---'),' > '), @@ -49066,10 +49237,10 @@ BEGIN , st.saleFk as salePreviousPrepared , iss.userFk , ts.quantity - FROM tmp.sale ts - LEFT JOIN (SELECT DISTINCT saleFk + FROM tmp.sale ts + LEFT JOIN (SELECT DISTINCT saleFk FROM vn.saleTracking st - JOIN vn.state s ON s.id = st.stateFk + 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 @@ -49080,10 +49251,9 @@ BEGIN 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 + WHERE w.id = vWarehouseFk AND NOT sc.isHideForPickers - HAVING (iss.id AND st.saleFk) OR salePreviousPrepared IS NULL - ; + HAVING (iss.id AND st.saleFk) OR salePreviousPrepared IS NULL; DROP TEMPORARY TABLE IF EXISTS tmp.salePlacementList_2; CREATE TEMPORARY TABLE tmp.salePlacementList_2 @@ -49091,13 +49261,13 @@ BEGIN SELECT saleFk, priority as olderPriority FROM (SELECT saleFk, priority FROM tmp.salePlacementList - ORDER BY isPreviousPrepared DESC, + ORDER BY isPreviousPrepared DESC, itemShelvingSaleFk IS NULL DESC, - visible >= quantity DESC, + visible >= quantity DESC, visible > 0 DESC, IFNULL(shelvingPriority,0) DESC, priority - LIMIT 10000000000000000000 + LIMIT 10000000000000000000 ) sub GROUP BY saleFk; @@ -49106,7 +49276,7 @@ BEGIN 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; + 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 @@ -49114,16 +49284,16 @@ BEGIN /* -- Anula el orden de antigüedad y ordena por ubicación UPDATE tmp.salePlacementList - SET saleOrder = `order`;*/ + SET saleOrder = `order`;*/ SELECT spl.* FROM tmp.salePlacementList spl JOIN vn.sale s ON s.id = spl.saleFk ORDER BY saleOrder, - isPreviousPrepared DESC, - itemShelvingSaleFk, + isPreviousPrepared DESC, + itemShelvingSaleFk DESC, IF(vIsPicker, visible = 0, TRUE), - s.quantity <= spl.visible DESC, + s.quantity <= spl.visible DESC, shelvingPriority DESC, -- PAK 05/11/2021 priority; @@ -49131,6 +49301,7 @@ BEGIN tmp.sale, tmp.sale2, tmp.`grouping`, + tmp.salePlacementList, tmp.grouping2, tmp.salePlacementList_2, tmp.salePlacementList_3; @@ -49140,8 +49311,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `collection_addItem` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49149,77 +49318,87 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_addItem`(vItemFk INT, vQuantity INT, vTicketFk INT) BEGIN DECLARE vConcept VARCHAR(50); DECLARE itemFk INT; DECLARE vSaleFk INT default 0; - + DECLARE vDescription VARCHAR(50); DECLARE vItemName VARCHAR(50); - + SELECT barcodeToItem(vItemFk) INTO itemFk; - - SELECT CONCAT(vn.getUser()," ",DATE_FORMAT(NOW( ), "%H:%i" )," ",i.name) INTO vConcept FROM vn.item i WHERE i.id = itemFk; - + + SELECT CONCAT(vn.getUser()," ",DATE_FORMAT(util.VN_NOW( ), "%H:%i" )," ",i.name) INTO vConcept FROM vn.item i WHERE i.id = itemFk; + SELECT name INTO vItemName FROM vn.item WHERE id = vItemFk; SELECT CONCAT("Añadido articulo ", vItemName, " cantidad:", vQuantity) INTO vDescription; - - INSERT INTO vn.ticketLog (originFk, userFk, action , description) + + INSERT INTO vn.ticketLog (originFk, userFk, action , description) VALUES(vTicketFk, vn.getUser(), 'update', vDescription); - + INSERT INTO vn.sale (itemFk,ticketFk,concept,quantity,isAdded) VALUES (itemFk,vTicketFk,vConcept,vQuantity,1); SELECT last_insert_id() INTO vSaleFk; - + 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `collection_get` */; /*!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 collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_get`(vWorkerFk INT) BEGIN - - /* Obtiene colección del sacador si tiene líneas pendientes - * - * @param vWorkerFk id del worker - */ - SELECT c.id AS collectionFk, date(c.created) AS created, count(DISTINCT s.id) totalRow, count(DISTINCT st.id) pickedRow - FROM vn.collection c - JOIN vn.ticketCollection tc on tc.collectionFk = c.id - JOIN vn.sale s on s.ticketFk = tc.ticketFk - JOIN vn.state ss on ss.code = 'PREPARED' - LEFT JOIN vn.saleTracking st on st.saleFk = s.id AND st.stateFk = ss.id - WHERE c.workerFk = vWorkerFk - AND c.created >= TIMESTAMPADD(HOUR , -6,NOW()) - AND s.quantity != 0 + /* Obtiene colección del sacador si tiene líneas pendientes + * + * @param vWorkerFk id del worker + * + * @table Devuelve tabla temporal con las colecciones pendientes. + */ + DROP TEMPORARY TABLE IF EXISTS tCollection; + + CREATE TEMPORARY TABLE tCollection + SELECT c.id collectionFk, + date(c.created) created + FROM collection c + JOIN ticketCollection tc ON tc.collectionFk = c.id + JOIN sale s ON s.ticketFk = tc.ticketFk + JOIN ticketState ts ON ts.ticketFk = tc.ticketFk + JOIN state s2 ON s2.id = ts.stateFk + JOIN productionConfig pc + JOIN vn.state ss on ss.code = 'PREPARED' + LEFT JOIN vn.saleTracking st on st.saleFk = s.id AND st.stateFk = ss.id + WHERE c.workerFk = vWorkerFk + AND TIMESTAMPDIFF(HOUR, c.created , util.VN_NOW()) < pc.pendingCollectionsAge + AND s.quantity != 0 + AND s2.order < pc.pendingCollectionsOrder GROUP BY c.id - HAVING totalRow > pickedRow; - + HAVING COUNT(*) > COUNT(DISTINCT st.id); + + SELECT * FROM tCollection; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `collection_getTickets` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49227,6 +49406,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_getTickets`(vParamFk INT) BEGIN @@ -49234,15 +49415,15 @@ 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 + FROM vn.collection WHERE id = vParamFk; - SELECT t.id ticketFk, + SELECT t.id ticketFk, IF (!(vItemPackingTypeFk <=> 'V'), cc.code,CONCAT(SUBSTRING('ABCDEFGH',tc.wagon, 1),'-',tc.`level` )) `level`, am.name agencyName, t.warehouseFk, @@ -49251,20 +49432,20 @@ BEGIN FROM vn.ticket t LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk -- PAK 23/12/21 - LEFT JOIN vn.collectionColors cc - ON cc.wagon = tc.wagon - AND cc.shelve = tc.`level` + LEFT JOIN vn.collectionColors cc + ON cc.wagon = tc.wagon + AND cc.shelve = tc.`level` AND cc.trainFk = c2.trainFk -- PAK 23/12/21 - LEFT JOIN vn.zone z ON z.id = t.zoneFk + 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 + LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id AND tob.observationTypeFk = 1 - WHERE t.id = vParamFk + WHERE t.id = vParamFk AND t.shipped >= util.yesterday() UNION ALL - SELECT t.id ticketFk, + SELECT t.id ticketFk, IF(!(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`, am.name agencyName, t.warehouseFk, @@ -49273,15 +49454,15 @@ BEGIN FROM vn.ticket t JOIN vn.ticketCollection tc ON t.id = tc.ticketFk LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk -- PAK 23/12/21 - LEFT JOIN vn.collectionColors cc - ON cc.wagon = tc.wagon - AND cc.shelve = tc.`level` + LEFT JOIN vn.collectionColors cc + ON cc.wagon = tc.wagon + AND cc.shelve = tc.`level` AND cc.trainFk = c2.trainFk -- PAK 23/12/21 - LEFT JOIN vn.zone z ON z.id = t.zoneFk + 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 + LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id AND tob.observationTypeFk = 1 WHERE tc.collectionFk = vParamFk; @@ -49291,39 +49472,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collection_get_` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_get_`(vWorkerFk INT) -BEGIN - - /* Obtiene colección del sacador si tiene líneas pendientes - * - * @param vWorkerFk id del worker - */ - - SELECT c.id AS collectionFk, date(c.created) AS created - FROM vn.collection c - LEFT JOIN vn.state s ON c.stateFk = s.id - WHERE c.workerFk = vWorkerFk AND s.code = 'ON_PREPARATION' - AND created >= TIMESTAMPADD(HOUR , -6,NOW()); - - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `collection_kill` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49331,31 +49479,31 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_kill`(vSelf INT) BEGIN - + /* Elimina una coleccion y coloca sus tickets en OK - * + * */ - + INSERT INTO vncontrol.inter(state_id, Id_Ticket) SELECT s.id, ticketFk FROM vn.ticketCollection tc JOIN vn.state s ON s.code = 'OK' WHERE tc.collectionFk = vSelf; - - DELETE FROM vn.collection + + DELETE FROM vn.collection WHERE 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `collection_missingTrash` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49363,6 +49511,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_missingTrash`( vSaleFk BIGINT, @@ -49403,7 +49553,7 @@ BEGIN SELECT t.id INTO vTicketFk FROM ticket t - WHERE t.created > DATE_SUB(NOW(), INTERVAL 1 DAY) + WHERE t.created > DATE_SUB(util.VN_NOW(), INTERVAL 1 DAY) AND t.clientFk = vClientFk AND t.warehouseFk = vWarehouseFk LIMIT 1; @@ -49420,7 +49570,7 @@ BEGIN WHERE code = 'VNL'; CALL ticket_add(vClientFk, - NOW(), vWarehouseFk, + util.VN_NOW(), vWarehouseFk, vCompanyVnlFk, vConsignatario, NULL, @@ -49432,7 +49582,7 @@ BEGIN SELECT t.id INTO vTicketFk FROM ticket t - WHERE t.created > DATE_SUB(NOW(), INTERVAL 1 DAY) + WHERE t.created > DATE_SUB(util.VN_NOW(), INTERVAL 1 DAY) AND t.clientFk = vClientFk AND t.warehouseFk = vWarehouseFk LIMIT 1; @@ -49453,7 +49603,7 @@ BEGIN isAdded) SELECT itemFk, vTicketFk, - CONCAT(concept," ",getWorkerCode(), " ", LEFT(CAST(NOW() AS TIME),5)), + CONCAT(concept," ",getWorkerCode(), " ", LEFT(CAST(util.VN_NOW() AS TIME),5)), vQuantity, originalQuantity, price, @@ -49481,8 +49631,349 @@ 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 `collection_new` */; +/*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_new`(vSectorFk INT, vWagons INT, vTrainFk INT, vUserFk INT, OUT vCollectionFk INT) +proc:BEGIN +/* Genera colecciones de tickets y devuelve el primer vn.collection.id + * + * @param vSectorFk Identificador de vn.sector + * @param vWagons Número de carros que lleva + * @param vTrainFk Identificador de vn.train + * @param vUserFk Identificador de account.user + * + * @return vCollectionFk Número de colección + */ + + DECLARE vWarehouseFk INT; + DECLARE vMaxTickets INT; + DECLARE vStateFk INT; + DECLARE vFirstTicketFk INT; + DECLARE vHour INT; + DECLARE vMinute INT; + DECLARE vWorkerCode VARCHAR(3); + DECLARE vWagonCounter INT DEFAULT 0; + DECLARE vTicketFk INT; + DECLARE vItemPackingTypeFk VARCHAR(1); + DECLARE vHasAssignedTickets BOOLEAN; + DECLARE vMaxNotReadyCollections INT; + DECLARE vNotReadyCollections INT; + DECLARE vHasUniqueCollectionTime BOOL; + DECLARE vDone INT DEFAULT FALSE; + DECLARE vLockName VARCHAR(215); + DECLARE vLockTime INT DEFAULT 15; + DECLARE vFreeWagonFk INT; + DECLARE cur1 CURSOR FOR + SELECT ticketFk + FROM tmp.productionBuffer + WHERE ticketFk <> vFirstTicketFk + ORDER BY + HH, + mm, + productionOrder DESC, + m3 DESC, + agency, + zona, + routeFk, + ticketFk + LIMIT vMaxTickets; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + SELECT + pc.ticketTrolleyMax * vWagons, + pc.maxNotReadyCollections, + pc.hasUniqueCollectionTime, + w.code, + s.warehouseFk, + s.itemPackingTypeFk, + st.id, + CONCAT('collection_new',vSectorFk) + INTO + vMaxTickets, + vMaxNotReadyCollections, + vHasUniqueCollectionTime, + vWorkerCode, + vWarehouseFk, + vItemPackingTypeFk, + vStateFk, + vLockName + FROM vn.productionConfig pc + JOIN vn.worker w ON w.id = vUserFk + JOIN vn.sector s ON s.id = vSectorFk + JOIN vn.state st ON st.`code` = 'ON_PREPARATION'; + + -- Si hay colecciones sin terminar, sale del proceso + CALL vn.collection_get(vUserFk); + + SELECT COUNT(*) + INTO vNotReadyCollections + FROM tCollection; + + DROP TEMPORARY TABLE tCollection; + + IF vMaxNotReadyCollections < vNotReadyCollections THEN + CALL util.throw('Hay colecciones pendientes'); + LEAVE proc; + END IF; + + IF NOT GET_LOCK(vLockName,vLockTime) THEN + LEAVE proc; + END IF; + + -- Se prepara el tren, con tantos vagones como sea necesario. + CREATE OR REPLACE TEMPORARY TABLE tTrain + (wagon INT, + shelve INT, + liters INT, + `lines`INT, + height INT, + ticketFk INT, + PRIMARY KEY(wagon, shelve)) + ENGINE = MEMORY; + + WHILE vWagons > vWagonCounter DO + SET vWagonCounter = vWagonCounter + 1; + + INSERT INTO tTrain(wagon, shelve, liters, `lines`, height) + SELECT vWagonCounter, cv.`level` , cv.liters , cv.`lines` , cv.height + FROM vn.collectionVolumetry cv + WHERE cv.trainFk = vTrainFk + AND cv.itemPackingTypeFk = vItemPackingTypeFk; + END WHILE; + + -- Esto desaparecerá cuando tengamos la table cache.ticket + CALL vn.productionControl(vWarehouseFk, 0); + + ALTER TABLE tmp.productionBuffer + ADD COLUMN liters INT, + ADD COLUMN height INT; + + -- Se obtiene nº de colección. + INSERT INTO vn.collection + SET workerFk = vUserFk, + itemPackingTypeFk = vItemPackingTypeFk, + trainFk = vTrainFk; + + SELECT LAST_INSERT_ID() INTO vCollectionFk; + + -- Los tickets de recogida en Algemesí sólo se sacan si están asignados. + -- Los pedidos con riesgo no se sacan aunque se asignen. + DELETE pb.* + FROM tmp.productionBuffer pb + JOIN vn.state s ON s.id = pb.state + WHERE (pb.agency = 'REC_ALGEMESI' + AND s.code <> 'PICKER_DESIGNED') + OR pb.problem LIKE '%RIESGO%'; + + -- 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 vHasAssignedTickets + FROM tmp.productionBuffer pb + JOIN vn.state s ON s.id = pb.state + WHERE s.code = 'PICKER_DESIGNED' + AND pb.workerCode = vWorkerCode; + + -- Se dejan en la tabla tmp.productionBuffer sólo aquellos tickets adecuados + IF vHasAssignedTickets THEN + DELETE pb.* + FROM tmp.productionBuffer pb + JOIN vn.state s ON s.id = pb.state + WHERE s.code <> 'PICKER_DESIGNED' + OR pb.workerCode <> vWorkerCode; + ELSE + DELETE pb.* + 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 + JOIN vn.productionConfig pc + WHERE pb.shipped <> util.VN_CURDATE() + OR (pb.ubicacion IS NULL AND a.isOwn = TRUE) + OR (s.isPreparable = FALSE AND s.isPrintable = FALSE) + OR pb.collectionH IS NOT NULL + OR pb.collectionV IS NOT NULL + OR pb.collectionN IS NOT NULL + OR (pb.H = 0 AND pb.V > 0 AND vItemPackingTypeFk = 'H') + OR (pb.V = 0 AND vItemPackingTypeFk = 'V') + OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking) + OR LENGTH(pb.problem) > 0; + END IF; + + -- Es importante que el primer ticket se coja en todos los casos + SELECT ticketFk, HH, mm + INTO vFirstTicketFk, vHour, vMinute + FROM tmp.productionBuffer + ORDER BY + HH, + mm, + productionOrder DESC, + m3 DESC, + agency, + zona, + routeFk, + ticketFk + LIMIT 1; + + -- Hay que excluir aquellos que no tengan la misma hora de preparación, si procede + IF vHasUniqueCollectionTime THEN + DELETE + FROM tmp.productionBuffer + WHERE HH <> vHour + OR mm <> vMinute; + END IF; + + SET vTicketFk = vFirstTicketFk; + + OPEN cur1; + + read_loop: LOOP + SET vDone = FALSE; + + CALL vn.ticket_splitItemPackingType(vTicketFk, vItemPackingTypeFk); + + DROP TEMPORARY TABLE tmp.ticketIPT; + + UPDATE tmp.productionBuffer pb + JOIN (SELECT @litros:= SUM(litros) liters, COUNT(*) `lines`, MAX(i.`size`) height + FROM vn.saleVolume sv + JOIN vn.sale s ON s.id = sv.saleFk + JOIN vn.item i ON i.id = s.itemFk + WHERE sv.ticketFk = vTicketFk ) sub + SET pb.liters = sub.liters, pb.`lines` = sub.`lines`, pb.height = sub.height + WHERE pb.ticketFk = vTicketFk; + + UPDATE tTrain tt + JOIN tmp.productionBuffer pb ON pb.ticketFk = vTicketFk + SET tt.ticketFk = pb.ticketFk + WHERE tt.liters >= pb.liters + AND tt.`lines` >= pb.`lines` + AND (tt.height >= pb.height OR vItemPackingTypeFk <> 'V') + AND tt.ticketFk IS NULL + ORDER BY + wagon, + shelve, + tt.liters, + tt.`lines`, + tt.height + LIMIT 1; + + -- Si no le encuentra una balda adecuada, intentamos darle un carro entero + -- si queda alguno libre + + IF NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN + SELECT tt.wagon + INTO vFreeWagonFk + FROM tTrain tt + LEFT JOIN (SELECT DISTINCT wagon + FROM tTrain + WHERE ticketFk IS NOT NULL + ) nn ON nn.wagon = tt.wagon + WHERE nn.wagon IS NULL + ORDER BY wagon + LIMIT 1; + + IF vFreeWagonFk THEN + UPDATE tTrain + SET ticketFk = vFirstTicketFk + WHERE wagon = vFreeWagonFk; + END IF; + END IF; + + FETCH cur1 INTO vTicketFk; + + IF vDone OR NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk IS NULL) THEN + LEAVE read_loop; + END IF; + END LOOP; + + CLOSE cur1; + + IF (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN + 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 + INSERT IGNORE INTO vn.ticketCollection(ticketFk, collectionFk, `level`, wagon, liters) + SELECT tt.ticketFk, vCollectionFk, tt.shelve, tt.wagon, tt.liters + FROM tTrain tt + WHERE tt.ticketFk IS NOT NULL + ORDER BY tt.wagon, tt.shelve; + + -- Actualiza el estado de los tickets + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT vStateFk, ticketFk, vUserFk + 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; + + 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; + + ELSE + + -- CALL util.throw('No ha sido posible obtener colección'); + DELETE FROM vn.collection WHERE id = vCollectionFk; + SET vCollectionFk = NULL; + + END IF; + + DO RELEASE_LOCK(vLockName); +/* + SELECT + pb.HH, + pb.mm, + pb.agency, + tc.collectionFk, + tc.ticketFk, + tc.wagon, + tc.`level`, + tc.liters, + tc.itemCount, + pb.liters, + pb.`lines` + FROM vn.collection c + JOIN vn.ticketCollection tc ON tc.collectionFk = c.id + JOIN tmp.productionBuffer pb ON pb.ticketFk = tc.ticketFk + WHERE c.created >= util.VN_CURDATE() + ORDER BY tc.collectionFk DESC, tc.wagon, tc.`level`; + */ + DROP TEMPORARY TABLE + tTrain, + tmp.productionBuffer; +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_newSmartTag` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49490,6 +49981,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_newSmartTag`(vSectorFk INT) proc:BEGIN @@ -49502,7 +49995,7 @@ proc:BEGIN WHERE w.id = vn.getUser(); SELECT COUNT(ws.id) INTO vWagons - FROM workerShelving ws + FROM workerShelving ws WHERE ws.workerFk = vWorkerFk AND ws.collectionFk IS NULL; @@ -49532,7 +50025,7 @@ proc:BEGIN ORDER BY wagon ASC, level ASC; UPDATE vn.ticketCollection tc - JOIN tmp.smartTags ts ON tc.wagon = ts.wagon AND tc.level = ts.level + JOIN tmp.smartTags ts ON tc.wagon = ts.wagon AND tc.level = ts.level SET tc.smartTagFk = ts.code WHERE tc.collectionFk = vCollectionFk; @@ -49543,8 +50036,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `collection_newWithWagon` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49552,6 +50043,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_newWithWagon`(vSectorFk INT, vWagons INT) proc:BEGIN @@ -49579,14 +50072,14 @@ proc:BEGIN DECLARE vTrainFk INT DEFAULT 1; DECLARE vUserFk INT; DECLARE vHourMatters BOOL DEFAULT TRUE; - + SELECT pc.ticketPrintedMax * vWagons, pc.ticketTrolleyMax * vWagons, pc.maxNotReadyCollections INTO vMaxTicketPrinted, vMaxTickets, vMaxNotReadyCollections FROM vn.productionConfig pc; /*IF NOT vn.deviceProductionUser_Exists(vUserFk) THEN - + LEAVE proc; - + END IF;*/ SELECT w.code, w.id INTO vWorkerCode, vUserFk @@ -49598,44 +50091,44 @@ proc:BEGIN INTO vIsPreviousPrepared, vWarehouseFk, vItemPackingTypeFk FROM vn.sector WHERE id = vSectorFk; -- Hola - + -- Si está habilitado el modo cazador para las motos, y el usuario no esta registrado, se sale. - - IF (SELECT isTractorHuntingMode FROM vn.deviceProductionConfig dpc) AND vItemPackingTypeFk = 'H' THEN - IF (SELECT COUNT(*) FROM vn.workerWithoutTractor wwt WHERE wwt.workerFk = vUserFk) THEN + + IF (SELECT isTractorHuntingMode FROM vn.deviceProductionConfig dpc) AND vItemPackingTypeFk = 'H' THEN + IF (SELECT COUNT(*) FROM vn.workerWithoutTractor wwt WHERE wwt.workerFk = vUserFk) THEN CALL util.throw('Usuario no registrado con moto'); LEAVE proc; END IF; END IF; - - + + -- Si hay colecciones sin terminar, sale del proceso SELECT count(*) INTO vNotReadyCollections FROM ( SELECT count(DISTINCT s.id) totalRow, count(DISTINCT st.id) pickedRow - FROM vn.collection c - JOIN vn.ticketCollection tc ON tc.collectionFk = c.id - JOIN vn.sale s ON s.ticketFk = tc.ticketFk + FROM vn.collection c + JOIN vn.ticketCollection tc ON tc.collectionFk = c.id + JOIN vn.sale s ON s.ticketFk = tc.ticketFk JOIN vn.state ss ON ss.code = 'PREPARED' LEFT JOIN vn.saleTracking st ON st.saleFk = s.id AND st.stateFk = ss.id - WHERE c.workerFk = vUserFk - AND c.created >= TIMESTAMPADD(HOUR , -6,NOW()) + WHERE c.workerFk = vUserFk + AND c.created >= TIMESTAMPADD(HOUR , -6,util.VN_NOW()) AND s.quantity != 0 GROUP BY c.id - HAVING totalRow > pickedRow) sub; + HAVING totalRow > pickedRow) sub; IF vMaxNotReadyCollections < vNotReadyCollections THEN - + CALL util.throw('Hay colecciones pendientes'); LEAVE proc; - + END IF; IF vIsPreviousPrepared THEN CALL util.throw('Es de preparación previa'); LEAVE proc; -- Hasta que tengamos el altillo, vamos a cancelar esta opcion - + SELECT id INTO vStateFk FROM vn.state WHERE `code` = 'PREVIOUS_PREPARATION'; @@ -49647,37 +50140,37 @@ proc:BEGIN END IF; - CALL vn.productionControl(vWarehouseFk, 0); + CALL vn.productionControl(vWarehouseFk, 0); -- Esto hay que corregirlo añadiendo un nuevo parámetro al proc. PAK 23/12/21 IF vSectorFk = 65 THEN -- Pedidos pequeños - + SET vTrainFk = 2; - + SET vHourMatters = FALSE; - - DELETE pb.* + + DELETE pb.* FROM tmp.productionBuffer pb - JOIN vn.volumeConfig vc + JOIN vn.volumeConfig vc WHERE pb.m3 * 1000 > vc.minTicketVolume; - + END IF; - -- Se obtiene nº de colección y el buffer con los pedidos preparables + -- Se obtiene nº de colección y el buffer con los pedidos preparables INSERT INTO vn.collection SET workerFk = vUserFk, itemPackingTypeFk = vItemPackingTypeFk, trainFk = vTrainFk; - + SELECT LAST_INSERT_ID() INTO vCollectionFk; - + -- 05/08/2021 PAK Jose Frau pide que los tickets de recogida en Algemesí sólo se saquen si están asignados. DELETE pb.* FROM tmp.productionBuffer pb JOIN vn.state s ON s.id = pb.state WHERE pb.agency = 'REC_ALGEMESI' AND s.code != 'PICKER_DESIGNED'; - + -- 2/3/2022 PAK Se acuerda con Pepe que los pedidos con riesgo no se sacan aunque se asignen. DELETE pb.* FROM tmp.productionBuffer pb @@ -49690,13 +50183,13 @@ proc:BEGIN JOIN vn.state s ON s.id = pb.state WHERE s.code = 'PICKER_DESIGNED' AND pb.workerCode = vWorkerCode; - + IF hasAssignedTickets THEN - - UPDATE vn.collection - SET itemPackingTypeFk = NULL + + UPDATE vn.collection + SET itemPackingTypeFk = NULL WHERE id = vCollectionFk; - + DROP TEMPORARY TABLE IF EXISTS tmp.ticketToSplit; CREATE TEMPORARY TABLE tmp.ticketToSplit SELECT pb.ticketFk @@ -49704,42 +50197,42 @@ proc:BEGIN JOIN vn.state s ON s.id = pb.state WHERE s.code = 'PICKER_DESIGNED' AND pb.workerCode = vWorkerCode - ORDER BY HH, - mm, - s.`order` DESC, + ORDER BY HH, + mm, + s.`order` DESC, pb.m3 DESC; - - WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO - + + WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO + SELECT MIN(ticketFk) INTO vTicketToSplit FROM tmp.ticketToSplit; - - CALL vn.ticket_splitItemPackingType(vTicketToSplit); - + + CALL vn.ticket_splitItemPackingType(vTicketToSplit,IFNULL(vItemPackingTypeFk, 'H')); + INSERT INTO vn.ticketCollection(ticketFk, collectionFk) SELECT ticketFk, vCollectionFk FROM tmp.ticketIPT - WHERE (itemPackingTypeFk = vItemPackingTypeFk) ; - + WHERE (itemPackingTypeFk = vItemPackingTypeFk) ; + 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 - JOIN vn.productionConfig pc - WHERE pb.shipped = CURDATE() - AND (pb.ubicacion IS NOT NULL + JOIN vn.productionConfig pc + WHERE pb.shipped = util.VN_CURDATE() + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) AND s.isPreparable AND ( @@ -49747,7 +50240,7 @@ proc:BEGIN OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV)) OR (pb.H = 0 AND pb.V = 0 AND pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) ) - AND (pc.isPreviousPreparationRequired = FALSE + AND (pc.isPreviousPreparationRequired = FALSE OR pb.previousWithoutParking = FALSE); SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets; @@ -49758,16 +50251,16 @@ proc:BEGIN SELECT s2.id, pb.ticketFk, vUserFk FROM tmp.productionBuffer pb JOIN vn.agencyMode am ON am.id = pb.agencyModeFk - JOIN vn.agency a ON a.id = am.agencyFk + 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 JOIN vn.ticketConfig tc JOIN vn.productionConfig pc - WHERE pb.shipped = CURDATE() - AND (LENGTH(pb.problem) = 0 + WHERE pb.shipped = util.VN_CURDATE() + AND (LENGTH(pb.problem) = 0 OR (pb.problem = 'PEQUEÑO' AND vTrainFk = 2)) - AND (pb.ubicacion IS NOT NULL + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) AND s.isPrintable AND s.isOK @@ -49776,24 +50269,24 @@ proc:BEGIN OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV)) OR (pb.H = 0 AND pb.V = 0 AND pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) ) - AND t.created < TIMESTAMPADD(MINUTE, - tc.pickingDelay , NOW()) - AND (pc.isPreviousPreparationRequired = FALSE + AND t.created < TIMESTAMPADD(MINUTE, - tc.pickingDelay , util.VN_NOW()) + AND (pc.isPreviousPreparationRequired = FALSE OR pb.previousWithoutParking = FALSE) - ORDER BY HH, + ORDER BY HH, mm, s.`order` DESC, pb.m3 DESC LIMIT vMaxTicketPrinted; - + -- 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, (pb.H + pb.V = 0) isNeutral FROM tmp.productionBuffer pb JOIN vn.agencyMode am ON am.id = pb.agencyModeFk - JOIN vn.agency a ON a.id = am.agencyFk + 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 JOIN vn.productionConfig pc @@ -49802,46 +50295,46 @@ proc:BEGIN OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV)) OR (pb.H = 0 AND pb.V = 0 AND pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) ) - AND (pb.ubicacion IS NOT NULL + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) AND LENGTH(pb.problem) = 0 AND s.isPreparable - AND (pc.isPreviousPreparationRequired = FALSE + AND (pc.isPreviousPreparationRequired = FALSE OR pb.previousWithoutParking = FALSE) ORDER BY pb.HH, pb.mm, s.`order` DESC LIMIT vMaxTickets; - - WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO - + + WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO + SELECT MIN(ticketFk) INTO vTicketToSplit FROM tmp.ticketToSplit; - - - IF (SELECT isNeutral - FROM tmp.ticketToSplit + + + IF (SELECT isNeutral + FROM tmp.ticketToSplit WHERE ticketFk = vTicketToSplit) THEN - + INSERT INTO vn.ticketCollection(ticketFk, collectionFk) VALUES(vTicketToSplit, vCollectionFk); - + ELSE - - CALL vn.ticket_splitItemPackingType(vTicketToSplit); - + + CALL vn.ticket_splitItemPackingType(vTicketToSplit, vItemPackingTypeFk); + INSERT INTO vn.ticketCollection(ticketFk, collectionFk) SELECT ticketFk, vCollectionFk FROM tmp.ticketIPT WHERE itemPackingTypeFk = vItemPackingTypeFk; - + DROP TEMPORARY TABLE tmp.ticketIPT; - + END IF; - + DELETE FROM tmp.ticketToSplit WHERE ticketFk = vTicketToSplit; - + END WHILE; - + END IF; -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección @@ -49868,20 +50361,20 @@ proc:BEGIN SELECT t.ticketFk, SUM(s.quantity * vc.shelveVolume / i.packingShelve) shelveLiters FROM tmp.ticket t JOIN vn.sale s ON s.ticketFk = t.ticketFk - JOIN vn.item i ON i.id = s.itemFk + JOIN vn.item i ON i.id = s.itemFk JOIN vn.volumeConfig vc - WHERE i.packingShelve + WHERE i.packingShelve GROUP BY t.ticketFk; - UPDATE tmp.ticket t + UPDATE tmp.ticket t JOIN tmp.ticketShelveLiters tsl ON tsl.ticketFk = t.ticketFk SET t.shelveLiters = tsl.shelveLiters; -- Es importante que el primer ticket se coja en todos los casos - + SET vFirstTicketFk = 0; - SELECT ticketFk, HH, mm + SELECT ticketFk, HH, mm INTO vFirstTicketFk, vHour, vMinute FROM tmp.ticket ORDER BY productionOrder DESC, HH, mm @@ -49889,47 +50382,47 @@ proc:BEGIN -- Hay que excluir aquellos que no tengan la misma hora de preparación IF vHourMatters THEN - - DELETE + + DELETE FROM tmp.ticket - WHERE HH != vHour + WHERE HH != vHour OR mm != vMinute; - + END IF; - + -- 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.shelveLiters > vc.trolleyM3 * 1000) FROM tmp.ticket t - JOIN vn.volumeConfig vc + JOIN vn.volumeConfig vc WHERE t.ticketFk = vFirstTicketFk) THEN - DELETE - FROM tmp.ticket + DELETE + FROM tmp.ticket WHERE ticketFk != vFirstTicketFk; - + ELSE - + DELETE t.* - FROM tmp.ticket t - JOIN vn.volumeConfig vc + FROM tmp.ticket t + JOIN vn.volumeConfig vc WHERE t.shelveLiters > vc.trolleyM3 * 1000; - + END IF; -- Elimina los tickets bloqueados que no se van a preparar - DELETE tc.* + 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, + ( SELECT MAX(i.size) maxHeigth, tc.ticketFk FROM vn.ticketCollection tc JOIN vn.sale s ON s.ticketFk = tc.ticketFk @@ -49938,11 +50431,11 @@ proc:BEGIN 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, + SELECT cv.`level` as shelve, 1 as wagon, cv.`lines`, cv.liters, @@ -49958,7 +50451,7 @@ proc:BEGIN SET vWagonCounter = vWagonCounter + 1; INSERT INTO tmp.wagonsVolumetry(shelve, wagon, `lines`, liters, height) - SELECT cv.`level` as shelve, + SELECT cv.`level` as shelve, vWagonCounter as wagon, cv.`lines`, cv.liters, @@ -49974,11 +50467,11 @@ proc:BEGIN SELECT ticketFk, shelve, wagon, linesDif, LitersDif, heightDif FROM ( SELECT t.ticketFk, - wv.shelve, + wv.shelve, wv.wagon, t.productionOrder, - CAST(wv.`lines` AS SIGNED) - t.`lines` as linesDif, - CAST(wv.liters AS SIGNED) - t.shelveLiters as litersDif, + CAST(wv.`lines` AS SIGNED) - t.`lines` as linesDif, + CAST(wv.liters AS SIGNED) - t.shelveLiters as litersDif, CAST(wv.height AS SIGNED) - t.height as heightDif FROM tmp.wagonsVolumetry wv JOIN tmp.ticket t @@ -49987,14 +50480,14 @@ proc:BEGIN 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 @@ -50010,57 +50503,57 @@ proc:BEGIN 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 + ORDER BY heightDif, litersDif, linesDif LIMIT 1; END IF; IF vShelve > 0 THEN - - UPDATE tmp.ticket + + 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 + + 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 + + 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; @@ -50069,29 +50562,29 @@ proc:BEGIN DELETE FROM tmp.ticket WHERE shelve = 0; -- Elimina los tickets bloqueados que no se van a preparar - DELETE tc.* + 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.* + DELETE tc.* FROM vn.ticketCollection tc - JOIN vn.ticketCollection tc2 ON tc2.ticketFk = tc.ticketFk + 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; + WHERE c.id = vCollectionFk; -- Asigna las bandejas UPDATE vn.ticketCollection tc JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk - SET tc.level = t.shelve, + SET tc.level = t.shelve, tc.wagon = t.wagon, tc.itemCount = t.`lines`, tc.liters = t.shelveLiters; @@ -50099,38 +50592,38 @@ proc:BEGIN -- Actualiza el estado de los tickets INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) SELECT vStateFk, ticketFk, vUserFk - FROM vn.ticketCollection tc + 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 + IF (SELECT count(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk) THEN CALL vn.salesMerge_byCollection(vCollectionFk); UPDATE vn.collection c - JOIN (SELECT count(*) saleTotalCount , + 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, + ) sub + SET c.saleTotalCount = sub.saleTotalCount, c.salePickedCount = sub.salePickedCount WHERE c.id = vCollectionFk; - - SELECT vCollectionFk; + + SELECT vCollectionFk; ELSE CALL util.throw('No ha sido posible obtener colección'); DELETE FROM vn.collection WHERE id = vCollectionFk; - + END IF; DROP TEMPORARY TABLE @@ -50140,648 +50633,14 @@ proc:BEGIN tmp.wagonsVolumetry, tmp.ticketShelve, tmp.productionBuffer; - + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collection_newWithWagon_beta` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_newWithWagon_beta`(vUserFk INT, vSectorFk INT, vWagons 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 vWorkerCode VARCHAR(3); - DECLARE vWagon INT; - DECLARE vWagonCounter INT; - DECLARE vShelve INT; - DECLARE vTicket INT; - DECLARE vTicketToSplit INT; - DECLARE vPrintedTickets INT; - DECLARE vMaxTicketPrinted INT; - DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE hasAssignedTickets BOOLEAN; - DECLARE vMaxNotReadyCollections INT DEFAULT 0; - DECLARE vNotReadyCollections INT; - DECLARE vTrainFk INT DEFAULT 1; - DECLARE vNow DATETIME; - - SELECT ticketPrintedMax * vWagons, ticketTrolleyMax * vWagons, pc.maxNotReadyCollections , NOW() - INTO vMaxTicketPrinted, vMaxTickets, vMaxNotReadyCollections, vNow - FROM vn.productionConfig pc; - - SELECT w.code INTO vWorkerCode - FROM vn.worker w - WHERE w.id = vUserFk; - - -- 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 - INTO vIsPreviousPrepared, vWarehouseFk, vItemPackingTypeFk - FROM vn.sector - WHERE id = vSectorFk; -- Hola - --- Si está habilitado el modo cazador para las motos, y el usuario no esta registrado, se sale. - - IF (SELECT isTractorHuntingMode FROM vn.deviceProductionConfig dpc) AND vItemPackingTypeFk = 'H' THEN - IF (SELECT COUNT(*) FROM vn.workerWithoutTractor wwt WHERE wwt.workerFk = vUserFk) THEN - CALL util.throw('Usuario no registrado con moto'); - LEAVE proc; - END IF; - END IF; - --- Si hay colecciones sin terminar, sale del proceso - SELECT count(*) INTO vNotReadyCollections - FROM ( - SELECT count(DISTINCT s.id) totalRow, count(DISTINCT st.id) pickedRow - FROM vn.collection c - JOIN vn.ticketCollection tc ON tc.collectionFk = c.id - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - JOIN vn.state ss ON ss.code = 'PREPARED' - LEFT JOIN vn.saleTracking st ON st.saleFk = s.id AND st.stateFk = ss.id - WHERE c.workerFk = vUserFk - AND c.created >= TIMESTAMPADD(HOUR , -6,NOW()) - AND s.quantity != 0 - GROUP BY c.id - HAVING totalRow > pickedRow) sub; - -call util.debugAdd('wargo',CONCAT('vMaxNotReadyCollections ', vMaxNotReadyCollections)); -call util.debugAdd('wargo',CONCAT('vNotReadyCollections ',vNotReadyCollections)); - - IF vMaxNotReadyCollections < vNotReadyCollections THEN - - CALL util.throw('Hay colecciones pendientes'); - LEAVE proc; - - END IF; - - IF vIsPreviousPrepared THEN - - CALL util.throw('Es de preparación previa'); - 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; - - CALL vn.productionControl(vWarehouseFk, 0); - - -- Esto hay que corregirlo añadiendo un nuevo parámetro al proc. PAK 23/12/21 - IF vSectorFk = 65 THEN -- Pedidos pequeños - - SET vTrainFk = 2; - - DELETE pb.* - FROM tmp.productionBuffer pb - JOIN vn.volumeConfig vc - WHERE pb.m3 * 1000 > vc.minTicketVolume; - - END IF; - - -- Se obtiene nº de colección y el buffer con los pedidos preparables - INSERT INTO vn.collection - SET workerFk = vUserFk, - itemPackingTypeFk = vItemPackingTypeFk, - trainFk = vTrainFk; - - SELECT LAST_INSERT_ID() INTO vCollectionFk; - - -- 05/08/2021 PAK Jose Frau pide que los tickets de recogida en Algemesí sólo se saquen si están asignados. - DELETE pb.* - FROM tmp.productionBuffer pb - JOIN vn.state s ON s.id = pb.state - WHERE pb.agency = 'REC_ALGEMESI' - AND s.code != 'PICKER_DESIGNED'; - - -- 2/3/2022 PAK Se acuerda con Pepe que los pedidos con riesgo no se sacan aunque se asignen. - DELETE pb.* - FROM tmp.productionBuffer pb - WHERE pb.problem LIKE '%RIESGO%'; - - -- 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; - - 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 - 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 - WHERE (itemPackingTypeFk = vItemPackingTypeFk) ; - - 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 - JOIN vn.productionConfig pc - 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.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) - ) - AND (pc.isPreviousPreparationRequired = FALSE - OR pb.previousWithoutParking = FALSE); - -call util.debugAdd('wargo',CONCAT('vMaxTicketPrinted ', vMaxTicketPrinted)); -call util.debugAdd('wargo',CONCAT('vPrintedTickets ',vPrintedTickets)); - - SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets; - - -- AutoPRINT - - INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT s2.id, pb.ticketFk, vUserFk - 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 - JOIN vn.ticketConfig tc - JOIN vn.productionConfig pc - WHERE pb.shipped = CURDATE() - AND (LENGTH(pb.problem) = 0 - OR (pb.problem = 'PEQUEÑO' AND vTrainFk = 2)) - AND (pb.ubicacion IS NOT NULL - OR a.isOwn = FALSE ) - AND s.isPrintable - AND 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.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) - ) - AND t.created < TIMESTAMPADD(MINUTE, - tc.pickingDelay , NOW()) - AND (pc.isPreviousPreparationRequired = FALSE - OR pb.previousWithoutParking = FALSE) - ORDER BY HH, - mm, - s.`order` DESC, - pb.m3 DESC - LIMIT vMaxTicketPrinted; - - -- 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, IFNULL((pb.H + pb.V = 0),TRUE) isNeutral - 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 - JOIN vn.productionConfig pc - WHERE ( - (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH)) - OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV)) - OR (pb.H = 0 AND pb.V = 0 AND pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) - ) - AND (pb.ubicacion IS NOT NULL - OR a.isOwn = FALSE ) - AND LENGTH(pb.problem) = 0 - AND s.isPreparable - AND (pc.isPreviousPreparationRequired = FALSE - OR pb.previousWithoutParking = FALSE) - ORDER BY pb.HH, pb.mm, s.`order` DESC - LIMIT vMaxTickets; - -call util.debugAdd('wargo',CONCAT('tmp.ticketToSplit ', (SELECT COUNT(*) FROM tmp.ticketToSplit))); - - WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO - - SELECT MIN(ticketFk) INTO vTicketToSplit - FROM tmp.ticketToSplit; - - - IF (SELECT isNeutral - FROM tmp.ticketToSplit - WHERE ticketFk = vTicketToSplit) THEN - - INSERT INTO vn.ticketCollection(ticketFk, collectionFk) - VALUES(vTicketToSplit, vCollectionFk); - -call util.debugAdd('wargo',CONCAT('neutral ', vTicketToSplit)); - - ELSE - - CALL vn.ticket_splitItemPackingType(vTicketToSplit); - - INSERT INTO vn.ticketCollection(ticketFk, collectionFk) - SELECT ticketFk, vCollectionFk - FROM tmp.ticketIPT - WHERE itemPackingTypeFk = vItemPackingTypeFk; - -call util.debugAdd('wargo',CONCAT('NO neutral ', - (SELECT ticketFk FROM tmp.ticketIPT WHERE itemPackingTypeFk = vItemPackingTypeFk))); - - DROP TEMPORARY TABLE tmp.ticketIPT; - - END IF; - - DELETE FROM tmp.ticketToSplit - WHERE ticketFk = vTicketToSplit; - - END WHILE; - - END IF; - -call util.debugAdd('wargo',CONCAT('vn.ticketCollection ', - (SELECT COUNT(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk))); - - -- 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, - 0 AS shelveLiters, - 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; - - -- Voumen de las lineas de los pedidos, de acuerdo con el packingShelve establecido por los controladores - DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelveLiters; - CREATE TEMPORARY TABLE tmp.ticketShelveLiters - SELECT t.ticketFk, SUM(s.quantity * vc.shelveVolume / i.packingShelve) shelveLiters - FROM tmp.ticket t - JOIN vn.sale s ON s.ticketFk = t.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.volumeConfig vc - WHERE i.packingShelve - GROUP BY t.ticketFk; - - UPDATE tmp.ticket t - JOIN tmp.ticketShelveLiters tsl ON tsl.ticketFk = t.ticketFk - SET t.shelveLiters = tsl.shelveLiters; - - -- 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; - -call util.debugAdd('wargo',CONCAT('vFirstTicketFk ', vFirstTicketFk)); -call util.debugAdd('wargo',CONCAT('vHour ', vHour)); -call util.debugAdd('wargo',CONCAT('vMinute ', vMinute)); - -call util.debugAdd('wargo',CONCAT('tmp.ticket ', (SELECT COUNT(*) FROM tmp.ticket))); - - -- Hay que excluir aquellos que no tengan la misma hora de preparación - DELETE - FROM tmp.ticket - WHERE HH != vHour - OR mm != vMinute; - -call util.debugAdd('wargo',CONCAT('tmp.ticket misma hora ', (SELECT COUNT(*) FROM tmp.ticket))); - - -- 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.shelveLiters > 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.shelveLiters > vc.trolleyM3 * 1000; - - END IF; - -call util.debugAdd('wargo',CONCAT('tmp.ticket volumen ', (SELECT COUNT(*) FROM tmp.ticket))); - - -- 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; - -call util.debugAdd('wargo',CONCAT('vn.ticketCollection ', - (SELECT COUNT(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk))); - - -- 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 - WHERE cv.itemPackingTypeFk = IFNULL(vItemPackingTypeFk, 'H') - AND cv.trainFk = vTrainFk; - - 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') - AND cv.trainFk = vTrainFk; - - 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.shelveLiters 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; - -call util.debugAdd('wargo',CONCAT('vn.ticketCollection bloqueados ', - (SELECT COUNT(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk))); - - -- 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; - -call util.debugAdd('wargo',CONCAT('vn.ticketCollection otra coleccion ', - (SELECT COUNT(*) FROM vn.ticketCollection WHERE 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 - UPDATE vn.ticketCollection tc - JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk - SET tc.level = t.shelve, - tc.wagon = t.wagon, - tc.itemCount = t.`lines`, - tc.liters = t.shelveLiters; - - -- Actualiza el estado de los tickets - INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT vStateFk, ticketFk, vUserFk - 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; - - SELECT * FROM util.debug - where variable = 'wargo' - and created >= vNow - order by created; - - 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; - - CALL util.throw('No se ha obtenido colección'); - - END IF; - - DROP TEMPORARY TABLE - tmp.ticketToSplit, - tmp.ticketShelveLiters, - tmp.ticket, - tmp.wagonsVolumetry, - tmp.ticketShelve, - tmp.productionBuffer; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `collection_printSticker` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -50789,37 +50648,39 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_printSticker`(vSelf INT) BEGIN /** - * Imprime una etiqueta amarilla a partir de una colección + * Imprime una etiqueta amarilla a partir de una colección * - * @param vSelf colección - * @param vPrinterFk id de la impresora + * @param vSelf colección + * @param vPrinterFk id de la impresora */ DECLARE vReportFk INT; DECLARE vPrinterFk INT; - + SELECT s.reportFk, w.labelerFk INTO vReportFk, vPrinterFk - FROM worker w + FROM worker w LEFT JOIN sector s ON s.id= w.sectorFk WHERE w.id = account.myUser_getId() ; IF vReportFk AND vPrinterFk THEN INSERT INTO ticketTrolley(ticket, labelCount) SELECT ticketFk, 1 - FROM ticketCollection + FROM ticketCollection WHERE collectionFk = vSelf ON DUPLICATE KEY UPDATE labelCount = labelCount + 1; - INSERT INTO printQueue(priorityFk, reportFk, workerFk,printerFk) + INSERT INTO printQueue(priorityFk, reportFk, workerFk,printerFk) SELECT qp.id, vReportFk, account.myUser_getId(), vPrinterFk FROM queuePriority qp WHERE qp.`code`= 'high'; - + INSERT INTO printQueueArgs (printQueueFk, `name`, `value` ) - SELECT LAST_INSERT_ID(), 'param', vSelf; + SELECT LAST_INSERT_ID(), 'param', vSelf; END IF; END ;; DELIMITER ; @@ -50827,8 +50688,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `collection_setParking` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -50836,6 +50695,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_setParking`(IN `vCollectionFk` VARCHAR(8), IN `vParkingFk` INT) proc: BEGIN @@ -50855,8 +50716,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `collection_updateSale` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -50864,6 +50723,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_updateSale`( vSaleFk INT, @@ -50872,42 +50733,40 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_updateSale`( vStateFk INT, vTicketFk INT) BEGIN - + DECLARE vNumPrepared INT; DECLARE vNumTotal INT; - REPLACE INTO vn.saleTracking(saleFk,isChecked, originalQuantity, workerFk, actionFk,stateFk) + REPLACE INTO vn.saleTracking(saleFk,isChecked, originalQuantity, workerFk, actionFk,stateFk) VALUES(vSaleFk,1,vOriginalQuantity,vWorkerFk,vStateFk,vStateFk); - - UPDATE vn.sale SET isPicked = 1 + + UPDATE vn.sale SET isPicked = 1 WHERE id = vSaleFk; - + SELECT COUNT(s.id) INTO vNumPrepared FROM vn.sale s WHERE s.ticketFk = vTicketFk AND s.isPicked = 1; - + SELECT COUNT(s.id) INTO vNumTotal FROM vn.sale s WHERE s.ticketFk = vTicketFk; - + IF vNumPrepared = vNumTotal THEN - + INSERT INTO vncontrol.inter SET state_id = vStateFk, Id_Ticket = vTicketFk, Id_Trabajador = vWorkerFk; - + CALL vn.collection_update(vTicketFk); - + END IF; - - + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `company_getFiscaldata` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -50915,28 +50774,30 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `company_getFiscaldata`(workerFk INT) BEGIN - + DECLARE vCompanyFk INT; - - SELECT IFNULL(uc.companyFk, rc.defaultCompanyFk) + + SELECT IFNULL(uc.companyFk, rc.defaultCompanyFk) INTO vCompanyFk FROM vn.routeConfig rc LEFT JOIN userConfig uc ON uc.userFk = workerFk; - - + + SELECT s.name AS name , s.NIF AS nif , s.street AS street , s.city AS city , - s.postCode AS postCode - - FROM vn.company c + s.postCode AS postCode + + FROM vn.company c JOIN vn.worker w ON w.id = c.workerManagerFk - JOIN vn.supplier s ON s.id = c.id + JOIN vn.supplier s ON s.id = c.id WHERE c.id = vCompanyFk; END ;; DELIMITER ; @@ -50944,8 +50805,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `conveyorExpedition_Add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -50953,11 +50812,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `conveyorExpedition_Add`(vStarted DATETIME, vEnded DATETIME) BEGIN - + DECLARE startingMinute INT; TRUNCATE vn.conveyorExpedition; @@ -50974,23 +50835,23 @@ BEGIN conveyorBuildingClassFk) SELECT e.id, e.created, - 10 * p.depth as depth, + 10 * p.depth as depth, 10 * p.width as width, 10 * p.height as height, IFNULL(t.routeFk,am.agencyFk) routeFk, hour(e.created) * 60 + minute(e.created), IFNULL(et.description , a.name), IFNULL(t.routeFk,am.agencyFk) criterion, - IFNULL(p.conveyorBuildingClassFk , pc.defaultConveyorBuildingClass) + IFNULL(p.conveyorBuildingClassFk , pc.defaultConveyorBuildingClass) FROM vn.expedition e JOIN vn.ticket t ON t.id = e.ticketFk JOIN vn.packaging p ON p.id = e.packagingFk LEFT JOIN vn.zone z ON z.id = t.zoneFk LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN vn.agency a ON a.id = am.agencyFk - LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk - JOIN vn.packagingConfig pc + LEFT JOIN vn.agency a ON a.id = am.agencyFk + LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk + LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk + JOIN vn.packagingConfig pc WHERE t.warehouseFk IN (60,1,44) AND e.created BETWEEN vStarted AND vEnded AND p.height < 140 @@ -50999,8 +50860,8 @@ BEGIN SELECT MIN(productionMinute) INTO startingMinute FROM vn.conveyorExpedition ce ; - - UPDATE vn.conveyorExpedition + + UPDATE vn.conveyorExpedition SET productionMinute = productionMinute - startingMinute; END ;; @@ -51009,8 +50870,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `copyComponentsFromSaleList` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51018,6 +50877,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `copyComponentsFromSaleList`(vTargetTicketFk INT) BEGIN @@ -51056,8 +50917,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `createPedidoInterno` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51065,11 +50924,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `createPedidoInterno`(vItemFk INT,vQuantity INT) BEGIN - + UPDATE vn.item SET upToDown = vQuantity WHERE id = vItemFk; END ;; @@ -51078,8 +50939,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `crypt` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51087,57 +50946,59 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `crypt`(vText VARCHAR(255), vKey VARCHAR(255), OUT vResult VARCHAR(255) ) BEGIN DECLARE vEncryptedText VARCHAR(255) DEFAULT ''; - + DECLARE vKeyLength INT; DECLARE vKeyPosition INT DEFAULT 1; DECLARE vKeyChar VARCHAR(1); - + DECLARE vTextLength INT; DECLARE vTextPosition INT DEFAULT 1; DECLARE vTextChar VARCHAR(1); - + DECLARE vEncryptedChar VARCHAR(1); DECLARE vEncryptedCharPosition INT; - + DECLARE vChain VARCHAR(255) DEFAULT '#$.-_0123456789abcdefghijklmnopqrstuvwxyz'; DECLARE vChainTextPosition INT; DECLARE vChainKeyPosition INT; DECLARE vChainLength INT; - + DECLARE vInvalidadChars VARCHAR(255) DEFAULT ''; - - SET vTextLength = LENGTH(vText); + + SET vTextLength = LENGTH(vText); SET vKeyLength = LENGTH(vKey); SET vChainLength = LENGTH(vChain); - + WHILE vTextPosition <= vTextLength DO - + SET vTextChar = MID(vText,vTextPosition,1); SET vKeyChar = MID(vKey,vKeyPosition,1); - + SET vChainTextPosition = LOCATE(vTextChar, vChain); SET vInvalidadChars = IF(vChainTextPosition, vInvalidadChars, CONCAT(vInvalidadChars,vTextChar)); SET vChainKeyPosition = LOCATE(vKeyChar, vChain); SET vEncryptedCharPosition = vChainTextPosition + vChainKeyPosition; - + IF vEncryptedCharPosition > vChainLength THEN - + SET vEncryptedCharPosition = vEncryptedCharPosition - vChainLength; - + END IF; - + SET vEncryptedChar = MID(vChain, vEncryptedCharPosition,1); - + SET vEncryptedText = CONCAT(vEncryptedText, vEncryptedChar); - + SET vKeyPosition = IF(vKeyPosition = vKeyLength, 1,vKeyPosition + 1); SET vTextPosition = vTextPosition + 1; - + END WHILE; SET vResult = IF(LENGTH(vInvalidadChars), CONCAT('Caracteres no válidos: ',vInvalidadChars),vEncryptedText); @@ -51148,8 +51009,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `cryptOff` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51157,54 +51016,56 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `cryptOff`(vText VARCHAR(255), vKey VARCHAR(255), OUT vResult VARCHAR(255)) BEGIN DECLARE vUncryptedText VARCHAR(255) DEFAULT ''; - + DECLARE vKeyLength INT; DECLARE vKeyPosition INT DEFAULT 1; DECLARE vKeyChar VARCHAR(1); - + DECLARE vTextLength INT; DECLARE vTextPosition INT DEFAULT 1; DECLARE vTextChar VARCHAR(1); - + DECLARE vUncryptedChar VARCHAR(1); DECLARE vUncryptedCharPosition INT; - + DECLARE vChain VARCHAR(255) DEFAULT '#$.-_0123456789abcdefghijklmnopqrstuvwxyz'; DECLARE vChainTextPosition INT; DECLARE vChainKeyPosition INT; DECLARE vChainLength INT; - - SET vTextLength = LENGTH(vText); + + SET vTextLength = LENGTH(vText); SET vKeyLength = LENGTH(vKey); SET vChainLength = LENGTH(vChain); - + WHILE vTextPosition <= vTextLength DO - + SET vTextChar = MID(vText,vTextPosition,1); SET vKeyChar = MID(vKey,vKeyPosition,1); - + SET vChainTextPosition = LOCATE(vTextChar, vChain); SET vChainKeyPosition = LOCATE(vKeyChar, vChain); SET vUncryptedCharPosition = vChainTextPosition - vChainKeyPosition; - + IF vUncryptedCharPosition < 1 THEN - + SET vUncryptedCharPosition = vUncryptedCharPosition + vChainLength; - + END IF; - + SET vUncryptedChar = MID(vChain, vUncryptedCharPosition,1); - + SET vUncryptedText = CONCAT(vUncryptedText, vUncryptedChar); - + SET vKeyPosition = IF(vKeyPosition = vKeyLength, 1,vKeyPosition + 1); SET vTextPosition = vTextPosition + 1; - + END WHILE; SET vResult = vUncryptedText; @@ -51215,8 +51076,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `department_calcTree` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51224,6 +51083,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `department_calcTree`() BEGIN @@ -51259,8 +51120,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `department_calcTreeRec` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51268,6 +51127,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `department_calcTreeRec`( vSelf INT, @@ -51300,7 +51161,7 @@ BEGIN OR (vSelf IS NOT NULL AND parentFk = vSelf); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + SET vSons = 0; OPEN vChildren; @@ -51311,11 +51172,11 @@ BEGIN IF vDone THEN LEAVE myLoop; END IF; - + SET vIndex = vIndex + 1; SET vLft = vIndex; SET vSons = vSons + 1; - + CALL department_calcTreeRec( vChildFk, CONCAT(vPath, vChildFk, '/'), @@ -51341,8 +51202,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `department_doCalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51350,6 +51209,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `department_doCalc`() proc: BEGIN @@ -51370,7 +51231,7 @@ proc: BEGIN SELECT isChanged INTO vIsChanged FROM department_recalc; - + IF vIsChanged THEN UPDATE department_recalc SET isChanged = FALSE; CALL vn.department_calcTree; @@ -51383,8 +51244,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `department_getHasMistake` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51392,28 +51251,28 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `department_getHasMistake`() BEGIN - + /** * Obtiene los sectores a los cuales les ponemos errores * */ - + SELECT id, name FROM department WHERE hasToMistake <> FALSE; - - + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `department_getLeaves` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51421,6 +51280,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `department_getLeaves`( vParentFk INT, @@ -51464,19 +51325,19 @@ BEGIN FROM department g JOIN tChilds c ON c.id = g.id WHERE g.parentFk IS NOT NULL; - + INSERT IGNORE INTO tNodes SELECT id FROM tParents; - + IF ROW_COUNT() = 0 THEN LEAVE myLoop; END IF; - + DELETE FROM tChilds; INSERT INTO tChilds SELECT id FROM tParents; END LOOP; - + DROP TEMPORARY TABLE tChilds, tParents; @@ -51503,8 +51364,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `deviceLog_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51512,16 +51371,18 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` 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 + * @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); @@ -51532,8 +51393,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `deviceProductionUser_exists` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51541,23 +51400,23 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `deviceProductionUser_exists`(vUserFk INT) BEGIN - + /* SELECT COUNT(*) AS UserExists - FROM vn.deviceProductionUser dpu + FROM vn.deviceProductionUser dpu WHERE dpu.userFk = vUserFk;*/ SELECT TRUE; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `deviceProductionUser_getWorker` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51565,19 +51424,21 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `deviceProductionUser_getWorker`(vAndroid_id VARCHAR(50)) BEGIN /** - * Selecciona si hay registrado un device con un android_id - * - * @param vAndroid_id el número android_id del dispositivo - * + * Selecciona si hay registrado un device con un android_id + * + * @param vAndroid_id el número android_id del dispositivo + * */ SELECT 103; /* SELECT account.user_getNameFromId(dpu.userFk) - FROM deviceProductionUser dpu - JOIN deviceProduction dp ON dpu.deviceProductionFk = dp.id + FROM deviceProductionUser dpu + JOIN deviceProduction dp ON dpu.deviceProductionFk = dp.id WHERE dp.android_id = vAndroid_id;*/ END ;; @@ -51586,8 +51447,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `deviceProduction_getnameDevice` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51595,19 +51454,21 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `deviceProduction_getnameDevice`(vAndroid_id VARCHAR(50)) BEGIN /** * Selecciona el id del dispositivo que corresponde al vAndroid_id - * - * @param vAndroid_id el número android_id del dispositivo - * + * + * @param vAndroid_id el número android_id del dispositivo + * */ - SELECT dp.id + SELECT dp.id FROM deviceProduction dp - WHERE dp.android_id = vAndroid_id; + WHERE dp.android_id = vAndroid_id; END ;; DELIMITER ; @@ -51615,8 +51476,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `device_checkLogin` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51624,13 +51483,15 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` 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 */ @@ -51642,20 +51503,20 @@ BEGIN SELECT dpc.isAllUsersallowed INTO vIsAllUsersAllowed FROM vn.deviceProductionConfig dpc; - IF NOT vIsAllUsersAllowed THEN - + IF NOT vIsAllUsersAllowed THEN + SELECT COUNT(*) INTO vIsDepartment - FROM vn.workerDepartment dp + FROM vn.workerDepartment dp JOIN department d ON d.id = dp.departmentFk WHERE dp.workerFk = vUserFk AND d.hasToCheckLogin; - + IF vIsDepartment THEN SELECT COUNT(*) INTO vIsAuthorized - FROM vn.deviceProductionUser dpu + 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; @@ -51671,8 +51532,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `duaEntryValueUpdate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51680,20 +51539,22 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `duaEntryValueUpdate`(vDuaFk INT) BEGIN UPDATE duaEntry de - JOIN + JOIN ( SELECT b.entryFk, sum(b.quantity * b.buyingValue) as total FROM buy b JOIN duaEntry de ON de.entryFk = b.entryFk WHERE duaFk = vDuaFk GROUP BY b.entryFk ) sub ON sub.entryFk = de.entryFk - - LEFT JOIN + + LEFT JOIN (SELECT e.id, sum(iit.taxableBase) as euros FROM entry e JOIN invoiceInTax iit ON iit.invoiceInFk = e.invoiceInFk @@ -51701,19 +51562,17 @@ BEGIN WHERE de.duaFk = vDuaFk GROUP BY e.id ) sub2 ON sub2.id = de.entryFk - + SET de.value = sub.total, de.euroValue = sub2.euros WHERE duaFk = vDuaFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `duaInvoiceInBooking` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51721,6 +51580,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `duaInvoiceInBooking`(vDuaFk INT) BEGIN @@ -51729,7 +51590,7 @@ BEGIN DECLARE vInvoiceFk INT; DECLARE vASIEN BIGINT DEFAULT 0; DECLARE vCounter INT DEFAULT 0; - + DECLARE rs CURSOR FOR SELECT e.invoiceInFk FROM entry e @@ -51742,7 +51603,7 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; OPEN rs; - + UPDATE invoiceIn ii JOIN entry e ON e.invoiceInFk = ii.id JOIN duaEntry de ON de.entryFk = e.id @@ -51754,49 +51615,47 @@ BEGIN ii.bookEntried = IFNULL(ii.bookEntried,d.bookEntried), e.isConfirmed = TRUE WHERE d.id = vDuaFk; - + SELECT IFNULL(ASIEN,0) INTO vASIEN FROM dua WHERE id = vDuaFk; - + FETCH rs INTO vInvoiceFk; - + WHILE NOT done DO CALL invoiceInBookingMain(vInvoiceFk); - + IF vCounter > 0 OR vASIEN > 0 THEN - + UPDATE vn2008.XDiario x JOIN vn.ledgerConfig lc ON lc.lastBookEntry = x.ASIEN SET x.ASIEN = vASIEN; - + ELSE - + SELECT lastBookEntry INTO vASIEN FROM vn.ledgerConfig; - + END IF; - + SET vCounter = vCounter + 1; - + FETCH rs INTO vInvoiceFk; END WHILE; - + CLOSE rs; - - UPDATE dua + + UPDATE dua SET ASIEN = vASIEN WHERE id = vDuaFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `duaParcialMake` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51804,6 +51663,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `duaParcialMake`(vDuaFk INT) BEGIN @@ -51814,9 +51675,9 @@ BEGIN SELECT awbFk,companyFk FROM dua WHERE id = vDuaFk; - + SELECT LAST_INSERT_ID() INTO vNewDuaFk; - + INSERT INTO duaEntry(duaFk, entryFk, value, customsValue) SELECT vNewDuaFk, entryFk, value, value - customsValue FROM duaEntry @@ -51829,8 +51690,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `duaTaxBooking` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51838,6 +51697,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `duaTaxBooking`(vDuaFk INT) BEGIN @@ -51845,29 +51706,29 @@ BEGIN DECLARE vBookDated DATE; DECLARE vDiff DECIMAL(10,2); DECLARE vApunte BIGINT; - - SELECT ASIEN, IFNULL(bookEntried, CURDATE()) INTO vBookNumber, vBookDated - FROM dua + + SELECT ASIEN, IFNULL(bookEntried, util.VN_CURDATE()) INTO vBookNumber, vBookDated + FROM dua WHERE id = vDuaFk; - + IF vBookNumber IS NULL OR NOT vBookNumber THEN CALL ledger_next(vBookNumber); END IF; - + -- Apunte de la aduana INSERT INTO XDiario( ASIEN, FECHA, SUBCTA, - CONCEPTO, + CONCEPTO, EUROHABER, SERIE, empresa_id, CLAVE, FACTURA) - SELECT + SELECT vBookNumber, d.bookEntried, '4700000999', @@ -51880,20 +51741,20 @@ BEGIN FROM duaTax dt JOIN dua d ON d.id = dt.duaFk WHERE dt.duaFk = vDuaFk; - + -- Apuntes por tipo de IVA y proveedor - + INSERT INTO XDiario( ASIEN, FECHA, SUBCTA, - CONTRA, + CONTRA, EURODEBE, BASEEURO, - CONCEPTO, - FACTURA, + CONCEPTO, + FACTURA, IVA, - AUXILIAR, + AUXILIAR, SERIE, FECHA_EX, FECHA_OP, @@ -51913,17 +51774,17 @@ BEGIN FECREGCON ) - SELECT + SELECT vBookNumber ASIEN, vBookDated FECHA, tr.account SUBCTA, '4330002067' CONTRA, sum(dt.tax) EURODEBE, - sum(dt.base) BASEEURO, + sum(dt.base) BASEEURO, CONCAT('DUA nº',d.code) CONCEPTO, d.id FACTURA, dt.rate IVA, - '*' AUXILIAR, + '*' AUXILIAR, 'D' SERIE, d.issued FECHA_EX, d.operated FECHA_OP, @@ -51950,10 +51811,10 @@ BEGIN WHERE ta.effectived <= vBookDated AND taxAreaFk = 'WORLD' ORDER BY ta.effectived DESC - LIMIT 10000000000000000000 + LIMIT 10000000000000000000 ) tba GROUP BY rate - ) tr ON tr.rate = dt.rate + ) tr ON tr.rate = dt.rate JOIN supplier s ON s.id = d.companyFk WHERE d.id = vDuaFk GROUP BY dt.rate; @@ -51961,24 +51822,22 @@ BEGIN SELECT SUM(EURODEBE) -SUM(EUROHABER), MAX(id) INTO vDiff, vApunte FROM XDiario WHERE ASIEN = vBookNumber; - + UPDATE XDiario SET BASEEURO = 100 * (EURODEBE - vDiff) / IVA, - EURODEBE = EURODEBE - vDiff + EURODEBE = EURODEBE - vDiff WHERE id = vApunte; - + UPDATE dua SET ASIEN = vBookNumber WHERE id = vDuaFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `duaTax_doRecalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51986,26 +51845,28 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `duaTax_doRecalc`(vDuaFk INT) BEGIN /** * Borra los valores de duaTax y los vuelve a crear en base a la tabla duaEntry - * + * * @param vDuaFk Id del dua a recalcular **/ DELETE FROM duaTax WHERE duaFk = vDuaFk; - - INSERT INTO duaTax(duaFk, supplierFk, taxClassFk, base) + + INSERT INTO duaTax(duaFk, supplierFk, taxClassFk, base) SELECT vDuaFk, supplierFk, taxClassFk, sum(sub.Base) as Base FROM intrastat ist JOIN (SELECT - e.supplierFk, + e.supplierFk, i.intrastatFk, CAST(sum(b.quantity * b.buyingValue * de.customsValue / de.value) * di.amount/ tei.Base AS DECIMAL(10,2)) as Base - FROM buy b + FROM buy b JOIN item i ON i.id = b.itemFk JOIN entry e ON e.id = b.entryFk JOIN duaEntry de ON de.entryFk = e.id @@ -52013,15 +51874,15 @@ BEGIN ( SELECT i.intrastatFk, CAST(sum(b.quantity * b.buyingValue * de.customsValue / de.value) AS DECIMAL(10,2)) as Base - FROM buy b + FROM buy b JOIN item i ON i.id = b.itemFk JOIN entry e ON e.id = b.entryFk JOIN duaEntry de ON de.entryFk = e.id WHERE de.duaFk = vDuaFk GROUP BY i.intrastatFk - + ) tei ON tei.intrastatFk = i.intrastatFk - JOIN + JOIN ( SELECT intrastatFk, sum(amount) as amount FROM duaIntrastat @@ -52030,7 +51891,7 @@ BEGIN ) di ON di.intrastatFk = i.intrastatFk WHERE de.duaFk = vDuaFk GROUP BY e.supplierFk, i.intrastatFk - HAVING Base + HAVING Base ) sub ON ist.id = sub.intrastatFk GROUP BY ist.taxClassFk, sub.supplierFk; END ;; @@ -52039,8 +51900,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ediTables_Update` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52048,16 +51907,18 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ediTables_Update`() BEGIN - - INSERT IGNORE INTO vn.genus(name) + + INSERT IGNORE INTO vn.genus(name) SELECT latin_genus_name FROM edi.genus ; - INSERT IGNORE INTO vn.specie(name) - SELECT LCASE(latin_species_name) + INSERT IGNORE INTO vn.specie(name) + SELECT LCASE(latin_species_name) FROM edi.specie ; END ;; DELIMITER ; @@ -52065,8 +51926,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ektEntryAssign_setEntry` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52074,6 +51933,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ektEntryAssign_setEntry`() BEGIN @@ -52082,13 +51943,13 @@ DECLARE done INT DEFAULT FALSE; DECLARE vEntryFk INT; DECLARE vTravelFk INT; DECLARE vId INT; -DECLARE vLanded DATE DEFAULT CURDATE(); +DECLARE vLanded DATE DEFAULT util.VN_CURDATE(); DECLARE cur1 CURSOR FOR SELECT id FROM vn.ektEntryAssign; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - IF HOUR(NOW()) > 12 THEN + IF HOUR(util.VN_NOW()) > 12 THEN SET vLanded = TIMESTAMPADD(DAY,1,vLanded); @@ -52097,71 +51958,71 @@ DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; OPEN cur1; read_loop: LOOP - + SET done = FALSE; SET vEntryFk = 0; - + FETCH cur1 INTO vId; - + IF done THEN LEAVE read_loop; END IF; - + SELECT IFNULL(e.id,0) INTO vEntryFk FROM vn.entry e JOIN vn.travel tr ON tr.id = e.travelFk - JOIN vn.ektEntryAssign ea ON ea.warehouseOutFk = tr.warehouseOutFk + JOIN vn.ektEntryAssign ea ON ea.warehouseOutFk = tr.warehouseOutFk AND ea.warehouseInFk = tr.warehouseInFk AND ea.agencyModeFk = tr.agencyModeFk AND ea.supplierFk = e.supplierFk WHERE ea.id = vId AND tr.landed = vLanded LIMIT 1; - + IF NOT vEntryFk THEN - + SELECT IFNULL(e.id,0) INTO vEntryFk FROM vn.entry e JOIN vn.travel tr ON tr.id = e.travelFk - JOIN vn.ektEntryAssign ea ON ea.warehouseOutFk = tr.warehouseOutFk + JOIN vn.ektEntryAssign ea ON ea.warehouseOutFk = tr.warehouseOutFk AND ea.warehouseInFk = tr.warehouseInFk AND ea.agencyModeFk = tr.agencyModeFk WHERE ea.id = vId AND tr.landed = vLanded AND ea.supplierFk IS NULL LIMIT 1; - + END IF; - + IF NOT vEntryFk THEN - + SET vTravelFk = 0; - - SELECT IFNULL(MAX(tr.id),0) INTO vTravelFk + + SELECT IFNULL(MAX(tr.id),0) INTO vTravelFk FROM vn.travel tr - JOIN vn.ektEntryAssign ea ON ea.warehouseOutFk = tr.warehouseOutFk + JOIN vn.ektEntryAssign ea ON ea.warehouseOutFk = tr.warehouseOutFk AND ea.warehouseInFk = tr.warehouseInFk AND ea.agencyModeFk = tr.agencyModeFk WHERE ea.id = vId AND tr.landed = vLanded; - + IF NOT vTravelFk THEN - + INSERT INTO vn.travel(landed, shipped, warehouseInFk, warehouseOutFk, agencyModeFk) SELECT vLanded, vLanded, warehouseInFk, warehouseOutFk, agencyModeFk - FROM vn.ektEntryAssign + FROM vn.ektEntryAssign WHERE id = vId; - - SELECT MAX(tr.id) INTO vTravelFk + + SELECT MAX(tr.id) INTO vTravelFk FROM vn.travel tr - JOIN vn.ektEntryAssign ea ON ea.warehouseOutFk = tr.warehouseOutFk + JOIN vn.ektEntryAssign ea ON ea.warehouseOutFk = tr.warehouseOutFk AND ea.warehouseInFk = tr.warehouseInFk AND ea.agencyModeFk = tr.agencyFk WHERE ea.id = vId AND tr.landed = vLanded; - + END IF; - + INSERT INTO vn.entry(travelFk, supplierFk, companyFk, currencyFk) SELECT vTravelFk, IFNULL(ea.supplierFk,s.id), c.id, cu.id FROM vn.supplier s @@ -52169,13 +52030,13 @@ OPEN cur1; JOIN vn.currency cu ON cu.code = 'EUR' JOIN vn.ektEntryAssign ea ON ea.id = vId WHERE s.name = 'KONINKLIJE COOPERATIEVE BLOEMENVEILING FLORAHOLLAN'; - - SELECT MAX(id) INTO vEntryFk + + SELECT MAX(id) INTO vEntryFk FROM vn.entry WHERE travelFk = vTravelFk; - + END IF; - + UPDATE vn.ektEntryAssign SET entryFk = vEntryFk WHERE id = vId; @@ -52183,15 +52044,13 @@ OPEN cur1; END LOOP; CLOSE cur1; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `energyMeter_record` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52199,22 +52058,24 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `energyMeter_record`(vInput INT, vActiveTime INT) BEGIN DECLARE vConsumption INT; - + SELECT consumption INTO vConsumption FROM energyInput WHERE input = vInput; - INSERT INTO vn.energyMeter - SET - `input` = vInput, - `period` = DATE_FORMAT(NOW(), '%Y-%m-%d %H:00:00'), + INSERT INTO vn.energyMeter + SET + `input` = vInput, + `period` = DATE_FORMAT(util.VN_NOW(), '%Y-%m-%d %H:00:00'), `activeTime` = vActiveTime, `consumption` = CAST(IFNULL((vConsumption / 3600) * vActiveTime, 0) AS DECIMAL(10,2)) - ON DUPLICATE KEY UPDATE + ON DUPLICATE KEY UPDATE `activeTime` = `activeTime` + vActiveTime, `consumption` = `consumption` + CAST(VALUES(`consumption`) AS DECIMAL(10,2)); END ;; @@ -52223,8 +52084,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `entryDelivered` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52232,33 +52091,35 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `entryDelivered`(vDated DATE, vEntryFk INT) BEGIN DECLARE vTravelFk INT; - + SELECT travelFk INTO vTravelFk - FROM vn.entry + FROM vn.entry WHERE id = vEntryFk; - + IF (SELECT COUNT(*) FROM vn.entry WHERE travelFk = vTravelFk) = 1 THEN - + UPDATE vn.travel SET shipped = LEAST(shipped, vDated), landed = vDated WHERE id = vTravelFk; - + ELSE - + INSERT INTO vn.travel(shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, ref, isDelivered, isReceived) SELECT LEAST(shipped, vDated), vDated, warehouseInFk, warehouseOutFk, agencyModeFk, CONCAT(account.myUser_getName(),' ', vEntryFk), TRUE, TRUE FROM vn.travel WHERE id = vTravelFk; - + SELECT LAST_INSERT_ID() INTO vTravelFk; - - UPDATE vn.entry - SET travelFk = vTravelFk + + UPDATE vn.entry + SET travelFk = vTravelFk WHERE id = vEntryFk; - + END IF; END ;; @@ -52267,8 +52128,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `entryToTicket` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52276,6 +52135,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `entryToTicket`(vEntryFk INT, vTicketFk INT) BEGIN @@ -52287,15 +52148,13 @@ BEGIN WHERE b.entryFk = vEntryFk; CALL vn.ticket_recalcComponents(vTicketFk); - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `entryWithItem` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52303,6 +52162,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `entryWithItem`(vShipmentWarehouse INT, vLandingWarehouse INT,vSale INT, vVolume INT, netCost DECIMAL(10,2), vInOutDate DATE) BEGIN @@ -52311,29 +52172,29 @@ BEGIN DECLARE vEntry INT; DECLARE vBucket VARCHAR(10); DECLARE vSupplierFk INT; - + SET vSupplierFk = IF (vLandingWarehouse = 1, 850, 963); -- seleccionamos travel SELECT t.id, e.id INTO vTravel, vEntry FROM travel t LEFT JOIN entry e ON t.id = e.travelFk - WHERE t.landed = vInOutDate AND t.shipped = vInOutDate AND t.warehouseOutFk = vShipmentWarehouse + WHERE t.landed = vInOutDate AND t.shipped = vInOutDate AND t.warehouseOutFk = vShipmentWarehouse AND t.warehouseInFk = vLandingWarehouse AND t.agencyModeFk IS NULL AND e.supplierFk = vSupplierFk - LIMIT 1; - + LIMIT 1; + -- creamos el travel si es necesario IF IFNULL(vTravel, FALSE) = FALSE THEN INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk) VALUES (vInOutDate, vInOutDate, vLandingWarehouse, vShipmentWarehouse); SELECT LAST_INSERT_ID() INTO vTravel; END IF; - + -- creamos la Entrada si es necesario IF IFNULL(vEntry, FALSE) = FALSE THEN INSERT INTO entry (supplierFk, travelFk) VALUES (vSupplierFk, vTravel); -- proveedor 'CONFECCION ARTIFICIAL' SELECT LAST_INSERT_ID() INTO vEntry; END IF; - + -- creamos el cubo si es necesario SELECT id INTO vBucket FROM packaging WHERE volume = vVolume LIMIT 1; IF vBucket IS NULL THEN @@ -52343,7 +52204,7 @@ BEGIN SELECT id INTO vBucket FROM packaging WHERE volume = vVolume LIMIT 1; END IF; - INSERT INTO buy(itemFk,quantity, entryFk, packageFk, packing, stickers, buyingValue, price2, price3) + INSERT INTO buy(itemFk,quantity, entryFk, packageFk, packing, stickers, buyingValue, price2, price3) SELECT itemFk, quantity, vEntry, @@ -52361,8 +52222,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `entry_clone` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52370,18 +52229,20 @@ DELIMITER ; /*!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`@`localhost` PROCEDURE `entry_clone`(vSelf INT) BEGIN - + /* * Clona una entrada * * @param vSelf Identificador de vn.entry */ - + DECLARE vNewEntryFk INT; - + CALL vn.entry_cloneWithoutBuy(vSelf, vNewEntryFk); INSERT INTO vn.buy( entryFk, @@ -52430,17 +52291,15 @@ BEGIN itemOriginalFk FROM vn.buy b WHERE b.entryFk = vSelf; - + SELECT vNewEntryFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `entry_cloneWithoutBuy` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52448,6 +52307,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_cloneWithoutBuy`(vSelf INT, OUT vNewEntryFk INT) BEGIN @@ -52495,8 +52356,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `entry_fixMisfit` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52504,6 +52363,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_fixMisfit`(vSelf INT) BEGIN @@ -52568,8 +52429,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `entry_getRate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52577,6 +52436,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_getRate`(vEntry INT) BEGIN @@ -52585,7 +52446,7 @@ BEGIN -- Obtiene fecha de llegada y almacén entrante - SELECT landed, warehouseInFk INTO vLanded, vWarehouseFk + SELECT landed, warehouseInFk INTO vLanded, vWarehouseFk FROM vn.travel t JOIN vn.entry e ON t.id = e.travelFk WHERE e.id = vEntry; @@ -52598,13 +52459,13 @@ BEGIN SELECT * FROM ( SELECT * FROM - ( + ( SELECT rate0, rate1, rate2, rate3 FROM vn.rate WHERE dated <= vLanded AND warehouseFk = vWarehouseFk ORDER BY dated DESC - + ) sub UNION ALL SELECT rate0, rate1, rate2, rate3 @@ -52618,8 +52479,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `entry_moveNotPrinted` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52627,6 +52486,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_moveNotPrinted`(vSelf INT, vDays INT, vChangeEntry BOOL, OUT vNewEntryFk INT) BEGIN @@ -52655,14 +52516,14 @@ BEGIN SET e.travelFk = vNewTravelFk, e.evaNotes = CONCAT('No impresas de: ', vSelf, ' ', IFNULL(e.evaNotes,'')) WHERE e.id = vNewEntryFk; - + IF vChangeEntry THEN UPDATE vn.buy b SET b.entryFk = vNewEntryFk WHERE b.printedStickers = 0 AND b.entryFk = vSelf; END IF; - + INSERT INTO vn.buy( entryFk, itemFk, @@ -52712,7 +52573,7 @@ BEGIN FROM vn.buy b WHERE b.entryFk = vSelf AND b.printedStickers != b.stickers; - + IF vChangeEntry THEN UPDATE vn.buy SET stickers = printedStickers, @@ -52724,7 +52585,7 @@ BEGIN FROM vn.item i WHERE i.description = 'MISFIT' LIMIT 1; - + INSERT INTO vn.buy(entryFk, itemFk, quantity, @@ -52773,17 +52634,17 @@ BEGIN SELECT SUM(IFNULL(b.buyingValue * b.quantity, 0)) INTO vInvoiceAmountOldEntryFk FROM vn.buy b WHERE b.entryFk = vSelf; - + UPDATE vn.entry e JOIN vn.buy b ON b.entryFk = e.id SET e.ref = CONCAT(e.ref,'(1)'), e.invoiceAmount = vInvoiceAmountOldEntryFk WHERE e.id = vSelf; - + SELECT SUM(IFNULL(b.buyingValue * b.quantity, 0)) INTO vInvoiceAmountNewEntry FROM vn.buy b WHERE b.entryFk = vNewEntryFk; - + UPDATE vn.entry e JOIN vn.buy b ON b.entryFk = e.id SET e.ref = CONCAT(e.ref,'(2)'), @@ -52795,7 +52656,7 @@ BEGIN description = CONCAT('Se ha creado la entrada ', vNewEntryFk,' transferida desde la ', vSelf), userFk = account.myUser_getId(), originFk = vSelf; - + INSERT INTO entryLog SET action = 'update', description = CONCAT('Se ha creado la entrada ', vNewEntryFk,' transferida desde la ', vSelf), @@ -52807,8 +52668,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `entry_notifyChanged` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52816,6 +52675,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_notifyChanged`(vSelf INT, vBuyFk INT, vOldValues VARCHAR(512), vNewValues VARCHAR(512)) BEGIN @@ -52852,8 +52713,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `entry_recalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52861,6 +52720,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_recalc`() BEGIN @@ -52872,12 +52733,12 @@ BEGIN */ DECLARE v_done BOOL DEFAULT FALSE; DECLARE vEntryFk INTEGER; - + DECLARE vCur CURSOR FOR SELECT id FROM tmp.recalcEntryCommision; DECLARE CONTINUE HANDLER FOR NOT FOUND - SET v_done = TRUE; + SET v_done = TRUE; OPEN vCur; @@ -52888,7 +52749,7 @@ BEGIN IF v_done THEN LEAVE l; END IF; - + CALL vn2008.buy_tarifas_entry(vEntryFk); END LOOP; @@ -52899,8 +52760,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `entry_splitByShelving` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52908,12 +52767,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_splitByShelving`(vShelvingFk VARCHAR(3), vFromEntryFk INT, vToEntryFk INT) BEGIN /** * Divide las compras entre dos entradas de acuerdo con lo ubicado en una matr�cula - * + * * @param vShelvingFk Identificador de vn.shelving * @param vFromEntryFk Entrada origen * @param vToEntryFk Entrada destino @@ -52923,49 +52784,49 @@ BEGIN DECLARE buyStickers INT; DECLARE vDone BOOLEAN DEFAULT FALSE; - DECLARE cur CURSOR FOR + DECLARE cur CURSOR FOR SELECT bb.id buyFk, FLOOR(ish.visible / ish.packing) AS ishStickers, bb.stickers buyStickers FROM vn.itemShelving ish - JOIN (SELECT b.id, b.itemFk, b.stickers - FROM vn.buy b + JOIN (SELECT b.id, b.itemFk, b.stickers + FROM vn.buy b WHERE b.entryFk = vFromEntryFk ORDER BY b.stickers DESC - LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk + LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk AND bb.stickers >= FLOOR(ish.visible / ish.packing) WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci GROUP BY ish.id; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - -- Cantidades de la matrícula que exceden la de las entradas - SELECT ish.itemFk, - i.longName, + + -- Cantidades de la matrícula que exceden la de las entradas + SELECT ish.itemFk, + i.longName, FLOOR(ish.visible / ish.packing) AS etiEnMatricula, bb.stickers etiEnEntrada FROM vn.itemShelving ish - JOIN vn.item i ON i.id = ish.itemFk - LEFT JOIN (SELECT b.id, b.itemFk, b.stickers - FROM vn.buy b + JOIN vn.item i ON i.id = ish.itemFk + LEFT JOIN (SELECT b.id, b.itemFk, b.stickers + FROM vn.buy b WHERE b.entryFk = vFromEntryFk ORDER BY b.stickers DESC LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci AND IFNULL(bb.stickers,0) < FLOOR(ish.visible / ish.packing) GROUP BY ish.id; - + OPEN cur; read_loop: LOOP SET vDone = FALSE; - + FETCH cur INTO vBuyFk, ishStickers, buyStickers; - + IF vDone THEN LEAVE read_loop; END IF; - + IF ishStickers = buyStickers THEN UPDATE vn.buy SET entryFk = vToEntryFk @@ -52973,9 +52834,9 @@ BEGIN ELSE UPDATE vn.buy SET stickers = stickers - ishStickers, - quantity = stickers * packing + quantity = stickers * packing WHERE id = vBuyFk; - + INSERT INTO vn.buy(entryFk, itemFk, quantity, @@ -53035,7 +52896,7 @@ BEGIN itemOriginalFk FROM vn.buy WHERE id = vBuyFk; - + END IF; END LOOP; @@ -53046,8 +52907,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `entry_splitMisfit` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53055,19 +52914,21 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_splitMisfit`(vSelf INT) BEGIN - + /* Divide una entrada, pasando los registros que ha insertado vn.entry_fixMisfit de la entrada original * a la nueva */ - + DECLARE vNewEntryFk INT; DECLARE vBuyFk INT; SELECT MAX(b.id) INTO vBuyFk - FROM vn.buy b + FROM vn.buy b JOIN vn.item i ON i.id = b.itemFk WHERE b.entryFk = vSelf AND i.description = 'MISFIT'; @@ -53076,25 +52937,23 @@ BEGIN SELECT supplierFk, dated, CONCAT('E:',vSelf), travelFk, currencyFk, companyFk FROM vn.entry e WHERE e.id = vSelf; - - SET vNewEntryFk = LAST_INSERT_ID(); - UPDATE vn.buy b + SET vNewEntryFk = LAST_INSERT_ID(); + + UPDATE vn.buy b SET b.entryFk = vNewEntryFk WHERE b.entryFk = vSelf AND b.id > vBuyFk; - + SELECT vNewEntryFk; - - + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `errorProduction_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53102,6 +52961,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `errorProduction_add`( vAction VARCHAR(25), @@ -53114,7 +52975,7 @@ BEGIN * @param vAction Accion que se quiere añadir * @param vDatedFrom Fecha desde * @param vDatedTo Fecha hasta - */ + */ DECLARE vDepartment VARCHAR(255); DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; @@ -53173,7 +53034,7 @@ BEGIN WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND cr.description = vDepartment GROUP BY cd.workerFk; - + CREATE TEMPORARY TABLE tmp.volume ENGINE = MEMORY SELECT SUM(w.volume) volume, @@ -53184,23 +53045,23 @@ BEGIN CREATE TEMPORARY TABLE tmp.errorsByChecker ENGINE = MEMORY - SELECT sub1.workerFk, COUNT(id) errors + SELECT sub1.workerFk, COUNT(id) errors FROM ( SELECT st.workerFk, t.id FROM saleMistake sm JOIN saleTracking st ON sm.saleFk = st.saleFk JOIN vncontrol.accion a ON a.accion_id = st.actionFk - JOIN sale s ON s.id = sm.saleFk - JOIN ticket t on t.id = s.ticketFk + JOIN sale s ON s.id = sm.saleFk + JOIN ticket t on t.id = s.ticketFk WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo) AND a.accion = vAction GROUP BY s.ticketFk ) sub1 GROUP BY sub1.workerFk; - + IF (vDepartment = 'Sacadores') THEN - + INSERT INTO errorProduction(userFk, firstname, lastname, @@ -53233,12 +53094,12 @@ BEGIN LEFT JOIN tmp.errorsByChecker ec2 ON ec2.workerFk = t.workerFk JOIN (SELECT DISTINCT w.id -- Verificamos que son sacadores FROM vn.collection c - JOIN vn.state s ON s.id = c.stateFk + JOIN vn.state s ON s.id = c.stateFk JOIN vn.train tn ON tn.id = c.trainFk - JOIN vn.worker w ON w.id = c.workerFk + JOIN vn.worker w ON w.id = c.workerFk WHERE c.created BETWEEN vDatedFrom AND vDatedTo) sub ON sub.id = w.id GROUP BY w.id; - + CREATE TEMPORARY TABLE tmp.itemPickerErrors -- Errores de los sacadores, derivadores de los revisadores ENGINE = MEMORY SELECT COUNT(c.ticketFk) errors, @@ -53291,7 +53152,7 @@ BEGIN LEFT JOIN tmp.errorsByChecker ec2 ON ec2.workerFk = t.workerFk GROUP BY w.id; END IF; - + DROP TEMPORARY TABLE tmp.timeControlCalculate; DROP TEMPORARY TABLE tmp.total; DROP TEMPORARY TABLE IF EXISTS tmp.itemPickerErrors; @@ -53304,8 +53165,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `errorProduction_addLauncher` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53313,13 +53172,15 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` 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; + + SELECT DATE_SUB(util.VN_CURDATE(),INTERVAL 1 DAY), CONCAT(DATE_SUB(util.VN_CURDATE(),INTERVAL 1 DAY),' 23:59:59') INTO vDatedFrom, vDatedTo; CALL vn.errorProduction_add('SACAR', vDatedFrom, vDatedTo); CALL vn.errorProduction_add('ENCAJAR', vDatedFrom, vDatedTo); @@ -53330,8 +53191,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionGetFromRoute` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53339,6 +53198,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionGetFromRoute`( vExpeditionFk INT) @@ -53349,7 +53210,7 @@ BEGIN DECLARE vRouteFk INT DEFAULT 0; SELECT t.routeFk INTO vRouteFk - FROM vn.expedition exp + FROM vn.expedition exp INNER JOIN ticket t on t.id = exp.ticketFk WHERE exp.id = vExpeditionFk; @@ -53375,8 +53236,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionPallet_Del` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53384,6 +53243,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_Del`(vPalletFk INT) BEGIN @@ -53397,8 +53258,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionPallet_List` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53406,6 +53265,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_List`(vTruckFk INT) BEGIN @@ -53426,8 +53287,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionPallet_printLabel` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53435,6 +53294,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_printLabel`(vSelf INT) BEGIN @@ -53477,15 +53338,15 @@ 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionPallet_View` */; /*!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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_View`(vPalletFk INT) BEGIN @@ -53506,8 +53367,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionScan_Add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53515,6 +53374,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionScan_Add`(vPalletFk INT, vTruckFk INT) BEGIN @@ -53522,22 +53383,22 @@ BEGIN DECLARE vTotal INT DEFAULT 0; IF vPalletFk = 0 THEN -- Nuevo pallet - - INSERT INTO vn.expeditionPallet(truckFk) + + INSERT INTO vn.expeditionPallet(truckFk) VALUES(vTruckFk); - + SELECT LAST_INSERT_ID() INTO vPalletFk; - + END IF; - + SELECT COUNT(expeditionFk) INTO vTotal FROM vn.expeditionScan WHERE palletFk = vPalletFk; - + IF vTotal <> 0 THEN - SELECT expeditionFk, + SELECT expeditionFk, palletFk - FROM vn.expeditionScan + FROM vn.expeditionScan WHERE palletFk = vPalletFk; - ELSE + ELSE SELECT 0 expeditionFk,vPalletFk palletFk; END IF; END ;; @@ -53546,8 +53407,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionScan_Del` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53555,6 +53414,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionScan_Del`(vScanFk INT) BEGIN @@ -53568,8 +53429,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionScan_List` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53577,6 +53436,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionScan_List`(vPalletFk INT) BEGIN @@ -53598,8 +53459,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionScan_Put` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53607,67 +53466,67 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionScan_Put`(vPalletFk INT, vExpeditionFk INT) BEGIN - - REPLACE vn.expeditionScan(expeditionFk, palletFk) + + REPLACE vn.expeditionScan(expeditionFk, palletFk) VALUES(vExpeditionFk, vPalletFk); - + SELECT LAST_INSERT_ID() INTO vPalletFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionState_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_add`(vParam INT, vStateCode VARCHAR(100)) BEGIN - + /** * Inserta nuevos registros en la tabla vn.expeditionState, segun el parámetro - * + * * @param vParam Identificador de vn.expedition o de vn.route * @param vStateCode Corresponde a vn.expeditionStateType.code */ - + IF (SELECT COUNT(*) FROM vn.route r WHERE r.id = vParam) THEN - + INSERT INTO vn.expeditionState(expeditionFk, typeFk) SELECT e.id, est.id FROM vn.expedition e JOIN vn.ticket t ON t.id = e.ticketFk JOIN vn.expeditionStateType est ON est.code = vStateCode WHERE t.routeFk = vParam; - + ELSE - + INSERT INTO vn.expeditionState(expeditionFk, typeFk) SELECT vParam, est.id FROM vn.expeditionStateType est WHERE est.code = vStateCode; - + END IF; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionState_addByAdress` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53675,6 +53534,8 @@ DELIMITER ; /*!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`@`localhost` PROCEDURE `expeditionState_addByAdress`(vAdressFk INT, vRouteFk INT, vStateCode VARCHAR(100)) BEGIN @@ -53691,7 +53552,7 @@ BEGIN SELECT e.id, est.id FROM vn.expedition e JOIN vn.expeditionStateType est ON est.code = vStateCode - JOIN vn.ticket t ON t.id = e.ticketFk + JOIN vn.ticket t ON t.id = e.ticketFk WHERE t.addressFk = vAdressFk AND t.routeFk = vRouteFk; END ;; @@ -53700,26 +53561,26 @@ 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionState_addByExpedition` */; /*!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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_addByExpedition`(vExpeditionFk INT, vStateCode VARCHAR(100)) BEGIN - + /** * Inserta nuevos registros en la tabla vn.expeditionState - * + * * @param vExpeditionFk Identificador de vn.expedition * @param vStateCode Corresponde a vn.expeditionStateType.code */ - + INSERT INTO vn.expeditionState(expeditionFk, typeFk) SELECT vExpeditionFk, est.id FROM vn.expeditionStateType est @@ -53731,8 +53592,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionState_addByPallet` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53740,68 +53599,76 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_addByPallet`(vPalletFk INT, vStateCode VARCHAR(100)) BEGIN /** * Inserta nuevos registros en la tabla vn.expeditionState - * + * * @param vPalletFk Identificador de vn.expedition * @param vStateCode Corresponde a vn.expeditionStateType.code */ - DROP TEMPORARY TABLE IF EXISTS tmp.expeditionScan; - CREATE TEMPORARY TABLE tmp.expeditionScan + DECLARE hasExpeditions BOOL; + + DROP TEMPORARY TABLE IF EXISTS tExpeditionScan; + CREATE TEMPORARY TABLE tExpeditionScan SELECT expeditionFk, est.id typeFk FROM vn.expeditionScan e JOIN vn.expeditionStateType est ON est.code = vStateCode WHERE e.palletFk = vPalletFk; + SELECT COUNT(*) INTO hasExpeditions FROM tExpeditionScan; + + IF NOT hasExpeditions THEN + DROP TEMPORARY TABLE tExpeditionScan; + CALL util.throw('palletDoesNotExist'); + END IF; + INSERT INTO vn.expeditionState(expeditionFk, typeFk) SELECT expeditionFk, typeFk - FROM tmp.expeditionScan; - - DROP TEMPORARY TABLE IF EXISTS tmp.expeditionScan; + FROM tExpeditionScan; + DROP TEMPORARY TABLE tExpeditionScan; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionState_addByRoute` */; /*!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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_addByRoute`(vRouteFk INT, vStateCode VARCHAR(100)) BEGIN - + /** * Inserta nuevos registros en la tabla vn.expeditionState, por rutas - * + * * @param vRouteFk Identificador de vn.route * @param vStateCode Corresponde a vn.expeditionStateType.code */ - + INSERT INTO vn.expeditionState(expeditionFk, typeFk) SELECT e.id, est.id FROM vn.expedition e JOIN vn.ticket t ON t.id = e.ticketFk JOIN vn.expeditionStateType est ON est.code = vStateCode WHERE t.routeFk = vRouteFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionTruck_Add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53809,12 +53676,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionTruck_Add`(vHour VARCHAR(5), vDescription VARCHAR(45)) BEGIN INSERT INTO vn.expeditionTruck(ETD,description) - VALUES(CONCAT(CURDATE(), ' ', vHour), vDescription); + VALUES(CONCAT(util.VN_CURDATE(), ' ', vHour), vDescription); END ;; DELIMITER ; @@ -53822,8 +53691,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionTruck_List` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53831,15 +53698,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionTruck_List`() BEGIN - SELECT id truckFk, - ETD, + SELECT id truckFk, + ETD, description Destino FROM vn.expeditionTruck - WHERE ETD BETWEEN CURDATE() AND util.dayend(CURDATE()) + WHERE ETD BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) ORDER BY ETD; END ;; DELIMITER ; @@ -53847,8 +53716,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expedition_getFromRoute` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53856,6 +53723,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expedition_getFromRoute`(vRouteFk INT) BEGIN @@ -53880,7 +53749,7 @@ BEGIN JOIN address a ON t.addressFk = a.id JOIN route r ON r.id = t.routeFk LEFT JOIN warehouse w ON t.warehouseFk = w.id - LEFT JOIN (SELECT sub.ticketFk, + LEFT JOIN (SELECT sub.ticketFk, CONCAT('(', GROUP_CONCAT(DISTINCT sub.itemPackingTypeFk ORDER BY sub.items DESC SEPARATOR ','), ') ') itemPackingTypeConcat FROM (SELECT s.ticketFk , i.itemPackingTypeFk, COUNT(*) items FROM ticket t @@ -53899,8 +53768,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expedition_getState` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53908,10 +53775,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expedition_getState`(vExpeditionFk INT) BEGIN - + DECLARE vTicketsPendientes INT; DECLARE vEtiquetasTotales INT; DECLARE vEtiquetasEscaneadas INT; @@ -53921,24 +53790,24 @@ BEGIN 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 + 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 + FROM vn.expeditionScan es JOIN vn.expedition e ON e.id = es.expeditionFk - JOIN vn.ticket t ON t.id = e.ticketFk + JOIN vn.ticket t ON t.id = e.ticketFk WHERE t.routeFk = vRouteFk; - + SELECT e.ticketFk ticket, t.nickname cliente, a.city ciudad, @@ -53952,25 +53821,23 @@ BEGIN vTicketsPendientes AS ticketsPendientes, vEtiquetasTotales AS etiquetasTotales, vEtiquetasEscaneadas AS etiquetasEscaneadas - 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 + 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 */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expedition_StateGet` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53978,15 +53845,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expedition_StateGet`(vExpeditionFk INT) BEGIN - + /* Devuelve una "ficha" con todos los datos relativos a la expedición - * - * param vExpeditionFk + * + * param vExpeditionFk */ - + DECLARE vTicketsPendientes INT; DECLARE vEtiquetasTotales INT; DECLARE vEtiquetasEscaneadas INT; @@ -53997,34 +53866,34 @@ BEGIN 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 + 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 + FROM vn.expeditionScan es JOIN vn.expedition e ON e.id = es.expeditionFk - JOIN vn.ticket t ON t.id = e.ticketFk + JOIN vn.ticket t ON t.id = e.ticketFk WHERE t.routeFk = vRouteFk; - + SELECT COUNT(*) INTO vEtiquetasLeidasSorter - FROM srt.expedition e + 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 + JOIN vn.ticket t ON t.id = ve.ticketFk WHERE t.routeFk = vRouteFk AND e.created != e.updated - AND ISNULL(es.expeditionFk); - - + AND ISNULL(es.expeditionFk); + + SELECT e.ticketFk ticket, t.nickname cliente, a.city ciudad, @@ -54039,25 +53908,23 @@ BEGIN 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 + 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 */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `faultsReview` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54065,19 +53932,21 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `faultsReview`(vWarehouseFk INT) BEGIN DECLARE vCalcVisibleFk INT; - + CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk); - + DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadar; - + CREATE TEMPORARY TABLE tmp.itemShelvingRadar (PRIMARY KEY (itemFk)) - ENGINE = MEMORY + ENGINE = MEMORY SELECT iss.itemFk, i.size, i.subName producer, @@ -54090,7 +53959,7 @@ BEGIN LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk WHERE iss.warehouseFk = vWarehouseFk GROUP BY iss.itemFk; - + SELECT ishr.*, sub.longName, CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) AS nicho, CAST(sub.fault AS DECIMAL(10,0)) as faltas @@ -54101,11 +53970,11 @@ BEGIN JOIN vn.client c ON c.id = t.clientFk WHERE c.typeFk = 'loses' COLLATE utf8_unicode_ci AND s.isPicked = FALSE - AND date(t.shipped) = CURDATE() + AND date(t.shipped) = util.VN_CURDATE() AND t.warehouseFk = vWarehouseFk ) sub ON sub.itemFk = ishr.itemFk ; - + END ;; DELIMITER ; @@ -54113,8 +53982,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `faultsReview_isChecked` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54122,6 +53989,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `faultsReview_isChecked`(vItemFk INT, vWarehouseFk INT) BEGIN @@ -54131,7 +54000,7 @@ BEGIN JOIN vn.client c ON c.id = t.clientFk SET s.isPicked = TRUE WHERE c.typeFk = 'loses' COLLATE utf8_unicode_ci - AND date(t.shipped) = CURDATE() + AND date(t.shipped) = util.VN_CURDATE() AND t.warehouseFk = vWarehouseFk AND s.itemFk = vItemFk; @@ -54141,8 +54010,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `freelance_getInfo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54150,6 +54017,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `freelance_getInfo`(workerFk INT) BEGIN @@ -54168,8 +54037,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `fustControl` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54177,10 +54044,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `fustControl`(vFromDated DATE, vToDated DATE) BEGIN - + DECLARE vSijsnerClientFk INT DEFAULT 19752; DECLARE vDateStart DATETIME; @@ -54189,68 +54058,68 @@ BEGIN SET vDateStart = vFromDated; SET vDateEnd = util.Dayend(vToDated); - SELECT p.id FustCode, - CAST(sent.stucks AS DECIMAL(10,0)) FH, - CAST(tp.stucks AS DECIMAL(10,0)) Tickets, - CAST(-sj.stucks AS DECIMAL(10,0)) Sijsner, + SELECT p.id FustCode, + CAST(sent.stucks AS DECIMAL(10,0)) FH, + CAST(tp.stucks AS DECIMAL(10,0)) Tickets, + CAST(-sj.stucks AS DECIMAL(10,0)) Sijsner, CAST(IFNULL(sent.stucks,0) - IFNULL(tp.stucks,0) + IFNULL(sj.stucks,0) AS DECIMAL(10,0)) saldo FROM vn.packaging p LEFT JOIN ( SELECT FustCode, sum(fustQuantity) stucks FROM ( SELECT IFNULL(pe.equivalentFk ,b.packageFk) FustCode, s.quantity / b.packing AS fustQuantity - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk - JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND lb.warehouse_id = t.warehouseFk - JOIN vn.buy b ON b.id = lb.buy_id - JOIN vn.packaging p ON p.id = b.packageFk + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.warehouse w ON w.id = t.warehouseFk + JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk + JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND lb.warehouse_id = t.warehouseFk + JOIN vn.buy b ON b.id = lb.buy_id + JOIN vn.packaging p ON p.id = b.packageFk LEFT JOIN vn.packageEquivalent pe ON pe.packagingFk = p.id - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.province p2 ON p2.id = a.provinceFk - JOIN vn.country c ON c.id = p2.countryFk + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.province p2 ON p2.id = a.provinceFk + JOIN vn.country c ON c.id = p2.countryFk WHERE t.shipped BETWEEN vDateStart AND vDateEnd AND wa.name = 'VNH' - AND p.isPackageReturnable - AND c.country = 'FRANCIA') sub + AND p.isPackageReturnable + AND c.country = 'FRANCIA') sub GROUP BY FustCode) sent ON sent.FustCode = p.id LEFT JOIN ( SELECT FustCode, sum(quantity) stucks FROM ( SELECT IFNULL(pe.equivalentFk ,tp.packagingFk) FustCode, tp.quantity - FROM vn.ticketPackaging tp - JOIN vn.ticket t ON t.id = tp.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk - JOIN vn.packaging p ON p.id = tp.packagingFk + FROM vn.ticketPackaging tp + JOIN vn.ticket t ON t.id = tp.ticketFk + JOIN vn.warehouse w ON w.id = t.warehouseFk + JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk + JOIN vn.packaging p ON p.id = tp.packagingFk LEFT JOIN vn.packageEquivalent pe ON pe.packagingFk = p.id - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.province p2 ON p2.id = a.provinceFk - JOIN vn.country c ON c.id = p2.countryFk + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.province p2 ON p2.id = a.provinceFk + JOIN vn.country c ON c.id = p2.countryFk WHERE t.shipped BETWEEN vDateStart AND vDateEnd AND wa.name = 'VNH' - AND p.isPackageReturnable + AND p.isPackageReturnable AND c.country = 'FRANCIA' AND t.clientFk != vSijsnerClientFk - AND tp.quantity > 0) sub + AND tp.quantity > 0) sub GROUP BY FustCode) tp ON tp.FustCode = p.id LEFT JOIN ( SELECT FustCode, sum(quantity) stucks FROM ( SELECT IFNULL(pe.equivalentFk ,tp.packagingFk) FustCode, tp.quantity - FROM vn.ticketPackaging tp - JOIN vn.ticket t ON t.id = tp.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk - JOIN vn.packaging p ON p.id = tp.packagingFk + FROM vn.ticketPackaging tp + JOIN vn.ticket t ON t.id = tp.ticketFk + JOIN vn.warehouse w ON w.id = t.warehouseFk + JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk + JOIN vn.packaging p ON p.id = tp.packagingFk LEFT JOIN vn.packageEquivalent pe ON pe.packagingFk = p.id WHERE t.shipped BETWEEN TIMESTAMPADD(DAY, 1, vDateStart ) AND TIMESTAMPADD(DAY, 1, vDateEnd ) AND wa.name = 'VNH' - AND p.isPackageReturnable - AND t.clientFk = vSijsnerClientFk) sub + AND p.isPackageReturnable + AND t.clientFk = vSijsnerClientFk) sub GROUP BY FustCode) sj ON sj.FustCode = p.id - WHERE sent.stucks + WHERE sent.stucks OR tp.stucks OR sj.stucks; @@ -54260,8 +54129,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `fustControlDetail` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54269,10 +54136,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `fustControlDetail`(vFromDated DATE, vToDated DATE) BEGIN - + DECLARE vSijsnerClientFk INT DEFAULT 19752; DECLARE vDateStart DATETIME; @@ -54280,37 +54149,35 @@ BEGIN SET vDateStart = vFromDated; SET vDateEnd = util.Dayend(vToDated); - + SELECT a.nickname shopName, - a.city , - IFNULL(pe.equivalentFk ,tp.packagingFk) FustCode, + a.city , + IFNULL(pe.equivalentFk ,tp.packagingFk) FustCode, tp.quantity, tp.ticketFk, CONCAT('From ', vFromDated,' to ', vToDated) AS dateRange - FROM vn.ticketPackaging tp - JOIN vn.ticket t ON t.id = tp.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk - JOIN vn.packaging p ON p.id = tp.packagingFk + FROM vn.ticketPackaging tp + JOIN vn.ticket t ON t.id = tp.ticketFk + JOIN vn.warehouse w ON w.id = t.warehouseFk + JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk + JOIN vn.packaging p ON p.id = tp.packagingFk LEFT JOIN vn.packageEquivalent pe ON pe.packagingFk = p.id - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.province p2 ON p2.id = a.provinceFk - JOIN vn.country c ON c.id = p2.countryFk + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.province p2 ON p2.id = a.provinceFk + JOIN vn.country c ON c.id = p2.countryFk WHERE t.shipped BETWEEN vFromDated AND util.dayend(vToDated) AND wa.name = 'VNH' - AND p.isPackageReturnable + AND p.isPackageReturnable AND c.country = 'FRANCIA' AND t.clientFk != vSijsnerClientFk AND tp.quantity > 0; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `fv_pca` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54318,6 +54185,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `fv_pca`() BEGIN @@ -54328,8 +54197,8 @@ DECLARE vTicketFk INT; DECLARE vSaleFk INT; DECLARE vClonTicket INT DEFAULT 0; -DECLARE cur1 CURSOR FOR -SELECT s.ticketFk, s.id +DECLARE cur1 CURSOR FOR +SELECT s.ticketFk, s.id FROM vn.sale s JOIN vn.ticket t ON t.id = s.ticketFk JOIN vn.item i ON i.id = s.itemFk @@ -54345,17 +54214,17 @@ OPEN cur1; FETCH cur1 INTO vTicketFk, vSaleFk; WHILE done = 0 DO - + SELECT t.id INTO vClonTicket FROM vn.ticket t JOIN (SELECT addressFk, shipped FROM vn.ticket WHERE id = vTicketFk) sub USING(addressFk, shipped) WHERE t.warehouseFk = 44 LIMIT 1; - + SELECT vTicketFk, vClonTicket; - + IF vClonTicket = 0 THEN - + INSERT INTO ticket ( clientFk, shipped, @@ -54383,12 +54252,12 @@ FETCH cur1 INTO vTicketFk, vSaleFk; zonePrice, zoneBonus, routeFk - + FROM ticket WHERE id = vTicketFk; SET vClonTicket = LAST_INSERT_ID(); - + SELECT 'lstID', vClonTicket; /* INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) @@ -54398,20 +54267,20 @@ FETCH cur1 INTO vTicketFk, vSaleFk; WHERE t.id = vClonTicket; */ INSERT INTO ticketLog - SET originFk = vTicketFk, userFk = account.myUser_getId(), `action` = 'insert', + SET originFk = vTicketFk, 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; - + END WHILE; CLOSE cur1; @@ -54423,8 +54292,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `getDayExpeditions` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54432,18 +54299,20 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `getDayExpeditions`() BEGIN - SELECT - e.expeditions_id as expeditionFk, + SELECT + e.expeditions_id as expeditionFk, date_format(e.odbc_date,'%Y-%m-%d') as expeditionDate, e.ticket_id as ticketFk, t.routeFk as routeFk FROM vn2008.expeditions e INNER JOIN vn.ticket t ON t.id = e.ticket_id - WHERE DATE(odbc_date) = CURDATE(); + WHERE DATE(odbc_date) = util.VN_CURDATE(); END ;; DELIMITER ; @@ -54451,8 +54320,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `getInfoDelivery` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54460,6 +54327,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `getInfoDelivery`(vRouteFk INT) BEGIN @@ -54474,8 +54343,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `getItemUbication` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54483,15 +54350,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `getItemUbication`(vItemFk VARCHAR(22)) BEGIN - + /* * @deprecated Utilizar itemShelving_getInfo - * + * */ - + CALL itemshelving_getInfo(vItemFk); END ;; @@ -54500,8 +54369,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `getPedidosInternos` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54509,6 +54376,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `getPedidosInternos`() BEGIN @@ -54521,8 +54390,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `greuge_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54530,6 +54397,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `greuge_add`() BEGIN @@ -54538,9 +54407,9 @@ BEGIN */ DECLARE vDated DATE; - SELECT DATE_SUB(CURDATE(), INTERVAL yearsToDelete YEAR) INTO vDated + SELECT DATE_SUB(util.VN_CURDATE(), INTERVAL yearsToDelete YEAR) INTO vDated FROM vn.greugeConfig; - + INSERT INTO vn.greuge(clientFk, description, amount, shipped, created, greugeTypeFk) SELECT clientFk, 'Suma agrupada', SUM(amount), MAX(shipped), MAX(created), greugeTypeFk FROM vn.greuge @@ -54556,44 +54425,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `intrastat_data_neto_Update` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `intrastat_data_neto_Update`(IN vInvoiceInFk INT) -BEGIN - - UPDATE vn2008.intrastat_data id - JOIN ( - SELECT i.intrastatFk, - LEAST(SUM(b.quantity) * IFNULL(it.gramsMax,100000) / 1000, - SUM(ic.cm3 * b.quantity) * IF(i.density, i.density, it.density) / 1000000) as neto - FROM entry e - JOIN travel tr ON tr.id = e.travelFk - JOIN buy b ON b.entryFk = e.id - JOIN item i ON i.id = b.itemFk - join itemType it ON it.id = i.typeFk - JOIN itemCost ic ON ic.itemFk = i.id AND tr.warehouseInFk = ic.warehouseFk - WHERE e.invoiceInFk = vinvoiceInFk - GROUP BY i.intrastatFk) sub ON sub.intrastatFk = id.intrastat_id - SET id.neto = ROUND(sub.neto, 1) - WHERE id.recibida_id = vInvoiceInFk; - - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `inventoryFailureAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54601,6 +54432,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `inventoryFailureAdd`() BEGIN @@ -54609,8 +54442,8 @@ DECLARE done BOOL DEFAULT FALSE; DECLARE vTicketFk INT; DECLARE rs CURSOR FOR - SELECT id FROM vn.ticket - WHERE shipped = util.yesterday() + SELECT id FROM vn.ticket + WHERE shipped = util.yesterday() AND clientFk = 400 AND warehouseFk IN (1,44); @@ -54621,13 +54454,13 @@ OPEN rs; FETCH rs INTO vTicketFk; WHILE NOT done DO - + INSERT INTO vn.inventoryFailure(dated, itemFk, quantity, value, warehouseFk, throwerFk) - SELECT t.shipped, - s.itemFk, - s.quantity, + SELECT t.shipped, + s.itemFk, + s.quantity, b.buyingValue + b.freightValue + b.packageValue + b.comissionValue, - t.warehouseFk, + t.warehouseFk, w.id FROM vn.ticket t JOIN vn.sale s ON s.ticketFk = t.id @@ -54638,7 +54471,7 @@ WHILE NOT done DO AND s.quantity > 0; FETCH rs INTO vTicketFk; - + END WHILE; @@ -54653,8 +54486,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `inventoryMake` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54662,6 +54493,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `inventoryMake`(vDate DATE, vWh INT) proc: BEGIN @@ -54796,7 +54629,7 @@ proc: BEGIN JOIN entry e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk WHERE tr.warehouseInFk = vWh - AND tr.landed BETWEEN vDateLastInventory + AND tr.landed BETWEEN vDateLastInventory AND vDateYesterday AND NOT isRaid GROUP BY b.itemFk; @@ -54850,7 +54683,7 @@ proc: BEGIN inv.minPrice = b.minPrice, inv.producer = b.producer; - + INSERT INTO buy( itemFk, quantity, buyingValue, @@ -54885,16 +54718,16 @@ proc: BEGIN vEntryFk FROM tmp.inventory; - SELECT vWh, count(*), NOW() FROM tmp.inventory; - + SELECT vWh, count(*), util.VN_NOW() FROM tmp.inventory; + -- Actualizamos el campo lastUsed de vn.item UPDATE vn.item i JOIN tmp.inventory i2 ON i2.itemFk = i.id - SET i.lastUsed = NOW() + SET i.lastUsed = util.VN_NOW() WHERE i2.quantity; - + -- DROP TEMPORARY TABLE tmp.inventory; - + END LOOP; CLOSE cWarehouses; @@ -54908,11 +54741,11 @@ proc: BEGIN SELECT e.id as entryId, t.id as travelId FROM vn.travel t - JOIN vn.entry e ON e.travelFk = t.id + JOIN vn.entry e ON e.travelFk = t.id WHERE e.supplierFk = 4 - AND t.shipped <= TIMESTAMPADD(DAY, -2, TIMESTAMPADD(DAY, -10, CURDATE())) - AND (DAY(t.shipped) <> 1 OR shipped < TIMESTAMPADD(MONTH, -12, CURDATE())); - + AND t.shipped <= TIMESTAMPADD(DAY, -2, TIMESTAMPADD(DAY, -10, util.VN_CURDATE())) + AND (DAY(t.shipped) <> 1 OR shipped < TIMESTAMPADD(MONTH, -12, util.VN_CURDATE())); + DELETE e FROM vn.entry e JOIN tmp.entryToDelete tmp ON tmp.entryId = e.id; @@ -54926,8 +54759,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `inventoryMakeLauncher` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54935,6 +54766,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `inventoryMakeLauncher`() BEGIN @@ -54942,7 +54775,7 @@ BEGIN * Recalcula los inventarios de todos los almacenes. */ - call vn.inventoryMake(TIMESTAMPADD(DAY, -10, CURDATE()), 0); + call vn.inventoryMake(TIMESTAMPADD(DAY, -10, util.VN_CURDATE()), 0); END ;; DELIMITER ; @@ -54950,8 +54783,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `inventory_repair` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54959,6 +54790,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `inventory_repair`() BEGIN @@ -54974,7 +54807,7 @@ BEGIN b.id AS buyFk, b.entryFk, b.isIgnored, - b.price2, + b.price2, b.price3, b.stickers, b.packing, @@ -54988,20 +54821,20 @@ BEGIN s.id AS supplierFk, s.name AS supplier FROM itemType it - RIGHT JOIN (entry e + RIGHT JOIN (entry e LEFT JOIN supplier s ON s.id = e.supplierFk RIGHT JOIN buy b ON b.entryFk = e.id LEFT JOIN item i ON i.id = b.itemFk - LEFT JOIN ink ON ink.id = i.inkFk + LEFT JOIN ink ON ink.id = i.inkFk LEFT JOIN travel tr ON tr.id = e.travelFk LEFT JOIN warehouse w ON w.id = tr.warehouseInFk LEFT JOIN origin o ON o.id = i.originFk ) ON it.id = i.typeFk LEFT JOIN edi.ekt ek ON b.ektFk = ek.id - WHERE (b.packageFk = "--" OR b.price2 = 0 OR b.packing = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,CURDATE())) AND s.name = 'INVENTARIO'; - + WHERE (b.packageFk = "--" OR b.price2 = 0 OR b.packing = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())) AND s.name = 'INVENTARIO'; + DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOk; - CREATE TEMPORARY TABLE tmp.lastEntryOk + CREATE TEMPORARY TABLE tmp.lastEntryOk (PRIMARY KEY (buyFk)) SELECT i.id AS itemFk, @@ -55011,7 +54844,7 @@ BEGIN b.id AS buyFk, b.entryFk, b.isIgnored, - b.price2, + b.price2, b.price3, b.stickers, b.packing, @@ -55025,46 +54858,46 @@ BEGIN s.id AS supplierFk, s.name AS supplier FROM itemType it - RIGHT JOIN (entry e + RIGHT JOIN (entry e LEFT JOIN supplier s ON s.id = e.supplierFk RIGHT JOIN buy b ON b.entryFk = e.id LEFT JOIN item i ON i.id = b.itemFk - LEFT JOIN ink ON ink.id = i.inkFk + LEFT JOIN ink ON ink.id = i.inkFk LEFT JOIN travel tr ON tr.id = e.travelFk LEFT JOIN warehouse w ON w.id = tr.warehouseInFk LEFT JOIN origin o ON o.id = i.originFk ) ON it.id = i.typeFk LEFT JOIN edi.ekt ek ON b.ektFk = ek.id - WHERE b.packageFk != "--" AND b.price2 != 0 AND b.packing != 0 AND b.buyingValue > 0 AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-2,CURDATE())) + WHERE b.packageFk != "--" AND b.price2 != 0 AND b.packing != 0 AND b.buyingValue > 0 AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-2,util.VN_CURDATE())) ORDER BY tr.landed DESC; - + DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOkGroup; - CREATE TEMPORARY TABLE tmp.lastEntryOkGroup + CREATE TEMPORARY TABLE tmp.lastEntryOkGroup (INDEX (warehouseFk,itemFk)) SELECT * FROM tmp.lastEntryOk tmp GROUP BY tmp.itemFk,tmp.warehouseFk; - + UPDATE buy b JOIN tmp.lastEntry lt ON lt.buyFk = b.id JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk SET b.packageFk = eo.packageFk WHERE b.packageFk = "--"; - + UPDATE buy b JOIN tmp.lastEntry lt ON lt.buyFk = b.id JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk SET b.price2 = eo.price2 WHERE b.price2 = 0 ; - + UPDATE buy b JOIN tmp.lastEntry lt ON lt.buyFk = b.id JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk SET b.packing = eo.packing WHERE b.packing = 0; - + UPDATE buy b JOIN tmp.lastEntry lt ON lt.buyFk = b.id JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk SET b.buyingValue = eo.buyingValue WHERE b.buyingValue = 0; - + DROP TEMPORARY TABLE tmp.lastEntry; DROP TEMPORARY TABLE tmp.lastEntryOk; DROP TEMPORARY TABLE tmp.lastEntryOkGroup; @@ -55074,8 +54907,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceExpenceMake` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55083,6 +54914,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceExpenceMake`(IN vInvoice INT) BEGIN @@ -55102,7 +54935,7 @@ BEGIN JOIN item i ON i.id = s.itemFk GROUP BY i.expenceFk HAVING amount != 0; - + INSERT INTO invoiceOutExpence(invoiceOutFk, expenceFk, amount) SELECT vInvoice, tst.expenceFk, @@ -55110,15 +54943,13 @@ BEGIN FROM ticketToInvoice t JOIN ticketService ts ON ts.ticketFk = t.id JOIN ticketServiceType tst ON tst.id = ts.ticketServiceTypeFk - HAVING amount != 0; + HAVING amount != 0; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceFromAddress` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55126,21 +54957,23 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceFromAddress`(vMaxTicketDate DATETIME,vAddress INT,vCompany INT) -BEGIN +BEGIN + + DECLARE vMinDateTicket DATE DEFAULT TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()); - DECLARE vMinDateTicket DATE DEFAULT TIMESTAMPADD(MONTH, -3, CURDATE()); - SET vMaxTicketDate = vn2008.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 (Fecha BETWEEN vMinDateTicket - AND vMaxTicketDate) AND Id_Consigna = vAddress + AND vMaxTicketDate) AND Id_Consigna = vAddress AND Factura IS NULL AND empresa_id = vCompany; END ;; @@ -55149,8 +54982,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceFromClient` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55158,12 +54989,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceFromClient`(IN vMaxTicketDate datetime, IN vClientFk INT, IN vCompanyFk INT) BEGIN - DECLARE vMinTicketDate DATE DEFAULT TIMESTAMPADD(YEAR, -3, CURDATE()); + DECLARE vMinTicketDate DATE DEFAULT TIMESTAMPADD(YEAR, -3, util.VN_CURDATE()); SET vMaxTicketDate = util.dayend(vMaxTicketDate); - + DROP TEMPORARY TABLE IF EXISTS `ticketToInvoice`; CREATE TEMPORARY TABLE `ticketToInvoice` (PRIMARY KEY (`id`)) @@ -55179,8 +55012,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceFromTicket` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55188,12 +55019,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceFromTicket`(IN vTicket INT) -BEGIN +BEGIN DROP TEMPORARY TABLE IF EXISTS `ticketToInvoice`; - + CREATE TEMPORARY TABLE `ticketToInvoice` (PRIMARY KEY (`id`)) ENGINE = MEMORY @@ -55206,8 +55039,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceInBookingCommon` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55215,6 +55046,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInBookingCommon`(vInvoiceInId INT, OUT vSerialNumber INT) BEGIN @@ -55222,10 +55055,10 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS newInvoiceIn; CREATE TEMPORARY TABLE newInvoiceIn - SELECT + SELECT i.*, YEAR(i.booked) datedYear, - CONCAT('s/fra',RIGHT(i.supplierRef,8),':',LEFT(s.name, 10)) conceptWithSupplier, + CONCAT('s/fra',RIGHT(i.supplierRef,8),':',LEFT(s.name, 10)) conceptWithSupplier, (cc.id = c.id) isSameCountry, cit.id invoicesCount FROM invoiceIn i @@ -55238,7 +55071,7 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS newSupplier; CREATE TEMPORARY TABLE newSupplier - SELECT + SELECT s.*, REPLACE(s.account,' ','') supplierAccount, IF(c.CEE < 2, TRUE, FALSE) isUeeMember @@ -55251,11 +55084,11 @@ BEGIN CALL util.throw('INACTIVE_PROVIDER'); END IF; - SELECT IFNULL(MAX(i.serialNumber) + 1,1) + SELECT IFNULL(MAX(i.serialNumber) + 1,1) INTO vSerialNumber FROM invoiceIn i JOIN newInvoiceIn n - WHERE i.serial LIKE n.serial + WHERE i.serial LIKE n.serial AND YEAR(i.booked) = n.datedYear AND i.companyFk = n.companyFk GROUP BY i.companyFk; @@ -55266,8 +55099,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceInBookingMain` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55275,6 +55106,8 @@ DELIMITER ; /*!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`@`localhost` PROCEDURE `invoiceInBookingMain`(vInvoiceInId INT) BEGIN @@ -55284,7 +55117,7 @@ BEGIN CALL invoiceInBookingCommon(vInvoiceInId,vSerialNumber); - SELECT SUM(iit.taxableBase * IF( i.serial= 'R' AND ti.Iva <> 'HP DEVENGADO 21 ISP', 1 +(ti.PorcentajeIva/100),1)), + SELECT SUM(iit.taxableBase * IF( i.serial= 'R' AND ti.Iva <> 'HP DEVENGADO 21 ISP', 1 +(ti.PorcentajeIva/100),1)), SUM(iit.foreignValue * IF( i.serial= 'R', 1 + (ti.PorcentajeIva/100),1)), iit.taxableBase/iit.foreignValue INTO vTotalAmount, vTotalAmountDivisa, vRate @@ -55307,7 +55140,7 @@ BEGIN CLAVE, empresa_id ) - SELECT + SELECT vBookNumber, n.bookEntried, s.supplierAccount, @@ -55318,7 +55151,7 @@ BEGIN n.invoicesCount, vInvoiceInId, n.companyFk - FROM newInvoiceIn n + FROM newInvoiceIn n JOIN newSupplier s; -- Línea de Gastos @@ -55328,7 +55161,7 @@ BEGIN CONTRA, EURODEBE, EUROHABER, - CONCEPTO, + CONCEPTO, CAMBIO, DEBEME, HABERME, @@ -55348,7 +55181,7 @@ BEGIN n.invoicesCount NFACTICK, n.companyFk empresa_id FROM newInvoiceIn n - JOIN newSupplier s + JOIN newSupplier s JOIN invoiceInTax iit ON iit.invoiceInFk = n.id JOIN (SELECT * FROM expence e GROUP BY e.id)e ON e.id = iit.expenceFk WHERE e.name != 'Suplidos Transitarios nacionales' @@ -55359,13 +55192,13 @@ BEGIN INSERT INTO XDiario( ASIEN, FECHA, SUBCTA, - CONTRA, + CONTRA, EURODEBE, BASEEURO, - CONCEPTO, - FACTURA, + CONCEPTO, + FACTURA, IVA, - AUXILIAR, + AUXILIAR, SERIE, TIPOOPE, FECHA_EX, @@ -55414,34 +55247,34 @@ BEGIN n.booked FECREGCON, n.companyFk FROM newInvoiceIn n - JOIN newSupplier s + JOIN newSupplier s JOIN invoiceInTax it ON n.id = it.invoiceInFk JOIN sage.TiposIva ti ON ti.CodigoIva = it.taxTypeSageFk JOIN sage.TiposTransacciones ttr ON ttr.CodigoTransaccion = it.transactionTypeSageFk JOIN invoiceInSerial iis ON iis.code = n.serial JOIN (SELECT * FROM expence e GROUP BY e.id)e ON e.id = it.expenceFk LEFT JOIN ( - SELECT eWithheld.id - FROM invoiceInTax hold - JOIN expence eWithheld ON eWithheld.id = hold.expenceFk AND eWithheld.isWithheld + SELECT eWithheld.id + FROM invoiceInTax hold + JOIN expence eWithheld ON eWithheld.id = hold.expenceFk AND eWithheld.isWithheld WHERE hold.invoiceInFk = vInvoiceInId LIMIT 1 - ) eWithheld ON TRUE - WHERE it.taxTypeSageFk IS NOT NULL + ) eWithheld ON TRUE + WHERE it.taxTypeSageFk IS NOT NULL AND it.taxTypeSageFk NOT IN (22, 90) GROUP BY ti.PorcentajeIva, e.id; -- Línea iva inversor sujeto pasivo - + INSERT INTO XDiario( ASIEN, FECHA, SUBCTA, - CONTRA, + CONTRA, EUROHABER, BASEEURO, - CONCEPTO, - FACTURA, + CONCEPTO, + FACTURA, IVA, - AUXILIAR, + AUXILIAR, SERIE, TIPOOPE, FECHA_EX, @@ -55487,45 +55320,43 @@ BEGIN s.nif AS TERNIF, s.name AS TERNOM, n.companyFk - FROM newInvoiceIn n - JOIN newSupplier s + FROM newInvoiceIn n + JOIN newSupplier s JOIN invoiceInTax it ON n.id = it.invoiceInFk JOIN sage.TiposIva ti ON ti.CodigoIva = it.taxTypeSageFk JOIN sage.TiposTransacciones ttr ON ttr.CodigoTransaccion = it.transactionTypeSageFk - JOIN invoiceInSerial iis ON iis.code = n.serial + JOIN invoiceInSerial iis ON iis.code = n.serial JOIN (SELECT * FROM expence e GROUP BY e.id)e ON e.id = it.expenceFk WHERE ti.Iva = 'HP DEVENGADO 21 ISP' OR MID(s.account, 4, 1) = '1' GROUP BY ti.PorcentajeIva, e.id; - - -- Actualización del registro original + + -- Actualización del registro original UPDATE invoiceIn ii JOIN newInvoiceIn ni ON ii.id = ni.id SET ii.serialNumber = vSerialNumber, ii.isBooked = TRUE; - + -- Problemas derivados de la precisión en los decimales al calcular los impuestos - UPDATE XDiario - SET EURODEBE = EURODEBE - + UPDATE XDiario + SET EURODEBE = EURODEBE - (SELECT IF(ABS(sub.difference) = 0.01, sub.difference, 0) FROM( - SELECT SUM(IFNULL(ROUND(EURODEBE, 2),0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0)) difference + SELECT SUM(IFNULL(ROUND(EURODEBE, 2),0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0)) difference FROM XDiario WHERE ASIEN = vBookNumber )sub ) - WHERE ASIEN = vBookNumber + WHERE ASIEN = vBookNumber AND EURODEBE <> 0 ORDER BY id DESC LIMIT 1; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceInDueDay_calculate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55533,44 +55364,46 @@ DELIMITER ; /*!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`@`localhost` PROCEDURE `invoiceInDueDay_calculate`(vInvoiceInFk INT) BEGIN IF !(SELECT COUNT(*) - FROM invoiceInDueDay iid + FROM invoiceInDueDay iid WHERE iid.invoiceInFk = vInvoiceInFk) THEN - INSERT INTO invoiceInDueDay (invoiceInFk, - dueDated, - amount, - foreignValue) + INSERT INTO invoiceInDueDay (invoiceInFk, + dueDated, + amount, + foreignValue) SELECT vInvoiceInFk, - IF(payDay, + IF(payDay, IF(vn.getNextDueDate(issued, detail, payDay) < DATE_ADD(created, INTERVAL 2 DAY), DATE_ADD(created, INTERVAL 2 DAY), - vn.getNextDueDate(issued, detail, payDay)), + vn.getNextDueDate(issued, detail, payDay)), GREATEST(TIMESTAMPADD(DAY, 2, created), TIMESTAMPADD(DAY, detail, issued))), - 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.detail)) venc, + 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.detail)) venc, SUM(iit.foreignValue)/COUNT(DISTINCT(pdd.detail)) foreignValue, - s.payDemFk, + s.payDemFk, ii.companyFk, COUNT(DISTINCT(pdd.detail)) cont, s.payDay, ii.issued, DATE(ii.created) created - FROM invoiceIn ii - JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id - LEFT JOIN sage.TiposIva AS ti ON ti.CodigoIva= iit.taxTypeSageFk - JOIN supplier s ON s.id = ii.supplierFk - JOIN supplier s2 ON s2.id = ii.companyFk - JOIN vn.payDemDetail pdd ON pdd.id = s.payDemFk - WHERE ii.id = vInvoiceInFk + FROM invoiceIn ii + JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id + LEFT JOIN sage.TiposIva AS ti ON ti.CodigoIva= iit.taxTypeSageFk + JOIN supplier s ON s.id = ii.supplierFk + JOIN supplier s2 ON s2.id = ii.companyFk + JOIN vn.payDemDetail pdd ON pdd.id = s.payDemFk + WHERE ii.id = vInvoiceInFk GROUP BY ii.id ) sub - JOIN (SELECT @cont:=0) sub2 + JOIN (SELECT @cont:=0) sub2 JOIN vn.payDemDetail pdd ON pdd.id = sub.payDemFk GROUP BY detail; END IF; @@ -55581,8 +55414,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceInDueDay_recalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55590,23 +55421,23 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInDueDay_recalc`(vInvoiceInFk INT) BEGIN DELETE FROM invoiceInDueDay WHERE invoiceInFk = vInvoiceInFk; - + CALL invoiceInDueDay_calculate(vInvoiceInFk); - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceInTaxMakeByDua` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55614,6 +55445,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTaxMakeByDua`(vDuaFk INT) BEGIN @@ -55637,7 +55470,7 @@ BEGIN CALL vn2008.recibidaIvaInsert(vInvoiceInFk); CALL vn2008.recibidaVencimientoReplace(vInvoiceInFk); - + FETCH rs INTO vInvoiceInFk; END WHILE; @@ -55650,8 +55483,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceInTax_getFromDua` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55659,6 +55490,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTax_getFromDua`(vDuaFk INT) BEGIN @@ -55682,7 +55515,7 @@ BEGIN CALL invoiceInTax_getFromEntries(vInvoiceInFk); CALL invoiceInDueDay_calculate(vInvoiceInFk); - + FETCH rs INTO vInvoiceInFk; END WHILE; @@ -55695,8 +55528,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceInTax_getFromEntries` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55704,6 +55535,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTax_getFromEntries`(IN vId INT) BEGIN @@ -55714,7 +55547,7 @@ BEGIN SELECT MAX(rr.dated) INTO vDated FROM referenceRate rr JOIN invoiceIn ii ON ii.id = vId - WHERE rr.dated <= ii.issued + WHERE rr.dated <= ii.issued AND rr.currencyFk = ii.currencyFk ; IF vDated THEN @@ -55723,13 +55556,13 @@ BEGIN WHERE dated = vDated; END IF; - SELECT id INTO vExpenceFk - FROM vn.expence - WHERE `name` = 'Adquisición mercancia Extracomunitaria' - GROUP BY id + SELECT id INTO vExpenceFk + FROM vn.expence + WHERE `name` = 'Adquisición mercancia Extracomunitaria' + GROUP BY id LIMIT 1; - - DELETE FROM invoiceInTax + + DELETE FROM invoiceInTax WHERE invoiceInFk = vId; INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenceFk, foreignValue, taxTypeSageFk, transactionTypeSageFk) @@ -55743,9 +55576,9 @@ BEGIN JOIN entry e ON e.invoiceInFk = ii.id JOIN supplier s ON s.id = e.supplierFk JOIN buy b ON b.entryFk = e.id - LEFT JOIN referenceRate rr ON rr.currencyFk = ii.currencyFk + LEFT JOIN referenceRate rr ON rr.currencyFk = ii.currencyFk AND rr.dated = ii.issued - WHERE ii.id = vId + WHERE ii.id = vId HAVING taxableBase IS NOT NULL; END ;; DELIMITER ; @@ -55753,8 +55586,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceOutAgain` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55762,6 +55593,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutAgain`(IN vInvoiceRef VARCHAR(15), vTaxArea VARCHAR(25)) BEGIN @@ -55776,15 +55609,15 @@ BEGIN DECLARE vCountry INT; DECLARE vTaxArea VARCHAR(15); DECLARE vSpainCountryCode INT DEFAULT 1; - + SELECT id INTO vInvoiceFk - FROM invoiceOut + FROM invoiceOut WHERE ref = vInvoiceRef; - - UPDATE invoiceOut + + UPDATE invoiceOut SET hasPdf = 0 WHERE id = vInvoiceFk; - + SELECT s.countryFk INTO vCountry FROM supplier s JOIN invoiceOut io ON io.companyFk = s.id @@ -55793,38 +55626,36 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS ticketToInvoice; CREATE TEMPORARY TABLE ticketToInvoice - SELECT id - FROM ticket + SELECT id + FROM ticket WHERE refFk = vInvoiceRef; CALL invoiceExpenceMake(vInvoiceFk); - + CALL invoiceTaxMake(vInvoiceFk,vTaxArea); - + UPDATE invoiceOut io JOIN ( SELECT SUM(amount) AS total - FROM invoiceOutExpence + FROM invoiceOutExpence WHERE invoiceOutFk = vInvoiceFk ) base JOIN ( SELECT SUM(vat) AS total - FROM invoiceOutTax + FROM invoiceOutTax WHERE invoiceOutFk = vInvoiceFk ) vat SET io.amount = base.total + vat.total WHERE io.id = vInvoiceFk; - + CALL vn.invoiceOutBooking(vInvoiceFk); - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceOutBooking` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55832,6 +55663,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutBooking`(IN vInvoice INT) BEGIN @@ -55861,7 +55694,7 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS rs; CREATE TEMPORARY TABLE rs - SELECT + SELECT c.accountingAccount AS clientBookingAccount, io.amount as totalAmount, CONCAT('n/fra ', io.ref) as simpleConcept, @@ -55895,19 +55728,19 @@ BEGIN WHERE io.id = vInvoice; CALL vn.ledger_next(vBookNumber); - + -- Linea del cliente INSERT INTO XDiario( ASIEN, FECHA, - SUBCTA, + SUBCTA, EURODEBE, - CONCEPTO, + CONCEPTO, FECHA_EX, FECHA_OP, empresa_id ) - SELECT + SELECT vBookNumber AS ASIEN, rs.FECHA, rs.clientBookingAccount AS SUBCTA, @@ -55923,14 +55756,14 @@ BEGIN ASIEN, FECHA, SUBCTA, - CONTRA, + CONTRA, EUROHABER, - CONCEPTO, + CONCEPTO, FECHA_EX, FECHA_OP, empresa_id ) - SELECT + SELECT vBookNumber AS ASIEN, rs.FECHA, ioe.expenceFk AS SUBCTA, @@ -55944,8 +55777,8 @@ BEGIN JOIN invoiceOutExpence ioe WHERE ioe.invoiceOutFk = vInvoice; - SELECT GROUP_CONCAT(`name` SEPARATOR ',') - INTO vExpenceConcept + SELECT GROUP_CONCAT(`name` SEPARATOR ',') + INTO vExpenceConcept FROM expence e JOIN invoiceOutExpence ioe ON ioe.expenceFk = e.id WHERE ioe.invoiceOutFk = vInvoice; @@ -55955,7 +55788,7 @@ BEGIN ASIEN, FECHA, SUBCTA, - CONTRA, + CONTRA, EUROHABER, BASEEURO, CONCEPTO, @@ -55983,7 +55816,7 @@ BEGIN TIPORECTIF, empresa_id ) - SELECT + SELECT vBookNumber AS ASIEN, rs.FECHA, iot.pgcFk AS SUBCTA, @@ -56003,11 +55836,11 @@ BEGIN rs.FECHA_OP, rs.FECHA_EX, rs.TIPOOPE, - rs.NFACTICK, + rs.NFACTICK, rs.TERIDNIF, rs.TERNIF, rs.TERNOM, - pgc.mod340 AS L340, + pgc.mod340 AS L340, pgc.cplusTrascendency477Fk AS TIPOCLAVE, pgc.cplusTaxBreakFk as TIPOEXENCI, rs.TIPONOSUJE, @@ -56015,15 +55848,15 @@ BEGIN rs.TIPORECTIF, rs.companyFk AS empresa_id FROM rs - JOIN invoiceOutTax iot + JOIN invoiceOutTax iot JOIN pgc ON pgc.code = iot.pgcFk LEFT JOIN pgcEqu pe ON pe.vatFk = iot.pgcFk -- --------------- Comprueba si la linea es de iva con rec.equiv. asociado - LEFT JOIN pgc pgce ON pgce.code = pe.equFk + LEFT JOIN pgc pgce ON pgce.code = pe.equFk LEFT JOIN pgcEqu pe2 ON pe2.equFk = iot.pgcFk -- --------------- Comprueba si la linea es de rec.equiv. WHERE iot.invoiceOutFk = vInvoice; - + UPDATE invoiceOut - SET booked = CURDATE() + SET booked = util.VN_CURDATE() WHERE id = vInvoice; END ;; DELIMITER ; @@ -56031,8 +55864,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceOutBookingRange` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56040,6 +55871,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutBookingRange`() BEGIN @@ -56053,7 +55886,7 @@ BEGIN DECLARE done BOOL DEFAULT FALSE; - DECLARE rs CURSOR FOR + DECLARE rs CURSOR FOR SELECT io.id FROM invoiceOut io WHERE RIGHT(ref,7) BETWEEN 1724215 AND 1724224 @@ -56068,15 +55901,15 @@ BEGIN WHILE NOT done DO CALL invoiceOutBooking(vInvoice); - + FETCH rs INTO vInvoice ; - + SET vContador = vContador + 1; - + IF vContador MOD 50 = 0 THEN - + SELECT CONCAT(vContador, ' de momento') AS FACTURAS_ASENTADAS; - + END IF; END WHILE; @@ -56091,8 +55924,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceOutDelete` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56100,20 +55931,22 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutDelete`(vRef VARCHAR(15)) BEGIN DECLARE vAsien INTEGER; DECLARE vSendMail BOOL; DECLARE vBody TEXT; - + SELECT ASIEN INTO vAsien - FROM XDiario + FROM XDiario WHERE SERIE = SUBSTRING(vRef, 1, 1) AND FACTURA = SUBSTRING(vRef, 2, LENGTH(vRef)-1) LIMIT 1; - SELECT IF(enlazado OR enlazadoSage, TRUE, FALSE), + SELECT IF(enlazado OR enlazadoSage, TRUE, FALSE), CONCAT( ' @@ -56122,7 +55955,7 @@ BEGIN - ', + ', GROUP_CONCAT( CONCAT(' @@ -56135,14 +55968,14 @@ BEGIN ) SEPARATOR ' ' ), '
FECHACONCEPTO EURODEBE EUROHABER
', IFNULL(FECHA,''), '
' - ) + ) INTO vSendMail, vBody - FROM XDiario + FROM XDiario WHERE ASIEN = vAsien; - DELETE FROM XDiario + DELETE FROM XDiario WHERE ASIEN = vAsien; - + IF vSendMail THEN CALL mail_insert( 'administracion@verdnatura.es', @@ -56160,7 +55993,7 @@ BEGIN SET refFk = NULL WHERE refFk = vRef; - DELETE + DELETE FROM invoiceOut WHERE ref = vRef; @@ -56170,8 +56003,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceOutListByCompany` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56179,11 +56010,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutListByCompany`(vCompany INT, vStarted DATE, vEnded DATE) BEGIN -SELECT +SELECT c.socialName as RazonSocial, c.fi as NIF, io.ref as Factura, @@ -56195,7 +56028,7 @@ SELECT pgc.rate as Tipo, iot.vat as Cuota, pgc.name as Concepto - + FROM vn.invoiceOut io JOIN vn.invoiceOutTax iot ON iot.invoiceOutFk = io.id JOIN vn.client c ON c.id = io.clientFk @@ -56210,8 +56043,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceOutTaxAndExpence` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56219,6 +56050,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutTaxAndExpence`() BEGIN @@ -56236,10 +56069,10 @@ BEGIN DECLARE done BOOL DEFAULT FALSE; - DECLARE rs CURSOR FOR + DECLARE rs CURSOR FOR SELECT id,ref FROM invoiceOut io - + WHERE issued >= '2017-07-01' AND companyFk = 1381 AND io.amount IS NULL @@ -56254,37 +56087,37 @@ BEGIN WHILE NOT done DO - SELECT s.countryFk + SELECT s.countryFk INTO vCountry FROM supplier s JOIN invoiceOut io ON io.companyFk = s.id WHERE io.id = vInvoice; - + SELECT IF(c.isEqualizated AND i.taxAreaFk = 'NATIONAL','EQU',i.taxAreaFk) INTO vTaxArea FROM invoiceOutSerial i - JOIN invoiceOut io ON io.serial = i.code + JOIN invoiceOut io ON io.serial = i.code JOIN client c ON c.id = io.clientFk WHERE io.id = vInvoice; - + DROP TEMPORARY TABLE IF EXISTS ticketToInvoice; CREATE TEMPORARY TABLE ticketToInvoice - SELECT id - FROM ticket + SELECT id + FROM ticket WHERE refFk = vInvoiceRef; CALL invoiceExpenceMake(vInvoice); CALL invoiceTaxMake(vInvoice,vCountry,vTaxArea); - + FETCH rs INTO vInvoice ,vInvoiceRef; - + SET vContador = vContador + 1; - + IF vContador MOD 50 = 0 THEN - + SELECT CONCAT(vContador, ' de momento') AS FACTURAS_ASENTADAS; - + END IF; END WHILE; @@ -56299,8 +56132,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceOut_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56308,25 +56139,25 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_new`( vSerial VARCHAR(255), vInvoiceDate DATETIME, - vTaxArea VARCHAR(25), + vTaxArea VARCHAR(25), OUT vNewInvoiceId INT) BEGIN - -/* Creación de facturas emitidas. -* requiere previamente tabla ticketToInvoice(id). -* -* @param vSerial serie a la cual se hace la factura -* @param vInvoiceDate fecha de la factura -* @param vTaxArea tipo de iva en relacion a la empresa y al cliente -* @param vNewInvoiceId id de la factura que se acaba de generar -* -* @return vNewInvoiceId -*/ - +/** + * Creación de facturas emitidas. + * requiere previamente tabla ticketToInvoice(id). + * + * @param vSerial serie a la cual se hace la factura + * @param vInvoiceDate fecha de la factura + * @param vTaxArea tipo de iva en relacion a la empresa y al cliente + * @param vNewInvoiceId id de la factura que se acaba de generar + * @return vNewInvoiceId + */ DECLARE vSpainCountryCode INT DEFAULT 1; DECLARE vIsAnySaleToInvoice BOOL; DECLARE vIsAnyServiceToInvoice BOOL; @@ -56342,33 +56173,33 @@ BEGIN DECLARE vSimplifiedSerial VARCHAR(1) DEFAULT 'S'; DECLARE vNewInvoiceInId INT; DECLARE vIsInterCompany BOOL; - - SET vInvoiceDate = IFNULL(vInvoiceDate,CURDATE()); + + SET vInvoiceDate = IFNULL(vInvoiceDate,util.VN_CURDATE()); SELECT t.clientFk, t.companyFk INTO vClient, vCompany FROM ticketToInvoice tt JOIN ticket t ON t.id = tt.id - LIMIT 1; + LIMIT 1; - -- Eliminem de ticketToInvoice els tickets que no han de ser facturats - DELETE ti.* - FROM ticketToInvoice ti - JOIN ticket t ON t.id = ti.id - JOIN client c ON c.id = t.clientFk - WHERE YEAR(t.shipped) < 2001 + -- Eliminem de ticketToInvoice els tickets que no han de ser facturats + DELETE ti.* + FROM ticketToInvoice ti + JOIN ticket t ON t.id = ti.id + JOIN client c ON c.id = t.clientFk + WHERE YEAR(t.shipped) < 2001 OR c.isTaxDataChecked = FALSE - OR t.isDeleted - OR c.hasToInvoice = FALSE; + OR t.isDeleted + OR c.hasToInvoice = FALSE; - SELECT SUM(s.quantity * s.price * (100 - s.discount)/100), ts.id - INTO vIsAnySaleToInvoice, vIsAnyServiceToInvoice - FROM ticketToInvoice t - LEFT JOIN sale s ON s.ticketFk = t.id - LEFT JOIN ticketService ts ON ts.ticketFk = t.id; + SELECT SUM(s.quantity * s.price * (100 - s.discount)/100), ts.id + INTO vIsAnySaleToInvoice, vIsAnyServiceToInvoice + FROM ticketToInvoice t + LEFT JOIN sale s ON s.ticketFk = t.id + LEFT JOIN ticketService ts ON ts.ticketFk = t.id; - IF (vIsAnySaleToInvoice OR vIsAnyServiceToInvoice) - AND (vCorrectingSerial = vSerial OR NOT hasAnyNegativeBase()) + IF (vIsAnySaleToInvoice OR vIsAnyServiceToInvoice) + AND (vCorrectingSerial = vSerial OR NOT hasAnyNegativeBase()) THEN -- el trigger añade el siguiente Id_Factura correspondiente a la vSerial @@ -56380,153 +56211,151 @@ BEGIN clientFk, dued, companyFk, - cplusInvoiceType477Fk + cplusInvoiceType477Fk ) - SELECT + SELECT 1, vSerial, vInvoiceDate, vClient, getDueDate(vInvoiceDate, dueDay), vCompany, - IF(vSerial = vCorrectingSerial, - vCplusCorrectingInvoiceTypeFk, + IF(vSerial = vCorrectingSerial, + vCplusCorrectingInvoiceTypeFk, IF(vSerial = vSimplifiedSerial, vCplusSimplifiedInvoiceTypeFk, vCplusStandardInvoiceTypeFk)) - FROM client - WHERE id = vClient; + FROM client + WHERE id = vClient; SET vNewInvoiceId = LAST_INSERT_ID(); - + SELECT `ref` - INTO vNewRef + INTO vNewRef FROM invoiceOut WHERE id = vNewInvoiceId; UPDATE ticket t - JOIN ticketToInvoice ti ON ti.id = t.id - SET t.refFk = vNewRef; + JOIN ticketToInvoice ti ON ti.id = t.id + SET t.refFk = vNewRef; DROP TEMPORARY TABLE IF EXISTS tmp.updateInter; - CREATE TEMPORARY TABLE tmp.updateInter ENGINE = MEMORY - SELECT s.id,ti.id ticket_id,vWorker Id_Trabajador + CREATE TEMPORARY TABLE tmp.updateInter ENGINE = MEMORY + SELECT s.id,ti.id ticket_id,vWorker Id_Trabajador FROM ticketToInvoice ti - LEFT JOIN vn.ticketState ts ON ti.id = ts.ticket - JOIN state s - WHERE IFNULL(ts.alertLevel,0) < 3 and s.`code` = vn.getAlert3State(ti.id); - + LEFT JOIN ticketState ts ON ti.id = ts.ticket + JOIN state s + WHERE IFNULL(ts.alertLevel,0) < 3 and s.`code` = getAlert3State(ti.id); + INSERT INTO vncontrol.inter(state_id,Id_Ticket,Id_Trabajador) SELECT * FROM tmp.updateInter; - - INSERT INTO ticketLog (action, userFk,originFk, description) - SELECT 'UPDATE',account.myUser_getId(),ti.id, CONCAT('Crea factura ',vNewRef) + INSERT INTO ticketLog (action, userFk, originFk, description) + SELECT 'UPDATE', account.myUser_getId(), ti.id, CONCAT('Crea factura ', vNewRef) FROM ticketToInvoice ti; CALL invoiceExpenceMake(vNewInvoiceId); CALL invoiceTaxMake(vNewInvoiceId,vTaxArea); - + UPDATE invoiceOut io JOIN ( SELECT SUM(amount) AS total - FROM invoiceOutExpence + FROM invoiceOutExpence WHERE invoiceOutFk = vNewInvoiceId ) base JOIN ( SELECT SUM(vat) AS total - FROM invoiceOutTax + FROM invoiceOutTax WHERE invoiceOutFk = vNewInvoiceId ) vat SET io.amount = base.total + vat.total WHERE io.id = vNewInvoiceId; - + DROP TEMPORARY TABLE tmp.updateInter; SELECT ios.isCEE INTO vIsInterCompany FROM vn.ticket t - JOIN vn.company c ON c.clientFk = t.clientFk - JOIN vn.invoiceOut io ON io.`ref` = t.refFk + JOIN vn.company c ON c.clientFk = t.clientFk + JOIN vn.invoiceOut io ON io.`ref` = t.refFk JOIN vn.invoiceOutSerial ios ON ios.code = io.serial WHERE t.refFk = vNewRef; - + IF (vIsInterCompany) THEN - + SELECT vCompany INTO vSupplier; SELECT id INTO vCompany FROM company WHERE clientFk = vClient; - + INSERT INTO invoiceIn(supplierFk, supplierRef, issued, companyFk) SELECT vSupplier, vNewRef, vInvoiceDate, vCompany; - + SET vNewInvoiceInId = LAST_INSERT_ID(); - + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; CREATE TEMPORARY TABLE tmp.ticket (KEY (ticketFk)) ENGINE = MEMORY SELECT id ticketFk FROM ticketToInvoice; - + CALL `ticket_getTax`('NATIONAL'); - + SET @vTaxableBaseServices := 0.00; SET @vTaxCodeGeneral := NULL; - + INSERT INTO vn.invoiceInTax(invoiceInFk, taxableBase, expenceFk, taxTypeSageFk, transactionTypeSageFk) SELECT vNewInvoiceInId, @vTaxableBaseServices, sub.expenceFk, sub.taxTypeSageFk , sub.transactionTypeSageFk FROM ( - SELECT @vTaxableBaseServices := SUM(tst.taxableBase) taxableBase, i.expenceFk, i.taxTypeSageFk , i.transactionTypeSageFk, @vTaxCodeGeneral := i.taxClassCodeFk + SELECT @vTaxableBaseServices := SUM(tst.taxableBase) taxableBase, i.expenceFk, i.taxTypeSageFk , i.transactionTypeSageFk, @vTaxCodeGeneral := i.taxClassCodeFk FROM tmp.ticketServiceTax tst JOIN vn.invoiceOutTaxConfig i ON i.taxClassCodeFk = tst.code - WHERE i.isService + WHERE i.isService HAVING taxableBase ) sub; - + INSERT INTO vn.invoiceInTax(invoiceInFk, taxableBase, expenceFk, taxTypeSageFk, transactionTypeSageFk) - SELECT vNewInvoiceInId, SUM(tt.taxableBase) - IF(tt.code = @vTaxCodeGeneral, @vTaxableBaseServices, 0) taxableBase, i.expenceFk, i.taxTypeSageFk , i.transactionTypeSageFk + SELECT vNewInvoiceInId, SUM(tt.taxableBase) - IF(tt.code = @vTaxCodeGeneral, @vTaxableBaseServices, 0) taxableBase, i.expenceFk, i.taxTypeSageFk , i.transactionTypeSageFk FROM tmp.ticketTax tt JOIN vn.invoiceOutTaxConfig i ON i.taxClassCodeFk = tt.code - WHERE !i.isService - GROUP BY tt.pgcFk - HAVING taxableBase - ORDER BY tt.priority; - - CALL `vn`.`invoiceInDueDay_calculate`(vNewInvoiceInId); - - INSERT INTO vn2008.intrastat_data (recibida_id, intrastat_id, importe, unidades, Paises_Id, neto) - SELECT - vNewInvoiceInId, - i.intrastatFk, - CAST(SUM((s.quantity * s.price * (100 - s.discount) / 100)) AS DECIMAL(10,2)) importe, - CAST(SUM(IFNULL(i.stems, 1) * s.quantity) AS DECIMAL (10 , 2 )) stems, - s2.countryFk, - CAST(SUM(IF(sv.physicalWeight, sv.physicalWeight, i.density * sub.cm3delivery/1000000)) AS DECIMAL(10,2)) neto - FROM vn.sale s - LEFT JOIN (SELECT ic.itemFk, ic.cm3delivery - FROM vn.itemCost ic - WHERE ic.cm3 - GROUP BY ic.itemFk) sub ON s.itemFk = sub.itemFk - LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id - LEFT JOIN vn.ticket t ON s.ticketFk = t.id - LEFT JOIN vn.supplier s2 ON s2.id = t.companyFk - LEFT JOIN vn.item i ON i.id = s.itemFk - LEFT JOIN vn.intrastat it ON it.id = i.intrastatFk - JOIN vn.invoiceOut iOut ON iOut.ref = t.refFk - WHERE iOut.`ref` = vNewRef - GROUP BY i.intrastatFk - ORDER BY i.intrastatFk; - - + WHERE !i.isService + GROUP BY tt.pgcFk + HAVING taxableBase + ORDER BY tt.priority; + + CALL invoiceInDueDay_calculate(vNewInvoiceInId); + + INSERT INTO invoiceInIntrastat ( + invoiceInFk, + intrastatFk, + amount, + stems, + countryFk, + net) + SELECT + vNewInvoiceInId, + i.intrastatFk, + CAST(sv.eurosValue AS DECIMAL (10, 2)), + CAST(SUM(IFNULL(i.stems, 1) * s.quantity) AS DECIMAL (10, 2)), + su.countryFk, + CAST(SUM(IFNULL(sv.physicalWeight, sv.weight)) AS DECIMAL(10, 2)) + FROM sale s + LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id + LEFT JOIN ticket t ON s.ticketFk = t.id + LEFT JOIN supplier su ON su.id = t.companyFk + LEFT JOIN item i ON i.id = s.itemFk + JOIN invoiceOut iOut ON iOut.ref = t.refFk + WHERE iOut.`ref` = vNewRef + GROUP BY i.intrastatFk; + DROP TEMPORARY TABLE tmp.ticket; DROP TEMPORARY TABLE tmp.ticketAmount; DROP TEMPORARY TABLE tmp.ticketTax; DROP TEMPORARY TABLE tmp.ticketServiceTax; - + END IF; - + END IF; - + DROP TEMPORARY TABLE `ticketToInvoice`; END ;; DELIMITER ; @@ -56534,8 +56363,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceOut_newFromClient` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56543,6 +56370,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_newFromClient`(IN vClientFk int, IN vSerial char(2), IN vMaxShipped date, IN vCompanyFk int, IN vTaxArea varchar(25), @@ -56550,7 +56379,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_newFromClient`(IN vClien BEGIN /** * Factura los tickets de un cliente hasta una fecha dada - * @param vClientFk Id del cliente a facturar + * @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 @@ -56558,7 +56387,7 @@ BEGIN * @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 @@ -56569,14 +56398,14 @@ BEGIN IF NOT vIsRefEditable THEN CALL util.throw('serial non editable'); END IF; - END IF; - + END IF; + CALL invoiceFromClient(vMaxShipped, vClientFk, vCompanyFk); - CALL invoiceOut_new(vSerial, CURDATE(), vTaxArea, vInvoiceId); + CALL invoiceOut_new(vSerial, util.VN_CURDATE(), vTaxArea, vInvoiceId); UPDATE invoiceOut SET `ref` = vRef - WHERE id = vInvoiceId + WHERE id = vInvoiceId AND vRef IS NOT NULL; IF vSerial <> 'R' AND NOT ISNULL(vInvoiceId) AND vInvoiceId <> 0 THEN @@ -56588,8 +56417,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceOut_newFromTicket` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56597,6 +56424,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_newFromTicket`(IN vTicketFk int, IN vSerial char(2), IN vTaxArea varchar(25), IN vRef varchar(25), OUT vInvoiceId int) @@ -56605,13 +56434,13 @@ 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, + * @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); + CALL invoiceOut_new(vSerial, util.VN_CURDATE(), vTaxArea, vInvoiceId); IF vRef IS NOT NULL THEN SELECT isRefEditable INTO vIsRefEditable @@ -56620,11 +56449,11 @@ BEGIN IF NOT vIsRefEditable THEN CALL util.throw('serial non editable'); END IF; - - UPDATE invoiceOut + + UPDATE invoiceOut SET `ref` = vRef WHERE id = vInvoiceId; - END IF; + END IF; IF vSerial <> 'R' AND NOT ISNULL(vInvoiceId) AND vInvoiceId <> 0 THEN CALL invoiceOutBooking(vInvoiceId); @@ -56635,8 +56464,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceTaxMake` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56644,6 +56471,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceTaxMake`(vInvoice INT, vTaxArea VARCHAR(25)) BEGIN @@ -56657,14 +56486,14 @@ BEGIN */ DELETE FROM invoiceOutTax WHERE invoiceOutFk = vInvoice; - + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; CREATE TEMPORARY TABLE tmp.ticket (KEY (ticketFk)) ENGINE = MEMORY SELECT id ticketFk FROM ticketToInvoice; - + CALL ticket_getTax(vTaxArea); INSERT INTO invoiceOutTax( @@ -56681,7 +56510,7 @@ BEGIN GROUP BY pgcFk HAVING BASE ORDER BY priority; - + DROP TEMPORARY TABLE tmp.ticket; DROP TEMPORARY TABLE tmp.ticketTax; DROP TEMPORARY TABLE tmp.ticketAmount; @@ -56692,8 +56521,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemBarcode_update` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56701,12 +56528,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemBarcode_update`(vItemFk INT,vCode VARCHAR(22), vDelete BOOL) BEGIN IF vDelete THEN DELETE FROM vn.itemBarcode WHERE itemFk = vItemFk AND code = vCode; -ELSE +ELSE INSERT INTO vn.itemBarcode(itemFk,code) VALUES (vItemFk,vCode); END IF; @@ -56716,8 +56545,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemFreight_Show` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56725,11 +56552,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemFreight_Show`(vItemFk INT, vWarehouseFk INT) BEGIN - - SELECT cm3 Volumen_Entrada, + + SELECT cm3 Volumen_Entrada, cm3delivery Volumen_Salida, p.volume Volumen_del_embalaje, p.width Ancho_del_embalaje, @@ -56742,11 +56571,11 @@ BEGIN b.id buyFk, b.entryFk, w.name warehouseFk - FROM vn.itemCost ic - JOIN vn.item i ON i.id = ic.itemFk - 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 + FROM vn.itemCost ic + JOIN vn.item i ON i.id = ic.itemFk + LEFT JOIN cache.last_buy lb ON lb.item_id = ic.itemFk AND lb.warehouse_id = ic.warehouseFk + LEFT JOIN vn.buy b ON b.id = lb.buy_id + LEFT JOIN vn.packaging p ON p.id = b.packageFk LEFT JOIN vn.warehouse w ON w.id = ic.warehouseFk WHERE ic.itemFk = vItemFk AND ic.warehouseFk = vWarehouseFk; @@ -56756,8 +56585,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemFuentesBalance` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56765,38 +56592,40 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` 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 + FROM vn.sector s WHERE s.code = 'FUENTES_PICASSE'; - + CALL cache.stock_refresh(FALSE); - SELECT i.id itemFk, + SELECT i.id itemFk, i.longName, i.size, i.subName, - v.amount - IFNULL(fue.Fuentes,0) - IFNULL(alb.albenfruit,0) as visible, - fue.Fuentes, + v.amount - IFNULL(fue.Fuentes,0) - IFNULL(alb.albenfruit,0) as visible, + fue.Fuentes, alb.Albenfruit, - 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) + 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) - IFNULL(fue.Fuentes,0) - IFNULL(alb.albenfruit,0) as saldo - FROM vn.item i - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk + FROM vn.item i + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk LEFT JOIN ( SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS Fuentes FROM vn.itemShelving ish @@ -56804,7 +56633,7 @@ BEGIN JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.sector s ON s.id = p.sectorFk WHERE s.code = 'FUENTES_PICASSE' - GROUP BY ish.itemFk + GROUP BY ish.itemFk ) fue ON fue.itemFk = i.id LEFT JOIN ( SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS Albenfruit @@ -56813,20 +56642,20 @@ BEGIN JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.sector s ON s.id = p.sectorFk WHERE s.code = 'ALBENFRUIT' - GROUP BY ish.itemFk + GROUP BY ish.itemFk ) alb ON alb.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())) + WHERE dat BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE())) AND warehouse_id = vWarehouseFk GROUP BY item_id ) sale ON sale.item_id = i.id 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())) + WHERE dat BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE())) AND warehouse_id = vWarehouseFk AND isVirtualStock = FALSE GROUP BY item_id @@ -56834,13 +56663,13 @@ BEGIN 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())) + WHERE dat BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE())) AND warehouse_id = vWarehouseFk GROUP BY item_id ) mov ON mov.item_id = i.id - WHERE (v.amount OR fue.Fuentes OR alb.Albenfruit) + WHERE (v.amount OR fue.Fuentes OR alb.Albenfruit) AND i.itemPackingTypeFk = 'H' - AND ic.shortLife + AND ic.shortLife ; END ;; @@ -56849,8 +56678,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemPlacementFromTicket` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56858,11 +56685,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementFromTicket`(vTicket INT) BEGIN /** - * Llama a itemPlacementUpdateVisible + * Llama a itemPlacementUpdateVisible * de los articulos de la tabla temporal tmp.itemPlacement(itemFk) * @treturn tmp.itemPlacement * @param vTicket Id del Ticket @@ -56876,9 +56705,9 @@ BEGIN FROM ticket t JOIN sale s ON s.ticketFk = t.id WHERE t.id = vTicket; - + CALL itemPlacementUpdateVisible(); - + DROP TEMPORARY TABLE tmp.itemPlacement; END ;; DELIMITER ; @@ -56886,8 +56715,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemPlacementSupplyAiming` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56895,6 +56722,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSupplyAiming`(vShelvingFk VARCHAR(10), quantity INT, vItemFk INT) BEGIN @@ -56911,7 +56740,7 @@ BEGIN CAST(FLOOR(LEAST(ish.stock,quantity) / ish.packing) AS DECIMAL(10,0)), ' x ', ish.packing, - IF ( + IF ( LEAST(ish.stock,quantity) MOD ish.packing, CONCAT(' + ',CAST(LEAST(ish.stock,quantity) MOD ish.packing AS DECIMAL(10,0))), '' @@ -56929,8 +56758,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemPlacementSupplyCloseOrder` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56938,11 +56765,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSupplyCloseOrder`(vId INT, vQuantity INT) BEGIN - UPDATE vn.itemPlacementSupply + UPDATE vn.itemPlacementSupply SET priority = 10 WHERE id = vId; @@ -56952,8 +56781,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemPlacementSupplyGetOrder` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56961,6 +56788,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSupplyGetOrder`(vSector INT ) BEGIN @@ -56968,7 +56797,7 @@ BEGIN DECLARE vId INT; DECLARE vLastParkingFk INT; DECLARE vNextParkingFk INT; - + SELECT sh.parkingFk INTO vLastParkingFk FROM vn.itemShelvingPlacementSupply isps JOIN vn.itemShelving ish ON ish.id = isps.itemShelvingFk @@ -56976,9 +56805,9 @@ BEGIN WHERE isps.userFk = getUser() ORDER BY isps.created DESC LIMIT 1; - + SET vNextParkingFk = vn.itemShelvingPlacementSupply_ClosestGet(vLastParkingFk); - + SELECT ipsl.id INTO vId FROM vn.itemPlacementSupplyList ipsl JOIN vn.itemShelvingPlacementSupplyStock ispss ON ispss.itemFk = ipsl.itemFk @@ -56987,13 +56816,13 @@ BEGIN AND ipsl.sectorFk = vSector ORDER BY ipsl.repoUserFk DESC, ipsl.priority DESC, (ispss.parkingFk = vNextParkingFk) DESC, ispss.parking DESC, ipsl.created LIMIT 1; - + UPDATE vn.itemPlacementSupply SET repoUserFk = getUser() WHERE id = vId; - - SELECT * FROM vn.itemPlacementSupplyList - WHERE id = vId + + SELECT * FROM vn.itemPlacementSupplyList + WHERE id = vId AND sectorFk = vSector; END ;; @@ -57002,8 +56831,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemPlacementSupplyStockGetTargetList` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57011,30 +56838,32 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSupplyStockGetTargetList`(vItemFk INT,vSectorFk INT) BEGIN /* Devuelve la lista de ubicaciones para itemFk en ese sector. Se utiliza en la preparación previa. * Este proc se llama a continuacion de ticketToPrePrepare - * + * * @param vItemFk Identificador de vn.item * @param vSectorFk Identificador de vn.sector */ - + DECLARE vWarehouseAliasFk INT; - + SELECT w.aliasFk INTO vWarehouseAliasFk FROM vn.sector s JOIN vn.warehouse w ON w.id = s.warehouseFk WHERE s.id = vSectorFk; - - SELECT ish.shelvingFk shelving, - p.code parking, + + SELECT ish.shelvingFk shelving, + p.code parking, sum(ish.visible) as stockTotal, ish.created, p.pickingOrder - FROM vn.itemShelving ish + FROM vn.itemShelving ish 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 @@ -57044,16 +56873,14 @@ BEGIN AND ish.itemFk = vItemFk GROUP BY ish.id ORDER BY sh.priority DESC; - - + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemProposal` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57061,6 +56888,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemProposal`(vItemFk INT, vTicketFk INT,vShowType BOOL) BEGIN @@ -57071,20 +56900,20 @@ BEGIN * @param vItemFk item id * @param vTicketFk ticket id * @param vShowType mostrar tipos - */ + */ DECLARE vWarehouseFk INT; DECLARE vShipped DATE; 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); @@ -57094,16 +56923,16 @@ BEGIN SELECT warehouseFk, shipped INTO vWarehouseFk, vShipped FROM vn.ticket WHERE id = vTicketFk; - + 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, vShipped); - + SELECT i.id itemFk, i.longName, i.subName, @@ -57136,7 +56965,7 @@ BEGIN 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.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, @@ -57144,7 +56973,7 @@ BEGIN (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 ; @@ -57152,8 +56981,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemProposal_Add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57161,6 +56988,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemProposal_Add`(vSaleFk INT, vMateFk INT, vQuantity INT) BEGIN @@ -57170,7 +56999,7 @@ BEGIN * @param vSaleFk id de la tabla sale * @param vMateFk articulo sustituto * @ param vQuantity cantidad que se va a sustituir - */ + */ DECLARE vTicketFk INT; DECLARE vItemFk INT; DECLARE vWarehouseFk SMALLINT; @@ -57179,41 +57008,41 @@ BEGIN DECLARE vBox INT; DECLARE vPacking INT; DECLARE vRoundQuantity INT DEFAULT 1; - + SELECT s.ticketFk, LEAST(s.quantity, vQuantity), s.itemFk,t.shipped,t.warehouseFk INTO vTicketFk, vQuantity, vItemFk,vDate,vWarehouseFk FROM vn.sale s JOIN vn.ticket t ON t.id = s.ticketFk WHERE s.id = vSaleFk; - + UPDATE vn.sale SET quantity = quantity - vQuantity WHERE id = vSaleFk; - + CALL vn.buyUltimate(vWarehouseFk, vDate); - + SELECT `grouping`, groupingMode, packing INTO vGrouping,vBox,vPacking FROM buy b JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk WHERE tmp.itemFk = vMateFk AND tmp.WarehouseFk = vWarehouseFk; - + IF vBox = 2 AND vPacking > 0 THEN SET vRoundQuantity = vPacking; END IF; IF vBox = 1 AND vGrouping > 0 THEN SET vRoundQuantity = vGrouping; END IF; - + INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept) SELECT vTicketFk, vMateFk, CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ',i.longName) FROM vn.item i WHERE id = vMateFk; - + SELECT LAST_INSERT_ID() INTO vSaleFk; - + CALL vn.sale_calculateComponent(vSaleFk, NULL); - + INSERT INTO vn.itemProposal(itemFk, mateFk, counter) VALUES(vItemFk, vMateFk, 1) ON DUPLICATE KEY UPDATE counter = counter + 1; @@ -57224,8 +57053,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemProposal_beta` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57233,6 +57060,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemProposal_beta`(vItemFk INT, vTicketFk INT) BEGIN @@ -57242,13 +57071,13 @@ BEGIN DECLARE vCalcFk INT; DECLARE vTypeFk INT; DECLARE vResultsMax INT DEFAULT 10; - + 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); @@ -57258,16 +57087,16 @@ BEGIN SELECT warehouseFk, shipped INTO vWarehouseFk, vShipped FROM vn.ticket WHERE id = vTicketFk; - + 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 + 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, vShipped); - + SELECT i.id itemFk, i.longName, i.subName, @@ -57285,7 +57114,7 @@ BEGIN (i.value8 <=> vValue8 COLLATE utf8_general_ci) match8, a.available, IFNULL(ip.counter,0) counter - FROM vn.item i + 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 @@ -57299,7 +57128,7 @@ BEGIN (it1.value = vValue1 COLLATE utf8_general_ci) DESC, (i.tag5 = vTag5 COLLATE utf8_general_ci) DESC, (i.value5 = vValue5 COLLATE utf8_general_ci) DESC, - (i.tag6 = vTag6 COLLATE utf8_general_ci) DESC, + (i.tag6 = vTag6 COLLATE utf8_general_ci) DESC, (i.value6 = vValue6 COLLATE utf8_general_ci) DESC, (i.tag7 = vTag7 COLLATE utf8_general_ci) DESC, (i.value7 = vValue7 COLLATE utf8_general_ci) DESC, @@ -57313,8 +57142,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemRefreshTags` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57322,6 +57149,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemRefreshTags`(IN vItem INT) BEGIN @@ -57335,7 +57164,7 @@ BEGIN CREATE TEMPORARY TABLE tmp.item SELECT vItem id; - + CALL item_refreshTags(); DROP TEMPORARY TABLE tmp.item; @@ -57346,8 +57175,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemSale_byWeek` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57355,27 +57182,29 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemSale_byWeek`(vWeek INT, IN vYear INT, vItemFk INT, vWarehouseFk INT) BEGIN - + DECLARE vStarted DATE; DECLARE vEnded DATETIME; SELECT MIN(dated), util.dayEnd(MAX(dated)) INTO vStarted, vEnded - FROM `time` t + FROM `time` t WHERE CONCAT(vYear, LPAD(vWeek, 2, 0)) = t.period; SELECT t.shipped, w.name warehouse, - s.ticketFk, + s.ticketFk, c.quality, t.nickname client, - am.name agencyName, + am.name agencyName, wk.code salesPerson, s.itemFk, - IFNULL(CONCAT(ig.longName,' ',ig.`size`,' ',ig.subName), s.concept) AS concept, - s.quantity, + IFNULL(CONCAT(ig.longName,' ',ig.`size`,' ',ig.subName), s.concept) AS concept, + s.quantity, s.price, s.priceFixed, s.discount, @@ -57385,15 +57214,15 @@ BEGIN wk.id salesPersonFk FROM sale s JOIN ticket t ON t.id = s.ticketFk - JOIN warehouse w ON w.id = t.warehouseFk + JOIN warehouse w ON w.id = t.warehouseFk JOIN address a ON a.id = t.addressFk LEFT JOIN agencyMode am ON am.id = t.agencyModeFk JOIN `client` c ON c.id = a.clientFk - LEFT JOIN worker wk ON wk.id = c.salesPersonFk + LEFT JOIN worker wk ON wk.id = c.salesPersonFk LEFT JOIN ticketLastState tls ON tls.ticketFk = t.id - LEFT JOIN saleBuy sb ON sb.saleFk = s.id - LEFT JOIN buy b ON b.id = sb.buyFk - LEFT JOIN item ig ON ig.id = b.itemOriginalFk + LEFT JOIN saleBuy sb ON sb.saleFk = s.id + LEFT JOIN buy b ON b.id = sb.buyFk + LEFT JOIN item ig ON ig.id = b.itemOriginalFk WHERE s.itemFk = vItemFk AND t.shipped BETWEEN vStarted AND vEnded AND IF(vWarehouseFk = 0, w.hasComission , t.warehouseFk = vWarehouseFk) @@ -57405,8 +57234,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemSaveMin` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57414,15 +57241,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemSaveMin`(min INT,vBarcode VARCHAR(22)) BEGIN DECLARE vItemFk INT; SELECT vn.barcodeToItem(vBarcode) INTO vItemFk; - + UPDATE vn.item SET minimum = min WHERE id = vItemFk; - + END ;; @@ -57431,8 +57260,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemSearchShelving` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57440,12 +57267,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemSearchShelving`(`vShelvingFk` VARCHAR(3)) BEGIN SELECT p.`column` AS col , p.`row` - FROM vn.shelving s - JOIN parking p ON s.parkingFk = p.id + FROM vn.shelving s + JOIN parking p ON s.parkingFk = p.id WHERE s.`code` = vShelvingFk COLLATE utf8_general_ci; END ;; DELIMITER ; @@ -57453,8 +57282,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelvingDelete` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57462,6 +57289,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingDelete`(vId INT) BEGIN @@ -57474,8 +57303,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelvingLog_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57483,47 +57310,47 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingLog_get`(vShelvingFk VARCHAR(10) ) BEGIN - + /** * Devuelve el log de los item en cada carro * - * @param vShelvingFk Matrícula del carro - * + * @param vShelvingFk Matrícula del carro + * */ - - SELECT isl.itemShelvingFk, - isl.created, - isl.accion, - isl.itemFk, - isl.shelvingFk, - isl.quantity, + + SELECT isl.itemShelvingFk, + isl.created, + isl.accion, + isl.itemFk, + isl.shelvingFk, + isl.quantity, isl.visible, - isl.available, - isl.grouping, - isl.packing, - isl.stars, - item.longName, - item.size, - item.subName, - worker.code, + isl.available, + isl.grouping, + isl.packing, + isl.stars, + item.longName, + item.size, + item.subName, + worker.code, isl.accion - FROM item - JOIN itemShelvingLog isl ON item.id = isl.itemFk + FROM item + JOIN itemShelvingLog isl ON item.id = isl.itemFk JOIN worker ON isl.workerFk = worker.id WHERE shelvingFk = vShelvingFk OR isl.itemFk = vShelvingFk ORDER BY isl.created DESC; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelvingMakeFromDate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57531,10 +57358,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingMakeFromDate`(IN `vShelvingFk` VARCHAR(8), IN `vBarcode` VARCHAR(22), IN `vShelve` VARCHAR(2), IN `vQuantity` INT, IN `vPackagingFk` VARCHAR(10), IN `vGrouping` INT, IN `vPacking` INT, IN `vWarehouseFk` INT, `vCreated` VARCHAR(22)) BEGIN - + DECLARE vItemFk INT; SELECT vn.barcodeToItem(vBarcode) INTO vItemFk; @@ -57553,9 +57382,9 @@ BEGIN END IF; - IF (SELECT COUNT(*) FROM vn.itemShelving - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk - AND itemFk = vItemFk + IF (SELECT COUNT(*) FROM vn.itemShelving + WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk + AND itemFk = vItemFk AND packing = vPacking) = 1 THEN UPDATE vn.itemShelving @@ -57587,16 +57416,14 @@ BEGIN LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk LEFT JOIN vn.buy b ON b.id = lb.buy_id WHERE i.id = vItemFk; - 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelvingMatch` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57604,14 +57431,16 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingMatch`(vEntryFk INT, vAllTravel BOOLEAN, vFromTimed DATETIME, vToTimed DATETIME) BEGIN DECLARE vTravelFk INT; - - SELECT travelFk INTO vTravelFk - FROM entry + + SELECT travelFk INTO vTravelFk + FROM entry WHERE id = vEntryFk; SELECT i.id, i.longName, i.size, i.subName, b.stickers, ish.etiquetas, b.printed @@ -57624,7 +57453,7 @@ BEGIN GROUP BY itemFk ) b ON b.itemFk = i.id LEFT JOIN ( - SELECT itemFk, sum(cast(visible / packing AS DECIMAL(10,0))) AS etiquetas + SELECT itemFk, sum(cast(visible / packing AS DECIMAL(10,0))) AS etiquetas FROM itemShelving ish JOIN shelving sh ON sh.code = ish.shelvingFk LEFT JOIN parking pk ON pk.id = sh.parkingFk @@ -57639,8 +57468,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelvingPlacementSupplyAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57648,6 +57475,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingPlacementSupplyAdd`(vItemShelvingFk INT, vItemPlacementSupplyFk INT, vQuantity INT) BEGIN @@ -57664,7 +57493,7 @@ BEGIN UPDATE vn.itemShelving SET visible = visible - vQuantity WHERE id = vItemShelvingFk; - + END ;; DELIMITER ; @@ -57672,8 +57501,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelvingProblem` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57681,61 +57508,61 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingProblem`(vSectorFk INT) BEGIN DECLARE vVisibleCache INT; DECLARE vWarehouseFk INT; - + SELECT warehouseFk INTO vWarehouseFk FROM vn.sector WHERE id = vSectorFk; CALL cache.visible_refresh (vVisibleCache, FALSE, vWarehouseFk); - - SELECT t.id as ticketFk, - CAST(s.quantity AS DECIMAL(10,0)) as Cantidad, - s.itemFk, - s.concept, - v.visible - GREATEST(0,iss.visible) + IFNULL(sub3.transit,0) as Nicho, + + SELECT t.id as ticketFk, + CAST(s.quantity AS DECIMAL(10,0)) as Cantidad, + s.itemFk, + s.concept, + v.visible - GREATEST(0,iss.visible) + IFNULL(sub3.transit,0) as Nicho, i.subName, - GREATEST(0,iss.visible - IFNULL(sub3.transit,0)) as Altillo, + GREATEST(0,iss.visible - IFNULL(sub3.transit,0)) as Altillo, s.id as saleFk, IFNULL(sub3.transit,0) transit, v.visible, s.isPicked, s.reserved, t.shipped, tst.productionOrder, mm.Id_Movimiento - FROM vn.ticket t + FROM vn.ticket t JOIN vn.ticketState tst ON tst.ticketFk = t.id JOIN vn.sale s ON s.ticketFk = t.id JOIN vn.item i ON i.id = s.itemFk JOIN cache.visible v ON s.itemFk = v.item_id AND v.calc_id = vVisibleCache LEFT JOIN vn2008.Movimientos_mark mm ON mm.Id_Movimiento = s.id AND mm.stateFk = 26 - JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id + JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id LEFT JOIN - (SELECT itemFk, sum(saldo) as transit - FROM vn.itemPlacementSupplyList - WHERE saldo > 0 + (SELECT itemFk, sum(saldo) as transit + FROM vn.itemPlacementSupplyList + WHERE saldo > 0 AND sectorFk = vSectorFk GROUP BY itemFk) sub3 ON sub3.itemFk = i.id - WHERE v.visible + IFNULL(sub3.transit,0) - GREATEST(0,iss.visible) < s.quantity + WHERE v.visible + IFNULL(sub3.transit,0) - GREATEST(0,iss.visible) < s.quantity AND IFNULL(sub3.transit,0) < s.quantity - AND s.isPicked = FALSE + AND s.isPicked = FALSE AND s.reserved = FALSE - AND t.shipped BETWEEN CURDATE() AND MIDNIGHT(CURDATE()) + AND t.shipped BETWEEN util.VN_CURDATE() AND MIDNIGHT(util.VN_CURDATE()) AND tst.isPreviousPreparable = TRUE AND t.warehouseFk = vWarehouseFk AND iss.sectorFk = vSectorFk AND mm.Id_Movimiento IS NULL ORDER BY itemFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelvingRadar` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57743,10 +57570,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar`(vSectorFk INT) proc:BEGIN - + DECLARE vCalcVisibleFk INT; DECLARE vCalcAvailableFk INT; DECLARE hasFatherSector BOOLEAN; @@ -57754,25 +57583,25 @@ proc:BEGIN DECLARE vWarehouseFk INT DEFAULT 0; DECLARE vSonSectorFk INT; DECLARE vWorkerFk INT; - - SELECT s.workerFk - INTO vWorkerFk + + SELECT s.workerFk + INTO vWorkerFk FROM vn.sector s WHERE s.id = vSectorFk; - + IF IFNULL(vWorkerFk,0) THEN - + CALL vn.itemShelvingRadar_Urgent(vWorkerFk); LEAVE proc; - + end if; - - + + SELECT w.id, s.warehouseFk INTO vBuyerFk, vWarehouseFk - FROM vn.worker w + FROM vn.worker w JOIN vn.sector s ON s.code = w.code WHERE s.id = vSectorFk; - + SELECT s.id INTO vSectorFk FROM vn.sector s WHERE s.warehouseFk = vWarehouseFk @@ -57782,21 +57611,21 @@ proc:BEGIN SELECT COUNT(*) INTO hasFatherSector FROM vn.sector WHERE sonFk = vSectorFk; - + SELECT warehouseFk, sonFk INTO vWarehouseFk, vSonSectorFk FROM vn.sector WHERE id = vSectorFk; - + CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk); - CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, CURDATE()); - + CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE()); + DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadar; - + IF hasFatherSector THEN - + CREATE TEMPORARY TABLE tmp.itemShelvingRadar (PRIMARY KEY (itemFk)) - ENGINE = MEMORY + ENGINE = MEMORY SELECT * FROM ( SELECT iss.itemFk, i.longName, @@ -57807,7 +57636,7 @@ proc:BEGIN SUM(IF(iss.sectorFk = vSectorFk, IFNULL(iss.visible,0), 0)) downstairs, IF(it.isPackaging, null, IFNULL(v.visible,0)) as visible, vSectorFk as sectorFk - + FROM vn.itemShelvingStock iss JOIN vn.sector s ON s.id = iss.sectorFk JOIN vn.item i on i.id = iss.itemFk @@ -57816,11 +57645,11 @@ proc:BEGIN LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk WHERE vSectorFk IN (iss.sectorFk, s.sonFk) AND it.workerFk != 3366 - + GROUP BY iss.itemFk - + UNION ALL - + SELECT v.item_id, i.longName, i.size, @@ -57830,7 +57659,7 @@ proc:BEGIN 0 downstairs, IF(it.isPackaging, NULL, v.visible) visible, vSectorFk as sectorFk - FROM cache.visible v + FROM cache.visible v JOIN vn.item i on i.id = v.item_id JOIN vn.itemType it ON it.id = i.typeFk AND vBuyerFk IN (0,it.workerFk) LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id AND iss.warehouseFk = vWarehouseFk @@ -57839,8 +57668,8 @@ proc:BEGIN AND iss.itemFk IS NULL AND it.isInventory ) sub GROUP BY itemFk; - - SELECT ishr.*, + + SELECT ishr.*, CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) AS nicho, CAST(downstairs - IFNULL(notPickedYed,0) AS DECIMAL(10,0)) as pendiente FROM tmp.itemShelvingRadar ishr @@ -57855,13 +57684,13 @@ proc:BEGIN ) sub ON sub.itemFk = ishr.itemFk ORDER BY i.typeFk, i.longName ; - - + + ELSE - + CREATE TEMPORARY TABLE tmp.itemShelvingRadar (PRIMARY KEY (itemFk)) - ENGINE = MEMORY + ENGINE = MEMORY SELECT iss.itemFk, 0 `hour`, 0 `minute`, @@ -57873,7 +57702,7 @@ proc:BEGIN IFNULL(a.available,0) available, IFNULL(v.visible - iss.visible,0) dayEndVisible, IFNULL(v.visible - iss.visible,0) firstNegative, - IFNULL(v.visible - iss.visible,0) itemPlacementVisible, + IFNULL(v.visible - iss.visible,0) itemPlacementVisible, IFNULL(i.minimum * b.packing,0) itemPlacementSize, ips.onTheWay, iss.visible itemShelvingStock, @@ -57887,13 +57716,13 @@ proc:BEGIN LEFT JOIN cache.available a ON a.item_id = iss.itemFk AND a.calc_id = vCalcAvailableFk LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk LEFT JOIN (SELECT itemFk, sum(saldo) as onTheWay - FROM vn.itemPlacementSupplyList - WHERE saldo > 0 + FROM vn.itemPlacementSupplyList + WHERE saldo > 0 GROUP BY itemFk ) ips ON ips.itemFk = i.id - WHERE IFNULL(iss.sectorFk,0) IN (0, vSectorFk) - OR iss.sectorFk = vSectorFk; - /* + WHERE IFNULL(iss.sectorFk,0) IN (0, vSectorFk) + OR iss.sectorFk = vSectorFk; + /* UPDATE tmp.itemShelvingRadar isr JOIN vn.itemShelvingStock iss ON iss.itemFk = isr.itemFk SET isr.dayEndVisible = isr.dayEndVisible + iss.visible, @@ -57904,10 +57733,10 @@ proc:BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.itemOutTime; CREATE TEMPORARY TABLE tmp.itemOutTime SELECT *,SUM(amount) quantity - FROM + FROM (SELECT item_id itemFk, - amount, - IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) as hours, + amount, + IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) as hours, IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) as minutes FROM vn2008.item_out io JOIN tmp.itemShelvingRadar isr ON isr.itemFk = io.item_id @@ -57915,23 +57744,23 @@ proc:BEGIN JOIN vn.ticketState ts on ts.ticketFk = io.ticketFk JOIN vn.state s ON s.id = ts.stateFk LEFT JOIN vn.zone z ON z.id = t.zoneFk - LEFT JOIN (SELECT DISTINCT saleFk - FROM vn.saleTracking st - WHERE st.created > CURDATE() + LEFT JOIN (SELECT DISTINCT saleFk + FROM vn.saleTracking st + WHERE st.created > util.VN_CURDATE() AND st.isChecked ) stPrevious ON `stPrevious`.`saleFk` = io.saleFk WHERE t.warehouseFk = vWarehouseFk - AND s.isPicked = 0 - AND NOT io.Reservado + AND s.isPicked = 0 + AND NOT io.Reservado AND stPrevious.saleFk IS NULL - AND io.dat >= CURDATE() - AND io.dat < CURDATE()+1 + AND io.dat >= util.VN_CURDATE() + AND io.dat < util.VN_CURDATE()+1 ) sub GROUP BY itemFk, hours, minutes; - + INSERT INTO tmp.itemShelvingRadar (itemFk) SELECT itemFk FROM tmp.itemOutTime - ON DUPLICATE KEY UPDATE dayEndVisible = dayEndVisible + quantity, + ON DUPLICATE KEY UPDATE dayEndVisible = dayEndVisible + quantity, firstNegative = if (firstNegative < 0, firstNegative, firstNegative + quantity), `hour` = ifnull(if (firstNegative > 0 , `hour`, hours),0), `minute` = ifnull(if (firstNegative > 0, `minute`, minutes),0); @@ -57941,21 +57770,19 @@ proc:BEGIN dayEndVisible = 0, firstNegative = 0 WHERE itemPlacementVisible = - itemShelvingStock; - */ + */ SELECT * FROM tmp.itemShelvingRadar; END IF; DROP TEMPORARY TABLE tmp.itemShelvingRadar; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelvingRadar_Entry` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57963,6 +57790,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar_Entry`(vEntryFk INT) BEGIN @@ -57970,25 +57799,25 @@ BEGIN DECLARE vWarehouseFk INT DEFAULT 1; DECLARE vCalcVisibleFk INT; DECLARE vCalcAvailableFk INT; - DECLARE vTodayDayEnd DATETIME DEFAULT util.dayEnd(CURDATE()); - + DECLARE vTodayDayEnd DATETIME DEFAULT util.dayEnd(util.VN_CURDATE()); + CALL cache.visible_refresh(vCalcVisibleFk, FALSE, 1); - CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, CURDATE()); - + CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE()); + DROP TEMPORARY TABLE IF EXISTS tmp.item; CREATE TEMPORARY TABLE tmp.item ENGINE = MEMORY SELECT DISTINCT itemFk - FROM vn.buy + FROM vn.buy WHERE entryFk = vEntryFk; - + DROP TEMPORARY TABLE IF EXISTS tmp.item2; CREATE TEMPORARY TABLE tmp.item2 ENGINE = MEMORY SELECT * FROM tmp.item; - - SELECT i.id as itemFk, + + SELECT i.id as itemFk, i.minimum, CAST(IFNULL(v.visible,0) - IFNULL(iss.visible,0) AS DECIMAL(10,0)) as enNicho, CAST(IFNULL(a.available,0) AS DECIMAL(10,0)) as disponible, @@ -58003,24 +57832,22 @@ BEGIN JOIN tmp.item2 ti ON ti.itemFk = s.itemFk JOIN vn.ticket t ON t.id = s.ticketFk LEFT JOIN vn.ticketState tst ON tst.ticketFk = t.id - WHERE t.shipped BETWEEN CURDATE() AND vTodayDayEnd + WHERE t.shipped BETWEEN util.VN_CURDATE() AND vTodayDayEnd AND t.warehouseFk = vWarehouseFk AND IFNULL(tst.productionOrder,0) < 5 GROUP BY s.itemFK ) ts ON ts.itemFk = i.id; - - + + DROP TEMPORARY TABLE tmp.item; DROP TEMPORARY TABLE tmp.item2; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelvingRadar_Entry_State_beta` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58028,6 +57855,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar_Entry_State_beta`(vEntryFk INT) BEGIN @@ -58035,43 +57864,41 @@ BEGIN DECLARE vWarehouseFk INT DEFAULT 1; DECLARE vCalcVisibleFk INT; DECLARE vCalcAvailableFk INT; - DECLARE vTodayDayEnd DATETIME DEFAULT util.dayEnd(CURDATE()); - + DECLARE vTodayDayEnd DATETIME DEFAULT util.dayEnd(util.VN_CURDATE()); + CALL cache.visible_refresh(vCalcVisibleFk, FALSE, 1); - CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, CURDATE()); - + CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE()); + DROP TEMPORARY TABLE IF EXISTS tmp.item; CREATE TEMPORARY TABLE tmp.item ENGINE = MEMORY SELECT DISTINCT itemFk - FROM vn.buy + FROM vn.buy WHERE entryFk = vEntryFk; - + DROP TEMPORARY TABLE IF EXISTS tmp.item2; CREATE TEMPORARY TABLE tmp.item2 ENGINE = MEMORY SELECT * FROM tmp.item; - - SELECT i.id as itemFk, + + SELECT i.id as itemFk, CAST(IFNULL(iss.visible,0) - IFNULL(v.visible,0) AS DECIMAL(10,0)) as outShelving FROM vn.item i JOIN tmp.item ti ON ti.itemFk = i.id LEFT JOIN cache.visible v ON v.calc_id = vCalcVisibleFk AND v.item_id = i.id LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = i.id; - - + + DROP TEMPORARY TABLE tmp.item; DROP TEMPORARY TABLE tmp.item2; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelvingRadar_Urgent` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58079,6 +57906,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar_Urgent`() BEGIN @@ -58090,7 +57919,7 @@ BEGIN CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk); - SELECT * FROM + SELECT * FROM (SELECT sub.itemFk, sub.longName, CONCAT(DATE_FORMAT(sub2.etd,'%H:%i'), ' salen ', CAST(sub2.pendiente AS DECIMAL(10,0)), ' unidades.') `size`, @@ -58108,14 +57937,14 @@ BEGIN 0 upstairs, SUM(IFNULL(iss.visible,0)) downstairs, IF(it.isPackaging, null, IFNULL(v.visible,0)) visible, - IFNULL(iss.sectorFk,0) sectorFk + IFNULL(iss.sectorFk,0) sectorFk FROM itemShelvingStock iss JOIN sector s ON s.id = iss.sectorFk JOIN item i on i.id = iss.itemFk JOIN itemType it ON it.id = i.typeFk LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = @vCalcVisibleFk WHERE s.warehouseFk = vWarehouseFk - GROUP BY itemFk + GROUP BY itemFk ) sub LEFT JOIN (SELECT s.itemFk, SUM(s.quantity) pendiente, MIN(zc.`hour`) etd FROM sale s LEFT JOIN saleTracking st ON st.saleFk = s.id @@ -58123,12 +57952,12 @@ BEGIN LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk JOIN client c on c.id = t.clientFk JOIN clientType ct ON ct.id = c.clientTypeFk - WHERE t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) AND ISNULL(st.saleFk) AND ct.code IN ('normal', 'trust') GROUP BY s.itemFk - ) sub2 ON sub2.itemFk = sub.itemFk - UNION ALL + ) sub2 ON sub2.itemFk = sub.itemFk + UNION ALL SELECT v.item_id , i.longName, CONCAT(DATE_FORMAT(sub5.etd,'%H:%i'), ' salen ', CAST(sub5.pendiente AS DECIMAL(10,0)), ' unidades.') `size`, @@ -58142,7 +57971,7 @@ BEGIN FROM cache.visible v JOIN item i ON i.id = v.item_id JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemShelvingStock iss ON iss.itemFk = v.item_id + LEFT JOIN itemShelvingStock iss ON iss.itemFk = v.item_id LEFT JOIN (SELECT s.itemFk , SUM(s.quantity) pendiente, MIN(zc.`hour`) etd FROM sale s LEFT JOIN saleTracking st ON st.saleFk = s.id @@ -58150,13 +57979,13 @@ BEGIN LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk JOIN client c on c.id = t.clientFk JOIN clientType ct ON ct.id = c.clientTypeFk - WHERE t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) AND ISNULL(st.saleFk) AND ct.code IN ('normal', 'trust') GROUP BY s.itemFk ) sub5 ON sub5.itemFk = v.item_id WHERE v.calc_id = @vCalcVisibleFk - AND ISNULL(iss.itemFk) + AND ISNULL(iss.itemFk) ) sub3 WHERE nicho ORDER BY LEFT(producer,3), etd, producer; @@ -58166,8 +57995,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_Add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58175,15 +58002,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSale_Add`(vItemShelvingFk INT, vSaleFk INT, vQuantity INT) BEGIN /** * Añade línea a itemShelvingSale y regulariza el carro - * + * * @param vItemShelvingFk Id itemShelving * @param vSaleFk Id de sale - * @param vQuantity cantidad a regularizar + * @param vQuantity cantidad a regularizar */ INSERT INTO itemShelvingSale(itemShelvingFk, saleFk, @@ -58208,8 +58037,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelvingTransfer` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58217,14 +58044,16 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingTransfer`(vItemShelvingFk INT,shelvingFkD VARCHAR(22)) BEGIN - + UPDATE vn.itemShelving SET shelvingFk = shelvingFkD WHERE id = vItemShelvingFk; - + SELECT true; END ;; @@ -58233,8 +58062,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58242,10 +58069,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vShelve VARCHAR(2), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) BEGIN - + /** * Añade registro o lo actualiza si ya existe. @@ -58258,7 +58087,7 @@ BEGIN * @param vGrouping el grouping del producto en itemShelving, NULL para coger el de la ultima compra * @param vPacking el packing del producto, NULL para coger el de la ultima compra * @param vWarehouseFk indica el sector - * + * **/ DECLARE vItemFk INT; @@ -58268,21 +58097,21 @@ BEGIN IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN INSERT IGNORE INTO parking(code) VALUES(vShelvingFk); - INSERT INTO shelving(code, parkingFk) + INSERT INTO shelving(code, parkingFk) SELECT vShelvingFk, id - FROM parking + FROM parking WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; END IF; - IF (SELECT COUNT(*) FROM itemShelving - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk - AND itemFk = vItemFk + IF (SELECT COUNT(*) FROM itemShelving + WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk + AND itemFk = vItemFk AND packing = vPacking) = 1 THEN UPDATE itemShelving SET visible = visible+vQuantity - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; + WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; ELSE CALL cache.last_buy_refresh(FALSE); @@ -58312,8 +58141,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_addByClaim` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58321,6 +58148,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_addByClaim`(vClaimFk INT, vShelvingFk VARCHAR(3)) BEGIN @@ -58338,7 +58167,7 @@ BEGIN JOIN ticket t ON t.id = c.ticketFk WHERE c.id = vClaimFk; - CALL buyUltimate (vWarehouseFk, CURDATE()); + CALL buyUltimate (vWarehouseFk, util.VN_CURDATE()); INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible) SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible @@ -58355,8 +58184,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_BuyerGet` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58364,20 +58191,20 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_BuyerGet`( ) BEGIN SELECT * FROM vn.buyer; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_BuyerTask` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58385,6 +58212,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_BuyerTask`(vWorkerFk INT ) BEGIN @@ -58408,15 +58237,13 @@ BEGIN AND it.workerFk = vWorkerFk AND ish.stars IS NULL ORDER BY p.pickingOrder; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_filterBuyer` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58424,6 +58251,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_filterBuyer`(vBuyerFk INT, vWarehouseFk INT) proc:BEGIN @@ -58435,15 +58264,15 @@ proc:BEGIN * @return Lista de articulos */ DECLARE vCalcVisibleFk INT; - + IF vBuyerFk = 103 THEN -- hay que arreglarlo despues de la campaña PAK 23/04/2022 - CALL vn.itemShelvingRadar_Urgent(); + CALL vn.itemShelvingRadar_Urgent(); LEAVE proc; END IF; CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk); - SELECT * FROM + SELECT * FROM (SELECT sub.itemFk, sub.longName, CONCAT('Hoy saldrán ', CAST(sub2.pendiente AS DECIMAL(10,0)), ' unidades.') `size`, @@ -58460,7 +58289,7 @@ proc:BEGIN 0 upstairs, SUM(IFNULL(iss.visible,0)) downstairs, IF(it.isPackaging, null, IFNULL(v.visible,0)) visible, - IFNULL(iss.sectorFk,0) sectorFk + IFNULL(iss.sectorFk,0) sectorFk FROM itemShelvingStock iss JOIN sector s ON s.id = iss.sectorFk JOIN item i on i.id = iss.itemFk @@ -58468,19 +58297,19 @@ proc:BEGIN LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk WHERE s.warehouseFk = vWarehouseFk AND it.workerFk = vBuyerFk - GROUP BY itemFk + GROUP BY itemFk ) sub LEFT JOIN (SELECT s.itemFk, SUM(s.quantity) pendiente FROM sale s LEFT JOIN saleTracking st ON st.saleFk = s.id - JOIN ticket t ON t.id = s.ticketFk + JOIN ticket t ON t.id = s.ticketFk JOIN client c on c.id = t.clientFk JOIN clientType ct ON ct.id = c.clientTypeFk - WHERE t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) AND ISNULL(st.saleFk) AND ct.code IN ('normal', 'trust') GROUP BY s.itemFk - ) sub2 ON sub2.itemFk = sub.itemFk - UNION ALL + ) sub2 ON sub2.itemFk = sub.itemFk + UNION ALL SELECT v.item_id , i.longName, CONCAT('Hoy saldrán ', CAST(sub5.pendiente AS DECIMAL(10,0)), ' unidades.') `size`, @@ -58493,20 +58322,20 @@ proc:BEGIN FROM cache.visible v JOIN item i ON i.id = v.item_id JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemShelvingStock iss ON iss.itemFk = v.item_id + LEFT JOIN itemShelvingStock iss ON iss.itemFk = v.item_id LEFT JOIN (SELECT s.itemFk , SUM(s.quantity) pendiente FROM sale s LEFT JOIN saleTracking st ON st.saleFk = s.id - JOIN ticket t ON t.id = s.ticketFk + JOIN ticket t ON t.id = s.ticketFk JOIN client c on c.id = t.clientFk JOIN clientType ct ON ct.id = c.clientTypeFk - WHERE t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) AND ISNULL(st.saleFk) AND ct.code IN ('normal', 'trust') GROUP BY s.itemFk ) sub5 ON sub5.itemFk = v.item_id WHERE v.calc_id = vCalcVisibleFk - AND ISNULL(iss.itemFk) + AND ISNULL(iss.itemFk) AND it.workerFk = vBuyerFk ) sub3 WHERE nicho @@ -58517,8 +58346,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58526,18 +58353,20 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_get`(IN vShelvingFk VARCHAR(8)) BEGIN /** - * Lista artículos de itemshelving + * Lista artículos de itemshelving * * @param vShelvingFk matrícula del carro - * + * **/ - SELECT ish.itemFk as item, - IFNULL(i.longName, CONCAT(i.name, ' ', i.size)) as description, + SELECT ish.itemFk as item, + IFNULL(i.longName, CONCAT(i.name, ' ', i.size)) as description, ish.visible as visible, ceil(ish.visible/ish.packing) as stickers, ish.packing as packing, @@ -58559,8 +58388,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_getAlternatives` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58568,6 +58395,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_getAlternatives`(vShelvingFk VARCHAR(10)) BEGIN @@ -58577,7 +58406,7 @@ BEGIN * * @param vShelvingFk matricula del carro */ - SELECT is2.id,is2.shelvingFk , p.code, is2.itemFk , is2.visible, p.pickingOrder + SELECT is2.id,is2.shelvingFk , p.code, is2.itemFk , is2.visible, p.pickingOrder FROM itemShelving is2 JOIN shelving sh ON sh.code = is2.shelvingFk JOIN parking p ON p.id = sh.parkingFk @@ -58594,8 +58423,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_getInfo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58603,6 +58430,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_getInfo`(vItemFk VARCHAR(22)) BEGIN @@ -58631,8 +58460,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_getSaleDate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58640,38 +58467,40 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_getSaleDate`(vShelvingFk VARCHAR(3)) BEGIN - + /* Devuelve la minima fecha en que se necesita cada producto en esa matricula. - * + * * @param vShelvingFk Matrícula del carro o pallet */ - + DECLARE vWarehouseFk INT; SELECT warehouseFk INTO vWarehouseFk FROM shelving s - JOIN parking p ON s.parkingFk = p.id + JOIN parking p ON s.parkingFk = p.id JOIN sector st ON st.id = p.sectorFk WHERE s.code = vShelvingFk COLLATE utf8_unicode_ci; - + DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingDistinct; CREATE TEMPORARY TABLE tmp.itemShelvingDistinct (PRIMARY KEY (itemFk)) ENGINE = MEMORY SELECT itemFk, SUM(visible) visible - FROM vn.itemShelving + FROM vn.itemShelving WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci - GROUP BY itemFk; - + GROUP BY itemFk; + DROP TEMPORARY TABLE IF EXISTS tmp.item; CREATE TEMPORARY TABLE tmp.item (PRIMARY KEY (itemFk)) ENGINE = MEMORY SELECT * FROM tmp.itemShelvingDistinct; - + DROP TEMPORARY TABLE IF EXISTS tmp.stockByDay; CREATE TEMPORARY TABLE tmp.stockByDay (index (itemFk, dated)) @@ -58682,42 +58511,42 @@ BEGIN FROM ( SELECT * FROM ( SELECT t2.* FROM ( - SELECT item_id itemFk, amount, CURDATE() dated - FROM cache.stock + SELECT item_id itemFk, amount, util.VN_CURDATE() dated + FROM cache.stock WHERE warehouse_id = vWarehouseFk UNION ALL - SELECT ish.itemFk, - sum(visible), CURDATE() - FROM vn.itemShelving ish - JOIN shelving sh ON sh.code = ish.shelvingFk - JOIN parking p ON sh.parkingFk = p.id + SELECT ish.itemFk, - sum(visible), util.VN_CURDATE() + FROM vn.itemShelving ish + JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN parking p ON sh.parkingFk = p.id JOIN sector s ON s.id = p.sectorFk - WHERE s.isReserve + WHERE s.isReserve GROUP BY ish.itemFk UNION ALL SELECT item_id, sum(iei.amount), dat FROM vn2008.item_entry_in iei - WHERE dat >= CURDATE() + WHERE dat >= util.VN_CURDATE() AND warehouse_id = vWarehouseFk AND isVirtualStock = FALSE GROUP BY item_id, dat - UNION ALL + UNION ALL SELECT item_id, sum(ieo.amount), dat - FROM vn2008.item_entry_out ieo - WHERE dat >= CURDATE() + FROM vn2008.item_entry_out ieo + WHERE dat >= util.VN_CURDATE() AND warehouse_id = vWarehouseFk GROUP BY item_id, dat UNION ALL SELECT i.itemFk, sum(io.amount), dat FROM vn2008.item_out io JOIN tmp.item i ON i.itemFk = io.item_id - WHERE io.dat >= CURDATE() + WHERE io.dat >= util.VN_CURDATE() AND io.warehouse_id = vWarehouseFk GROUP BY io.item_id, io.dat - ) t2 + ) t2 JOIN tmp.itemShelvingDistinct ish ON ish.itemFk = t2.itemFk) t order by t.itemFk, DATE(t.dated), t.amount DESC) t3; - - SELECT sbd.itemFk, i.longName, DATE(dated) dated, ish.visible amount, sbd.stock + + SELECT sbd.itemFk, i.longName, DATE(dated) dated, ish.visible amount, sbd.stock FROM tmp.stockByDay sbd JOIN vn.item i ON i.id = sbd.itemFk JOIN tmp.itemShelvingDistinct ish ON ish.itemFk = sbd.itemFk @@ -58734,8 +58563,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_inventory` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58743,17 +58570,19 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` 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; @@ -58761,38 +58590,36 @@ BEGIN 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, + SELECT p.code parking , + ish.shelvingFk , + ish.itemFk, i.longName, - ish.visible , + ish.visible , ish.visible / ish.packing packs, - ish.packing, + 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 + 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 */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_StarsUpdate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58800,6 +58627,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_StarsUpdate`(vId INT, vStars INT) BEGIN @@ -58807,15 +58636,13 @@ BEGIN UPDATE vn.itemShelving SET stars = vStars WHERE id = vId; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_update` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58823,6 +58650,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_update`(vVisible INT, vPacking INT, vShelf INT ,vGrouping INT ) BEGIN @@ -58835,9 +58664,9 @@ BEGIN * @param vGrouping el grouping del producto en itemShelving */ UPDATE itemShelving - SET visible = vVisible, - packing = vPacking, - grouping = vGrouping + SET visible = vVisible, + packing = vPacking, + grouping = vGrouping WHERE id = vShelf; END ;; @@ -58846,8 +58675,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemStock` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58855,6 +58682,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemStock`(vWarehouseFk SMALLINT, vDated DATETIME, vItemFk INT) BEGIN @@ -58864,36 +58693,36 @@ BEGIN * @param vDated max date to filter * @param vItemFk item id **/ - + DECLARE vIsLogifloraDay BOOLEAN; SET vDated = TIMESTAMP(DATE(vDated), '00:00:00'); SELECT vn.isLogifloraDay(vDated, vWarehouseFk) INTO vIsLogifloraDay ; - + DROP TEMPORARY TABLE IF EXISTS tmp.itemList; CREATE TEMPORARY TABLE tmp.itemList (UNIQUE INDEX i USING HASH (itemFk)) ENGINE = MEMORY SELECT itemFk, SUM(quantity) stock, SUM(quantity) visible, SUM(quantity) available FROM ( - SELECT itemFk, quantity + SELECT itemFk, quantity FROM itemTicketOut - WHERE shipped >= CURDATE() AND shipped < vDated + WHERE shipped >= util.VN_CURDATE() AND shipped < vDated AND warehouseFk = vWarehouseFk AND (vItemFk IS NULL OR itemFk = vItemFk) UNION ALL - SELECT itemFk, quantity + SELECT itemFk, quantity FROM itemEntryIn i - LEFT JOIN edi.warehouseFloramondo wf ON wf.entryFk = i.entryFk - WHERE i.landed >= CURDATE() AND i.landed < vDated + LEFT JOIN edi.warehouseFloramondo wf ON wf.entryFk = i.entryFk + WHERE i.landed >= util.VN_CURDATE() AND i.landed < vDated AND i.warehouseInFk = vWarehouseFk AND (vItemFk IS NULL OR i.itemFk = vItemFk) AND (ISNULL(wf.entryFk) OR vIsLogifloraDay) UNION ALL - SELECT itemFk, quantity + SELECT itemFk, quantity FROM itemEntryOut - WHERE shipped >= CURDATE() AND shipped < vDated + WHERE shipped >= util.VN_CURDATE() AND shipped < vDated AND warehouseOutFk = vWarehouseFk AND (vItemFk IS NULL OR itemFk = vItemFk) ) t @@ -58902,7 +58731,7 @@ BEGIN CALL `cache`.stock_refresh (FALSE); INSERT INTO tmp.itemList (itemFk,stock,visible,available) - SELECT item_id,amount,amount,amount + SELECT item_id,amount,amount,amount FROM `cache`.stock WHERE warehouse_id = vWarehouseFk AND (vItemFk IS NULL OR vItemFk = item_id) ON DUPLICATE KEY UPDATE @@ -58915,8 +58744,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemTagMake` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58924,11 +58751,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTagMake`(vItemFk INT) BEGIN -/* * Crea los tags usando la tabla plantilla itemTag +/* * Crea los tags usando la tabla plantilla itemTag * y si no existe a partir de la ficha del artículo. * @param vItemFk El item al que se le añaden los tags */ @@ -58938,33 +58767,33 @@ BEGIN DECLARE vProducer VARCHAR(50); DECLARE vOrigin VARCHAR(20); DECLARE vTypeFk INTEGER; - - DELETE FROM itemTag + + DELETE FROM itemTag WHERE itemFk = vItemFk; - - SELECT typeFk INTO vTypeFk + + SELECT typeFk INTO vTypeFk FROM item WHERE id = vItemFk; - + INSERT INTO itemTag(itemFk, tagFk, value, priority) SELECT vItemFk, itt.tagFk, NULL, itt.priority FROM itemTag it LEFT JOIN itemTypeTag itt ON itt.itemTypeFk = vTypeFk WHERE it.itemFk = vItemFk; - + IF (SELECT COUNT(*) FROM itemTag WHERE itemFk = vItemFk LIMIT 1) = 0 THEN - SELECT ik.name, i.size, i.category, p.name, o.name + SELECT ik.name, i.size, i.category, p.name, o.name INTO vInk, vSize, vCategory, vProducer, vOrigin FROM item i LEFT JOIN ink ik ON ik.id = i.inkFk LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible LEFT JOIN origin o ON o.id = i.originFk WHERE i.id = vItemFk; - + INSERT IGNORE INTO itemTag(itemFk, tagFk, value, priority) VALUES(vItemFk, 1, vInk, 1); - + INSERT IGNORE INTO itemTag(itemFk, tagFk, value, priority) VALUES (vItemFk, 8, vSize, 2); @@ -58973,37 +58802,37 @@ BEGIN INSERT IGNORE INTO itemTag(itemFk, tagFk, value, priority) VALUES(vItemFk, 37, vProducer, 4); - + INSERT IGNORE INTO itemTag(itemFk, tagFk, value, priority) VALUES(vItemFk, 35, vOrigin, 5); END IF; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemTagReorder` */; /*!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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTagReorder`(itemTypeFk INT) BEGIN SET @isTriggerDisabled = TRUE; - + -- No se puede usar temporary porque da error Error Code: 1137. No puedo reabrir tabla: 'i DROP TABLE IF EXISTS tmp.item; CREATE TABLE tmp.item SELECT DISTINCT i.id - FROM vn.item i + FROM vn.item i WHERE i.typeFk = itemTypeFk; UPDATE itemTag it @@ -59012,8 +58841,8 @@ BEGIN JOIN itemTypeTag itt ON itt.itemTypeFk = item.typeFk AND itt.tagFk = it.tagFk SET it.priority = itt.priority WHERE itt.itemTypeFk = itemTypeFk; - - CALL item_refreshTags(); + + CALL item_refreshTags(); SET @isTriggerDisabled = FALSE; @@ -59024,8 +58853,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemTagReorderByName` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -59033,17 +58860,19 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTagReorderByName`(vName VARCHAR(255)) BEGIN SET @isTriggerDisabled = TRUE; - + -- No se puede usar temporary porque da error Error Code: 1137. No puedo reabrir tabla: 'i DROP TABLE IF EXISTS tmp.item; CREATE TABLE tmp.item SELECT DISTINCT i.id - FROM vn.item i + FROM vn.item i WHERE i.`name` LIKE CONCAT(vName,'%'); UPDATE itemTag it @@ -59052,8 +58881,8 @@ BEGIN JOIN itemTypeTag itt ON itt.itemTypeFk = item.typeFk AND itt.tagFk = it.tagFk SET it.priority = itt.priority WHERE itt.itemTypeFk = itemTypeFk; - - CALL item_refreshTags(); + + CALL item_refreshTags(); SET @isTriggerDisabled = FALSE; @@ -59064,8 +58893,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemTag_replace` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -59073,47 +58900,47 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTag_replace`(vItemFromFk INT, vItemToFk INT, vPicture VARCHAR(100)) BEGIN - + /* Reemplaza los tags de un artículo por los de otro, así como su imagen - * + * * @param vItemFromFk id de vn.item con el artículo del que se toman los tags * @param vItemToFk id de vn.item con el artículo del que se toman los tags * @param vPicture imagen del artículo. Opcional. Si no se especifica, hereada la del vItemFromFk */ - DELETE FROM vn.itemTag + DELETE FROM vn.itemTag WHERE itemFk = vItemToFk; - + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) SELECT vItemToFk, tagFk, value, priority - FROM vn.itemTag + FROM vn.itemTag WHERE itemFk = vItemFromFk; - + IF ISNULL(vPicture) THEN - - SELECT image INTO vPicture - FROM vn.item + + SELECT image INTO vPicture + FROM vn.item WHERE id = vItemFromFk; - + END IF; - UPDATE vn.item i + UPDATE vn.item i SET i.image = vPicture WHERE i.id = vItemToFk; - + CALL vn.itemRefreshTags(vItemToFk); - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemTopSeller` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -59121,6 +58948,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTopSeller`() BEGIN @@ -59130,9 +58959,9 @@ BEGIN SELECT DISTINCT id FROM vn.itemCategory WHERE merchandise <> FALSE; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN + DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN RESIGNAL; END; @@ -59141,55 +58970,53 @@ BEGIN SELECT s.itemFk, SUM(s.quantity) AS total, v.tipo_id typeFk FROM vn.sale s INNER JOIN bs.ventas v ON v.Id_Movimiento = s.id - WHERE v.fecha BETWEEN TIMESTAMPADD(DAY, - 7, CURDATE()) AND CURDATE() + WHERE v.fecha BETWEEN TIMESTAMPADD(DAY, - 7, util.VN_CURDATE()) AND util.VN_CURDATE() GROUP BY s.itemFk; - + DROP TABLE IF EXISTS tmp.topSeller; - CREATE TEMPORARY TABLE tmp.topSeller - ( + CREATE TEMPORARY TABLE tmp.topSeller + ( `id` int(11) NOT NULL DEFAULT '0', `typeFk` smallint(5) unsigned NOT NULL, `itemCategoryFk` int(10) unsigned NOT NULL, `total` bigint(21) NOT NULL DEFAULT '0' ) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - + OPEN rs; read_loop: LOOP FETCH rs INTO vCategoryFk; - + IF vDone THEN LEAVE read_loop; END IF; - + INSERT INTO tmp.topSeller SELECT tsm.itemFk, tsm.typeFk, it.categoryFk, tsm.total FROM tmp.topSellerMin tsm INNER JOIN vn.itemType it ON it.id = tsm.typeFk WHERE it.categoryFk = vCategoryFk ORDER BY tsm.itemFk ,tsm.total DESC - LIMIT 5; + LIMIT 5; END LOOP; CLOSE rs; - + SELECT i.name ,i.id, i.image, i.typeFk, it.categoryFk AS itemCategoryFk, ic.name AS itemCategoryName, it.name AS itemTypeName, ts.total FROM tmp.topSeller ts INNER JOIN vn.item i ON i.id = ts.id INNER JOIN vn.itemType it ON it.id = ts.typeFk INNER JOIN vn.itemCategory ic ON ic.id = it.categoryFk; - + DROP TABLE IF EXISTS topSellerMin; DROP TABLE IF EXISTS tmp.topSeller; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemTrash` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -59197,11 +59024,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTrash`( - vItemFk INT, - vWarehouseFk INT, - vQuantity INT, + vItemFk INT, + vWarehouseFk INT, + vQuantity INT, vIsTrash BOOLEAN) BEGIN @@ -59209,59 +59038,57 @@ BEGIN DECLARE vClientFk INT; DECLARE vCompanyVnlFk INT DEFAULT 442; DECLARE vCalc INT; - - SELECT barcodeToItem(vItemFk) INTO vItemFk; - + + SELECT barcodeToItem(vItemFk) INTO vItemFk; + SELECT IF(vIsTrash, 200, 400) INTO vClientFk; - + SELECT t.id INTO vTicketFk FROM ticket t - JOIN address a ON a.id=t.addressFk + JOIN address a ON a.id=t.addressFk WHERE t.warehouseFk = vWarehouseFk AND t.clientFk = vClientFk - AND DATE(t.shipped) = CURDATE() + AND DATE(t.shipped) = util.VN_CURDATE() AND a.isDefaultAddress - LIMIT 1; - + LIMIT 1; + CALL cache.visible_refresh(vCalc, TRUE, vWarehouseFk); - - IF vTicketFk IS NULL THEN - + + IF vTicketFk IS NULL THEN + CALL ticket_add( - vClientFk, - CURDATE(), - vWarehouseFk, - vCompanyVnlFk, - NULL, - NULL, - NULL, - CURDATE(), + vClientFk, + util.VN_CURDATE(), + vWarehouseFk, + vCompanyVnlFk, + NULL, + NULL, + NULL, + util.VN_CURDATE(), account.myUser_getId(), FALSE, vTicketFk); END IF; - + INSERT INTO sale(ticketFk, itemFk, concept, quantity) - SELECT vTicketFk, + SELECT vTicketFk, vItemFk, - CONCAT(longName,' ',getWorkerCode(), ' ', LEFT(CAST(NOW() AS TIME),5)), + CONCAT(longName,' ',getWorkerCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)), vQuantity - FROM item + FROM item WHERE id = vItemFk; - - UPDATE cache.visible + + UPDATE cache.visible SET visible = visible - vQuantity - WHERE calc_id = vCalc + WHERE calc_id = vCalc AND item_id = vItemFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemUpdateTag` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -59269,6 +59096,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemUpdateTag`(IN vItem BIGINT) BEGIN @@ -59294,7 +59123,7 @@ SET tag6 = t.name, value6 = it.value WHERE it.priority = 2 AND (vItem IS NULL OR vItem = it.itemFk); -UPDATE item i +UPDATE item i JOIN itemTag it ON it.itemFk = i.id JOIN tag t ON t.id = it.tagFk SET tag7 = t.name, value7 = it.value @@ -59314,8 +59143,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -59323,273 +59150,218 @@ DELIMITER ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_clean`(OUT vHasError BOOL) -BEGIN -/** - * Elimina todos los items repetidos y los sustituye - * por el que tiene menor id - * - * @return Si da error devuelve a true vHasError - */ - DECLARE CONTINUE HANDLER FOR SQLSTATE '40001' - BEGIN - SET vHasError = TRUE; - END; - - SET @isModeInventory:= TRUE; - - -- Deletes - START TRANSACTION; - - UPDATE IGNORE vn.itemCost ic - JOIN tmp.itemsToReplace itr ON ic.itemFk = itr.idOld - SET ic.itemFk = itr.idNew; - - DELETE ic.* - FROM vn.itemCost ic - JOIN tmp.itemsToReplace itr ON ic.itemFk = itr.idOld; - - DELETE rt.* - FROM vn2008.rec_translator rt - JOIN tmp.itemsToReplace itr ON rt.Id_Article = itr.idOld; - - DELETE w.* - FROM bs.waste w - JOIN tmp.itemsToReplace itr ON w.itemFk = itr.idOld; - - DELETE pf.* - FROM vn.priceFixed pf - JOIN tmp.itemsToReplace itr ON pf.itemFk = itr.idOld; - - DELETE imp.* - FROM vn.itemMatchProperties imp - JOIN tmp.itemsToReplace itr ON imp.itemFk = itr.idOld; - - DELETE ib.* - FROM vn.itemBotanical ib - JOIN tmp.itemsToReplace itr ON ib.itemFk = itr.idOld; - - DELETE ip.* - FROM vn.itemProposal ip - JOIN tmp.itemsToReplace itr ON ip.itemFk = itr.idOld; - - DELETE it.* - FROM vn.itemTag it - JOIN tmp.itemsToReplace itr ON it.itemFk = itr.idOld; - - DELETE ib.* - FROM vn.itemBarcode ib - JOIN tmp.itemsToReplace itr ON ib.itemFk = itr.idOld; - - DELETE itc.* - FROM vn.itemTaxCountry itc - JOIN tmp.itemsToReplace itr ON itc.itemFk = itr.idOld; - - COMMIT; - - -- Updates - START TRANSACTION; - - UPDATE vn.buy b - JOIN tmp.itemsToReplace itr ON b.itemFk = itr.idOld - SET b.itemFk = itr.idNew; - - UPDATE vn.sale s - JOIN tmp.itemsToReplace itr ON s.itemFk = itr.idOld - SET s.itemFk = itr.idNew; - - UPDATE vn.specialPrice sp - JOIN tmp.itemsToReplace itr ON sp.itemFk = itr.idOld - SET sp.itemFk = itr.idNew; - - UPDATE vn.packaging p - JOIN tmp.itemsToReplace itr ON p.itemFk = itr.idOld - SET p.itemFk = itr.idNew; - - UPDATE vn.packaging p - JOIN tmp.itemsToReplace itr ON p.freightItemFk = itr.idOld - SET p.freightItemFk = itr.idNew; - - UPDATE hedera.orderRow o - JOIN tmp.itemsToReplace itr ON o.itemFk = itr.idOld - SET o.itemFk = itr.idNew; - - UPDATE vn.itemLog il - JOIN tmp.itemsToReplace itr ON il.originFk = itr.idOld - SET il.originFk = itr.idNew; - - UPDATE vn.itemShelving ish - JOIN tmp.itemsToReplace itr ON ish.itemFk = itr.idOld - SET ish.itemFk = itr.idNew; - - UPDATE vn.ticketPackagingStartingStock tpss - JOIN tmp.itemsToReplace itr ON tpss.itemFk = itr.idOld - SET tpss.itemFk = itr.idNew; - - UPDATE vn.inventoryFailure ifa - JOIN tmp.itemsToReplace itr ON ifa.itemFk = itr.idOld - SET ifa.itemFk = itr.idNew; - - UPDATE vn.genericAllocation ga - JOIN tmp.itemsToReplace itr ON ga.itemFk = itr.idOld - SET ga.itemFk = itr.idNew; - - UPDATE vn.itemPlacementSupply ips - JOIN tmp.itemsToReplace itr ON ips.itemFk = itr.idOld - SET ips.itemFk = itr.idNew; - - COMMIT; - - -- Eliminamos los items repetidos - START TRANSACTION; - - DELETE i.* - FROM vn.item i - JOIN tmp.itemsToReplace itr ON i.id = itr.idOld; - - COMMIT; - - SET @isModeInventory:= FALSE; - SET vHasError = FALSE; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `item_cleanLauncher` */; -/*!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 */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_cleanLauncher`() +CREATE DEFINER=`root`@`localhost` PROCEDURE `item_clean`() BEGIN /** - * Inicia el procedimiento vn.item_clean + * Elimina todos los items repetidos y los + * sustituye por el que tiene menor id */ - DECLARE vItemTo INT DEFAULT 0; - DECLARE vStep INT DEFAULT 0; - DECLARE vCounter INT DEFAULT 0; DECLARE vItemFrom INT; DECLARE vItemEnd INT; + DECLARE vItemOld INT; + DECLARE vItemNew INT; + DECLARE vCurrentItem INT; DECLARE vQuantity INT; - DECLARE vHasError BOOL; + DECLARE vCounter INT DEFAULT 0; + DECLARE vIsStop BOOL DEFAULT FALSE; + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE curItemClean CURSOR FOR + SELECT i.id idOld, + i2.id idNew + FROM vn.item i + JOIN (SELECT i.id, + i.name, + i.subname, + i.value5, + i.value6, + i.value7, + i.value8, + i.value9, + i.value10, + i.NumberOfItemsPerCask, + i.EmbalageCode, + i.quality + FROM vn.item i + LEFT JOIN (SELECT i.id, + sr.NumberOfUnits, + MAX(di.LatestOrderDateTime) lodt + FROM vn.item i + JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk + JOIN edi.deliveryInformation di ON di.supplyResponseID = i.supplyResponseFk + GROUP BY i.id) sub ON sub.id = i.id + WHERE isFloramondo + AND (ISNULL(i.supplyResponseFk) + OR sub.NumberOfUnits = 0 + OR sub.lodt < util.VN_NOW()) + GROUP BY i.name, + subname, + value5, + value6, + value7, + value8, + value9, + value10, + NumberOfItemsPerCask, + EmbalageCode, + quality + ORDER BY i.id) i2 ON i2.name <=> i.name + AND i2.subname <=> i.subname + AND i2.value5 <=> i.value5 + AND i2.value6 <=> i.value6 + AND i2.value7 <=> i.value7 + AND i2.value8 <=> i.value8 + AND i2.value9 <=> i.value9 + AND i2.value10 <=> i.value10 + AND i2.NumberOfItemsPerCask <=> i.NumberOfItemsPerCask + AND i2.EmbalageCode <=> i.EmbalageCode + AND i2.quality <=> i.quality + WHERE isFloramondo + AND i.id <> i2.id + ORDER BY i.id; + + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET vDone = TRUE; SELECT itemFrom INTO vItemFrom - FROM vn.itemCleanCount + FROM vn.itemCleanLog ORDER BY created DESC LIMIT 1; - - IF ISNULL(vItemFrom) THEN + + IF vItemFrom IS NULL THEN SELECT MIN(id) INTO vItemFrom FROM vn.item i WHERE isFloramondo; END IF; - - SELECT quantity, step - INTO vQuantity, vStep + + SELECT quantity + INTO vQuantity FROM vn.itemCleanConfig; SET vItemEnd = vItemFrom + vQuantity; - DROP TEMPORARY TABLE IF EXISTS tmp.itemsToReplaceSource; - CREATE TEMPORARY TABLE tmp.itemsToReplaceSource - SELECT i.id idOld, - i2.id idNew - FROM vn.item i - JOIN (SELECT i.id, - i.name, - i.subname, - i.value5, - i.value6, - i.value7, - i.value8, - i.value9, - i.value10, - i.NumberOfItemsPerCask, - i.EmbalageCode, - i.quality - FROM vn.item i - LEFT JOIN (SELECT i.id, - sr.NumberOfUnits, - MAX(di.LatestOrderDateTime) lodt - FROM vn.item i - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - JOIN edi.deliveryInformation di ON di.supplyResponseID = i.supplyResponseFk - GROUP BY i.id) sub ON sub.id = i.id - WHERE isFloramondo - AND (ISNULL(i.supplyResponseFk) - OR sub.NumberOfUnits = 0 - OR sub.lodt < NOW()) - GROUP BY i.name, - subname, - value5, - value6, - value7, - value8, - value9, - value10, - NumberOfItemsPerCask, - EmbalageCode, - quality - ORDER BY i.id) i2 ON i2.name <=> i.name - AND i2.subname <=> i.subname - AND i2.value5 <=> i.value5 - AND i2.value6 <=> i.value6 - AND i2.value7 <=> i.value7 - AND i2.value8 <=> i.value8 - AND i2.value9 <=> i.value9 - AND i2.value10 <=> i.value10 - AND i2.NumberOfItemsPerCask <=> i.NumberOfItemsPerCask - AND i2.EmbalageCode <=> i.EmbalageCode - AND i2.quality <=> i.quality - WHERE isFloramondo - AND i.id <> i2.id - ORDER BY i2.id; - - WHILE vItemTo < vItemEnd AND NOT (SELECT isStop FROM vn.itemCleanConfig) DO - - SET vItemTo = LEAST(vItemEnd, vItemFrom + vStep); - - SELECT COUNT(*) INTO vCounter - FROM tmp.itemsToReplaceSource - WHERE idNew BETWEEN vItemFrom AND vItemTo; - - DROP TEMPORARY TABLE IF EXISTS tmp.itemsToReplace; - CREATE TEMPORARY TABLE tmp.itemsToReplace - SELECT * - FROM tmp.itemsToReplaceSource - WHERE idNew BETWEEN vItemFrom AND vItemTo; - - CALL vn.item_clean(vHasError); - - IF NOT vHasError THEN - SET vItemFrom = vItemTo; + SET @isModeInventory:= TRUE; + + OPEN curItemClean; + curItemClean: LOOP + + FETCH curItemClean INTO vItemOld, vItemNew; + + START TRANSACTION; + + # Deletes + UPDATE IGNORE vn.itemCost + SET itemFk = vItemNew + WHERE itemFk = vItemOld; + + DELETE FROM vn.itemCost + WHERE itemFk = vItemOld; + + DELETE FROM vn2008.rec_translator + WHERE Id_Article = vItemOld; + + DELETE FROM bs.waste + WHERE itemFk = vItemOld; + + DELETE FROM vn.priceFixed + WHERE itemFk = vItemOld; + + DELETE FROM vn.itemMatchProperties + WHERE itemFk = vItemOld; + + DELETE FROM vn.itemBotanical + WHERE itemFk = vItemOld; + + DELETE FROM vn.itemProposal + WHERE itemFk = vItemOld; + + DELETE FROM vn.itemTag + WHERE itemFk = vItemOld; + + DELETE FROM vn.itemBarcode + WHERE itemFk = vItemOld; + + DELETE FROM vn.itemTaxCountry + WHERE itemFk = vItemOld; + + # Updates + UPDATE vn.buy + SET itemFk = vItemNew + WHERE itemFk = vItemOld; + + UPDATE vn.sale + SET itemFk = vItemNew + WHERE itemFk = vItemOld; + + UPDATE vn.specialPrice + SET itemFk = vItemNew + WHERE itemFk = vItemOld; + + UPDATE vn.packaging + SET itemFk = vItemNew + WHERE itemFk = vItemOld; + + UPDATE vn.packaging + SET freightItemFk = vItemNew + WHERE freightItemFk = vItemOld; + + UPDATE hedera.orderRow + SET itemFk = vItemNew + WHERE itemFk = vItemOld; + + UPDATE vn.itemLog + SET originFk = vItemNew + WHERE originFk = vItemOld; + + UPDATE vn.itemShelving + SET itemFk = vItemNew + WHERE itemFk = vItemOld; + + UPDATE vn.ticketPackagingStartingStock + SET itemFk = vItemNew + WHERE itemFk = vItemOld; + + UPDATE vn.inventoryFailure + SET itemFk = vItemNew + WHERE itemFk = vItemOld; + + UPDATE vn.genericAllocation + SET itemFk = vItemNew + WHERE itemFk = vItemOld; + + UPDATE vn.itemPlacementSupply + SET itemFk = vItemNew + WHERE itemFk = vItemOld; + + # Eliminamos el item sustituido + DELETE FROM vn.item + WHERE id = vItemOld; + + COMMIT; + + SELECT isStop INTO vIsStop + FROM vn.itemCleanConfig; + + IF vIsStop OR vItemOld > vItemEnd OR vDone THEN + LEAVE curItemClean; END IF; - - INSERT INTO vn.itemCleanCount(itemFrom, itemDeleted) - VALUES (vItemFrom, vCounter); - - END WHILE; - DROP TEMPORARY TABLE IF EXISTS tmp.itemsToReplace; - DROP TEMPORARY TABLE IF EXISTS tmp.itemsToReplaceSource; + SET vCounter = vCounter + 1; + END LOOP; + CLOSE curItemClean; + + INSERT INTO itemCleanLog (itemFrom, itemDeleted) + VALUES (vItemOld, vCounter); + + SET @isModeInventory:= FALSE; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_deactivateUnused` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -59597,6 +59369,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_deactivateUnused`() BEGIN @@ -59623,7 +59397,7 @@ BEGIN UPDATE vn.item i JOIN tmp.buyMaxCreated bmc ON bmc.itemFk = i.id SET i.isActive = FALSE - WHERE bmc.created < CURDATE() - INTERVAL vMonthToDeactivate MONTH; + WHERE bmc.created < util.VN_CURDATE() - INTERVAL vMonthToDeactivate MONTH; DROP TEMPORARY TABLE IF EXISTS tmp.buyMaxCreated; END ;; @@ -59632,8 +59406,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_getBalance` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -59641,11 +59413,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getBalance`(IN vItemId int, IN vWarehouse int) BEGIN DECLARE vDateInventory DATETIME; - DECLARE vCurdate DATE DEFAULT CURDATE(); + DECLARE vCurdate DATE DEFAULT util.VN_CURDATE(); DECLARE vDayEnd DATETIME DEFAULT util.dayEnd(vCurdate); SELECT inventoried INTO vDateInventory FROM config; @@ -59663,8 +59437,8 @@ BEGIN `in` AS invalue, `out`, @a := @a + IFNULL(`in`,0) - IFNULL(`out`,0) as balance, - @currentLineFk := IF (@shipped < CURDATE() - OR (@shipped = CURDATE() AND (isPicked OR alertLevel >= 2)), + @currentLineFk := IF (@shipped < util.VN_CURDATE() + OR (@shipped = util.VN_CURDATE() AND (isPicked OR alertLevel >= 2)), lineFk,@currentLineFk) lastPreparedLineFk, isTicket, lineFk, @@ -59691,15 +59465,15 @@ BEGIN JOIN entry e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN supplier s ON s.id = e.supplierFk - JOIN alertLevel al ON al.id = + JOIN alertLevel al ON al.id = CASE - WHEN tr.landed < CURDATE() THEN 3 - WHEN tr.landed = CURDATE() AND tr.isReceived = TRUE THEN 3 + WHEN tr.landed < util.VN_CURDATE() THEN 3 + WHEN tr.landed = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 3 ELSE 0 END JOIN state st ON st.code = al.code WHERE tr.landed >= vDateInventory - AND vWarehouse = tr.warehouseInFk + AND vWarehouse = tr.warehouseInFk AND b.itemFk = vItemId AND e.isExcludedFromAvailable = FALSE AND e.isRaid = FALSE @@ -59725,10 +59499,10 @@ BEGIN JOIN travel tr ON tr.id = e.travelFk JOIN warehouse w ON w.id = tr.warehouseOutFk JOIN supplier s ON s.id = e.supplierFk - JOIN alertLevel al ON al.id = + JOIN alertLevel al ON al.id = CASE - WHEN tr.shipped < CURDATE() THEN 3 - WHEN tr.shipped = CURDATE() AND tr.isReceived = TRUE THEN 3 + WHEN tr.shipped < util.VN_CURDATE() THEN 3 + WHEN tr.shipped = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 3 ELSE 0 END JOIN state st ON st.code = al.code @@ -59762,15 +59536,15 @@ BEGIN LEFT JOIN state st ON st.code = ts.code JOIN client c ON c.id = t.clientFk JOIN clientType ct ON ct.id = c.clientTypeFk - JOIN alertLevel al ON al.id = + JOIN alertLevel al ON al.id = CASE - WHEN t.shipped < curdate() THEN 3 - WHEN t.shipped > util.dayEnd(curdate()) THEN 0 + WHEN t.shipped < util.VN_CURDATE() THEN 3 + WHEN t.shipped > util.dayEnd(util.VN_CURDATE()) THEN 0 ELSE IFNULL(ts.alertLevel, 0) END LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED' LEFT JOIN saleTracking stk ON stk.saleFk = s.id AND stk.stateFk = stPrep.id - LEFT JOIN claimBeginning cb ON s.id = cb.saleFk + LEFT JOIN claimBeginning cb ON s.id = cb.saleFk WHERE t.shipped >= vDateInventory AND s.itemFk = vItemId AND vWarehouse =t.warehouseFk @@ -59783,8 +59557,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_getInfo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -59792,13 +59564,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getInfo`(IN `vBarcode` VARCHAR(22), IN `vWarehouseFk` INT) BEGIN - /** * Devuelve información relativa al item correspondiente del vBarcode pasado - * + * * @param vBarcode código relativo al ítem * @param vWarehouseFk código del almacén */ @@ -59806,17 +59579,17 @@ BEGIN DECLARE vCacheAvailableFk INT; DECLARE vVisibleItemShelving INT; DECLARE vItemFk INT; - + CALL cache.visible_refresh(vCacheVisibleFk, FALSE, vWarehouseFk); - CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, CURDATE()); - CALL buyUltimate(vWarehouseFk, CURDATE()); - + CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE()); + CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); + SELECT barcodeToItem(vBarcode) INTO vItemFk; SELECT SUM(visible) INTO vVisibleItemShelving FROM itemShelvingStock - WHERE itemFk = vItemFk + WHERE itemFk = vItemFk AND warehouseFk = vWarehouseFk; - + SELECT i.id, i.longName, i.tag5, @@ -59844,32 +59617,30 @@ BEGIN i.comment reference, u.name buyer, IFNULL(b.buyingValue, 0) + - IFNULL(b.freightValue, 0) + - IFNULL(b.comissionValue, 0) + + IFNULL(b.freightValue, 0) + + IFNULL(b.comissionValue, 0) + IFNULL(b.packageValue, 0) itemCost FROM item i LEFT JOIN producer p ON p.id = i.producerFk LEFT JOIN origin o ON o.id = i.originFk - LEFT JOIN cache.visible v ON v.calc_id = vCacheVisibleFk + LEFT JOIN cache.visible v ON v.calc_id = vCacheVisibleFk AND v.item_id = i.id - LEFT JOIN cache.available a ON a.calc_id = vCacheAvailableFk + LEFT JOIN cache.available a ON a.calc_id = vCacheAvailableFk AND a.item_id = i.id LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = i.id - LEFT JOIN buy b ON b.id = bu.buyFk + LEFT JOIN buy b ON b.id = bu.buyFk AND bu.warehouseFk = vWarehouseFk JOIN itemType it ON it.id = i.typeFk - JOIN account.user u ON u.id = it.workerFk + JOIN account.user u ON u.id = it.workerFk WHERE i.id = vItemFk; - DROP TEMPORARY TABLE tmp.buyUltimate; + DROP TEMPORARY TABLE tmp.buyUltimate; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_getLack` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -59877,45 +59648,47 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getLack`(IN vForce BOOLEAN, IN vDays INT) BEGIN /** * Calcula una tabla con el máximo negativo visible para cada producto y almacen - * + * * @param vForce Fuerza el recalculo del stock * @param vDays Numero de dias a considerar **/ CALL `cache`.stock_refresh(vForce); - CALL item_getMinacum(NULL, CURDATE(), vDays, NULL); + CALL item_getMinacum(NULL, util.VN_CURDATE(), vDays, NULL); CALL item_getMinETD(); - SELECT i.id itemFk, + SELECT i.id itemFk, i.longName, w.id warehouseFk, - p.`name` producer, + p.`name` producer, i.`size`, i.category, - w.name warehouse, + w.name warehouse, SUM(IFNULL(sub.amount,0)) lack, i.inkFk, - IFNULL(im.timed, util.midnight()) timed - FROM (SELECT item_id, - warehouse_id, + IFNULL(im.timed, util.midnight()) timed + FROM (SELECT item_id, + warehouse_id, amount FROM cache.stock WHERE amount > 0 UNION ALL - SELECT itemFk, - warehouseFk, + SELECT itemFk, + warehouseFk, amount FROM tmp.itemMinacum ) sub JOIN warehouse w ON w.id = sub.warehouse_id JOIN item i ON i.id = sub.item_id - LEFT JOIN producer p ON p.id = i.producerFk - JOIN itemType it ON it.id = i.typeFk + LEFT JOIN producer p ON p.id = i.producerFk + JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN tmp.itemMinETD im ON im.itemFk = i.id WHERE w.isForTicket @@ -59932,8 +59705,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_getMinacum` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -59941,6 +59712,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getMinacum`(IN vWarehouseFk TINYINT, IN vDatedFrom DATETIME, IN vRange INT, IN vItemFk INT) BEGIN @@ -59964,44 +59737,44 @@ BEGIN CREATE TEMPORARY TABLE tmp.itemMinacum (INDEX(itemFk)) ENGINE = MEMORY - SELECT sub1.itemFk, - sub1.warehouseFk, - minacum(sub1.dated, amount, DATE(vDatedFrom)) amount - FROM (SELECT sub.itemFk, - sub.dated, - SUM(sub.amount) amount, - sub.warehouseFk - FROM (SELECT s.itemFk, + SELECT sub1.itemFk, + sub1.warehouseFk, + minacum(sub1.dated, amount, DATE(vDatedFrom)) amount + FROM (SELECT sub.itemFk, + sub.dated, + SUM(sub.amount) amount, + sub.warehouseFk + FROM (SELECT s.itemFk, DATE(t.shipped) dated, - -s.quantity amount, + -s.quantity amount, t.warehouseFk - FROM sale s - JOIN ticket t ON t.id = s.ticketFk + FROM sale s + JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND s.quantity != 0 AND (vItemFk IS NULL OR s.itemFk = vItemFk) AND (vWarehouseFk IS NULL OR t.warehouseFk = vWarehouseFk) UNION ALL - SELECT b.itemFk, - t.landed, - b.quantity, - t.warehouseInFk - FROM buy b - JOIN entry e ON e.id = b.entryFk - LEFT JOIN travel t ON t.id = e.travelFk + SELECT b.itemFk, + t.landed, + b.quantity, + t.warehouseInFk + FROM buy b + JOIN entry e ON e.id = b.entryFk + LEFT JOIN travel t ON t.id = e.travelFk WHERE t.landed BETWEEN vDatedFrom AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND !e.isExcludedFromAvailable + AND !e.isExcludedFromAvailable AND b.quantity != 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) UNION ALL - SELECT b.itemFk, - t.shipped, - -b.quantity, + SELECT b.itemFk, + t.shipped, + -b.quantity, t.warehouseOutFk - FROM buy b - JOIN entry e ON e.id = b.entryFk - LEFT JOIN travel t ON t.id = e.travelFk + FROM buy b + JOIN entry e ON e.id = b.entryFk + LEFT JOIN travel t ON t.id = e.travelFk WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk) AND !e.isExcludedFromAvailable @@ -60013,15 +59786,13 @@ BEGIN ) sub1 GROUP BY sub1.itemFk, sub1.warehouseFk HAVING amount != 0; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_getMinETD` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60029,15 +59800,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getMinETD`() BEGIN - + /* Devuelve una tabla temporal con la primera ETD, para todos los artículos con salida hoy. - * + * * @return tmp.itemMinETD(itemFk, timed) */ - + DECLARE vMidnight DATETIME DEFAULT util.midnight(); DROP TEMPORARY TABLE IF EXISTS tmp.itemMinETD; @@ -60048,8 +59821,8 @@ BEGIN SELECT s.itemFk, MIN(TIME(IFNULL(z.`hour`,vMidnight))) timed FROM ticket t JOIN sale s ON s.ticketFk = t.id - LEFT JOIN `zone` z ON z.id = t.zoneFk - WHERE t.shipped BETWEEN CURDATE() AND vMidnight + LEFT JOIN `zone` z ON z.id = t.zoneFk + WHERE t.shipped BETWEEN util.VN_CURDATE() AND vMidnight GROUP BY s.itemFk; END ;; DELIMITER ; @@ -60057,8 +59830,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_getSimilar` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60066,6 +59837,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getSimilar`(vItemFk INT, vWarehouseFk INT, vDate DATE, vIsShowedByType BOOL) BEGIN @@ -60078,33 +59851,33 @@ BEGIN * @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) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; DECLARE vTag5 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; DECLARE vTag6 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; DECLARE vTag7 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; DECLARE vTag8 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; - + DECLARE vValue1 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; DECLARE vValue5 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; DECLARE vValue6 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; DECLARE vValue7 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; DECLARE vValue8 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; - + 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, @@ -60137,7 +59910,7 @@ BEGIN ORDER BY counter DESC, (t1.name = vTag1) DESC, (it1.value = vValue1) DESC, - (i.tag6 = vTag6) DESC, + (i.tag6 = vTag6) DESC, (i.value6 = vValue6) DESC, (i.tag5 = vTag5) DESC, (i.value5 = vValue5) DESC, @@ -60146,7 +59919,7 @@ BEGIN (i.tag8 = vTag8) DESC, (i.value8 = vValue8) DESC LIMIT 30; - + END ;; DELIMITER ; @@ -60154,8 +59927,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_GetVisible` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60163,41 +59934,43 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_GetVisible`(vWarehouse SMALLINT, vItem INT) BEGIN - DECLARE vTomorrow DATETIME DEFAULT TIMESTAMPADD(DAY, 1, CURDATE()); - + DECLARE vTomorrow DATETIME DEFAULT TIMESTAMPADD(DAY, 1, util.VN_CURDATE()); + INSERT INTO vn2008.tmp_item (item_id, visible) SELECT item_id, SUM(amount) amount FROM ( - SELECT i.itemFk AS item_id, quantity AS amount + SELECT i.itemFk AS item_id, quantity AS amount FROM itemTicketOut i - LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk + LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk JOIN state s ON s.id = ts.stateFk - LEFT JOIN (SELECT DISTINCT saleFk - FROM saleTracking st + LEFT JOIN (SELECT DISTINCT saleFk + FROM saleTracking st JOIN state s ON s.id = st.stateFk - WHERE st.created > CURDATE() + WHERE st.created > util.VN_CURDATE() AND (s.isPicked OR st.isChecked) ) stPrevious ON `stPrevious`.`saleFk` = i.saleFk WHERE i.warehouseFk = vWarehouse AND (vItem IS NULL OR i.itemFk = vItem) AND (s.isPicked OR i.reserved OR stPrevious.saleFk ) - AND i.shipped >= CURDATE() AND i.shipped < vTomorrow + AND i.shipped >= util.VN_CURDATE() AND i.shipped < vTomorrow UNION ALL - SELECT iei.itemFk, quantity + SELECT iei.itemFk, quantity FROM itemEntryIn iei - WHERE (iei.isReceived != FALSE /*OR ip.modificationDate > CURDATE()*/) - AND iei.landed >= CURDATE() AND iei.landed < vTomorrow + WHERE (iei.isReceived != FALSE /*OR ip.modificationDate > util.VN_CURDATE()*/ ) + AND iei.landed >= util.VN_CURDATE() AND iei.landed < vTomorrow AND iei.warehouseInFk = vWarehouse AND (vItem IS NULL OR iei.itemFk = vItem) AND iei.isVirtualStock is FALSE UNION ALL - SELECT itemFk, quantity + SELECT itemFk, quantity FROM itemEntryOut WHERE isDelivered != FALSE - AND shipped >= CURDATE() AND shipped < vTomorrow + AND shipped >= util.VN_CURDATE() AND shipped < vTomorrow AND warehouseOutFk = vWarehouse AND (vItem IS NULL OR itemFk = vItem) ) t @@ -60210,8 +59983,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_refreshTags` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60219,6 +59990,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_refreshTags`() BEGIN @@ -60227,7 +60000,7 @@ BEGIN * * @param temporary table tmp.item(id) del articulo **/ - + DECLARE done INT DEFAULT FALSE; DECLARE vItemFk INT; DECLARE cur1 CURSOR FOR SELECT id FROM tmp.item; @@ -60237,13 +60010,13 @@ BEGIN OPEN cur1; read_loop: LOOP - + FETCH cur1 INTO vItemFk; - + IF done THEN LEAVE read_loop; END IF; - + UPDATE item i LEFT JOIN itemTag it1 ON it1.priority = 1 AND it1.itemFk = i.id LEFT JOIN itemTag it2 ON it2.priority = 2 AND it2.itemFk = i.id @@ -60258,54 +60031,54 @@ BEGIN LEFT JOIN tagAbbreviation ta2 ON ta2.`value` = it2.`value` AND ta2.tagFk IS NULL LEFT JOIN itemTag it3 ON it3.priority = 3 AND it3.itemFk = i.id LEFT JOIN tagAbbreviation ta3 ON ta3.`value` = it3.`value` - SET i.`name` = CONCAT_WS(' ', - IFNULL(ta1.abbreviation,it1.`value`), - IFNULL(ta2.abbreviation,it2.`value`), + SET i.`name` = CONCAT_WS(' ', + IFNULL(ta1.abbreviation,it1.`value`), + IFNULL(ta2.abbreviation,it2.`value`), IF(i.isFloramondo,'',IFNULL(ta3.abbreviation,it3.`value`))) WHERE i.id = vItemFk; - + UPDATE item i LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 4 SET i.subName = it.`value` WHERE i.id = vItemFk; - + UPDATE item i LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 5 LEFT JOIN tag t ON t.id = it.tagFk SET tag5 = t.name, value5 = it.`value` WHERE i.id = vItemFk; - + UPDATE item i LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 6 LEFT JOIN tag t ON t.id = it.tagFk SET tag6 = t.name, value6 = it.`value` WHERE i.id = vItemFk; - + UPDATE item i LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 7 - LEFT JOIN tag t ON t.id = it.tagFk + LEFT JOIN tag t ON t.id = it.tagFk SET i.tag7 = t.name, i.value7 = it.`value` WHERE i.id = vItemFk; - + UPDATE item i LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 8 LEFT JOIN tag t ON t.id = it.tagFk SET tag8 = t.name, value8 = it.`value` WHERE i.id = vItemFk; - + UPDATE item i LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 9 LEFT JOIN tag t ON t.id = it.tagFk SET tag9 = t.name, value9 = it.`value` WHERE i.id = vItemFk; - + UPDATE item i LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 10 LEFT JOIN tag t ON t.id = it.tagFk SET tag10 = t.name, value10 = it.`value` WHERE i.id = vItemFk; - -- Al insertar el tag color se modifica también el antiguo campo color + -- Al insertar el tag color se modifica también el antiguo campo color UPDATE item i JOIN tag t ON t.overwrite = 'inkFk' JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id @@ -60320,7 +60093,7 @@ BEGIN JOIN origin o ON o.`name` = it.`value` SET i.originFk = o.id WHERE i.id = vItemFk; - + -- Al insertar el tag medida se modifica también en la tabla item UPDATE item i JOIN tag t ON t.overwrite = 'size' @@ -60335,36 +60108,34 @@ BEGIN JOIN producer p ON p.`name` = it.`value` SET i.producerFk = p.id WHERE i.id = vItemFk; - + -- Al insertar el tag tallos se modifica también en la tabla item UPDATE item i JOIN tag t ON t.overwrite = 'stems' JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id SET i.stems = it.`value` WHERE i.id = vItemFk; - + -- Al insertar el tag categoria se modifica también en la tabla item UPDATE item i JOIN tag t ON t.overwrite = 'category' JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id SET i.category = it.`value` WHERE i.id = vItemFk; - + -- Comprueba si existe un genérico y lo asigna CALL vn.item_setGeneric(vItemFk); - + END LOOP; CLOSE cur1; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_refreshTags_beta` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60372,6 +60143,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_refreshTags_beta`() BEGIN @@ -60380,7 +60153,7 @@ BEGIN * * @param temporary table tmp.item(id) del articulo **/ - + DECLARE done INT DEFAULT FALSE; DECLARE vItemFk INT; DECLARE cur1 CURSOR FOR SELECT id FROM tmp.item; @@ -60390,13 +60163,13 @@ BEGIN OPEN cur1; read_loop: LOOP - + FETCH cur1 INTO vItemFk; - + IF done THEN LEAVE read_loop; END IF; - + UPDATE item i LEFT JOIN itemTag it1 ON it1.priority = 1 AND it1.itemFk = i.id LEFT JOIN itemTag it2 ON it2.priority = 2 AND it2.itemFk = i.id @@ -60411,54 +60184,54 @@ BEGIN LEFT JOIN tagAbbreviation ta2 ON ta2.`value` = it2.`value` LEFT JOIN itemTag it3 ON it3.priority = 3 AND it3.itemFk = i.id LEFT JOIN tagAbbreviation ta3 ON ta3.`value` = it3.`value` - SET i.`name` = CONCAT_WS(' ', - IFNULL(ta1.abbreviation,it1.`value`), - IFNULL(ta2.abbreviation,it2.`value`), + SET i.`name` = CONCAT_WS(' ', + IFNULL(ta1.abbreviation,it1.`value`), + IFNULL(ta2.abbreviation,it2.`value`), IF(i.id > 400000,'',IFNULL(ta3.abbreviation,it3.`value`))) WHERE i.id = vItemFk; - + UPDATE item i JOIN tmp.itemToRefresh tmpI ON tmpI.id = i.id LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 4 SET i.subName = it.`value`; - + UPDATE item i LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 5 LEFT JOIN tag t ON t.id = it.tagFk SET tag5 = t.name, value5 = it.`value` WHERE i.id = vItemFk; - + UPDATE item i LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 6 LEFT JOIN tag t ON t.id = it.tagFk SET tag6 = t.name, value6 = it.`value` WHERE i.id = vItemFk; - + UPDATE item i LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 7 - LEFT JOIN tag t ON t.id = it.tagFk + LEFT JOIN tag t ON t.id = it.tagFk SET i.tag7 = t.name, i.value7 = it.`value` WHERE i.id = vItemFk; - + UPDATE item i LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 8 LEFT JOIN tag t ON t.id = it.tagFk SET tag8 = t.name, value8 = it.`value` WHERE i.id = vItemFk; - + UPDATE item i LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 9 LEFT JOIN tag t ON t.id = it.tagFk SET tag9 = t.name, value9 = it.`value` WHERE i.id = vItemFk; - + UPDATE item i LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 10 LEFT JOIN tag t ON t.id = it.tagFk SET tag10 = t.name, value10 = it.`value` WHERE i.id = vItemFk; - -- Al insertar el tag color se modifica también el antiguo campo color + -- Al insertar el tag color se modifica también el antiguo campo color UPDATE item i JOIN tag t ON t.overwrite = 'inkFk' JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id @@ -60473,7 +60246,7 @@ BEGIN JOIN origin o ON o.`name` = it.`value` SET i.originFk = o.id WHERE i.id = vItemFk; - + -- Al insertar el tag medida se modifica también en la tabla item UPDATE item i JOIN tag t ON t.overwrite = 'size' @@ -60488,26 +60261,24 @@ BEGIN JOIN producer p ON p.`name` = it.`value` SET i.producerFk = p.id WHERE i.id = vItemFk; - + -- Al insertar el tag tallos se modifica también en la tabla item UPDATE item i JOIN tag t ON t.overwrite = 'stems' JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = t.id SET i.stems = it.`value` WHERE i.id = vItemFk; - + END LOOP; CLOSE cur1; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_saveReference` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60515,6 +60286,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_saveReference`(vBarcode VARCHAR(22), vReference VARCHAR(150)) BEGIN @@ -60525,11 +60298,11 @@ BEGIN * @param vBarcode del item * @param vReference referencia a actualizar */ - + DECLARE vItemFk INT; SELECT barcodeToItem(vBarcode) INTO vItemFk; - + UPDATE item SET comment = vReference WHERE id = vItemFk; END ;; @@ -60538,8 +60311,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_setGeneric` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60547,12 +60318,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_setGeneric`(vSelf INT) BEGIN /** * Asigna el código genérico a un item, salvo que sea un código de item genérico. - * + * * @param vSelf identificador de vn.item */ DECLARE vGenericFk INT; @@ -60561,14 +60334,14 @@ BEGIN FROM ( SELECT itemFk, (sum(matches) = maxMatches) `match` FROM ( - SELECT ga.id gaid, - ga.itemFk, - (it.value <=> ga.origin) - + (it.value <=> ga.color) - + (it.value <=> ga.quality) - + (it.value <=> ga.numFlores) - + (it.value <=> ga.category) - + (it.value <=> ga.productor) matches, + SELECT ga.id gaid, + ga.itemFk, + (it.value <=> ga.origin) + + (it.value <=> ga.color) + + (it.value <=> ga.quality) + + (it.value <=> ga.numFlores) + + (it.value <=> ga.category) + + (it.value <=> ga.productor) matches, !ISNULL(ga.origin) +!ISNULL(ga.color) +!ISNULL(ga.quality) @@ -60576,19 +60349,19 @@ BEGIN +!ISNULL(ga.category) +!ISNULL(ga.productor) maxMatches FROM vn.item i - JOIN vn.itemTag it ON it.itemFk = i.id + JOIN vn.itemTag it ON it.itemFk = i.id JOIN vn.genericAllocation ga ON (i.typeFk = ga.typeFk OR ga.typeFk IS NULL) AND (i.longName = ga.longName OR ga.longName IS NULL) AND (i.`size` = ga.`size` OR ga.`size` IS NULL) AND i.id != ga.itemFk WHERE i.id = vSelf - AND NOT i.isFloramondo) sub + AND NOT i.isFloramondo) sub GROUP BY gaid HAVING `match`) sub2; - UPDATE vn.item - SET genericFk = vGenericFk + UPDATE vn.item + SET genericFk = vGenericFk WHERE id = vSelf; END ;; DELIMITER ; @@ -60596,38 +60369,36 @@ 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_updatePackingShelve` */; /*!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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_updatePackingShelve`(vSelf INT, vPacking INT) BEGIN - + /** * Actualiza el valor de item.packingShelve - * + * * @param vSelf Identificador de vn.item * @param vPacking Cantidad de unidades de venta que caben en una bandeja */ - - UPDATE vn.item i + + UPDATE vn.item i SET i.packingShelve = vPacking WHERE i.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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_updatePackingType` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60635,6 +60406,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_updatePackingType`(vItem INT, vItemPackingTypeFk VARCHAR(1)) BEGIN @@ -60652,8 +60425,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_ValuateInventory` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60661,6 +60432,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_ValuateInventory`(IN vDated DATE, IN vIsDetailed BOOLEAN) BEGIN @@ -60669,9 +60442,9 @@ BEGIN DECLARE vHasNotInventory BOOLEAN DEFAULT FALSE; DECLARE vInventoried2 DATE; DECLARE vDateDayEnd DATETIME; - + SET vDateDayEnd = util.dayEnd(vDated); - + SELECT landed INTO vInventoried FROM travel tr JOIN entry E ON E.travelFk = tr.id @@ -60681,7 +60454,7 @@ BEGIN LIMIT 1; SET vHasNotInventory = IF (vInventoried is null, TRUE, FALSE); - + IF vHasNotInventory THEN SELECT landed INTO vInventoried2 @@ -60702,13 +60475,13 @@ BEGIN CREATE TEMPORARY TABLE inv (warehouseFk SMALLINT, Id_Article BIGINT, - cantidad INT, + cantidad INT, coste DOUBLE DEFAULT 0, total DOUBLE DEFAULT 0, Almacen VARCHAR(20), PRIMARY KEY (Almacen, Id_Article) USING HASH) ENGINE = MEMORY; - + IF vHasNotInventory = TRUE THEN INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) @@ -60736,7 +60509,7 @@ BEGIN JOIN itemType t ON t.id = i.typeFk JOIN warehouse w ON w.id = tr.warehouseInFk WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd - AND IF(tr.landed = CURDATE(), tr.isReceived, trUE) + AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, trUE) AND NOT e.isRaid AND w.valuatedInventory AND t.isInventory @@ -60769,7 +60542,7 @@ BEGIN AND it.isInventory ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + s.quantity * IF(vHasNotInventory,1,-1); - IF vDated = CURDATE() THEN -- volver a poner lo que esta aun en las estanterias + IF vDated = util.VN_CURDATE() THEN -- volver a poner lo que esta aun en las estanterias INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) SELECT w.id, s.itemFk, s.quantity * IF(vHasNotInventory,0,1), w.`name` @@ -60785,7 +60558,7 @@ BEGIN AND it.isInventory ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + s.quantity * IF(vHasNotInventory,0,1); - END IF; + END IF; -- Mercancia en transito INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) @@ -60803,7 +60576,7 @@ BEGIN AND t.isInventory AND e.isConfirmed ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (b.quantity); - + CALL vn.buyUltimate(NULL,vDateDayEnd); UPDATE inv i @@ -60818,20 +60591,20 @@ BEGIN IF vIsDetailed THEN SELECT inv.warehouseFk, - i.id itemFk, - i.longName , - i.size, - inv.Cantidad, + i.id itemFk, + i.longName , + i.size, + inv.Cantidad, tp.name Tipo, - ic.name Reino, - inv.coste, + ic.name Reino, + inv.coste, cast(inv.total as decimal(10,2)) total, almacen FROM inv JOIN warehouse w on w.id = warehouseFk JOIN item i ON i.id = inv.Id_Article JOIN itemType tp ON tp.id = i.typeFk - JOIN itemCategory ic ON ic.id = tp.categoryFk + JOIN itemCategory ic ON ic.id = tp.categoryFk WHERE w.valuatedInventory and inv.total > 0 order by inv.total desc; @@ -60857,8 +60630,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ledger_doCompensation` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60866,6 +60637,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ledger_doCompensation`(vDated DATE, vCompensationAccount VARCHAR(10) , vBankFk VARCHAR(10), vConcept VARCHAR(255), vAmount DECIMAL(10,2), vCompanyFk INT, vOriginalAccount VARCHAR(10)) BEGIN @@ -60878,37 +60651,37 @@ BEGIN * @param vConcept descripcion * @param vAmount cantidad que se compensa * @param vCompany empresa - * @param vOriginalAccount cuenta contable desde la cual se compensa - * - */ + * @param vOriginalAccount cuenta contable desde la cual se compensa + * + */ DECLARE vNewBookEntry INT; DECLARE vIsClientCompensation INT; DECLARE vClientFk INT; DECLARE vSupplierFk INT; DECLARE vIsOriginalAClient BOOL; DECLARE vPayMethodCompensation INT; - + CALL ledger_next(vNewBookEntry); SELECT COUNT(id) INTO vIsOriginalAClient FROM client WHERE accountingAccount LIKE vOriginalAccount COLLATE utf8_general_ci; - SELECT id, COUNT(id) INTO vClientFk, vIsClientCompensation - FROM client + SELECT id, COUNT(id) INTO vClientFk, vIsClientCompensation + FROM client WHERE accountingAccount LIKE vCompensationAccount COLLATE utf8_general_ci; - + SET @vAmount1:= 0.0; SET @vAmount2:= 0.0; - INSERT INTO XDiario (ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, empresa_id) - VALUES ( vNewBookEntry, - vDated, - vOriginalAccount, - vCompensationAccount, - vConcept, + INSERT INTO XDiario (ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, empresa_id) + VALUES ( vNewBookEntry, + vDated, + vOriginalAccount, + vCompensationAccount, + vConcept, @vAmount1:= IF( - (vIsOriginalAClient AND vAmount > 0) OR - (NOT vIsOriginalAClient AND vAmount < 0), - 0, + (vIsOriginalAClient AND vAmount > 0) OR + (NOT vIsOriginalAClient AND vAmount < 0), + 0, ABS(vAmount) ), @vAmount2:= IF(@vAmount1, @@ -60917,20 +60690,20 @@ BEGIN ), vCompanyFk ), - ( vNewBookEntry, - vDated, - vCompensationAccount, - vOriginalAccount, - vConcept, + ( vNewBookEntry, + vDated, + vCompensationAccount, + vOriginalAccount, + vConcept, @vAmount2, @vAmount1, vCompanyFk); - + IF vIsClientCompensation THEN IF vIsOriginalAClient THEN SET vAmount = -vAmount; END IF; - INSERT INTO receipt(invoiceFk, amountPaid, payed, bankFk, companyFk, clientFk, isConciliate) + INSERT INTO receipt(invoiceFk, amountPaid, payed, bankFk, companyFk, clientFk, isConciliate) VALUES (vConcept, vAmount, vDated, vBankFk, vCompanyFk, vClientFk, TRUE); ELSE IF NOT vIsOriginalAClient THEN @@ -60938,7 +60711,7 @@ BEGIN END IF; SELECT id INTO vSupplierFk FROM supplier WHERE `account` LIKE vCompensationAccount COLLATE utf8_general_ci; SELECT id INTO vPayMethodCompensation FROM payMethod WHERE `code` = 'compensation'; - + INSERT INTO payment (received, dueDated, supplierFk, amount, bankFk, payMethodFk, concept, companyFk, isConciliated) VALUES(vDated, vDated, vSupplierFk, vAmount, vBankFk, vPayMethodCompensation, vConcept, vCompanyFk, TRUE); END IF; @@ -60948,8 +60721,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ledger_next` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60957,21 +60728,21 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ledger_next`(OUT vNewBookEntry INT) BEGIN - + UPDATE vn.ledgerConfig SET lastBookEntry = LAST_INSERT_ID(lastBookEntry + 1); SET vNewBookEntry = LAST_INSERT_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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `logAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60979,6 +60750,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `logAdd`(vOriginFk INT, vActionCode VARCHAR(45), vEntity VARCHAR(45), vDescription TEXT) BEGIN @@ -60990,7 +60763,7 @@ BEGIN * @param vEntity Nombre que hace referencia a la tabla. * @param descripcion Descripción de la acción realizada por el usuario */ - + CALL logAddWithUser(vOriginFk, account.myUser_getId(), vActionCode, vEntity, vDescription); END ;; DELIMITER ; @@ -60998,8 +60771,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `logAddWithUser` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61007,6 +60778,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `logAddWithUser`(vOriginFk INT, vUserId INT, vActionCode VARCHAR(45), vEntity VARCHAR(45), vDescription TEXT) BEGIN @@ -61039,8 +60812,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `logShow` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61048,6 +60819,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `logShow`(vOriginFk INT, vEntity VARCHAR(45)) BEGIN @@ -61058,15 +60831,15 @@ BEGIN * @param vEntity Nombre que hace referencia a la tabla. */ DECLARE vTableName VARCHAR(45); - + SET vTableName = CONCAT(vEntity, 'Log'); - + SET @qryLog := CONCAT( 'SELECT ot.id, ot.originFk, ot.userFk, u.name, ot.action, ot.creationDate, ot.description FROM ', vTableName, ' AS ot', ' INNER JOIN account.user u ON u.id = ot.userFk', ' WHERE ot.originFk = ', vOriginFk, ' ORDER BY ot.creationDate DESC' ); - + PREPARE stmt FROM @qryLog; EXECUTE stmt; END ;; @@ -61075,8 +60848,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `lungSize_generator` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61084,6 +60855,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `lungSize_generator`(vDate DATE) BEGIN @@ -61091,9 +60864,9 @@ BEGIN SET @buildingOrder := 0; SET @route := 0; set @cajas := 0; - + UPDATE tmp.sorter - SET buildingOrder = @buildingOrder := IF(@route = @route := routeFk, @buildingOrder, 0) + 1 + SET buildingOrder = @buildingOrder := IF(@route = @route := routeFk, @buildingOrder, 0) + 1 where date(created) = vDate order by routeFk, created, weight DESC; @@ -61111,23 +60884,23 @@ set @cajas := 0; UPDATE tmp.sorter SET lungGrow = IF(palletOrder = 0, -13, lungGrow); - + DELETE FROM tmp.lungSize WHERE dia = vDate; - + INSERT INTO tmp.lungSize(dia, hora,size) select vDate,hora, @cajas := @cajas + cajas as size from ( select IF(lungGrow BETWEEN -12 AND -1, ETD,time_format(created,"%H:%i")) as hora, sum(if(lungGrow <= 0, lungGrow, 1)) as cajas, @cajas := 0 - from tmp.sorter + from tmp.sorter where date(created) = vDate group by hora ) sub; - + SELECT * FROM tmp.lungSize WHERE dia = vDate; - - + + END ;; @@ -61136,8 +60909,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `machineWorker_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61145,34 +60916,34 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `machineWorker_add`(vPlate VARCHAR(10), vWorkerFk INT) BEGIN - + /** * Inserta registro si el vWorkerFk no ha registrado nada en las últimas 12 horas * @param vPlate número de matrícula - * @param vWorkerFk id del worker - * -*/ - UPDATE vn.machineWorker mw - JOIN vn.machine m ON m.id = mw.machineFk - SET mw.outTimed = NOW() + * @param vWorkerFk id del worker + * +*/ + UPDATE vn.machineWorker mw + JOIN vn.machine m ON m.id = mw.machineFk + SET mw.outTimed = util.VN_NOW() WHERE (mw.workerFk = vWorkerFk OR m.plate = vPlate) AND ISNULL(mw.outTimed); - + INSERT INTO machineWorker (machineFk, workerFk) SELECT m.id, vWorkerFk FROM machine m - WHERE m.plate= vPlate; + WHERE m.plate= vPlate; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `machineWorker_getHistorical` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61180,33 +60951,33 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `machineWorker_getHistorical`(vPlate VARCHAR(20), vWorkerFk INT) BEGIN /** - * Obtiene historial de la matrícula vPlate que el trabajador vWorkerFk escanea, + * Obtiene historial de la matrícula vPlate que el trabajador vWorkerFk escanea, * si es jefe de producción muestra el historial completo. - * + * * @param vPlate número de matrícula - * @param vWorkerFk id del trabajador - * + * @param vWorkerFk id del trabajador + * */ DECLARE vWorkerName VARCHAR(255) DEFAULT account.user_getNameFromId(vWorkerFk); - SELECT mw.inTimed,account.user_getNameFromId(mw.workerFk) as workerName, mw.outTimed + SELECT mw.inTimed,account.user_getNameFromId(mw.workerFk) as workerName, mw.outTimed FROM machineWorker mw JOIN machine m ON m.plate = vPlate WHERE mw.machineFk = m.id AND mw.workerFk = IF(account.user_hasRole(vWorkerName, 'coolerAssist'), mw.workerFk, vWorkerFk) - ORDER BY mw.inTimed DESC; + ORDER BY mw.inTimed DESC; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `machineWorker_update` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61214,16 +60985,18 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `machineWorker_update`(vPlate VARCHAR(10), vWorkerFk INT) BEGIN - + /** - * Actualiza el registro correspondiente si el vWorkerFk se ha registrado en las últimas horas (campo maxHours de machineWorkerConfig) 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 - * + * @param vWorkerFk id del trabajador + * */ DECLARE vMachineFk INT(10); @@ -61232,32 +61005,30 @@ BEGIN SELECT m.id INTO vMachineFk FROM machine m WHERE m.plate = vPlate; - + SELECT maxHours INTO vMaxHours FROM machineWorkerConfig; - IF (SELECT COUNT(*) + IF (SELECT COUNT(*) FROM machineWorker m WHERE m.workerFk = vWorkerFk - AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, NOW()) AND ISNULL(m.outTimed)) THEN - + AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, util.VN_NOW()) AND ISNULL(m.outTimed)) THEN + UPDATE machineWorker m SET m.outTimed = CURRENT_TIMESTAMP() - WHERE m.workerFk = vWorkerFk - AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, NOW()) + WHERE m.workerFk = vWorkerFk + AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, util.VN_NOW()) AND ISNULL(m.outTimed) AND m.machineFk = vMachineFk; - + END IF; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `machine_getWorkerPlate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61265,22 +61036,24 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `machine_getWorkerPlate`(vWorkerFk INT) BEGIN /** - * Selecciona la matrícula del vehículo del workerfk - * + * Selecciona la matrícula del vehículo del workerfk + * * @param vWorkerFk el id del trabajador - * - * + * + * **/ - + SELECT m.plate - FROM machine m - JOIN machineWorker mw ON mw.machineFk = m.id - WHERE mw.inTimed >= TIMESTAMPADD(HOUR , -12,NOW()) - AND ISNULL(mw.outTimed) + FROM machine m + JOIN machineWorker mw ON mw.machineFk = m.id + WHERE mw.inTimed >= TIMESTAMPADD(HOUR , -12,util.VN_NOW()) + AND ISNULL(mw.outTimed) AND mw.workerFk = vWorkerFk; END ;; @@ -61289,8 +61062,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `mail_insert` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61298,6 +61069,8 @@ DELIMITER ; /*!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`@`localhost` PROCEDURE `mail_insert`( vReceiver VARCHAR(255), @@ -61308,17 +61081,17 @@ BEGIN /** * Inserta en la tabla vn.mail * - * @param vReceiver Receptor del correo + * @param vReceiver Receptor del correo * @param vReplyTo A quién contestar el correo * @param vSubject Título del correo * @param vBody Cuerpo del correo */ - + DECLARE vIsRepeated BOOLEAN; SELECT COUNT(*) INTO vIsRepeated FROM vn.mail - WHERE creationDate >= CURDATE() + WHERE creationDate >= util.VN_CURDATE() AND `receiver` = vReceiver AND `replyTo` = vReplyTo AND `subject` = vSubject @@ -61340,8 +61113,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `makeNewItem` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61349,17 +61120,19 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `makeNewItem`() BEGIN DECLARE newItemFk INT; - + SELECT getNewItemId() INTO newItemFk; - + INSERT INTO item(id,name,typeFk,originFk) SELECT newItemFk, 'Nuevo artículo', 78,39; - + SELECT newItemFk; @@ -61369,8 +61142,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `makePCSGraf` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61378,6 +61149,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `makePCSGraf`(vDated DATE) BEGIN @@ -61387,42 +61160,40 @@ BEGIN DECLARE vMinute INT DEFAULT 0; DECLARE vBoxes INT; - + DROP TEMPORARY TABLE IF EXISTS vn.pcsDay; CREATE TEMPORARY TABLE vn.pcsDay SELECT 0 as hh, 0 as mm, 0 as boxes; - + -- Creamos una tabla soporte para acumular las cajas a lo largo del dia WHILE vHour < 24 DO - + WHILE vMinute < 59 DO - + SET vMinute = vMinute + 1; - + INSERT INTO vn.pcsDay(hh,mm) VALUES(vHour, vMinute); - + END WHILE; - + SET vMinute = -1; SET vHour = vHour + 1; - + END WHILE; - + -- Acumulamos UPDATE vn.pcsDay pd LEFT JOIN (SELECT * FROM vn.pcs_graf WHERE dia = vDated) pg USING(hh,mm) SET pd.boxes = pd.boxes + pg.box; - + SELECT * FROM vn.pcsDay; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `manaSpellersRequery` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61430,6 +61201,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `manaSpellersRequery`(vWorkerFk INTEGER) BEGIN @@ -61437,41 +61210,41 @@ BEGIN * Recalcula el mana consumido por un trabajador * * @param vWorkerFk Id Trabajador - */ + */ DECLARE vWorkerIsExcluded BOOLEAN; DECLARE vFromDated DATE; - DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,CURDATE()); + DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,util.VN_CURDATE()); DECLARE vMana INT; DECLARE vAutoMana INT; DECLARE vClaimMana INT; DECLARE vManaBank INT; DECLARE vManaGreugeType INT; - + SELECT COUNT(*) INTO vWorkerIsExcluded FROM workerManaExcluded WHERE workerFk = vWorkerFk; - + IF NOT vWorkerIsExcluded THEN - SELECT id INTO vMana + SELECT id INTO vMana FROM `component` WHERE code = 'mana'; - - SELECT id INTO vAutoMana + + SELECT id INTO vAutoMana FROM `component` WHERE code = 'autoMana'; - - SELECT id INTO vClaimMana + + SELECT id INTO vClaimMana FROM `component` WHERE code = 'manaClaim'; - - SELECT id INTO vManaBank + + SELECT id INTO vManaBank FROM `bank` WHERE code = 'mana'; - - SELECT id INTO vManaGreugeType + + SELECT id INTO vManaGreugeType FROM `greugeType` WHERE code = 'mana'; - SELECT max(dated) INTO vFromDated + SELECT max(dated) INTO vFromDated FROM clientManaCache; - + REPLACE workerMana (workerFk, amount) - SELECT vWorkerFk, sum(mana) FROM + SELECT vWorkerFk, sum(mana) FROM ( SELECT s.quantity * sc.value as mana FROM ticket t @@ -61492,8 +61265,8 @@ BEGIN FROM greuge g JOIN client c ON c.id = g.clientFk WHERE c.salesPersonFk = vWorkerFk AND g.greugeTypeFk = vManaGreugeType - AND g.shipped > vFromDated and g.shipped < CURDATE() - UNION ALL + AND g.shipped > vFromDated and g.shipped < util.VN_CURDATE() + UNION ALL SELECT cc.mana FROM clientManaCache cc JOIN client c ON c.id = cc.clientFk @@ -61506,8 +61279,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `mergeTicketWithArray` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61515,6 +61286,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `mergeTicketWithArray`(IN vMainTicket INT(11), IN arrayTickets VARCHAR(50)) BEGIN @@ -61529,7 +61302,7 @@ BEGIN SELECT Factura IS NOT NULL INTO isBilled FROM vn2008.Tickets WHERE Id_Ticket = vMainTicket; IF NOT isBilled THEN - + SELECT Id_Trabajador INTO worker from vn2008.Trabajadores where user_id = account.myUser_getId(); DROP TEMPORARY TABLE IF EXISTS vn2008.Tickets_to_fusion; @@ -61546,31 +61319,31 @@ BEGIN FROM vn2008.Tickets_to_fusion tf INNER JOIN vn2008.ticket_observation tco USING(Id_Ticket) ON DUPLICATE KEY UPDATE `text` = CONCAT(ticket_observation.`text`,CONCAT(' Ticket ', VALUES(Id_Ticket), ':' , VALUES(`text`), '. ')); - + UPDATE vn2008.Movimientos M JOIN vn2008.Tickets_to_fusion USING(Id_Ticket) SET M.Id_Ticket = vMainTicket; - + UPDATE vn2008.expeditions M JOIN vn2008.Tickets_to_fusion t ON t.Id_Ticket = M.ticket_id SET M.ticket_id = vMainTicket; - + UPDATE vn.ticketPackaging tp JOIN vn2008.Tickets_to_fusion t ON t.Id_Ticket = tp.ticketFk SET tp.ticketFk = vMainTicket; - + UPDATE vn2008.Tickets SET Bultos = (SELECT COUNT(*) FROM vn2008.expeditions WHERE ticket_id = vMainTicket AND EsBulto) WHERE Id_Ticket = vMainTicket; - + UPDATE vn2008.Tickets JOIN vn2008.Tickets_to_fusion USING(Id_Ticket) SET Fecha = TIMESTAMPADD(YEAR,-1 * (YEAR(Fecha)-2000), Fecha), Id_Ruta = NULL; - + UPDATE vn.ticketLog tl JOIN vn2008.Tickets_to_fusion t ON t.Id_Ticket = tl.originFk SET tl.originFk = vMainTicket; - + UPDATE vn2008.Tickets SET Localizacion = CONCAT(Tickets.Localizacion,' ',IFNULL((SELECT GROUP_CONCAT(Localizacion SEPARATOR ' ') FROM vn2008.Tickets_to_fusion),'')) WHERE Id_Ticket = vMainTicket; @@ -61578,15 +61351,15 @@ BEGIN UPDATE vn2008.Splits s RIGHT JOIN vn2008.Tickets_to_fusion t USING(Id_Ticket) SET s.Id_Ticket = vMainTicket; - + UPDATE vn2008.Ordenes o RIGHT JOIN vn2008.Tickets_to_fusion t ON t.Id_Ticket = o.ticketFk SET o.ticketFk = vMainTicket; IF (SELECT COUNT(*) FROM vn2008.Splits WHERE Id_Ticket=vMainTicket) > 1 THEN - + SELECT Id_Split INTO vMainSplit FROM vn2008.Splits WHERE Id_Ticket = vMainTicket LIMIT 1; - + SELECT group_concat(Notas,',') INTO messageForSplit FROM vn2008.Splits WHERE Id_Ticket = vMainTicket; UPDATE vn2008.Splits SET Notas = messageForSplit WHERE Id_Split=vMainSplit; UPDATE vn2008.Split_lines sl JOIN vn2008.Splits s USING (Id_Split) SET sl.Id_Split=vMainSplit WHERE Id_Ticket=vMainTicket; @@ -61595,11 +61368,11 @@ BEGIN SELECT GROUP_CONCAT(Id_Ticket SEPARATOR ',') into messageLog FROM vn2008.Tickets_to_fusion; CALL vn2008.Ditacio(vMainTicket,'Fusion','T',worker,messageLog,NULL); - + DELETE ts FROM vn2008.Tickets_state ts JOIN vn2008.Tickets_to_fusion t USING(Id_Ticket); - + DROP TEMPORARY TABLE vn2008.Tickets_to_fusion; - END IF; + END IF; END ;; DELIMITER ; @@ -61607,8 +61380,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `mysqlConnectionsSorter_kill` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61616,25 +61387,27 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqlConnectionsSorter_kill`() BEGIN /** - * Elimina conexiones del usuario sorter con tiempo >= 30seg. Asociado al evento con el mismo nombre - */ - + * Elimina conexiones del usuario sorter con tiempo >= 30seg. Asociado al evento con el mismo nombre + */ + DECLARE vDone INT DEFAULT 0; DECLARE vProcesId INT; DECLARE vCursor CURSOR FOR - SELECT p.id + SELECT p.id FROM information_schema.processlist p - WHERE USER = 'sorter' + WHERE USER = 'sorter' AND TIME >= 30; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + OPEN vCursor; l: LOOP @@ -61657,8 +61430,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `mysqlPreparedCount_check` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61666,12 +61437,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqlPreparedCount_check`() BEGIN DECLARE vPreparedCount INTEGER; - SELECT VARIABLE_VALUE INTO vPreparedCount + SELECT VARIABLE_VALUE INTO vPreparedCount FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE '%prepared_stmt_count%'; @@ -61679,7 +61452,7 @@ BEGIN CALL `vn`.`mail_insert`('cau@verdnatura.es', NULL, 'Problemas BBDD prepared_stmt_count', - CONCAT('Existen problemas con el servicio de Logiflora, prepared_stmt_count con valor: ', + CONCAT('Existen problemas con el servicio de Logiflora, prepared_stmt_count con valor: ', vPreparedCount, ', está próximo a exceder su límite. \r\n Hay que reiniciar el servicio LF.VMP.Service del servidor a3.') ); @@ -61691,8 +61464,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `nextShelvingCodeMake` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61700,43 +61471,45 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `nextShelvingCodeMake`() BEGIN DECLARE newShelving VARCHAR(3); DECLARE vCode VARCHAR(3); - + SELECT MAX(code) INTO vCode FROM vn.shelving WHERE isPrinted = FALSE; - + SET @a1 := ASCII(MID(vCode,1,1)); SET @a2 := ASCII(MID(vCode,2,1)); SET @a3 := ASCII(MID(vCode,3,1)) + 1; - + IF @a3 > 90 THEN - + SET @a3 = 65; SET @a2 = @a2 + 1; - + IF @a2 > 90 THEN - + SET @a2 = 65; SET @a1 = @a1 + 1; - + IF @a1 > 90 THEN - + SET @a1 = 65; - + END IF; - + END IF; - + END IF; SET newShelving = CHAR(@a1,@a2,@a3 USING utf8); - + INSERT INTO vn.shelving(code) VALUES(newShelving); END ;; @@ -61745,8 +61518,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `observationAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61754,6 +61525,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `observationAdd`(vOriginFk INT, vTableCode VARCHAR(45), vDescription TEXT) BEGIN @@ -61765,18 +61538,18 @@ BEGIN * @param descripcion Texto de la observacion */ DECLARE vTableName VARCHAR(45); - + SET vTableName = CONCAT(vTableCode,'Observation'); - + IF ISNULL(vTableName) THEN CALL util.throw('CODE_NOT_FOUND'); END IF; - + SET @qryLog := CONCAT( 'INSERT INTO ', vTableName, ' (originFk, userFk, description)', ' VALUES (', vOriginFk, ', ', account.myUser_getId(), ', "', vDescription, '")' ); - + PREPARE stmt FROM @qryLog; EXECUTE stmt; DEALLOCATE PREPARE stmt; @@ -61786,8 +61559,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `orderCreate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61795,6 +61566,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `orderCreate`( vLanded DATE, @@ -61806,15 +61579,15 @@ BEGIN DECLARE vDeliveryMethod INT; DECLARE vClient INT; - + SELECT deliveryMethodFk INTO vDeliveryMethod - FROM vn.agencyMode + FROM vn.agencyMode WHERE id = vAgencyMode; - + SELECT clientFk INTO vClient FROM vn.address WHERE id = vAddress; - + INSERT INTO hedera.order(date_send,customer_id,delivery_method_id,agency_id,address_id,source_app) VALUES( vLanded,vClient ,vDeliveryMethod,vAgencyMode ,vAddress ,vSourceApp); @@ -61826,8 +61599,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `orderDelete` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61835,20 +61606,20 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `orderDelete`(IN vId INT) BEGIN DELETE FROM hedera.`order` where id = vId; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `orderListCreate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61856,6 +61627,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `orderListCreate`( vLanded DATE, @@ -61867,15 +61640,13 @@ BEGIN DECLARE vOrderId INT; CALL vn.orderCreate(vLanded,vAgencyMode,vAddress,vSourceApp,vOrderId); SELECT vOrderId; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `orderListVolume` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61883,11 +61654,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `orderListVolume`(IN vOrderId INT) BEGIN - SELECT + SELECT o.id, o.itemFk, i.description, @@ -61903,8 +61676,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `packageInvoicing` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61912,8 +61683,10 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `packageInvoicing`( +CREATE DEFINER=`root`@`localhost` PROCEDURE `packageInvoicing`( IN vClient INT, IN vDate DATE, IN vCompany INT, @@ -61932,20 +61705,20 @@ BEGIN SET vGraceDays = IF(vIsAllInvoiceable ,0, 30); SET vGraceDate = TIMESTAMPADD(DAY, - vGraceDays, vDate); - - /* Clientes especiales: + + /* Clientes especiales: 3240 MADEFLOR 992 JAVIER FELIU 4 TONI VENDRELL */ - + IF vClient IN (992, 3240, 4) THEN - + SET vGraceDays = 365; - + END IF; /* Fin clientes especiales */ - + SET vDateEnd = DATE_ADD(vDate, INTERVAL 1 DAY); DROP TEMPORARY TABLE IF EXISTS tmp.packageToInvoice; @@ -61969,22 +61742,22 @@ BEGIN FROM tmp.packageToInvoice GROUP BY itemFk HAVING totalQuantity > 0; - + SELECT COUNT(*) INTO vIsInvoiceable FROM tmp.packageToInvoicePositives; IF vIsInvoiceable THEN - CALL ticket_add(vClient, + CALL ticket_add(vClient, vDateEnd, - vWarehouse, - vCompany, - NULL, - NULL, - NULL, - vDateEnd, - account.myUser_getId(), + vWarehouse, + vCompany, + NULL, + NULL, + NULL, + vDateEnd, + account.myUser_getId(), TRUE, vNewTicket); @@ -61993,52 +61766,50 @@ BEGIN packagingFk, quantity, pvp) - SELECT vNewTicket, - pti.packagingFk, - - SUM(pti.quantity) AS totalQuantity, + SELECT vNewTicket, + pti.packagingFk, + - SUM(pti.quantity) AS totalQuantity, pti.price FROM tmp.packageToInvoice pti - LEFT JOIN tmp.packageToInvoicePositives ptip ON pti.itemFk = ptip.itemFk - WHERE ptip.itemFK IS NOT NULL + LEFT JOIN tmp.packageToInvoicePositives ptip ON pti.itemFk = ptip.itemFk + WHERE ptip.itemFK IS NOT NULL OR vIsAllInvoiceable GROUP BY packagingFk HAVING totalQuantity; INSERT INTO sale( ticketFk, - itemFk, - concept, - quantity, + itemFk, + concept, + quantity, price ) - SELECT vNewTicket, - pti.itemFk, - i.name as concept, - sum(pti.quantity) as totalQuantity, + SELECT vNewTicket, + pti.itemFk, + i.name as concept, + sum(pti.quantity) as totalQuantity, pti.price FROM tmp.packageToInvoice pti JOIN item i ON i.id = pti.itemFk LEFT JOIN tmp.packageToInvoicePositives ptip ON pti.itemFk = ptip.itemFk - WHERE ptip.itemFK IS NOT NULL + WHERE ptip.itemFK IS NOT NULL OR vIsAllInvoiceable GROUP BY pti.itemFk HAVING totalQuantity; - + INSERT INTO saleComponent(saleFk, componentFk, value) SELECT id, vComponentCost, price FROM sale WHERE ticketFk = vNewTicket; - + END IF; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `packingListPrinted` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -62046,6 +61817,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `packingListPrinted`(ticketFk INT) BEGIN @@ -62056,15 +61829,13 @@ BEGIN WHERE mm.valor = 1 -- Listo para imprimir AND mm.stateFk = 9 -- Encajando AND m.Id_Ticket = ticketFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `packingListSwitch` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -62072,21 +61843,23 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `packingListSwitch`(saleFk INT) BEGIN DECLARE valueFk INT; DECLARE encajando INT DEFAULT 9; - - SELECT valor INTO valueFk - FROM vn2008.Movimientos_mark - WHERE Id_Movimiento = saleFk + + SELECT valor INTO valueFk + FROM vn2008.Movimientos_mark + WHERE Id_Movimiento = saleFk AND stateFk = encajando; - + SET valueFk = (IFNULL(valueFk,0) + 1) MOD 3; - - REPLACE vn2008.Movimientos_mark(Id_Movimiento, valor, Id_Trabajador, stateFk) + + REPLACE vn2008.Movimientos_mark(Id_Movimiento, valor, Id_Trabajador, stateFk) VALUES(saleFk,valueFk,account.myUser_getId(),encajando); @@ -62096,8 +61869,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `packingSite_startCollection` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -62105,6 +61876,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `packingSite_startCollection`(vSelf INT, vTicketFk INT) BEGIN @@ -62142,8 +61915,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `parking_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -62151,6 +61922,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_add`(vFromColumn INT, vToColumn INT, vFromRow INT, vToRow INT, vSectorFk INT, vIsLetterMode BOOLEAN) BEGIN @@ -62160,34 +61933,34 @@ BEGIN DECLARE vLetters VARCHAR(26) DEFAULT 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; DECLARE vMaxId INT; DECLARE vCode VARCHAR(8); - + SET vColumn = vFromColumn; SET vRow = vFromRow; SET vCode = CONCAT(LPAD(vColumn,3,'0'),'-',IF(vIsLetterMode, MID(vLetters, vRow, 1), LPAD(vRow, 2,'0'))); - + SELECT MAX(id) INTO vMaxId FROM vn.parking; WHILE vColumn <= vToColumn DO - + WHILE vRow <= vToRow DO - + INSERT IGNORE INTO vn.parking(`column`, `row`, sectorFk, `code`, pickingOrder) VALUES (vColumn, vRow, vSectorFk, vCode, vColumn * 100 + vRow ) ON DUPLICATE KEY UPDATE `code` = vCode; - + SET vRow = vRow + 1; SET vCode = CONCAT(LPAD(vColumn,3,'0'),'-',IF(vIsLetterMode, MID(vLetters, vRow, 1), LPAD(vRow, 2,'0'))); - + END WHILE; - + SET vRow = vFromRow; SET vColumn = vColumn + 1; - + SET vCode = CONCAT(LPAD(vColumn,3,'0'),'-',IF(vIsLetterMode, MID(vLetters, vRow, 1), LPAD(vRow, 2,'0'))); - + END WHILE; - + SELECT * FROM vn.parking WHERE `column` BETWEEN vFromColumn AND vToColumn; END ;; @@ -62196,8 +61969,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `parking_algemesi` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -62205,6 +61976,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_algemesi`(vFromRow INT, vToRow INT, vSectorFk INT, vLetter VARCHAR(1), vPickingOrder INT, vTrolleysByLine INT) BEGIN @@ -62212,67 +61985,65 @@ BEGIN DECLARE vRow INT; DECLARE vCode VARCHAR(8); DECLARE i INT; - + IF vToRow < vFromRow THEN - + SET vRow = vFromRow; - + WHILE vRow >= vToRow DO - + SET i = 1; - + WHILE i <= vTrolleysByLine DO - + SET vCode = CONCAT(vLetter,'-', LPAD(vRow,2,'0'),'-', i); - + INSERT IGNORE INTO vn.parking( sectorFk, `code`, pickingOrder) VALUES (vSectorFk, vCode, vPickingOrder + (i * 10)) ON DUPLICATE KEY UPDATE `code` = vCode; - + SET i = i + 1; - + END WHILE; - + SET vRow = vRow - 1; - + END WHILE; ELSE - + SET vRow = vFromRow; - + WHILE vRow <= vToRow DO - + SET i = 1; - + WHILE i <= vTrolleysByLine DO - + SET vCode = CONCAT(vLetter,'-', LPAD(vRow,2,'0'),'-', i); - + INSERT IGNORE INTO vn.parking( sectorFk, `code`, pickingOrder) VALUES (vSectorFk, vCode, vPickingOrder + (i * 10) ) ON DUPLICATE KEY UPDATE `code` = vCode; - + SET i = i + 1; - + END WHILE; - + SET vRow = vRow + 1; - + END WHILE; - - + + END IF; - - + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `parking_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -62280,6 +62051,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_new`(vStart INT, vEnd INT, vSectorFk INT) BEGIN @@ -62288,36 +62061,34 @@ BEGIN DECLARE vColumn INT; DECLARE vLetters VARCHAR(200); DECLARE vLettersLength INT; - + SET vColumn = vStart; SET vRow = 1; SET vLetters = 'ABCDEF'; SET vLettersLength = LENGTH(vLetters); - + WHILE vColumn <= vEnd DO - + REPLACE vn.parking(`column`, `row`, `code`, sectorFk) VALUES(vColumn, vRow, CONCAT(vColumn,MID(vLetters,vRow,1)), vSectorFk); - + SET vRow = vRow + 1; - + IF vRow > vLettersLength THEN - + SET vRow = 1; SET vColumn = vColumn + 1; - + END IF; - + END WHILE; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `parking_setOrder` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -62325,14 +62096,16 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_setOrder`(vWarehouseFk INT) BEGIN - + /* * Ordena el orden de preparacion de los parking de acuerdo con la tabla vn.corridor */ - + UPDATE vn.parking p JOIN ( SELECT code, @@ -62341,23 +62114,21 @@ BEGIN SELECT c.prepOrder, p.code, @orden := 0, - IF(c.isAscendent, 1,-1) * CAST(SUBSTRING(p.code,3,2) AS DECIMAL(2,0)) subCorridor , - CAST(IF(LENGTH(p.code) > 5, SUBSTRING(p.code,6,2), 0) AS DECIMAL(2,0)) ubication + IF(c.isAscendent, 1,-1) * CAST(SUBSTRING(p.code,3,2) AS DECIMAL(2,0)) subCorridor , + CAST(IF(LENGTH(p.code) > 5, SUBSTRING(p.code,6,2), 0) AS DECIMAL(2,0)) ubication FROM vn.parking p - JOIN vn.sector s ON s.id = p.sectorFk + JOIN vn.sector s ON s.id = p.sectorFk JOIN vn.corridor c ON c.code = LEFT(p.code,1) COLLATE utf8_general_ci - WHERE s.warehouseFk = vWarehouseFk) sub - ORDER BY sub.prepOrder, subCorridor, ubication) sub2 ON sub2.code = p.code + WHERE s.warehouseFk = vWarehouseFk) sub + ORDER BY sub.prepOrder, subCorridor, ubication) sub2 ON sub2.code = p.code SET p.pickingOrder = sub2.po; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `placement_test` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -62365,13 +62136,15 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `placement_test`(vParamFk INT(11)) BEGIN DECLARE vCalcFk INT; DECLARE vWarehouseFk INT; DECLARE vWarehouseAliasFk INT; - DECLARE vCurrentYear INT DEFAULT YEAR(NOW()); + DECLARE vCurrentYear INT DEFAULT YEAR(util.VN_NOW()); DROP TEMPORARY TABLE IF EXISTS tmp.sale; CREATE TEMPORARY TABLE tmp.sale @@ -62454,7 +62227,7 @@ BEGIN 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, + IF(iss.id, TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,iss.created)), TO_SECONDS(TIMESTAMPADD(YEAR,- year(ish.created),ish.created)) + TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,util.VN_NOW()))) as priority, 0 as saleOrder, sc.isPreviousPrepared, iss.id as itemShelvingSaleFk, @@ -62523,8 +62296,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `prepareClientList` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -62532,28 +62303,28 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `prepareClientList`() BEGIN - + /* * Require la tabla tmp.ticket(id,clientFk) */ - + DROP TEMPORARY TABLE IF EXISTS tmp.client; CREATE TEMPORARY TABLE tmp.client (PRIMARY KEY (id)) ENGINE = MEMORY SELECT DISTINCT clientFk id - FROM tmp.ticket; + FROM tmp.ticket; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `prepareTicketList` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -62561,11 +62332,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `prepareTicketList`(vStartingDate DATETIME, vEndingDate DATETIME) BEGIN - - DROP TEMPORARY TABLE IF EXISTS tmp.productionTicket; + + DROP TEMPORARY TABLE IF EXISTS tmp.productionTicket; CREATE TEMPORARY TABLE tmp.productionTicket (PRIMARY KEY (ticketFk)) ENGINE = MEMORY @@ -62575,11 +62348,11 @@ BEGIN JOIN vn.client c ON c.id = t.clientFk WHERE c.typeFk IN ('normal','handMaking','internalUse') AND ( - t.shipped BETWEEN CURDATE() AND vEndingDate + t.shipped BETWEEN util.VN_CURDATE() AND vEndingDate OR ( ts.alertLevel < 3 AND t.shipped >= vStartingDate - AND t.shipped < CURDATE() + AND t.shipped < util.VN_CURDATE() ) ); END ;; @@ -62588,8 +62361,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `previousSticker_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -62597,6 +62368,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `previousSticker_get`(vSaleGroupFk INT) BEGIN @@ -62604,9 +62377,9 @@ BEGIN * Devuelve los campos a imprimir en una etiqueta de preparación previa. * Actualiza el valor de vn.saleGroup.parkingFk en el caso de que exista un saleGroup del mismo ticket * con parking, del mismo sector, para que todos se pongan juntos - * + * * @param vSaleGroupFk Identificador de vn.saleGroup - */ + */ DECLARE vTicketFk INT; DECLARE vParkingFk INT; DECLARE vSectorFk INT; @@ -62617,35 +62390,35 @@ BEGIN JOIN vn.sale s ON s.id = sgd.saleFk WHERE sgd.saleGroupFk = vSaleGroupFk LIMIT 1; - - SELECT sg.parkingFk, sc.sectorFk + + SELECT sg.parkingFk, sc.sectorFk INTO vParkingFk, vSectorFk FROM vn.saleGroup sg JOIN vn.sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id JOIN vn.sectorCollection sc ON sc.id = scsg.sectorCollectionFk JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = sg.id - JOIN vn.sale s ON s.id = sgd.saleFk + JOIN vn.sale s ON s.id = sgd.saleFk WHERE s.ticketFk = vTicketFk - AND sg.parkingFk IS NOT NULL + AND sg.parkingFk IS NOT NULL LIMIT 1; UPDATE vn.saleGroup sg SET sg.parkingFk = vParkingFk WHERE sg.id = vSaleGroupFk AND sg.sectorFk = vSectorFk; - + SELECT sgd.saleGroupFk, - t.id ticketFk, + t.id ticketFk, p.code as location, t.observations, - IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) shippingHour, + IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) shippingHour, IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) shippingMinute , IFNULL(MAX(i.itemPackingTypeFk),'H') itemPackingTypeFk , count(*) items FROM vn.sale s - JOIN vn.item i ON i.id = s.itemFk + JOIN vn.item i ON i.id = s.itemFk JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id - JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk + JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk JOIN vn.ticket t ON t.id = s.ticketFk LEFT JOIN vn.parking p ON p.id = sg.parkingFk LEFT JOIN vn.`zone` z ON z.id = t.zoneFk @@ -62656,8 +62429,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `productionControl` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -62665,86 +62436,87 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `productionControl`(vWarehouseFk INT, vScopeDays INT) proc: BEGIN - - /** - * Devuelve un listado de tickets con parámetros relativos a la producción de los días en rango - * - * @param vWarehouseFk Identificador de vn.warehouse - * @param vScopeDays Número de días desde hoy en adelante que entran en el cálculo. - * - * @return Table tmp.productionBuffer - */ - - DECLARE vEndingDate DATETIME DEFAULT TIMESTAMPADD(DAY,vScopeDays,util.dayEnd(CURDATE())); - +/** + * Devuelve un listado de tickets con parámetros relativos a la producción de los días en rango + * + * @param vWarehouseFk Identificador de vn.warehouse + * @param vScopeDays Número de días desde hoy en adelante que entran en el cálculo. + * + * @return Table tmp.productionBuffer + */ + DECLARE vEndingDate DATETIME DEFAULT TIMESTAMPADD(DAY, LEAST(1,vScopeDays), util.dayEnd(util.VN_CURDATE())); DECLARE vIsTodayRelative BOOLEAN; + # Se comenta el IF para poder depurar (redmine #4537) + # IF vWarehouseFk <> 60 OR vScopeDays > 2 OR vScopeDays < 0 THEN + CALL util.debugAdd('productionControl', CONCAT('wh: ', vWarehouseFk, ' sd: ', vScopeDays)); + # END IF; + SELECT isTodayRelative INTO vIsTodayRelative - FROM vn.worker + FROM vn.worker WHERE userFk = vn.getUser(); - CALL vn.prepareTicketList(TIMESTAMPADD(DAY,-1,CURDATE()), vEndingDate); + CALL vn.prepareTicketList(TIMESTAMPADD(DAY, -1, util.VN_CURDATE()), vEndingDate); - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - CREATE TEMPORARY TABLE tmp.ticket + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket SELECT * FROM tmp.productionTicket; - + CALL vn.prepareClientList(); - DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems; - CREATE TEMPORARY TABLE tmp.sale_getProblems + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) ENGINE = MEMORY SELECT tt.ticketFk, tt.clientFk, t.warehouseFk, t.shipped FROM tmp.productionTicket tt JOIN vn.ticket t ON t.id = tt.ticketFk; - + CALL vn.ticket_getProblems(vIsTodayRelative); - - DROP TEMPORARY TABLE IF EXISTS tmp.productionBuffer; - CREATE TEMPORARY TABLE tmp.productionBuffer + + CREATE OR REPLACE TEMPORARY TABLE tmp.productionBuffer (PRIMARY KEY(ticketFk)) ENGINE = MEMORY - SELECT tt.ticketFk - , tt.clientFk - , t.warehouseFk - , t.nickname - , t.packages - , IF(HOUR(t.shipped), HOUR(t.shipped), IFNULL(HOUR(zc.hour),HOUR(z.hour))) as HH - , IFNULL(HOUR(zc.hour),HOUR(z.hour)) as Departure - , IF(MINUTE(t.shipped), MINUTE(t.shipped), IFNULL(MINUTE(zc.hour), MINUTE(z.hour))) as mm - , t.routeFk - , IF(am.deliveryMethodFk = 2,z.`id`,0) as zona - , t.nickname addressNickname - , a.postalCode - , a.city - , p.name province - , CONCAT(z.`name`,' ',IFNULL(RIGHT(t.routeFk,3),'')) agency - , am.id agencyModeFk - , 0 AS `lines` - , CAST( 0 AS DECIMAL(5,2)) AS m3 - , CAST( 0 AS DECIMAL(5,2)) AS preparationRate - , "" as problem - , IFNULL(tls.state,2) AS state - , w.code workerCode - , DATE(t.shipped) shipped - , wk.code AS salesPersonCode - , p.id provinceFk - , tls.productionOrder - , ifnull(tls.alertLevel,0) alertLevel - , t.isBoxed as palletized - , IF(rm.isPickingAllowed ,rm.bufferFk, NULL) ubicacion - , tlu.lastUpdated - , ifnull(st.graphCategory,0) graphCategory - , pk.code as parking - , 0 AS H - , 0 AS V - , 0 AS N - , st.isOk - , ag.isOwn - , rm.bufferFk + SELECT tt.ticketFk, + tt.clientFk, + t.warehouseFk, + t.nickname, + t.packages, + IF(HOUR(t.shipped), HOUR(t.shipped),COALESCE(HOUR(zc.hour),HOUR(z.hour))) HH, + COALESCE(HOUR(zc.hour),HOUR(z.hour)) Departure, + COALESCE(MINUTE(t.shipped), MINUTE(zc.hour), MINUTE(z.hour)) mm, + t.routeFk, + IF(am.deliveryMethodFk = 2,z.`id`,0) zona, + t.nickname addressNickname, + a.postalCode, + a.city, + p.name province, + CONCAT(z.`name`,' ',IFNULL(RIGHT(t.routeFk,3),'')) agency, + am.id agencyModeFk, + 0 `lines`, + CAST( 0 AS DECIMAL(5,2)) m3, + CAST( 0 AS DECIMAL(5,2)) preparationRate, + "" problem, + IFNULL(tls.state,2) state, + w.code workerCode, + DATE(t.shipped) shipped, + wk.code salesPersonCode, + p.id provinceFk, + tls.productionOrder, + IFNULL(tls.alertLevel,0) alertLevel, + t.isBoxed palletized, + IF(rm.isPickingAllowed ,rm.bufferFk, NULL) ubicacion, + tlu.lastUpdated, + ifnull(st.graphCategory,0) graphCategory, + pk.code parking, + 0 H, + 0 V, + 0 N, + st.isOk, + ag.isOwn, + rm.bufferFk FROM tmp.productionTicket tt JOIN vn.ticket t on tt.ticketFk = t.id LEFT JOIN vn.ticketStateToday tst ON tst.ticket = t.id @@ -62754,55 +62526,56 @@ proc: BEGIN JOIN vn.address a on a.id = t.addressFk LEFT JOIN vn.province p on p.id = a.provinceFk JOIN vn.agencyMode am ON am.id = t.agencyModeFk - JOIN vn.agency ag ON ag.id = am.agencyFk + JOIN vn.agency ag ON ag.id = am.agencyFk LEFT JOIN vn.ticketState tls on tls.ticket = tt.ticketFk LEFT JOIN vn.ticketLastUpdated tlu ON tlu.ticketFk = tt.ticketFk LEFT JOIN vn.worker w on w.id = tls.worker - LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN vn.zone z ON z.id = t.zoneFk - LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND date(t.shipped) = zc.dated + LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk + LEFT JOIN vn.`zone` z ON z.id = t.zoneFk + LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk + AND DATE(t.shipped) = zc.dated LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id LEFT JOIN vn.parking pk ON pk.id = tp.parkingFk WHERE t.warehouseFk = vWarehouseFk AND am.deliveryMethodFk IN (1,2,3); - - -- Problemas por ticket - ALTER TABLE tmp.productionBuffer + + # Problemas por ticket + ALTER TABLE tmp.productionBuffer CHANGE COLUMN `problem` `problem` VARCHAR(255), ADD COLUMN `collectionH` INT, ADD COLUMN `collectionV` INT, ADD COLUMN `collectionN` INT; - + UPDATE tmp.productionBuffer pb JOIN tmp.ticket_problems tp ON tp.ticketFk = pb.ticketFk SET pb.problem = TRIM(CAST(CONCAT( IFNULL(tp.itemShortage,''), - IFNULL(tp.itemDelay,''), - IFNULL(tp.itemLost,''), - IF(tp.isFreezed,' CONGELADO',''), - IF(tp.hasHighRisk,' RIESGO',''), - IF(tp.hasTicketRequest, ' COD 100',''), - IF(tp.isTaxDataChecked, '',' FICHA INCOMPLETA'), - IF(tp.hasComponentLack,' COMPONENTES', ''), - IF(HOUR(NOW()) < pb.HH AND tp.isTooLittle,' PEQUEÑO', '') - ) as char(255))); - - -- Clientes Nuevos o Recuperados + IFNULL(tp.itemDelay,''), + IFNULL(tp.itemLost,''), + IF(tp.isFreezed,' CONGELADO',''), + IF(tp.hasHighRisk,' RIESGO',''), + IF(tp.hasTicketRequest, ' COD 100',''), + IF(tp.isTaxDataChecked, '',' FICHA INCOMPLETA'), + IF(tp.hasComponentLack,' COMPONENTES', ''), + IF(HOUR(util.VN_NOW()) < pb.HH AND tp.isTooLittle,' PEQUEÑO', '') + ) AS char(255))); + + # Clientes Nuevos o Recuperados UPDATE tmp.productionBuffer pb LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = pb.clientFk JOIN vn.productionConfig pc SET pb.problem = TRIM(CAST(CONCAT('NUEVO ', pb.problem) AS CHAR(255))) WHERE (ISNULL(cnb.clientFk) OR cnb.isRookie) AND pc.rookieDays; - - -- Líneas y volumen por ticket + + # Líneas y volumen por ticket UPDATE tmp.productionBuffer pb JOIN ( SELECT tt.ticketFk, - COUNT(*) as `lines`, - sum(sv.volume) as m3, - IFNULL(sum(IF(sv.isPicked,sv.volume,0)) / sum(sv.volume),0) as rate + COUNT(*) `lines`, + SUM(sv.volume) m3, + IFNULL(SUM(IF(sv.isPicked,sv.volume,0)) / SUM(sv.volume),0) rate FROM tmp.productionTicket tt - JOIN vn.saleVolume sv on sv.ticketFk = tt.ticketFk + JOIN vn.saleVolume sv ON sv.ticketFk = tt.ticketFk GROUP BY tt.ticketFk ) m on m.ticketFk = pb.ticketFk SET pb.`lines` = m.`lines`, @@ -62812,63 +62585,62 @@ proc: BEGIN DELETE FROM tmp.productionBuffer WHERE `lines`= 0; - -- Lineas por linea de encajado + # Lineas por linea de encajado UPDATE tmp.productionBuffer pb - JOIN ( SELECT ticketFk, - sum(sub.H) H, - sum(sub.V) V, - sum(sub.N) N + JOIN ( SELECT ticketFk, + SUM(sub.H) H, + SUM(sub.V) V, + SUM(sub.N) N FROM ( SELECT t.ticketFk, - sum(i.itemPackingTypeFk = 'H') H, - sum(i.itemPackingTypeFk = 'V') V, - sum(ISNULL(i.itemPackingTypeFk)) N + SUM(i.itemPackingTypeFk = 'H') H, + SUM(i.itemPackingTypeFk = 'V') V, + SUM(ISNULL(i.itemPackingTypeFk)) N FROM tmp.productionTicket t JOIN vn.sale s ON s.ticketFk = t.ticketFk JOIN vn.item i ON i.id = s.itemFk - GROUP BY t.ticketFk, i.itemPackingTypeFk) sub + GROUP BY t.ticketFk, i.itemPackingTypeFk) sub GROUP BY ticketFk - ) sub2 ON sub2.ticketFk = pb.ticketFk + ) sub2 ON sub2.ticketFk = pb.ticketFk SET pb.H = sub2.H, pb.V = sub2.V, pb.N = sub2.N; - - -- Colecciones segun tipo de encajado + # Colecciones segun tipo de encajado UPDATE tmp.productionBuffer pb JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk - SET pb.collectionH = IF(pb.H,tc.collectionFk,NULL), + SET pb.collectionH = IF(pb.H,tc.collectionFk,NULL), pb.collectionV = IF(pb.V,tc.collectionFk,NULL), pb.collectionN = IF(pb.N,tc.collectionFk,NULL); - - -- Previa pendiente + + # Previa pendiente ALTER TABLE tmp.productionBuffer ADD previousWithoutParking BOOL DEFAULT FALSE; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketWithPrevia; - CREATE TEMPORARY TABLE tmp.ticketWithPrevia + + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketWithPrevia (ticketFk INT PRIMARY KEY, salesCount INT DEFAULT 0, salesInParkingCount INT DEFAULT 0) ENGINE = MEMORY; --- Insertamos todos los tickets que tienen productos parkineados en sectores de previa, segun el sector + # Insertamos todos los tickets que tienen productos parkineados + # en sectores de previa, segun el sector INSERT INTO tmp.ticketWithPrevia(ticketFk, salesCount) SELECT pb.ticketFk, COUNT(DISTINCT s.id) - FROM tmp.productionBuffer pb + FROM tmp.productionBuffer pb JOIN vn.sale s ON s.ticketFk = pb.ticketFk JOIN vn.itemShelvingStock iss ON iss.itemFk = s.itemFk JOIN vn.sector sc ON sc.id = iss.sectorFk JOIN vn.item i ON i.id = iss.itemFk WHERE iss.isPreviousPrepared - AND (ISNULL(sc.itemPackingTypeFk) + AND (ISNULL(sc.itemPackingTypeFk) OR (ISNULL(i.itemPackingTypeFk) AND NOT pb.V) OR sc.itemPackingTypeFk = i.itemPackingTypeFk ) GROUP BY pb.ticketFk; - - -- Se calcula la cantidad de productos que estan ya preparados porque su saleGroup está aparcado + + # Se calcula la cantidad de productos que estan ya preparados porque su saleGroup está aparcado UPDATE tmp.ticketWithPrevia twp - JOIN ( SELECT pb.ticketFk, count(DISTINCT s.id) salesInParkingCount + JOIN ( SELECT pb.ticketFk, COUNT(DISTINCT s.id) salesInParkingCount FROM tmp.productionBuffer pb JOIN vn.sale s ON s.ticketFk = pb.ticketFk JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id @@ -62877,43 +62649,42 @@ proc: BEGIN GROUP BY pb.ticketFk ) sub ON twp.ticketFk = sub.ticketFk SET twp.salesInParkingCount = sub.salesInParkingCount; - -- Marcamos como pendientes aquellos que no coinciden las cantidades - UPDATE tmp.productionBuffer pb + # Marcamos como pendientes aquellos que no coinciden las cantidades + UPDATE tmp.productionBuffer pb JOIN tmp.ticketWithPrevia twp ON twp.ticketFk = pb.ticketFk SET pb.previousWithoutParking = TRUE WHERE twp.salesCount > twp.salesInParkingCount; - + DROP TEMPORARY TABLE tmp.productionTicket; DROP TEMPORARY TABLE tmp.ticket; DROP TEMPORARY TABLE tmp.risk; DROP TEMPORARY TABLE tmp.ticket_problems; DROP TEMPORARY TABLE tmp.ticketWithPrevia; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `productionSectorList` */; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `productionSectorList`(vSectorFk INT) BEGIN - + /** * Devuelve el listado de vn.sale que se puede preparar en previa para ese sector - * + * * @param vSectorFk Identificador de vn.sector */ - + DECLARE vWarehouseFk INT; SELECT warehouseFk INTO vWarehouseFk @@ -62921,30 +62692,30 @@ BEGIN WHERE id = vSectorFk; DROP TEMPORARY TABLE IF EXISTS tmp.whiteTicket; - CREATE TEMPORARY TABLE tmp.whiteTicket + CREATE TEMPORARY TABLE tmp.whiteTicket (ticketFk INT PRIMARY KEY) SELECT s.ticketFk , count(*) AS saleNum, sum(ISNULL(i.itemPackingTypeFk)) iptNull FROM vn.sale s JOIN vn.item i ON i.id = s.itemFk JOIN vn.ticket t ON t.id = s.ticketFk - WHERE t.shipped BETWEEN CURDATE() AND TIMESTAMPADD(HOUR, 23, CURDATE()) + WHERE t.shipped BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(HOUR, 23, util.VN_CURDATE()) GROUP BY s.ticketFk HAVING saleNum = iptNull; - + DROP TEMPORARY TABLE IF EXISTS tmp.sectorTypeTicket; - CREATE TEMPORARY TABLE tmp.sectorTypeTicket + CREATE TEMPORARY TABLE tmp.sectorTypeTicket (ticketFk INT PRIMARY KEY) SELECT s.ticketFk , sum(i.itemPackingTypeFk <=> sc.itemPackingTypeFk) iptSector FROM vn.sale s JOIN vn.item i ON i.id = s.itemFk JOIN vn.ticket t ON t.id = s.ticketFk JOIN vn.sector sc ON sc.id = vSectorFk - WHERE t.shipped BETWEEN CURDATE() AND TIMESTAMPADD(HOUR, 23, CURDATE()) + WHERE t.shipped BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(HOUR, 23, util.VN_CURDATE()) GROUP BY s.ticketFk HAVING iptSector; CALL vn.productionControl(vWarehouseFk, 0); - + SELECT 0,999999,0 INTO @sameTicket, @ticket, @litrosTicket; SELECT @litrosTicket := IF(sub.ticketFk = @ticket, @litrosTicket + Litros, Litros) as LitrosTicket, @@ -62992,37 +62763,35 @@ BEGIN LEFT JOIN tmp.sectorTypeTicket stt ON stt.ticketFk = isa.ticketFk JOIN vn.client c ON c.id = t.clientFk JOIN tmp.productionBuffer pb ON pb.ticketFk = t.id - JOIN vn.packagingConfig pc - WHERE IF(s.isPreviousPreparedByPacking, - i.`size` > pc.previousPreparationMinimumSize - AND isa.packing > 1 + JOIN vn.packagingConfig pc + WHERE IF(s.isPreviousPreparedByPacking, + i.`size` > pc.previousPreparationMinimumSize + AND isa.packing > 1 AND (MOD(TRUNCATE(isa.quantity,0), isa.packing)= 0 ), TRUE) AND isa.sectorFk = vSectorFk AND isa.quantity > 0 AND pb.problem = "" - AND (i.itemPackingTypeFk <=> s.itemPackingTypeFk + AND (i.itemPackingTypeFk <=> s.itemPackingTypeFk OR ISNULL(s.itemPackingTypeFk) OR wt.ticketFk OR (stt.ticketFk AND ISNULL(i.itemPackingTypeFk))) GROUP BY saleFk HAVING isa.quantity <= totalAvailable ) sub2 - ORDER BY Hora, Minuto, ticketFk + ORDER BY Hora, Minuto, ticketFk LIMIT 10000000000000000000 ) sub ; DROP TEMPORARY TABLE tmp.whiteTicket; DROP TEMPORARY TABLE tmp.sectorTypeTicket; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `rangeDateInfo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63030,6 +62799,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `rangeDateInfo`(vStarted DATE, vEnded DATE) BEGIN @@ -63052,7 +62823,7 @@ BEGIN `yearMonth` INT ) ENGINE = MEMORY; - + WHILE vDated <= vEnded DO INSERT INTO tmp.rangeDate SET `dated` = vDated, @@ -63062,7 +62833,7 @@ BEGIN `day` = DAY(vDated), `week` = WEEK(vDated, 1), `yearMonth` = YEAR(vDated) * 100 + MONTH(vDated); - + SET vDated = DATE_ADD(vDated, INTERVAL 1 DAY); END WHILE; END ;; @@ -63071,8 +62842,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `rankingTeamByQuarter` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63080,19 +62849,21 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `rankingTeamByQuarter`(vYear INT, vQuarter INT) BEGIN DECLARE vMinimumSalesByQuarter INT; - + SELECT minimumSalesByQuarter INTO vMinimumSalesByQuarter FROM commissionConfig; - + DROP TEMPORARY TABLE IF EXISTS tmp.rankingTeam; CREATE TEMPORARY TABLE tmp.rankingTeam - (PRIMARY KEY(departmentFk)) ENGINE = MEMORY - SELECT + (PRIMARY KEY(departmentFk)) ENGINE = MEMORY + SELECT (sub1.importe - sub2.importe) / IF ((sub1.importe - sub2.importe) > 0,sub3.countPeople,1) AS diferencia, CONCAT(sub1.name, '(', @@ -63102,14 +62873,14 @@ BEGIN ')') AS teamPeople, sub1.departmentFk AS departmentFk FROM - (((SELECT + (((SELECT SUM(sub.importe) AS importe, sub.name AS name, sub.año AS año, sub.departmentFk AS departmentFk, COUNT(*) peopleMinSale FROM - (SELECT + (SELECT SUM(v.portfolioWeight) AS importe, d.`name`, v.año, @@ -63124,7 +62895,7 @@ BEGIN GROUP BY v.Id_Trabajador HAVING importe >= vMinimumSalesByQuarter) sub GROUP BY sub.departmentFk) sub1 - JOIN (SELECT + JOIN (SELECT SUM(v.portfolioWeight) AS importe, d.name, wd.departmentFk @@ -63152,8 +62923,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `rate_getPrices` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63161,6 +62930,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `rate_getPrices`(vDated DATE, vWarehouseFk INT) BEGIN @@ -63170,7 +62941,7 @@ BEGIN * @param vDated fecha para la cual calcula la tarifa * @param vWarehouseFk warehouse para el cual calcula la tafia * @return tmp.rate(rate0, rate1, rate2, rate3) - */ + */ DROP TEMPORARY TABLE IF EXISTS tRate; CREATE TEMPORARY TABLE tRate SELECT rate0, rate1, rate2, rate3 @@ -63178,13 +62949,13 @@ BEGIN WHERE dated <= vDated AND warehouseFk = vWarehouseFk ORDER BY dated DESC; - + DROP TEMPORARY TABLE IF EXISTS tmp.rate; CREATE TEMPORARY TABLE tmp.rate ENGINE = MEMORY SELECT * FROM ( - SELECT * FROM tRate + SELECT * FROM tRate UNION ALL SELECT rate0, rate1, rate2, rate3 FROM rateConfig ) sub2 @@ -63196,8 +62967,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `rate_getPrices2` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63205,6 +62974,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `rate_getPrices2`(vLanded DATE, vWarehouseFk INT) BEGIN @@ -63217,13 +62988,13 @@ BEGIN WHERE dated <= vLanded AND warehouseFk = vWarehouseFk ORDER BY dated DESC; - + DROP TEMPORARY TABLE IF EXISTS tmp.rate; CREATE TEMPORARY TABLE tmp.rate ENGINE = MEMORY SELECT * FROM ( - SELECT * FROM tRate + SELECT * FROM tRate UNION ALL SELECT rate0, rate1, rate2, rate3 FROM rateConfig ) sub2 @@ -63235,8 +63006,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `recipe_Cook` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63244,6 +63013,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `recipe_Cook`(vItemFk INT, vBunchesQuantity INT, vDate DATE) BEGIN @@ -63257,7 +63028,7 @@ BEGIN CALL cache.available_refresh(vCalc, FALSE, vWarehouseFk, vDate); DROP TEMPORARY TABLE IF EXISTS tmp.recipeCook; - + CREATE TEMPORARY TABLE tmp.recipeCook SELECT *, @counter := IF(@element = element COLLATE utf8_general_ci , @counter + 1, 1) as counter, @@ -63275,22 +63046,22 @@ BEGIN IFNULL((i.inkFk = r.inkFk ) ,0) + IFNULL((i.size = r.size) ,0) + IFNULL((i.name LIKE CONCAT('%',r.name,'%')) ,0) - + IFNULL((i.longName LIKE CONCAT('%',r.longName,'%')),0) + + IFNULL((i.longName LIKE CONCAT('%',r.longName,'%')),0) + IFNULL((i.typeFk = r.typeFk),0) as matches, i.typeFk, rl.previousSelected - FROM vn.recipe r + FROM vn.recipe r JOIN vn.item i ON (IFNULL(i.name LIKE CONCAT('%',r.name,'%'), 0) OR IFNULL(i.longName LIKE CONCAT('%',r.longName,'%'),0)) OR i.typeFk <=> r.typeFk JOIN cache.available a ON a.item_id = i.id AND a.calc_id = vCalc LEFT JOIN (SELECT recipe_ItemFk, element as log_element, selected_ItemFk, count(*) as previousSelected FROM vn.recipe_log - GROUP BY recipe_ItemFk, element, selected_ItemFk) rl ON rl.recipe_ItemFk = r.itemFk + GROUP BY recipe_ItemFk, element, selected_ItemFk) rl ON rl.recipe_ItemFk = r.itemFk AND rl.log_element = r.element AND rl.selected_ItemFk = i.id WHERE r.itemFk = vItemFk - AND a.available > vBunchesQuantity * r.quantity + AND a.available > vBunchesQuantity * r.quantity UNION ALL SELECT 100 itemFk, CONCAT('? ',r.element,' ',IFNULL(r.size,''),' ',IFNULL(r.inkFk,'')) as longName, @@ -63307,23 +63078,21 @@ BEGIN WHERE r.itemFk = vItemFk GROUP BY r.element ) sub - + ORDER BY element, matches DESC, previousSelected DESC; - - SELECT * + + SELECT * FROM tmp.recipeCook WHERE counter < 6 - OR itemFk = 100 + OR itemFk = 100 ; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `recipe_Plaster` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63331,6 +63100,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `recipe_Plaster`(vItemFk INT, vTicketFk INT, vQuantity INT) BEGIN @@ -63340,71 +63111,71 @@ BEGIN DECLARE vShipped DATE; DECLARE vEntryFk INT; DECLARE vTravelFk INT; - + CALL cache.last_buy_refresh(FALSE); - - SELECT warehouseFk, shipped + + SELECT warehouseFk, shipped INTO vWarehouseFk, vShipped - FROM vn.ticket + FROM vn.ticket WHERE id = vTicketFk; UPDATE vn.ticket t JOIN vn.item i ON i.id = vItemFk SET t.nickname = CONCAT(vQuantity,' ',i.longName) WHERE t.id = vTicketFk; - + SELECT b.buyingValue INTO vLastCost FROM vn.buy b JOIN cache.last_buy lb ON lb.buy_id = b.id WHERE lb.item_id = vItemFk ORDER BY (lb.warehouse_id = vWarehouseFk) DESC LIMIT 1; - + INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price) SELECT vTicketFk, 98, - vQuantity, i.longName, vLastCost FROM vn.item i WHERE i.id = vItemFk; - /* + /* SELECT tr.id INTO vTravelFk FROM vn.travel tr JOIN vn.warehouse w ON w.id = tr.warehouseOutFk WHERE tr.warehouseInFk = vWarehouseFk AND tr.landed = vShipped AND w.name = 'Confeccion'; - + IF IFNULL(vTravelFk,0) = 0 THEN - + INSERT INTO vn.travel(shipped, landed, warehouseInFk, warehouseOutFk, agencyFk) SELECT vShipped, vShipped, vWarehouseFk, w.id, am.id - FROM vn.warehouse w - JOIN vn.agencyMode am + FROM vn.warehouse w + JOIN vn.agencyMode am WHERE w.name = 'Confeccion' AND am.name = 'DIRECTO PROVEEDOR'; - + SET vTravelFk = LAST_INSERT_ID(); - - END IF; - + + END IF; + SELECT e.id INTO vEntryFk FROM vn.entry e JOIN vn.supplier s ON s.id = supplierFk WHERE e.travelFk = vTravelFk AND s.name = 'Confeccion Natural' AND e.isRaid = FALSE; - + IF IFNULL(vEntryFk,0) = 0 THEN - + INSERT INTO vn.entry(supplierFk, evaNotes, travelFk, companyFk) SELECT s.id, t.nickname, vTravelFk, c.id FROM vn.supplier s JOIN vn.ticket t ON t.id = vTicketFk - JOIN vn.company c ON c.code = 'VNL' + JOIN vn.company c ON c.code = 'VNL' WHERE s.name = 'Confeccion Natural'; - + SET vEntryFk = LAST_INSERT_ID(); - + END IF; - + INSERT INTO vn.buy(entryFk, itemFk, quantity, buyingValue, packageFk, packing, grouping) SELECT vEntryFk, b.itemFk, vQuantity, b.buyingValue, b.packageFk, b.packing, b.grouping FROM cache.last_buy lb @@ -63419,19 +63190,19 @@ 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `refund` */; /*!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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `refund`(IN vOriginTicket INT, OUT vNewTicket INT) BEGIN - + DECLARE vDone BIT DEFAULT 0; DECLARE vCustomer MEDIUMINT; DECLARE vWarehouse TINYINT; @@ -63446,26 +63217,26 @@ BEGIN DECLARE vSaleNew INT; DECLARE vSaleMain INT; DECLARE vZoneFk INT; - + DECLARE vRsMainTicket CURSOR FOR SELECT id, itemFk, - quantity, concept, price, discount - FROM vn.sale + FROM vn.sale WHERE ticketFk = vOriginTicket; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; - + SELECT id INTO vRefundAgencyMode FROM agencyMode WHERE `name` = 'ABONO'; - SELECT clientFk, warehouseFk, companyFk, addressFk + SELECT clientFk, warehouseFk, companyFk, addressFk INTO vCustomer, vWarehouse, vCompany, vAddress - FROM ticket + FROM ticket WHERE id = vOriginTicket; - - SELECT id INTO vZoneFk + + SELECT id INTO vZoneFk FROM zone WHERE agencyModeFk = vRefundAgencyMode LIMIT 1; - + INSERT INTO vn2008.Tickets ( Id_Cliente, Fecha, @@ -63479,39 +63250,39 @@ BEGIN ) SELECT vCustomer, - CURDATE(), + util.VN_CURDATE(), vAddress, vRefundAgencyMode, a.nickname, vWarehouse, vCompany, - CURDATE(), + util.VN_CURDATE(), vZoneFk FROM address a WHERE a.id = vAddress; SET vNewTicket = LAST_INSERT_ID(); - SET vDone := 0; + SET vDone := 0; OPEN vRsMainTicket ; FETCH vRsMainTicket INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; WHILE NOT vDone DO - + INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount) VALUES( vNewTicket, vItemFk, vQuantity, vConcept, vPrice, vDiscount ); - + SET vSaleNew = LAST_INSERT_ID(); - - INSERT INTO vn.saleComponent(saleFk,componentFk,`value`) - SELECT vSaleNew,componentFk,`value` - FROM vn.saleComponent + + INSERT INTO vn.saleComponent(saleFk,componentFk,`value`) + SELECT vSaleNew,componentFk,`value` + FROM vn.saleComponent WHERE saleFk = vSaleMain; - + FETCH vRsMainTicket INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; - + END WHILE; - CLOSE vRsMainTicket; + CLOSE vRsMainTicket; END ;; DELIMITER ; @@ -63519,8 +63290,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `replaceMovimientosMark` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63528,6 +63297,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `replaceMovimientosMark`( idMovimiento INT, @@ -63546,20 +63317,18 @@ BEGIN * usar vn.saleTracking_Replace * */ - - REPLACE INTO vn2008.Movimientos_mark(Id_Movimiento, valor, original_quantity, Id_Trabajador, stateFk) + + REPLACE INTO vn2008.Movimientos_mark(Id_Movimiento, valor, original_quantity, Id_Trabajador, stateFk) VALUES(idMovimiento,detalle,originalQuantity,idTrabajador,stateFk); - /*INSERT INTO vn.ticketLog (originFk, userFk, action , description) + /*INSERT INTO vn.ticketLog (originFk, userFk, action , description) VALUES(originFk, userFk, actionString, description);*/ - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `reportLabelCollection_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63567,9 +63336,11 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `reportLabelCollection_get`(vParam INT) -BEGIN +BEGIN /** * Obtiene los datos de etiquetas a partir de de un ticket o colección. * @@ -63578,7 +63349,7 @@ BEGIN DECLARE vIsCollection BOOL; SELECT IF(id, TRUE, FALSE) INTO vIsCollection - FROM vn.collection c + FROM vn.collection c WHERE id = vParam; SELECT c.itemPackingTypeFk, @@ -63599,11 +63370,11 @@ BEGIN FROM ticket t JOIN ticketCollection tc ON tc.ticketFk = t.id JOIN collection c ON c.id = tc.collectionFk - JOIN collectionColors cc ON cc.shelve = tc.`level` + LEFT JOIN collectionColors cc ON cc.shelve = tc.`level` AND cc.wagon = tc.wagon AND cc.trainFk = c.trainFk JOIN sale s ON s.ticketFk = t.id - LEFT JOIN saleVolume sv ON sv.saleFk = s.id + LEFT JOIN saleVolume sv ON sv.saleFk = s.id JOIN item i ON i.id = s.itemFk JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk @@ -63612,7 +63383,7 @@ BEGIN LEFT JOIN ticketTrolley tt ON tt.ticket = t.id LEFT JOIN `zone` zo ON t.zoneFk = zo.id LEFT JOIN routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN expeditionTruck et ON et.id = rm.expeditionTruckFk + LEFT JOIN expeditionTruck et ON et.id = rm.expeditionTruckFk WHERE IF(vIsCollection, tc.collectionFk = vParam, tc.ticketFk = vParam) GROUP BY t.id ORDER BY cc.`code`; @@ -63622,8 +63393,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `riskAllClients` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63631,19 +63400,21 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `riskAllClients`(maxRiskDate DATE) BEGIN - + DROP TEMPORARY TABLE IF EXISTS tmp.client_list; CREATE TEMPORARY TABLE tmp.client_list (PRIMARY KEY (Id_Cliente)) ENGINE = MEMORY SELECT id Id_Cliente, null grade FROM vn.client; - + CALL vn2008.risk_vs_client_list(maxRiskDate); - - SELECT + + SELECT c.RazonSocial, c.Id_Cliente, c.Credito, @@ -63655,7 +63426,7 @@ BEGIN JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente GROUP BY c.Id_cliente; - + DROP TEMPORARY TABLE IF EXISTS tmp.risk; DROP TEMPORARY TABLE IF EXISTS tmp.client_list; END ;; @@ -63664,8 +63435,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `routeGuessPriority` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63673,6 +63442,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `routeGuessPriority`(IN vRuta INT) BEGIN @@ -63685,7 +63456,7 @@ UPDATE ticket mt SELECT tt.addressFk, ROUND(IFNULL(AVG(t.priority),0),0) AS priority FROM ticket t JOIN ticket tt ON tt.addressFk = t.addressFk - WHERE t.shipped > TIMESTAMPADD(YEAR,-1,CURDATE()) + WHERE t.shipped > TIMESTAMPADD(YEAR,-1,util.VN_CURDATE()) AND tt.routeFk = vRuta GROUP BY addressFk ) sub ON sub.addressFk = mt.addressFk @@ -63697,8 +63468,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `routeInfo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63706,6 +63475,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `routeInfo`(vRouteFk INT) BEGIN @@ -63714,25 +63485,25 @@ BEGIN DECLARE vM3 INT; DECLARE vKg INT; DECLARE vMatricula varchar(50); - + SELECT sum(packages) as bultos INTO vPackages - FROM vn.ticket t + FROM vn.ticket t WHERE routeFk = vRouteFk; - + SELECT SUM(sv.physicalVolume), SUM(sv.physicalWeight) INTO vM3, vKg FROM vn.saleVolume sv WHERE sv.routeFk = vRouteFk; - + SELECT v.numberPlate as matricula INTO vMatricula - FROM vn.route r + FROM vn.route r JOIN vn.vehicle v ON r.vehicleFk = v.id WHERE r.id = vRouteFk; - + SELECT vRouteFk as Ruta, - vPackages as Bultos, + vPackages as Bultos, vM3 as m3, vKg as Kg, vMatricula as Matricula; @@ -63743,8 +63514,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `routeMonitor_calculate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63752,6 +63521,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `routeMonitor_calculate`(vDate DATE) BEGIN @@ -63762,12 +63533,12 @@ BEGIN SET vDate = TIMESTAMPADD(DAY,-1,vDate); DROP TEMPORARY TABLE IF EXISTS tmp.routesMonitor; - + CREATE TEMPORARY TABLE tmp.routesMonitor (INDEX (routeFk)) ENGINE = MEMORY SELECT DISTINCT(t.routeFk) routeFk - FROM vn.ticket t + FROM vn.ticket t WHERE t.shipped BETWEEN vDate AND vDateEND AND t.routeFk IS NOT NULL; @@ -63778,7 +63549,7 @@ BEGIN UPDATE routesMonitor rm JOIN route r ON r.id = rm.routeFk JOIN agencyMode a ON a.id = r.agencyModeFk - SET rm.`name` = a.name, + SET rm.`name` = a.name, rm.ticketFree = 0, rm.ticketProduction = 0, rm.ticketPacked = 0, @@ -63795,7 +63566,7 @@ BEGIN ) sub ON sub.routeFk = rm.routeFk SET rm.ticketFree = sub.ticketFree; - UPDATE routesMonitor rm + UPDATE routesMonitor rm JOIN(SELECT t.routeFk, COUNT(*) AS ticketPacked FROM vn.ticket t JOIN tmp.routesMonitor rm ON rm.routeFk = t.routeFk @@ -63803,7 +63574,7 @@ BEGIN JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk JOIN state s ON s.id = tt.stateFk AND s.alertLevel = 2 GROUP BY t.routeFk - ) sub ON sub.routeFk = rm.routeFk + ) sub ON sub.routeFk = rm.routeFk SET rm.ticketPacked = sub.ticketPacked; UPDATE routesMonitor rm @@ -63830,7 +63601,7 @@ BEGIN JOIN( SELECT t.routeFk, SUM(sv.volume) AS m3 FROM vn.ticket t JOIN tmp.routesMonitor rm ON rm.routeFk = t.routeFk - JOIN vn.saleVolume sv ON sv.ticketFk = t.id + JOIN vn.saleVolume sv ON sv.ticketFk = t.id GROUP BY t.routeFk ) sub ON sub.routeFk = rm.routeFk SET rm.m3 = sub.m3; @@ -63840,15 +63611,15 @@ BEGIN FROM vn.ticket t JOIN tmp.routesMonitor rm ON rm.routeFk = t.routeFk JOIN vn.expedition e ON e.ticketFk = t.id - JOIN vn.packaging pk ON pk.id = e.packagingFk + JOIN vn.packaging pk ON pk.id = e.packagingFk GROUP BY t.routeFk - ) sub ON sub.routeFk = rm.routeFk - SET rm.m3boxes = sub.m3boxes; + ) sub ON sub.routeFk = rm.routeFk + SET rm.m3boxes = sub.m3boxes; UPDATE routesMonitor rm - JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk + JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk SET rm.etd = et.ETD; - + DROP TEMPORARY TABLE tmp.routesMonitor; END ;; DELIMITER ; @@ -63856,8 +63627,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `routeSetOk` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63865,23 +63634,23 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `routeSetOk`( vRouteFk INT) BEGIN - + UPDATE vn.route r SET r.isOk = 1 WHERE r.id = vRouteFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `routeUpdateM3` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63889,6 +63658,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `routeUpdateM3`(vRoute INT) BEGIN @@ -63902,8 +63673,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `route_calcCommission` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63911,6 +63680,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `route_calcCommission`(vSelf INT) proc: BEGIN @@ -63931,11 +63702,10 @@ proc: BEGIN DELETE FROM routeCommission WHERE routeFk = vSelf; - SELECT wl.workerFk IS NULL INTO vIsFreelance + SELECT w.isFreelance INTO vIsFreelance FROM route r - LEFT JOIN workerLabour wl ON wl.workerFk = r.workerFk - WHERE r.id = vSelf - LIMIT 1; + JOIN worker w ON w.id = r.workerFk + WHERE r.id = vSelf; IF vIsFreelance THEN INSERT INTO routeCommission (routeFk, workCenterFk, freelanceYearlyM3) @@ -63947,8 +63717,7 @@ proc: BEGIN JOIN routeConfig rc WHERE r.id = vSelf AND r.workerFk - AND r.commissionWorkCenterFk - AND r.m3; + AND r.commissionWorkCenterFk; ELSE INSERT INTO routeCommission (routeFk, workCenterFk, km, m3, yearlyKm, yearlyM3, cat4m3, cat5m3) SELECT vSelf, @@ -63966,8 +63735,7 @@ proc: BEGIN AND r.kmStart AND r.kmEnd AND r.workerFk - AND r.commissionWorkCenterFk - AND r.m3; + AND r.commissionWorkCenterFk; END IF; END IF; END ;; @@ -63976,8 +63744,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `route_doRecalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63985,13 +63751,15 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `route_doRecalc`() proc: BEGIN /** * Recalculates modified route. */ - + DECLARE vDone BOOL; DECLARE vRouteFk INT; @@ -64000,7 +63768,7 @@ proc: BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN DO RELEASE_LOCK('vn.route_doRecalc'); @@ -64037,8 +63805,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `route_getTickets` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64046,6 +63812,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `route_getTickets`(vRouteFk INT) BEGIN @@ -64058,7 +63826,7 @@ BEGIN * @select Información de los tickets */ - SELECT + SELECT t.id AS Id, t.clientFk AS Client, a.id AS Address, @@ -64083,7 +63851,7 @@ BEGIN JOIN address a ON t.addressFk = a.id LEFT JOIN ticketLocation tl ON tl.ticketFk = t.id LEFT JOIN workerMedia wm ON wm.workerFk = c.salesPersonFk - LEFT JOIN + LEFT JOIN (SELECT tob.description AS Note, t.id FROM ticketObservation tob JOIN ticket t ON tob.ticketFk = t.id @@ -64092,8 +63860,8 @@ BEGIN AND ot.code = 'delivery' )tob ON tob.id = t.id LEFT JOIN stowaway st ON st.shipFk = t.id - LEFT JOIN - (SELECT sub.ticketFk, + LEFT JOIN + (SELECT sub.ticketFk, CONCAT('(', GROUP_CONCAT(DISTINCT sub.itemPackingTypeFk ORDER BY sub.items DESC SEPARATOR ','), ') ') itemPackingTypeFk FROM (SELECT s.ticketFk , i.itemPackingTypeFk, COUNT(*) items FROM ticket t @@ -64112,8 +63880,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `route_updateM3` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64121,6 +63887,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `route_updateM3`(vRoute INT) BEGIN @@ -64139,8 +63907,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `rutasAnalyze` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64148,12 +63914,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `rutasAnalyze`(vYear INT, vMonth INT) BEGIN /* Analiza los costes de las rutas de reparto y lo almacena en la tabla Rutas_Master -* +* * PAK 15/4/2019 */ @@ -64232,7 +64000,7 @@ BEGIN AND z.isVolumetric = FALSE GROUP BY r.id ON DUPLICATE KEY UPDATE Bultos = Bultos + VALUES(Bultos); - + -- Coste REAL de cada bulto "virtual", de acuerdo con el valor apuntado a mano en la ruta UPDATE bi.rutasBoard r INNER JOIN vn2008.Rutas_Master rm ON rm.año = r.year AND rm.mes = r.month AND rm.warehouse_id = r.warehouse_id @@ -64240,8 +64008,8 @@ BEGIN WHERE r.Bultos > 0 AND rm.año = vYear AND rm.mes = vMonth; - - -- Coste PRACTICO de cada bulto, de acuerdo con los componentes de tipo AGENCIA en cada linea de venta + + -- Coste PRACTICO de cada bulto, de acuerdo con los componentes de tipo AGENCIA en cada linea de venta UPDATE bi.rutasBoard r JOIN ( SELECT t.routeFk, sum(s.quantity * sc.value) practicoTotal @@ -64253,16 +64021,16 @@ BEGIN JOIN vn.`component` c ON c.id = sc.componentFk JOIN vn.componentType ct ON ct.id = c.typeFk WHERE ct.type = 'agencia' - AND tm.year = vYear + AND tm.year = vYear AND tm.month = vMonth GROUP BY r.id ) sub ON sub.routeFk = r.Id_Ruta SET r.practico = sub.practicoTotal / r.Bultos; - + -- Coste TEORICO de una caja "virtual" para cada ruta, teniendo en cuenta que hay carros, pallets, etc UPDATE bi.rutasBoard r JOIN ( - SELECT t.routeFk, + SELECT t.routeFk, SUM(t.zonePrice/ ebv.ratio)/ count(*) AS BultoTeoricoMedio FROM vn.ticket t JOIN vn.route r ON r.id = t.routeFk @@ -64272,7 +64040,7 @@ BEGIN JOIN vn.address ad ON ad.id = t.addressFk JOIN vn.client c ON c.id = ad.clientFk LEFT JOIN vn.zone z ON z.id = t.zoneFk - WHERE tm.year = vYear + WHERE tm.year = vYear AND tm.month = vMonth AND z.isVolumetric = FALSE GROUP BY t.routeFk) sub ON r.Id_Ruta = sub.routeFk @@ -64281,7 +64049,7 @@ BEGIN -- Coste VOLUMETRICO TEORICO de una caja "virtual" para cada ruta UPDATE bi.rutasBoard r JOIN ( - SELECT t.routeFk, + SELECT t.routeFk, SUM(freight) AS BultoTeoricoMedio FROM vn.ticket t JOIN vn.route r ON r.id = t.routeFk @@ -64289,7 +64057,7 @@ BEGIN JOIN vn.saleVolume sf ON sf.ticketFk = t.id JOIN vn.client c ON c.id = t.clientFk JOIN vn.zone z ON z.id = t.zoneFk - WHERE tm.year = vYear + WHERE tm.year = vYear AND tm.month = vMonth AND z.isVolumetric != FALSE GROUP BY t.routeFk) sub ON r.Id_Ruta = sub.routeFk @@ -64298,27 +64066,25 @@ BEGIN -- La diferencia entre el teorico y el practico se deberia de cobrar en greuges, cada noche UPDATE bi.rutasBoard r JOIN ( - SELECT t.routeFk, + SELECT t.routeFk, Sum(g.amount) AS greuge FROM vn.ticket t JOIN vn.route r ON r.id = t.routeFk JOIN vn.time tm ON tm.dated = r.created JOIN vn.greuge g ON g.ticketFk = t.id JOIN vn.greugeType gt ON gt.id = g.greugeTypeFk - WHERE tm.year = vYear + WHERE tm.year = vYear AND tm.month = vMonth AND gt.name = 'Diferencia portes' GROUP BY t.routeFk) sub ON r.Id_Ruta = sub.routeFk SET r.greuge = sub.greuge / r.Bultos; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `saleBuy_Add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64326,38 +64092,38 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `saleBuy_Add`(vSaleFk INT, vBuyFk INT) BEGIN - + /* Añade un registro a la tabla saleBuy en el caso de que sea posible mantener la trazabilidad - * + * * @param vSaleFk clave primaria de vn.sale * @param vBuyFk clave primaria de vn.buy */ - /*IF (SELECT COUNT(*) + /*IF (SELECT COUNT(*) FROM vn.sale s JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk WHERE s.id = vSaleFk AND ic.code = 'fruit') THEN */ - - IF (SELECT COUNT(*) FROM vn.buy WHERE id = vBuyFk AND itemOriginalFk) THEN - + + IF (SELECT COUNT(*) FROM vn.buy WHERE id = vBuyFk AND itemOriginalFk) THEN + INSERT INTO vn.saleBuy (saleFk, buyFk) VALUES(vSaleFk, vBuyFk); - + END IF; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `saleGroup_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64365,6 +64131,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `saleGroup_add`(vSectorFk INT) BEGIN @@ -64373,7 +64141,7 @@ BEGIN * * @param vSectorFk Identificador de vn.sector */ - INSERT INTO vn.saleGroup(userFk, sectorFk) + INSERT INTO vn.saleGroup(userFk, sectorFk) VALUES (account.myUser_getId(), vSectorFk); SELECT LAST_INSERT_ID(); @@ -64383,8 +64151,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `saleGroup_setParking` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64392,6 +64158,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `saleGroup_setParking`(IN `vSaleGroupFk` VARCHAR(8), IN `vParkingFk` INT) proc: BEGIN @@ -64404,7 +64172,7 @@ proc: BEGIN UPDATE vn.saleGroup sg SET sg.parkingFk = vParkingFk WHERE sg.id = vSaleGroupFk - AND sg.created >= TIMESTAMPADD(WEEK,-1,CURDATE()); + AND sg.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); CALL vn.ticket_setNextState(vn.ticket_get(vSaleGroupFk)); END ;; @@ -64413,8 +64181,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `saleMistake_Add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64422,6 +64188,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `saleMistake_Add`(vSaleFk INT, vUserFk INT, vTypeFk INT) BEGIN @@ -64435,8 +64203,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `saleMove` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64444,6 +64210,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `saleMove`(IN vSaleFk BIGINT, IN vQuantity BIGINT) BEGIN @@ -64472,19 +64240,19 @@ BEGIN IF vClientTypeFk <> 'handMaking' THEN SELECT t.id INTO vNewTicket - FROM ticket t + FROM ticket t JOIN ticketState ts ON ts.ticketFk = t.id WHERE t.addressFk = vAddressFk - AND t.warehouseFk = vWarehouseFk + AND t.warehouseFk = vWarehouseFk AND t.agencyModeFk = vAgencyModeFk AND t.landed <=> vLanded - AND t.shipped BETWEEN vShipped AND vShippedDayEnd + AND t.shipped BETWEEN vShipped AND vShippedDayEnd AND t.refFk IS NULL AND t.id <> vTicketOriginalFk AND IFNULL(ts.alertLevel,0) = 0 - LIMIT 1; + LIMIT 1; END IF; - + IF vNewTicket IS NULL THEN CALL vn.ticket_Clone(vTicketOriginalFk, vNewTicket); END IF; @@ -64493,41 +64261,39 @@ BEGIN SELECT vNewTicket, account.myUser_getId(), s.id FROM state s WHERE s.code = 'FIXING'; - + SELECT COUNT(id) INTO hasAlreadyItem FROM sale s WHERE s.ticketFk = vNewTicket AND s.itemFk = vItemFk; - + IF hasAlreadyItem = FALSE THEN - - INSERT INTO sale(ticketFk, itemFk, concept, quantity, price, discount) + + INSERT INTO sale(ticketFk, itemFk, concept, quantity, price, discount) SELECT vNewTicket, itemFk, concept, vQuantity, price, discount FROM sale s WHERE s.id = vSaleFk; - + SELECT LAST_INSERT_ID() INTO vNewSale; - + INSERT INTO saleComponent(saleFk, componentFk, `value`) SELECT vNewSale, componentFk, `value` - FROM saleComponent + FROM saleComponent WHERE saleFk = vSaleFk; - + ELSE - UPDATE sale + UPDATE sale SET quantity = quantity + vQuantity WHERE ticketFk = vNewTicket AND itemFk = vItemFk; END IF; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `salePreparingList` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64535,19 +64301,21 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `salePreparingList`(IN ticketFk BIGINT) BEGIN CALL cache.last_buy_refresh(FALSE); - SELECT t.clientFk, - t.shipped, - a.nickname, + SELECT t.clientFk, + t.shipped, + a.nickname, s.ticketFk, - s.itemFk, - s.quantity, - s.concept, + s.itemFk, + s.quantity, + s.concept, s.reserved, s.id saleFk, i.size, @@ -64571,7 +64339,7 @@ BEGIN LEFT JOIN vn.saleTracking stPrepared ON stPrepared.saleFk = s.id AND stPrepared.stateFk = 14 LEFT JOIN vn.saleTracking stControled ON stControled.saleFk = s.id AND stControled.stateFk = 8 LEFT JOIN vn.itemBarcode ib ON ib.itemFk = i.id - WHERE t.id = ticketFk + WHERE t.id = ticketFk GROUP BY s.id; END ;; DELIMITER ; @@ -64579,8 +64347,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `salesMerge` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64588,39 +64354,39 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `salesMerge`(vTicketFk INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.salesToPreserve; - + CREATE TEMPORARY TABLE tmp.salesToPreserve SELECT id, itemFk, sum(quantity) as newQuantity FROM vn.sale s WHERE s.ticketFk = vTicketFk AND s.itemFk NOT IN (95,98,100) GROUP by itemFk, price, discount; - - UPDATE vn.sale s + + UPDATE vn.sale s JOIN tmp.salesToPreserve stp ON stp.id = s.id SET quantity = newQuantity WHERE s.ticketFk = vTicketFk; - + DELETE s.* FROM vn.sale s LEFT JOIN tmp.salesToPreserve stp ON stp.id = s.id WHERE s.ticketFk = vTicketFk AND stp.id IS NULL AND s.itemFk NOT IN (95,98,100); - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `salesMerge_byCollection` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64628,6 +64394,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `salesMerge_byCollection`(vCollectionFk INT) BEGIN @@ -64647,17 +64415,17 @@ BEGIN OPEN cCur; myLoop: LOOP - + SET vDone = FALSE; - + FETCH cCur INTO vTicketFk; IF vDone THEN LEAVE myLoop; END IF; - + CALL vn.salesMerge(vTicketFk); - + END LOOP; CLOSE cCur; @@ -64669,8 +64437,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `saleSplit` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64678,45 +64444,47 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `saleSplit`(vSaleFk INT, vQuantity INT) BEGIN - + DECLARE vNewSaleFk INT; - - INSERT INTO vn.sale(itemFk, - concept, - price, - discount, - quantity, - ticketFk, + + INSERT INTO vn.sale(itemFk, + concept, + price, + discount, + quantity, + ticketFk, isPriceFixed) - SELECT s.itemFk, - i.longName, - s.price, - s.discount, + SELECT s.itemFk, + i.longName, + s.price, + s.discount, vQuantity, - s.ticketFk, - s.isPriceFixed + s.ticketFk, + s.isPriceFixed FROM vn.sale s JOIN vn.item i ON i.id = s.itemFk WHERE s.id = vSaleFk; - + UPDATE vn.sale s JOIN vn.item i ON i.id = s.itemFk SET s.quantity = s.quantity - vQuantity, s.concept = i.longName WHERE s.id = vSaleFk; - + SELECT LAST_INSERT_ID() INTO vNewSaleFk; - - INSERT INTO vn.saleComponent( saleFk, - componentFk, + + INSERT INTO vn.saleComponent( saleFk, + componentFk, value) - SELECT vNewSaleFk, - componentFk, + SELECT vNewSaleFk, + componentFk, value - FROM vn.saleComponent + FROM vn.saleComponent WHERE saleFk = vSaleFk; END ;; @@ -64725,29 +64493,29 @@ 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `saleTracking_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_add`(vSaleGroupFk INT) BEGIN - + /* Inserta en vn.saleTracking las lineas de una previa - * + * * @param vSaleGroupFk Identificador de vn.saleGroup */ - - REPLACE vn.saleTracking(saleFk, - isChecked, - workerFk, - actionFk, - stateFk) + + REPLACE vn.saleTracking(saleFk, + isChecked, + workerFk, + actionFk, + stateFk) SELECT sgd.saleFk , TRUE, account.myUser_getId(), @@ -64757,64 +64525,64 @@ BEGIN JOIN vncontrol.accion a ON a.accion = 'SACAR' JOIN vn.state s ON s.code = 'ON_PREPARATION' WHERE sgd.saleGroupFk = vSaleGroupFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `saleTracking_addPreparedSaleGroup` */; /*!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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_addPreparedSaleGroup`(vSaleGroupFk INT) BEGIN - + /** * Inserta lineas de vn.saleTracking para un saleGroup (previa) que escanea un sacador - * + * * @param vSaleGroupFk Identificador de vn.saleGroup */ - + REPLACE vn.saleTracking(saleFk, isChecked, workerFk, actionFk, stateFk) SELECT sgd.saleFk, TRUE, account.myUser_getId(), a.accion_id id, s.id FROM vn.saleGroupDetail sgd JOIN vncontrol.accion a ON a.accion = 'SACAR' JOIN vn.state s ON s.code = 'PREPARED' WHERE sgd.saleGroupFk = vSaleGroupFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `saleTracking_addPrevOK` */; /*!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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_addPrevOK`(vSectorCollectionFk INT) BEGIN - + /** * Inserta los registros de la colección de sector con el estado PREVIA OK - * + * * @param vSectorCollectionFk Identificador de vn.sectorCollection */ - + REPLACE vn.saleTracking(saleFk, isChecked, workerFk, @@ -64825,21 +64593,19 @@ BEGIN sc.userFk, a.accion_id, s.id - FROM vn.sectorCollection sc + FROM vn.sectorCollection sc JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id - JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk + JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk JOIN vn.state s ON s.code = 'OK PREVIOUS' JOIN vncontrol.accion a ON a.accion = 'PRESACAR' WHERE sc.id = vSectorCollectionFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `saleTracking_del` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64847,6 +64613,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_del`(vSaleFk INT, vState VARCHAR(50)) BEGIN @@ -64857,17 +64625,15 @@ BEGIN DELETE st.* FROM vn.saleTracking st JOIN vn.state s ON s.id = st.stateFk - WHERE st.saleFk = vSaleFk + WHERE st.saleFk = vSaleFk AND s.code = vState COLLATE utf8_unicode_ci; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `saleTracking_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64875,21 +64641,23 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_new`( vSaleFK INT, - vIsChecked BOOLEAN, - vOriginalQuantity INT, - vWorkerFk INT, - vAction VARCHAR(50), +CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_new`( vSaleFK INT, + vIsChecked BOOLEAN, + vOriginalQuantity INT, + vWorkerFk INT, + vAction VARCHAR(50), vState VARCHAR(50)) BEGIN - REPLACE vn.saleTracking(saleFk, - isChecked, - originalQuantity, - workerFk, - actionFk, - stateFk) + REPLACE vn.saleTracking(saleFk, + isChecked, + originalQuantity, + workerFk, + actionFk, + stateFk) SELECT vSaleFk, vIsChecked, vOriginalQuantity, @@ -64907,8 +64675,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `saleTracking_Replace` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64916,10 +64682,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_Replace`(vSaleFk INT, vIsChecked INT, vOriginalQuantity INT, vStateFk INT) BEGIN - REPLACE vn.saleTracking(saleFk, isChecked, originalQuantity, stateFk) + REPLACE vn.saleTracking(saleFk, isChecked, originalQuantity, stateFk) VALUES(vSaleFk, vIsChecked, vOriginalQuantity, vStateFk); END ;; DELIMITER ; @@ -64927,8 +64695,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `saleTracking_updateIsChecked` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64936,29 +64702,31 @@ DELIMITER ; /*!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`@`localhost` PROCEDURE `saleTracking_updateIsChecked`(vSaleFk INT, vIsChecked BOOL) BEGIN - + /** * Actualiza el estado del campo vn.saleTracking.isChecked y elimina las lineas de vn.itemShelving * si procede, en el caso de las preparaciones previas, por usuario - * + * * @param vSaleFk Identificador de vn.sale * @param vIsChecked Estado del registro */ - + UPDATE vn.saleTracking st JOIN vn.state s ON s.id = st.stateFk AND s.code = 'PREVIOUS_PREPARATION' SET st.isChecked = vIsChecked WHERE st.saleFk = vSaleFk AND st.workerFk = account.myUser_getId(); - + IF vIsChecked = FALSE THEN - - DELETE FROM vn.itemShelvingSale + + DELETE FROM vn.itemShelvingSale WHERE saleFk = vSaleFk; - + END IF; END ;; @@ -64967,8 +64735,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sale_calculateComponent` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64976,6 +64742,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_calculateComponent`(vSale INT, vOption INT) proc: BEGIN @@ -64984,15 +64752,15 @@ proc: BEGIN * * @param vSale Id de la venta * @param vOption indica en que componente pone el descuadre, NULL en casos habituales - */ + */ DROP TEMPORARY TABLE IF EXISTS tmp.recalculateSales; CREATE TEMPORARY TABLE tmp.recalculateSales SELECT s.id FROM sale s WHERE s.id = vSale; - + CALL vn.sale_recalcComponent(vOption); - + DROP TEMPORARY TABLE tmp.recalculateSales; END ;; DELIMITER ; @@ -65000,8 +64768,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sale_checkNoComponents` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65009,6 +64775,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_checkNoComponents`(vCreatedFrom DATETIME, vCreatedTo DATETIME) BEGIN @@ -65039,7 +64807,7 @@ BEGIN GROUP BY s.id; DECLARE CONTINUE HANDLER FOR NOT FOUND - SET v_done = TRUE; + SET v_done = TRUE; DROP TEMPORARY TABLE IF EXISTS tmp.coste; @@ -65047,7 +64815,7 @@ BEGIN CREATE TEMPORARY TABLE tmp.coste (PRIMARY KEY (id)) ENGINE = MEMORY SELECT s.id - FROM sale s + FROM sale s JOIN item i ON i.id = s.itemFk JOIN itemType tp ON tp.id = i.typeFk JOIN itemCategory ic ON ic.id = tp.categoryFk @@ -65066,26 +64834,24 @@ BEGIN IF v_done THEN LEAVE l; END IF; - + SELECT ticketFk, concept INTO vTicketFk, vConcept FROM sale WHERE id = vSaleFk; - + CALL util.debugAdd(vTicketFk, vConcept); CALL sale_calculateComponent(vSaleFk, 1); END LOOP; CLOSE vCur; - DROP TEMPORARY TABLE tmp.coste; + DROP TEMPORARY TABLE tmp.coste; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sale_getFromTicketOrCollection` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65093,6 +64859,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getFromTicketOrCollection`(vParam INT) BEGIN @@ -65163,7 +64931,7 @@ BEGIN TRIM(CONCAT(LPAD(s.concept,30,' '), ' ', RPAD(IFNULL(i.size,''),5,' '))) line1, '' cel1, - TRIM(CONCAT(LPAD(IFNULL(ip.productor,''),30,' '), ' ',LPAD(IFNULL(o.code,''),4,' '))) line2, + TRIM(CONCAT(LPAD(IFNULL(ip.productor,''),30,' '), ' ',LPAD(IFNULL(o.code,''),4,' '))) line2, IF(s.quantity MOD IFNULL(b.packing,s.quantity + 1), CONCAT(CAST(s.quantity/IFNULL(b.`grouping`,1) AS DECIMAL(10,0)),' x ',IFNULL(b.`grouping`,1)), CONCAT(CAST(s.quantity / IFNULL(b.packing,1) AS DECIMAL(10,0)),' pack de ',IFNULL(b.packing,1))) cel2, @@ -65174,17 +64942,17 @@ BEGIN IFNULL(c.workerFk,getUser()) as workerFk, IFNULL(SUM(iss.quantity),0) as pickedQuantity, i.packingShelve, - MIN(iss.created) picked + MIN(iss.created) picked FROM tmp.ticket t JOIN sale s ON s.ticketFk = t.id JOIN ticket tt ON tt.id = t.id LEFT JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND lb.warehouse_id = tt.warehouseFk - LEFT JOIN buy b ON b.id = lb.buy_id + LEFT JOIN buy b ON b.id = lb.buy_id JOIN item i ON i.id = s.itemFk LEFT JOIN ticketCollection tc ON tc.ticketFk = t.id LEFT JOIN collection c ON c.id = tc.collectionFk - LEFT JOIN (SELECT sub.saleFk, sub.isChecked, sub.stateFk, sub.originalQuantity - FROM (SELECT DISTINCT st.id, st.saleFk, st.isChecked, st.stateFk, st.originalQuantity + LEFT JOIN (SELECT sub.saleFk, sub.isChecked, sub.stateFk, sub.originalQuantity + FROM (SELECT DISTINCT st.id, st.saleFk, st.isChecked, st.stateFk, st.originalQuantity FROM tmp.ticket2 t JOIN sale s ON s.ticketFk = t.id JOIN saleTracking st ON st.saleFk = s.id @@ -65196,9 +64964,9 @@ BEGIN LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk LEFT JOIN itemProductor ip ON ip.itemFk = s.itemFk LEFT JOIN origin o ON o.id = i.originFk - LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id + LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id LEFT JOIN saleGroup sg ON sg.id = sgd.saleGroupFk - LEFT JOIN parking p ON p.id = sg.parkingFk + LEFT JOIN parking p ON p.id = sg.parkingFk GROUP BY s.id; DROP TEMPORARY TABLE @@ -65210,8 +64978,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sale_getProblems` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65219,6 +64985,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getProblems`(IN vIsTodayRelative tinyint(1)) BEGIN @@ -65237,20 +65005,20 @@ BEGIN DECLARE vComponentCount INT; DECLARE vCursor CURSOR FOR - SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, CURDATE(), date(tt.shipped)) + SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, util.VN_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()); + WHERE DATE(tt.shipped) BETWEEN util.VN_CURDATE() + AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), util.VN_CURDATE()); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; DELETE tt.* FROM tmp.sale_getProblems tt JOIN vn.ticketObservation tto ON tto.ticketFk = tt.ticketFk - JOIN vn.observationType ot ON ot.id = tto.observationTypeFk - WHERE ot.code = 'administrative' + JOIN vn.observationType ot ON ot.id = tto.observationTypeFk + WHERE ot.code = 'administrative' AND tto.description = 'Miriam'; - + DROP TEMPORARY TABLE IF EXISTS tmp.sale_problems; CREATE TEMPORARY TABLE tmp.sale_problems ( ticketFk INT(11), @@ -65282,19 +65050,19 @@ BEGIN -- Too Little INSERT INTO tmp.sale_problems(ticketFk, isTooLittle) - SELECT tp.ticketFk, TRUE + SELECT tp.ticketFk, TRUE FROM tmp.sale_getProblems tp JOIN vn.ticket t ON t.id = tp.ticketFk JOIN (SELECT t.addressFk, SUM(sv.litros) litros, t.totalWithoutVat FROM tmp.ticket_list tl JOIN vn.saleVolume sv ON sv.ticketFk = tl.ticketFk JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = CURDATE() + JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = util.VN_CURDATE() JOIN vn.agencyMode am ON am.id = t.agencyModeFk JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE NOW() < TIMESTAMPADD(MINUTE,MINUTE(zc.`hour`) ,TIMESTAMPADD(HOUR,HOUR(zc.`hour`),CURDATE())) + WHERE util.VN_NOW() < TIMESTAMPADD(MINUTE,MINUTE(zc.`hour`) ,TIMESTAMPADD(HOUR,HOUR(zc.`hour`),util.VN_CURDATE())) AND dm.code IN('AGENCY','DELIVERY','PICKUP') - AND t.shipped BETWEEN CURDATE() AND util.midnight() + AND t.shipped BETWEEN util.VN_CURDATE() AND util.midnight() GROUP BY t.addressFk) sub ON sub.addressFk = t.addressFk JOIN vn.volumeConfig vc WHERE sub.litros < vc.minTicketVolume @@ -65302,11 +65070,11 @@ BEGIN -- Faltan componentes INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk) - SELECT tl.ticketFk, (COUNT(DISTINCT s.id) * vComponentCount > COUNT(c.id)), s.id + 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 + LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id + LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired JOIN vn.ticket t ON t.id = tl.ticketFk JOIN vn.agencyMode am ON am.id = t.agencyModeFk JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk @@ -65329,7 +65097,7 @@ BEGIN SELECT DISTINCT clientFk FROM tmp.ticket_list; - CALL clientGetDebt(CURDATE()); + CALL clientGetDebt(util.VN_CURDATE()); INSERT INTO tmp.sale_problems(ticketFk, risk, hasHighRisk) SELECT DISTINCT tl.ticketFk, r.risk, ((r.risk - cc.riskTolerance) > c.credit + 10) @@ -65361,15 +65129,15 @@ BEGIN -- Disponible: no va a haber suficiente producto para preparar todos los pedidos CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouseFk, 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 - JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.itemType it on it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache WHERE date(t.shipped) = vDate AND ic.merchandise = TRUE @@ -65380,24 +65148,24 @@ BEGIN GROUP BY tl.ticketFk ON DUPLICATE KEY UPDATE isAvailable = FALSE, saleFk = VALUES(saleFk); - -- Faltas: visible, disponible y ubicado son menores que la cantidad vendida + -- Faltas: visible, disponible y ubicado son menores que la cantidad vendida CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouseFk); INSERT INTO tmp.sale_problems(ticketFk, itemShortage, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, - LEFT(CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')),250) problem, + SELECT tl.ticketFk, + LEFT(CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')),250) 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 - JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = i.id AND v.calc_id = vVisibleCache LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk + LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk WHERE IFNULL(v.visible,0) < s.quantity AND IFNULL(av.available ,0) < s.quantity AND IFNULL(issw.visible, 0) < s.quantity @@ -65406,11 +65174,11 @@ BEGIN AND ic.merchandise = TRUE AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) AND NOT i.generic - AND CURDATE() = vDate + AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk GROUP BY tl.ticketFk) sub ON DUPLICATE KEY UPDATE itemShortage = sub.problem, saleFk = sub.saleFk; - + -- Inventario: Visible suficiente, pero ubicado menor a la cantidad vendida INSERT INTO tmp.sale_problems(ticketFk, itemLost, saleFk) SELECT ticketFk, problem, saleFk @@ -65423,7 +65191,7 @@ BEGIN JOIN vn.itemType it on it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk + LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk WHERE IFNULL(v.visible,0) >= s.quantity AND IFNULL(issw.visible, 0) < s.quantity AND s.quantity > 0 @@ -65432,11 +65200,11 @@ BEGIN AND ic.merchandise = TRUE AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) AND NOT i.generic - AND CURDATE() = vDate + AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk GROUP BY tl.ticketFk) sub ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; - + -- Retraso: Disponible suficiente, pero no visible ni ubicado INSERT INTO tmp.sale_problems(ticketFk, itemDelay, saleFk) SELECT ticketFk, problem, saleFk @@ -65450,7 +65218,7 @@ BEGIN JOIN vn.itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk + LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk WHERE IFNULL(v.visible,0) < s.quantity AND IFNULL(av.available ,0) >= s.quantity AND IFNULL(issw.visible, 0) < s.quantity @@ -65460,14 +65228,14 @@ BEGIN AND ic.merchandise = TRUE AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) AND NOT i.generic - AND CURDATE() = vDate + AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk GROUP BY tl.ticketFk) 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 @@ -65484,8 +65252,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sale_getProblemsByTicket` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65493,20 +65259,22 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getProblemsByTicket`(IN vTicketFk INT, IN vIsTodayRelative TINYINT(1)) BEGIN /** - * Calcula los problemas de cada venta + * Calcula los problemas de cada venta * para un conjunto de tickets. * * @return Problems result */ DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems; - CREATE TEMPORARY TABLE tmp.sale_getProblems + CREATE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) ENGINE = MEMORY - SELECT t.id ticketFk, t.clientFk, t.warehouseFk, t.shipped + SELECT t.id ticketFk, t.clientFk, t.warehouseFk, t.shipped FROM ticket t WHERE t.id = vTicketFk; @@ -65523,8 +65291,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sale_PriceFix` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65532,10 +65298,12 @@ DELIMITER ; /*!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`@`localhost` PROCEDURE `sale_PriceFix`(vTicketFk INT) BEGIN - + DELETE sc.* FROM vn.saleComponent sc JOIN vn.sale s ON s.id = sc.saleFk @@ -65558,8 +65326,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sale_recalcComponent` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65567,59 +65333,61 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_recalcComponent`(vOption INT) proc: BEGIN -/** +/** * Actualiza los componentes * * @table tmp.recalculateSales - */ - DECLARE vShipped DATE; + */ + DECLARE vShipped DATE; DECLARE vWarehouseFk SMALLINT; DECLARE vAgencyModeFk INT; DECLARE vAddressFk INT; DECLARE vTicketFk BIGINT; DECLARE vItemFk BIGINT; - DECLARE vLanded DATE; + DECLARE vLanded DATE; DECLARE vIsEditable BOOLEAN; DECLARE vZoneFk INTEGER; - + DECLARE vSale INTEGER; DECLARE vDone BOOL DEFAULT FALSE; - + DECLARE vCur CURSOR FOR SELECT id from tmp.recalculateSales; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + OPEN vCur; l: LOOP SET vDone = FALSE; - FETCH vCur INTO vSale; - + FETCH vCur INTO vSale; + IF vDone THEN LEAVE l; END IF; - - SELECT t.refFk IS NULL, - s.ticketFk, - s.itemFk , - t.zoneFk, - t.warehouseFk, - t.shipped, - t.addressFk, - t.agencyModeFk, + + SELECT t.refFk IS NULL, + s.ticketFk, + s.itemFk , + t.zoneFk, + t.warehouseFk, + t.shipped, + t.addressFk, + t.agencyModeFk, t.landed - INTO vIsEditable, - vTicketFk, - vItemFk, - vZoneFk, - vWarehouseFk, - vShipped, - vAddressFk, - vAgencyModeFk, + INTO vIsEditable, + vTicketFk, + vItemFk, + vZoneFk, + vWarehouseFk, + vShipped, + vAddressFk, + vAgencyModeFk, vLanded FROM ticket t JOIN sale s ON s.ticketFk = t.id @@ -65627,59 +65395,59 @@ proc: BEGIN WHERE s.id = vSale; CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk, TRUE); - + IF (SELECT COUNT(*) FROM tmp.zoneGetLanded LIMIT 1) = 0 THEN CALL util.throw('There is no zone for these parameters'); END IF; - + IF vLanded IS NULL OR vZoneFk IS NULL THEN - + UPDATE ticket t - SET t.landed = (SELECT landed FROM tmp.zoneGetLanded LIMIT 1) + SET t.landed = (SELECT landed FROM tmp.zoneGetLanded LIMIT 1) WHERE t.id = vTicketFk AND t.landed IS NULL; - + IF vZoneFk IS NULL THEN SELECT zoneFk INTO vZoneFk FROM tmp.zoneGetLanded LIMIT 1; UPDATE ticket t SET t.zoneFk = vZoneFk WHERE t.id = vTicketFk AND t.zoneFk IS NULL; END IF; - + END IF; - + DROP TEMPORARY TABLE tmp.zoneGetLanded; - - -- rellena la tabla buyUltimate con la ultima compra - CALL buyUltimate (vWarehouseFk, vShipped); - + + -- rellena la tabla buyUltimate con la ultima compra + CALL buyUltimate (vWarehouseFk, vShipped); + DELETE FROM tmp.buyUltimate WHERE itemFk != vItemFk; - + DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot + CREATE TEMPORARY TABLE tmp.ticketLot SELECT vWarehouseFk warehouseFk, NULL available, vItemFk itemFk, buyFk, vZoneFk zoneFk FROM tmp.buyUltimate WHERE itemFk = vItemFk; - - CALL catalog_componentPrepare(); + + CALL catalog_componentPrepare(); CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); - + DROP TEMPORARY TABLE IF EXISTS tmp.sale; CREATE TEMPORARY TABLE tmp.sale (PRIMARY KEY (saleFk)) ENGINE = MEMORY SELECT vSale saleFk,vWarehouseFk warehouseFk; - + IF vOption IS NULL THEN SET vOption = IF(vIsEditable, 1, 6); END IF; - - CALL ticketComponentUpdateSale(vOption); + + CALL ticketComponentUpdateSale(vOption); CALL catalog_componentPurge(); - + DROP TEMPORARY TABLE tmp.buyUltimate; DROP TEMPORARY TABLE tmp.sale; - + END LOOP; - CLOSE vCur; + CLOSE vCur; END ;; DELIMITER ; @@ -65687,8 +65455,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sale_setQuantity` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65696,41 +65462,41 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_setQuantity`(vSaleFk INT, vQuantity INT) BEGIN /* * Actualiza la cantidad de la línea de venta - * + * * @vSaleFk id de la línea de venta * @vQuantity cantidad a modificar - * + * */ - + DECLARE vDescription VARCHAR(100); DECLARE vOrigin INT; - + SELECT CONCAT("Cambio cantidad ",concept," de ", quantity," a ", vQuantity) INTO vDescription - FROM sale + FROM sale WHERE id = vSaleFk; SELECT ticketFk INTO vOrigin FROM sale WHERE id = vSaleFk; CALL logAdd(vOrigin, 'update', 'ticket', vDescription); - - UPDATE sale + + UPDATE sale SET originalQuantity = quantity, quantity = vQuantity WHERE id = vSaleFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sale_updateOriginalQuantity` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65738,6 +65504,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_updateOriginalQuantity`(vSale INT, vQuantity INT) proc: BEGIN @@ -65753,8 +65521,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `saveLoadWorker` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65762,12 +65528,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `saveLoadWorker`(routeFk INT, workerFk INT) BEGIN -REPLACE INTO vn.routeLoadWorker(routeFk, workerFk) +REPLACE INTO vn.routeLoadWorker(routeFk, workerFk) VALUES(routeFk,workerFk); END ;; @@ -65776,8 +65544,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sectorCollectionSaleGroup_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65785,28 +65551,30 @@ DELIMITER ; /*!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`@`localhost` PROCEDURE `sectorCollectionSaleGroup_add`(vSaleGroupFk INT, vSectorCollectionFk INT) BEGIN - + /** - * Inserta un nuevo registro en vn.sectorCollectionSaleGroup + * Inserta un nuevo registro en vn.sectorCollectionSaleGroup * Actualiza el usuario en vn.saleGroup y reemplaza los registros de vn.saleTracking - * + * * @param vSaleGroupFk Identificador de vn.saleGroup * @param vSectorCollectionFk Identificador de vn.sectorCollection */ - + REPLACE vn.sectorCollectionSaleGroup(sectorCollectionFk, saleGroupFk) VALUES(vSectorCollectionFk, vSaleGroupFk); - + UPDATE vn.saleGroup sg JOIN vn.sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id JOIN vn.sectorCollection sc ON sc.id = scsg.sectorCollectionFk - SET sg.userFk = sc.userFk + SET sg.userFk = sc.userFk WHERE sg.id = vSaleGroupFk; - - + + INSERT IGNORE vn.saleTracking(saleFk, isChecked, workerFk, @@ -65818,25 +65586,23 @@ BEGIN a.accion_id, s.id FROM vn.saleGroupDetail sgd - JOIN vn.sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sgd.saleGroupFk + JOIN vn.sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sgd.saleGroupFk JOIN vn.sectorCollection sc ON sc.id = scsg.sectorCollectionFk JOIN vncontrol.accion a ON a.accion = 'SACAR' JOIN vn.state s ON s.code = 'PREVIOUS_PREPARATION' WHERE sgd.saleGroupFk = vSaleGroupFk; - + UPDATE vn.saleTracking st - JOIN vn.saleGroupDetail sgd ON sgd.saleFk = st.saleFk + JOIN vn.saleGroupDetail sgd ON sgd.saleFk = st.saleFk SET st.isChecked = TRUE WHERE sgd.saleGroupFk = vSaleGroupFk AND st.workerFk = 20; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sectorCollection_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65844,18 +65610,20 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_get`(vSectorFk INT) BEGIN - + /** * Devuelve las colecciones del sector que corresponden al usuario conectado, y que estan incompletas - * + * * @param vSectorFk Identificador de vn.sector */ - + SELECT DISTINCT sc.id collectionFk, sc.created - FROM vn.sectorCollection sc + FROM vn.sectorCollection sc JOIN vn.state s ON s.code = 'PREVIOUS_PREPARATION' LEFT JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk @@ -65863,18 +65631,16 @@ BEGIN LEFT JOIN vn.sale sl ON sl.id = st.saleFk WHERE sc.userFk = account.myUser_getId() AND (ISNULL(scsg.sectorCollectionFk) - OR + OR (NOT st.isChecked AND sl.quantity > 0)) - AND sc.created > CURDATE(); - + AND sc.created > util.VN_CURDATE(); + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sectorCollection_getSale` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65882,6 +65648,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_getSale`(vSelf INT) BEGIN @@ -65917,8 +65685,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sectorCollection_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65926,13 +65692,15 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_new`(vSectorFk INT) BEGIN /** * Inserta una nueva colección, si el usuario no tiene ninguna vacia. * Esto se hace para evitar que por error se generen colecciones sin sentido. - * + * * @param vSectorFk Identificador de #vn.sector */ DECLARE hasEmptyCollections BOOL; @@ -65941,12 +65709,12 @@ BEGIN SET vUserFk = account.myUser_getId(); SELECT (COUNT(sc.id) > 0) INTO hasEmptyCollections - FROM vn.sectorCollection sc - LEFT JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id + FROM vn.sectorCollection sc + LEFT JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id WHERE ISNULL(scsg.id) AND sc.userFk = vUserFk AND sc.sectorFk = vSectorFk - AND sc.created >= CURDATE(); + AND sc.created >= util.VN_CURDATE(); IF NOT hasEmptyCollections THEN INSERT INTO vn.sectorCollection(userFk, sectorFk) @@ -65958,8 +65726,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sectorProductivity_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65967,13 +65733,15 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorProductivity_add`() 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; + SELECT DATE_SUB(util.VN_CURDATE(),INTERVAL 1 DAY), CONCAT(DATE_SUB(util.VN_CURDATE(),INTERVAL 1 DAY),' 23:59:59') INTO vDatedFrom, vDatedTo; DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; DROP TEMPORARY TABLE IF EXISTS tmp.errorsByChecker; @@ -66045,8 +65813,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sector_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66054,6 +65820,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sector_get`() BEGIN @@ -66071,8 +65839,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sector_getWarehouse` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66080,6 +65846,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sector_getWarehouse`(vSectorFk INT) BEGIN @@ -66087,15 +65855,13 @@ BEGIN SELECT s.warehouseFk FROM vn.sector s WHERE s.id = vSectorFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `setParking` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66103,6 +65869,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `setParking`(IN `vParam` VARCHAR(8), IN `vParkingCode` VARCHAR(8)) proc: BEGIN @@ -66142,7 +65910,7 @@ proc: BEGIN SELECT COUNT(*) INTO vIsTicket FROM vn.ticket t WHERE t.id = vParam - AND t.shipped >= TIMESTAMPADD(WEEK,-1,CURDATE()); + AND t.shipped >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); IF vIsTicket THEN CALL vn.ticket_setParking(vParam, vParkingFk); @@ -66153,7 +65921,7 @@ proc: BEGIN SELECT COUNT(*) INTO vIsCollection FROM vn.collection c WHERE c.id = vParam - AND c.created >= TIMESTAMPADD(WEEK,-1,CURDATE()); + AND c.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); IF vIsCollection THEN CALL vn.collection_setParking(vParam, vParkingFk); @@ -66168,8 +65936,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `shelvingChange` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66177,23 +65943,23 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingChange`(IN `vShelvingO` VARCHAR(8), IN `vShelvingD` VARCHAR(8)) BEGIN UPDATE vn.itemShelving - SET shelvingFk = vShelvingD COLLATE utf8_unicode_ci - WHERE shelvingFk = vShelvingO COLLATE utf8_unicode_ci; - - + SET shelvingFk = vShelvingD COLLATE utf8_unicode_ci + WHERE shelvingFk = vShelvingO COLLATE utf8_unicode_ci; + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `shelvingLog_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66201,19 +65967,21 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingLog_get`(shelvingFk VARCHAR(10)) BEGIN - + /* Lista el log de un carro - * + * * @param shelvingFk matrícula del carro - * + * */ - + SELECT originFk, name, creationDate, description FROM shelvingLog sl - JOIN user u ON u.id = sl.userFk + JOIN user u ON u.id = sl.userFk WHERE sl.originFk = shelvingFk COLLATE utf8_general_ci ORDER BY creationDate DESC; @@ -66223,8 +65991,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `shelvingPark` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66232,18 +65998,20 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingPark`(IN `vParam` VARCHAR(8), IN `vParkingCode` VARCHAR(8)) proc: BEGIN -/* +/* * Aparca una colección, un ticket, un saleGroup o un shelving en un parking - * + * * @param vParam id del ticket, colección, saleGroup o shelving - * @param vParkingCode código del parking - * + * @param vParkingCode código del parking + * */ - + DECLARE vParkingFk INT; DECLARE vColumn VARCHAR(3); DECLARE vRow VARCHAR(2); @@ -66253,15 +66021,15 @@ proc: BEGIN DECLARE vIsCollection BOOL; DECLARE vCollection INT DEFAULT NULL; DECLARE vDone INT DEFAULT FALSE; - DECLARE vTicketFk INT; - DECLARE vCursor CURSOR FOR - SELECT IFNULL(tc2.ticketFk, t.id) - FROM ticket t - LEFT JOIN ticketCollection tc1 ON tc1.ticketFk = t.id - LEFT JOIN ticketCollection tc2 ON tc2.collectionFk = tc1.collectionFk + DECLARE vTicketFk INT; + DECLARE vCursor CURSOR FOR + SELECT IFNULL(tc2.ticketFk, t.id) + FROM ticket t + LEFT JOIN ticketCollection tc1 ON tc1.ticketFk = t.id + LEFT JOIN ticketCollection tc2 ON tc2.collectionFk = tc1.collectionFk WHERE t.id = vParam; - - + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; SET vParkingCode = replace(vParkingCode,' ','') ; @@ -66269,102 +66037,100 @@ proc: BEGIN SELECT id INTO vParkingFk FROM vn.parking WHERE code = vParkingCode COLLATE utf8_unicode_ci; - + IF vParkingFk IS NULL THEN LEAVE proc; END IF; - + -- Se comprueba si es una preparación previa SELECT COUNT(*) INTO vIsSaleGroup - FROM vn.saleGroup sg + FROM vn.saleGroup sg WHERE sg.id = vParam; - + IF vIsSaleGroup THEN - - UPDATE vn.saleGroup sg + + UPDATE vn.saleGroup sg SET sg.parkingFk = vParkingFk WHERE sg.id = vParam - AND sg.created >= TIMESTAMPADD(WEEK,-1,CURDATE()); - + AND sg.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); + CALL vn.ticket_setNextState(vn.ticket_get(vParam)); - + LEAVE proc; - + END IF; -- Se comprueba si es un ticket SELECT COUNT(*) INTO vIsTicket FROM vn.ticket t WHERE t.id = vParam - AND t.shipped >= TIMESTAMPADD(WEEK,-1,CURDATE()); + AND t.shipped >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); IF vIsTicket THEN INSERT INTO vn.ticketParking(ticketFk, parkingFk) - SELECT IFNULL(tc2.ticketFk, t.id), vParkingFk - FROM ticket t - LEFT JOIN ticketCollection tc1 ON tc1.ticketFk = t.id - LEFT JOIN ticketCollection tc2 ON tc2.collectionFk = tc1.collectionFk + SELECT IFNULL(tc2.ticketFk, t.id), vParkingFk + FROM ticket t + LEFT JOIN ticketCollection tc1 ON tc1.ticketFk = t.id + LEFT JOIN ticketCollection tc2 ON tc2.collectionFk = tc1.collectionFk WHERE t.id = vParam - ON DUPLICATE KEY UPDATE parkingFk = vParkingFk; - + ON DUPLICATE KEY UPDATE parkingFk = vParkingFk; + OPEN vCursor; l: LOOP - + FETCH vCursor INTO vTicketFk; - + IF vDone THEN LEAVE l; END IF; - + CALL vn.ticket_setNextState(vTicketFk); - + END LOOP; - + CLOSE vCursor; - + LEAVE proc; END IF; -- Se comprueba si es una coleccion de tickets SELECT COUNT(*) INTO vIsCollection - FROM vn.collection c - WHERE c.id = vParam - AND c.created >= TIMESTAMPADD(WEEK,-1,CURDATE()); - + FROM vn.collection c + WHERE c.id = vParam + AND c.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); + IF vIsCollection THEN REPLACE vn.ticketParking(ticketFk,parkingFk) SELECT tc.ticketFk, vParkingFk - FROM vn.ticketCollection tc + FROM vn.ticketCollection tc WHERE tc.collectionFk = vParam; - + LEAVE proc; END IF; -- Por descarte, se considera una matrícula INSERT INTO vn.shelvingLog (originFk, userFk, action , description) - SELECT vParam, account.myUser_getId(), 'update', CONCAT("Cambio parking ",vParam," de ", p.code," a ", vParkingCode) + SELECT vParam, account.myUser_getId(), 'update', CONCAT("Cambio parking ",vParam," de ", p.code," a ", vParkingCode) FROM parking p JOIN shelving s ON s.parkingFk = p.id WHERE s.code = vParam COLLATE utf8_unicode_ci; UPDATE vn.shelving - SET parkingFk = vParkingFk, parked = NOW(), isPrinted = TRUE + SET parkingFk = vParkingFk, parked = util.VN_NOW(), isPrinted = TRUE WHERE `code` = vParam COLLATE utf8_unicode_ci; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `shelvingParking_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66372,26 +66138,28 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingParking_get`(vShelvingFk VARCHAR(10), vWarehouseFk INT, vDayRange INT) BEGIN - -SELECT s.itemFk, + +SELECT s.itemFk, s.concept, - CAST(SUM(s.quantity) AS DECIMAL(10,0)) as sinServir, - CAST(IFNULL(ist.visible,0) AS DECIMAL(10,0)) as aparcado + CAST(SUM(s.quantity) AS DECIMAL(10,0)) as sinServir, + CAST(IFNULL(ist.visible,0) AS DECIMAL(10,0)) as aparcado FROM vn.sale s LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id JOIN vn.ticket t ON t.id = s.ticketFk LEFT JOIN vn.itemShelvingStock ist ON ist.itemFk = s.itemFk AND ist.warehouseFk = vWarehouseFk JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk AND ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci - WHERE t.shipped BETWEEN CURDATE() AND util.dayend(TIMESTAMPADD(DAY, GREATEST(0,vDayRange), CURDATE())) + WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(TIMESTAMPADD(DAY, GREATEST(0,vDayRange), util.VN_CURDATE())) AND iss.saleFk IS NULL AND t.warehouseFk = vWarehouseFk GROUP BY s.itemFk HAVING sinServir > aparcado; - + END ;; DELIMITER ; @@ -66399,8 +66167,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `shelvingPriority_update` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66408,6 +66174,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingPriority_update`(priority INT,vShelvingFk VARCHAR(10)) BEGIN @@ -66420,42 +66188,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `shelving_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 character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `shelving_clean`() BEGIN DELETE FROM vn.shelving WHERE length(code) > 3 - AND parked < TIMESTAMPADD(WEEK,-1,CURDATE()); - + AND parked < TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); + DELETE FROM vn.itemShelving WHERE visible <= 0 - AND created < TIMESTAMPADD(MONTH,-1,CURDATE()); + AND created < TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()); - DELETE ish.* + DELETE ish.* FROM vn.itemShelving ish JOIN vn.shelving sh ON sh.code = ish.shelvingFk WHERE sh.parkingFk IS NULL - AND ish.created < TIMESTAMPADD(WEEK,-1,CURDATE()); + AND ish.created < TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); UPDATE vn.shelving sh LEFT JOIN vn.itemShelving its ON its.shelvingFk = sh.`code` - SET isPrinted = 0, + SET isPrinted = 0, parkingFk = NULL WHERE its.id IS NULL - AND sh.isRecyclable - AND ( sh.parked IS NULL - OR - sh.parked < TIMESTAMPADD(MONTH,-1,CURDATE()) + AND sh.isRecyclable + AND ( sh.parked IS NULL + OR + sh.parked < TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()) ); END ;; @@ -66464,8 +66232,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `shelving_getSpam` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66473,31 +66239,33 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `shelving_getSpam`(vDated DATE, vWarehouseFk INT) BEGIN - + /** * Devuelve las matrículas con productos que no son necesarios para la venta hasta la fecha señalada - * + * * @param vDated Fecha hasta la que se puede pasar sin esos productos. * @param vWarehouse Identificador único de vn.warehouse */ - + DROP TEMPORARY TABLE IF EXISTS tmp.stock; CALL cache.stock_refresh(FALSE); CREATE TEMPORARY TABLE tmp.stock - SELECT i.id itemFk, - v.amount - IFNULL(fue.reserva,0) as visible, - fue.reserva, - sale.venta, - IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) as compra, + SELECT i.id itemFk, + v.amount - IFNULL(fue.reserva,0) as visible, + 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) - IFNULL(fue.reserva,0) as saldo - FROM vn.item i - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk + FROM vn.item i + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk LEFT JOIN ( SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS reserva FROM vn.itemShelving ish @@ -66506,20 +66274,20 @@ BEGIN JOIN vn.sector s ON s.id = p.sectorFk WHERE s.code = 'FUENTES_PICASSE' OR sh.isSpam - GROUP BY ish.itemFk + GROUP BY ish.itemFk ) 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 util.dayend(vDated) + WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated) AND warehouse_id = vWarehouseFk GROUP BY item_id ) sale ON sale.item_id = i.id LEFT JOIN ( SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as compra FROM vn2008.item_entry_in - WHERE dat BETWEEN CURDATE() AND util.dayend(vDated) + WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated) AND warehouse_id = vWarehouseFk AND isVirtualStock = FALSE GROUP BY item_id @@ -66527,32 +66295,32 @@ BEGIN LEFT JOIN ( SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as traslado FROM vn2008.item_entry_out - WHERE dat BETWEEN CURDATE() AND util.dayend(vDated) + WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated) AND warehouse_id = vWarehouseFk GROUP BY item_id ) mov ON mov.item_id = i.id WHERE v.amount; - - SELECT ish.shelvingFk matricula, + + SELECT ish.shelvingFk matricula, i.longName articulo, ish.visible, - count(*) lineas, - sum(ish.visible <= s.saldo) spam, + count(*) lineas, + sum(ish.visible <= s.saldo) spam, p.code parking, - s.description sector , + s.description sector , w.name AS almacen, sh.isSpam - FROM vn.itemShelving ish + FROM vn.itemShelving ish JOIN vn.item i ON i.id = ish.itemFk - JOIN vn.shelving sh ON sh.code = ish.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk - JOIN vn.sector s ON s.id = p.sectorFk - JOIN vn.warehouse w ON w.id = s.warehouseFk - LEFT JOIN tmp.stock s ON s.itemFk = ish.itemFk - WHERE (w.name = 'Algemesi' - OR (w.name = 'NuncaJamas' AND ish.created < curdate())) - AND ish.visible - GROUP BY ish.shelvingFk + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk + JOIN vn.warehouse w ON w.id = s.warehouseFk + LEFT JOIN tmp.stock s ON s.itemFk = ish.itemFk + WHERE (w.name = 'Algemesi' + OR (w.name = 'NuncaJamas' AND ish.created < util.VN_CURDATE())) + AND ish.visible + GROUP BY ish.shelvingFk HAVING lineas = spam OR isSpam; DROP TEMPORARY TABLE tmp.stock; @@ -66563,8 +66331,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `shelving_setParking` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66572,6 +66338,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `shelving_setParking`(IN `vShelvingCode` VARCHAR(8), IN `vParkingFk` INT) proc: BEGIN @@ -66588,7 +66356,7 @@ proc: BEGIN WHERE s.code = vShelvingCode COLLATE utf8_unicode_ci; UPDATE vn.shelving - SET parkingFk = vParkingFk, parked = NOW(), isPrinted = TRUE + SET parkingFk = vParkingFk, parked = util.VN_NOW(), isPrinted = TRUE WHERE code = vShelvingCode COLLATE utf8_unicode_ci; END ;; DELIMITER ; @@ -66596,8 +66364,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sleep_X_min` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66605,6 +66371,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sleep_X_min`() BEGIN @@ -66618,8 +66386,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `solunionRiskRequest` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66627,23 +66393,25 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `solunionRiskRequest`() BEGIN - + DROP TEMPORARY TABLE IF EXISTS tmp.client_list; CREATE TEMPORARY TABLE tmp.client_list (PRIMARY KEY (Id_Cliente)) ENGINE = MEMORY - SELECT * FROM (SELECT cc.client Id_Cliente, ci.grade FROM vn.creditClassification cc + SELECT * FROM (SELECT cc.client Id_Cliente, ci.grade FROM vn.creditClassification cc JOIN vn.creditInsurance ci ON cc.id = ci.creditClassification WHERE dateEnd IS NULL ORDER BY ci.creationDate DESC LIMIT 10000000000000000000) t1 GROUP BY Id_Cliente; - - CALL vn2008.risk_vs_client_list(CURDATE()); - - SELECT + + CALL vn2008.risk_vs_client_list(util.VN_CURDATE()); + + SELECT c.Id_Cliente, c.Cliente, c.Credito credito_vn, c.creditInsurance solunion, cast(r.risk as DECIMAL(10,0)) riesgo_vivo, cast(c.creditInsurance - r.risk as decimal(10,0)) margen_vivo, f.Consumo consumo_anual, c.Vencimiento, ci.grade @@ -66653,7 +66421,7 @@ BEGIN JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente JOIN bi.facturacion_media_anual f ON c.Id_Cliente = f.Id_Cliente GROUP BY Id_cliente; - + DROP TEMPORARY TABLE IF EXISTS tmp.risk; DROP TEMPORARY TABLE IF EXISTS tmp.client_list; END ;; @@ -66662,8 +66430,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `stockBuyedByWorker` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66671,6 +66437,8 @@ DELIMITER ; /*!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`@`localhost` PROCEDURE `stockBuyedByWorker`(vDate DATE, vWorker INT) BEGIN @@ -66691,7 +66459,7 @@ BEGIN JOIN vn2008.Compres c ON c.Id_compra = bu.buyFk WHERE r.display <> 0 AND tr.user_id = vWorker; - DROP TEMPORARY TABLE + DROP TEMPORARY TABLE tmp.buyUltimate, tmp_item; END ;; @@ -66700,8 +66468,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `stockBuyed_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66709,6 +66475,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `stockBuyed_add`(vDated DATE) BEGIN @@ -66719,15 +66487,15 @@ BEGIN */ CALL vn.stockTraslation(vDated); - DELETE - FROM vn.stockBuyed + DELETE + FROM vn.stockBuyed WHERE `date` = vDated; INSERT INTO vn.stockBuyed(`user`, buyed, `date`, description) - SELECT it.workerFk, - SUM(( ti.amount / b.packing ) * vn.buy_getVolume(b.id)) / vc.palletM3 / 1000000 buyed, + SELECT it.workerFk, + SUM(( ti.amount / b.packing ) * vn.buy_getVolume(b.id)) / vc.palletM3 / 1000000 buyed, vDated, - u.name + u.name FROM tmp_item ti JOIN vn.item i ON i.id = ti.item_id JOIN vn.itemType it ON it.id = i.typeFk @@ -66739,18 +66507,18 @@ BEGIN JOIN account.`user` u ON u.id = it.workerFk WHERE ic.display != 0 GROUP BY it.workerFk; - + INSERT INTO stockBuyed(buyed, `date`, description) SELECT SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000), vDated, IF(c.country = 'España',p.name,c.country) destiny FROM vn.itemTicketOut ito - JOIN vn.ticket t ON t.id = ito.ticketFk - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.province p ON p.id = a.provinceFk + JOIN vn.ticket t ON t.id = ito.ticketFk + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.province p ON p.id = a.provinceFk JOIN vn.country c ON c.id = p.countryFk JOIN vn.warehouse wh ON wh.id = t.warehouseFk JOIN vn.itemCost ic ON ic.itemFk = ito.itemFk AND ic.warehouseFk = t.warehouseFk JOIN vn.volumeConfig vc - WHERE ito.shipped BETWEEN vDated AND util.dayend(vDated) + WHERE ito.shipped BETWEEN vDated AND util.dayend(vDated) AND wh.code = 'VNH' GROUP BY destiny; @@ -66763,8 +66531,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `stockTraslation` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66772,6 +66538,8 @@ DELIMITER ; /*!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`@`localhost` PROCEDURE `stockTraslation`(vDate DATE) BEGIN @@ -66789,21 +66557,21 @@ BEGIN CREATE TEMPORARY TABLE tmp_item (UNIQUE INDEX i USING HASH (item_id)) ENGINE = MEMORY - SELECT item_id, SUM(amount) amount + SELECT item_id, SUM(amount) amount FROM vn2008.item_entry_in - WHERE dat = vDate - AND vDate >= CURDATE() + WHERE dat = vDate + AND vDate >= util.VN_CURDATE() AND warehouse_id = vWarehouse AND isVirtualStock is FALSE - GROUP BY item_id + GROUP BY item_id HAVING amount != 0; CALL `cache`.stock_refresh (FALSE); INSERT INTO tmp_item (item_id,amount) - SELECT item_id,s.amount + SELECT item_id,s.amount FROM `cache`.stock s - WHERE warehouse_id = vWarehouse + WHERE warehouse_id = vWarehouse ON DUPLICATE KEY UPDATE amount = tmp_item.amount + VALUES(amount); CALL buyUltimate(vWarehouse,vDate); @@ -66814,8 +66582,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `subordinateGetList` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66823,6 +66589,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `subordinateGetList`(vBossFk INT) BEGIN @@ -66831,10 +66599,10 @@ BEGIN DECLARE vBossId INT; DECLARE vDone BOOL; DECLARE workerCur CURSOR FOR - SELECT workerFk - FROM tmp.subordinate + SELECT workerFk + FROM tmp.subordinate WHERE NOT isChecked; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR 1062 BEGIN @@ -66842,29 +66610,29 @@ BEGIN END; DROP TEMPORARY TABLE IF EXISTS tmp.subordinate; - + CREATE TEMPORARY TABLE tmp.subordinate (PRIMARY KEY (workerFk)) ENGINE = MEMORY SELECT vBossFk AS workerFk, 0 AS isChecked; - + WHILE (SELECT COUNT(*) FROM tmp.subordinate WHERE NOT isChecked) > 0 DO OPEN workerCur; workerLoop: LOOP SET vDone = FALSE; FETCH workerCur INTO vBossId; - + IF vDone THEN LEAVE workerLoop; END IF; - - INSERT INTO tmp.subordinate - SELECT id, 0 - FROM worker + + INSERT INTO tmp.subordinate + SELECT id, 0 + FROM worker WHERE bossFk = vBossId; - - UPDATE tmp.subordinate + + UPDATE tmp.subordinate SET isChecked = 1 WHERE workerFk = vBossId; END LOOP; @@ -66877,8 +66645,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `supplierExpenses` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66886,6 +66652,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `supplierExpenses`(vEnded DATE) BEGIN @@ -66904,13 +66672,13 @@ BEGIN -- Calcula el balance inicial y final de cada proveedor INSERT INTO openingBalance SELECT MAX(dueDated), - supplierFk, - companyFk, + supplierFk, + companyFk, sum(amount) eurAmount, sum(divisa) foreignAmount FROM ( SELECT p.dueDated, - p.supplierFk, + p.supplierFk, p.companyFk, p.amount, p.divisa @@ -66926,7 +66694,7 @@ BEGIN SELECT iidd.dueDated, ii.supplierFk, ii.companyFk, - - iidd.amount, + - iidd.amount, - iidd.foreignValue FROM invoiceIn ii JOIN invoiceInDueDay iidd ON ii.id = iidd.invoiceInFk @@ -66934,14 +66702,14 @@ BEGIN JOIN company co ON co.id = ii.companyFk WHERE iidd.dueDated > '2014-12-31' AND iidd.dueDated <= vEnded - AND ii.isBooked AND co.`code` = 'VNL' + AND ii.isBooked AND co.`code` = 'VNL' AND c.`code` <> 'EUR' UNION ALL SELECT se.dueDated, se.supplierFk, se.companyFk, - - se.amount, + - se.amount, 0 FROM supplierExpense se JOIN currency c ON c.id = se.currencyFk @@ -66951,7 +66719,7 @@ BEGIN AND co.`code` = 'VNL' AND c.`code` <> 'EUR' ) sub GROUP BY companyFk, supplierFk; - + SELECT ob.dueDated , ob.supplierFk , ob.companyFk @@ -66969,8 +66737,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `supplierPackaging_ReportSource` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66978,6 +66744,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `supplierPackaging_ReportSource`(vFromDated DATE, vSupplierFk INT) BEGIN @@ -67038,7 +66806,7 @@ BEGIN SELECT MAX(`row`) INTO vMaxRow FROM tmp.supplierPackagingList; - + DROP TEMPORARY TABLE IF EXISTS tmp.supplierPackaging; CREATE TEMPORARY TABLE tmp.supplierPackaging( supplierFk INT, @@ -67052,7 +66820,7 @@ BEGIN warehouse INT, buyingValue INT, balance INT); - + l1: LOOP IF vCounter = vMaxRow THEN @@ -67061,12 +66829,12 @@ BEGIN SET vCounter = vCounter + 1; SET @vBalance = 0; END IF; - + SELECT itemFk INTO vItemFk FROM tmp.supplierPackagingList WHERE `row` = vCounter; - + INSERT INTO tmp.supplierPackaging SELECT supplierFk, itemFk, @@ -67094,9 +66862,9 @@ BEGIN WHERE supplierFk = vSupplierFk AND landed >= vFromDated AND itemFk = vItemFk - + UNION ALL - + SELECT vSupplierFk, itemFk, longName, @@ -67131,8 +66899,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `supplier_checkBalance` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67140,6 +66906,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `supplier_checkBalance`(IN vDateTo DATETIME, IN vIsConciliated BOOL) BEGIN @@ -67153,19 +66921,19 @@ BEGIN JOIN ( SELECT companyFk, supplierFk, ROUND(SUM(mysql),2) mysql, ROUND(SUM(sage),2) sage FROM ( SELECT companyFk, supplierFk, -SUM(iid.amount) as mysql, 0 sage FROM invoiceInDueDay iid - JOIN invoiceIn ii ON ii.id = iid.invoiceInFk + JOIN invoiceIn ii ON ii.id = iid.invoiceInFk WHERE IFNULL(ii.bookEntried, ii.issued) BETWEEN vDateFrom AND vDateTo AND ii.isBooked GROUP BY ii.id - UNION ALL + UNION ALL SELECT p.companyFk, p.supplierFk, p.amount, 0 FROM payment p JOIN payMethod pm ON pm.id = p.payMethodFk WHERE p.received BETWEEN vDateFrom AND vDateTo AND IF(vIsConciliated, p.isConciliated, TRUE) = TRUE AND NOT pm.code <=>'previousBalance' - UNION ALL - SELECT se.companyFk, se.supplierFk, - se.amount, 0 + UNION ALL + SELECT se.companyFk, se.supplierFk, - se.amount, 0 FROM supplierExpense se WHERE se.dated BETWEEN vDateFrom AND vDateTo AND IF(vIsConciliated, se.isConciliated, TRUE) = TRUE @@ -67186,8 +66954,36 @@ 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 `supplier_checkIsActive` */; +/*!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' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `supplier_checkIsActive`(vSelf INT) +BEGIN +/** + * Comprueba si un proveedor esta activo. + */ + DECLARE vIsActive BOOL; + + SELECT isActive INTO vIsActive + FROM vn.supplier + WHERE id = vSelf; + + IF NOT vIsActive THEN + CALL util.throw('INACTIVE_PROVIDER'); + 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 `supplier_disablePayMethodChecked` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67195,6 +66991,8 @@ DELIMITER ; /*!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`@`localhost` PROCEDURE `supplier_disablePayMethodChecked`() BEGIN @@ -67210,7 +67008,7 @@ BEGIN FROM vn.payment p LEFT JOIN vn.supplier s ON s.id = p.supplierFk LEFT JOIN vn.payMethod pm ON pm.id = s.payMethodFk - WHERE p.created < (CURDATE() - INTERVAL pm.graceMonthsDisableChecked MONTH) + WHERE p.created < (util.VN_CURDATE() - INTERVAL pm.graceMonthsDisableChecked MONTH) AND pm.graceMonthsDisableChecked AND s.isPayMethodChecked GROUP BY p.supplierFk) sdpmc ON sdpmc.supplierFk = s.id @@ -67222,8 +67020,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `test` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67231,6 +67027,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `test`() BEGIN @@ -67241,8 +67039,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketBoxesView` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67250,18 +67046,20 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketBoxesView`(IN vTicketFk INT) BEGIN - - SELECT s.id, - s.itemFk, - s.concept, - floor(s.quantity / b.packing) as Cajas, - b.packing, - s.isPicked, + + SELECT s.id, + s.itemFk, + s.concept, + floor(s.quantity / b.packing) as Cajas, + b.packing, + s.isPicked, i.size - FROM ticket t + FROM ticket t JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk JOIN cache.last_buy lb on lb.warehouse_id = t.warehouseFk AND lb.item_id = s.itemFk @@ -67272,15 +67070,13 @@ BEGIN AND p.isBox GROUP BY s.itemFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketBuiltTime` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67288,13 +67084,15 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketBuiltTime`(vDate DATE) BEGIN DECLARE vDateStart DATETIME DEFAULT DATE(vDate); DECLARE vDateEnd DATETIME DEFAULT util.dayEnd(vDate); - + DROP TEMPORARY TABLE IF EXISTS tmp.ticketBuiltTime; CREATE TEMPORARY TABLE tmp.ticketBuiltTime @@ -67307,7 +67105,7 @@ BEGIN SELECT ticketFk, builtTime FROM ( - SELECT + SELECT Id_Ticket as ticketFk, odbc_date as builtTime FROM @@ -67315,13 +67113,13 @@ BEGIN WHERE odbc_date BETWEEN vDateStart AND vDateEnd ORDER BY Id_Ticket, odbc_date DESC LIMIT 10000000000000000000 - ) sub + ) sub GROUP BY ticketFk ) sub2 ON sub2.ticketFk = t.id WHERE t.shipped BETWEEN vDate AND util.dayEnd(vDate) AND t.clientFk NOT IN (50,400,200) AND t.companyFk = 442 - + ; END ;; @@ -67330,8 +67128,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketCalculateClon` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67339,6 +67135,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculateClon`(IN vTicketNew INT, vTicketOld INT) BEGIN @@ -67358,10 +67156,10 @@ BEGIN DECLARE vZoneFk INT; REPLACE INTO orderTicket(orderFk,ticketFk) - SELECT orderFk, vTicketNew - FROM orderTicket + SELECT orderFk, vTicketNew + FROM orderTicket WHERE ticketFk = vTicketOld; - + SELECT t.clientFk, t.warehouseFk, date(t.shipped), t.addressFk, t.agencyModeFk, t.landed, a.agencyFk, t.zoneFk INTO vClient, vWarehouse, vShipped, vAddress, vAgencyMode, vLanded, vAgency, vZoneFk FROM agencyMode a @@ -67371,47 +67169,47 @@ BEGIN IF vLanded IS NULL THEN CALL zone_getLanded(vShipped, vAddress, vAgency, vWarehouse, TRUE); UPDATE ticket t - JOIN tmp.zoneGetLanded zgl ON t.warehouseFk = zgl.warehouseFk + JOIN tmp.zoneGetLanded zgl ON t.warehouseFk = zgl.warehouseFk SET t.landed = zgl.landed, t.zoneFk = zgl.zoneFk WHERE t.id = vTicketNew; - + SELECT zoneFk INTO vZoneFk FROM tmp.zoneGetLanded LIMIT 1; DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded; END IF; -- rellena la tabla tmp.buyUltimate con la ultima compra - CALL buyUltimate(vWarehouse, vShipped); + CALL buyUltimate(vWarehouse, vShipped); DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot + CREATE TEMPORARY TABLE tmp.ticketLot SELECT vWarehouse warehouseFk, NULL available, s.itemFk, bu.buyFk, vZoneFk zoneFk FROM sale s LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk WHERE s.ticketFk = vTicketOld GROUP BY s.itemFk; - - CALL catalog_componentPrepare(); + + CALL catalog_componentPrepare(); CALL catalog_componentCalculate(vZoneFk, vAddress, vShipped, vWarehouse); -- Bionizamos lineas con Preu = 0 DROP TEMPORARY TABLE IF EXISTS tmp.sale; CREATE TEMPORARY TABLE tmp.sale (PRIMARY KEY (saleFk)) ENGINE = MEMORY - SELECT s.id saleFk, vWarehouse warehouseFk + SELECT s.id saleFk, vWarehouse warehouseFk FROM sale s JOIN ticket t on t.id = s.ticketFk WHERE s.ticketFk = vTicketNew AND s.price = 0; - + CALL ticketComponentUpdateSale(1); -- Bionizamos lineas con Preu > 0 DROP TEMPORARY TABLE IF EXISTS tmp.sale; CREATE TEMPORARY TABLE tmp.sale (PRIMARY KEY (saleFk)) ENGINE = MEMORY - SELECT s.id saleFk, vWarehouse warehouseFk - FROM sale s + SELECT s.id saleFk, vWarehouse warehouseFk + FROM sale s JOIN ticket t on t.id = s.ticketFk WHERE s.ticketFk = vTicketNew AND s.price > 0; - + CALL ticketComponentUpdateSale(6); -- Log @@ -67419,19 +67217,17 @@ BEGIN -- Limpieza CALL catalog_componentPurge(); - DROP TEMPORARY TABLE IF EXISTS - tmp.buyUltimate, - tmp.sale, + DROP TEMPORARY TABLE IF EXISTS + tmp.buyUltimate, + tmp.sale, tmp.zoneGetLanded; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketCalculateFromType` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67439,6 +67235,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculateFromType`( vLanded DATE, vAddressFk INT, @@ -67446,12 +67244,12 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculateFromType`( vLanded D vTypeFk INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.item; - CREATE TEMPORARY TABLE tmp.item - (INDEX (itemFk)) - ENGINE = MEMORY + CREATE TEMPORARY TABLE tmp.item + (INDEX (itemFk)) + ENGINE = MEMORY SELECT id itemFk FROM vn.item WHERE typeFk = vTypeFk; - + CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk); DROP TEMPORARY TABLE tmp.item; DROP TEMPORARY TABLE tmp.ticketLot; @@ -67461,8 +67259,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketCalculatePurge` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67470,10 +67266,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculatePurge`() BEGIN - DROP TEMPORARY TABLE + DROP TEMPORARY TABLE tmp.ticketCalculateItem, tmp.ticketComponentPrice, tmp.ticketComponent, @@ -67485,8 +67283,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketClon` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67494,67 +67290,67 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketClon`(vTicketFk INT, vNewShipped DATE) BEGIN - + DECLARE done INT DEFAULT FALSE; - DECLARE vNewTicketFk INT; + DECLARE vNewTicketFk INT; DECLARE vOldSaleFk INT; DECLARE vNewSaleFk INT; - + DECLARE cur1 CURSOR FOR SELECT id FROM vn.sale WHERE ticketFk = vTicketFk; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - - SET vNewShipped = IFNULL(vNewShipped, CURDATE()); - + + SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE()); + CALL vn.ticket_Clone(vTicketFk, vNewTicketFk); - - UPDATE vn.ticket + + UPDATE vn.ticket SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed), shipped = vNewShipped WHERE id = vNewTicketFk; - + OPEN cur1; - + read_loop: LOOP - + FETCH cur1 INTO vOldSaleFk; - + IF done THEN LEAVE read_loop; END IF; - + INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed) SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed FROM vn.sale WHERE id = vOldSaleFk; - + SELECT max(id) INTO vNewSaleFk FROM vn.sale WHERE ticketFk = vNewTicketFk; - + INSERT INTO vn.saleComponent(saleFk, componentFk, value, isGreuge) SELECT vNewSaleFk, componentFk, value, isGreuge FROM vn.saleComponent WHERE saleFk = vOldSaleFk; - + END LOOP; CLOSE cur1; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketClon_OneYear` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67562,24 +67358,26 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketClon_OneYear`(vTicketFk INT) BEGIN DECLARE vShipped DATE; DECLARE vMaxDated DATE; - - SELECT shipped, TIMESTAMPADD(YEAR,1,shipped) + + SELECT shipped, TIMESTAMPADD(YEAR,1,shipped) INTO vShipped, vMaxDated FROM vn.ticket WHERE id = vTicketFk; - + WHILE vShipped <= vMaxDated DO - + SET vShipped = TIMESTAMPADD(WEEK, 1, vShipped); - + CALL vn.ticketClon(vTicketFk, vShipped); - + END WHILE; END ;; @@ -67588,8 +67386,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketCollection_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67597,22 +67393,22 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCollection_get`(vTicketFk INT) BEGIN - SELECT tc.collectionFk + SELECT tc.collectionFk FROM vn.ticketCollection tc WHERE ticketFk = vTicketFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketCollection_setUsedShelves` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67620,29 +67416,29 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCollection_setUsedShelves`(vTicketFk INT, vUsedShelves INT) BEGIN - + /* * Inserta número de baldas que ocupa un ticket - * + * * @param vTicketFk Identificador de ticket * @param vUsedShelves Número de baldas */ - + UPDATE ticketCollection tc SET tc.usedShelves = vUsedShelves WHERE tc.ticketFk = vTicketFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketComponentUpdate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67650,6 +67446,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketComponentUpdate`( vTicketFk INT, @@ -67672,18 +67470,18 @@ BEGIN END; START TRANSACTION; - + IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN - - UPDATE ticket t + + UPDATE ticket t JOIN address a ON a.id = vAddressFk SET t.nickname = a.nickname WHERE t.id = vTicketFk; - + END IF; - + UPDATE ticket t - SET + SET t.clientFk = vClientFk, t.agencyModeFk = vAgencyModeFk, t.addressFk = vAddressFk, @@ -67694,12 +67492,12 @@ BEGIN 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 @@ -67719,8 +67517,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketComponentUpdateSale` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67728,6 +67524,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketComponentUpdateSale`(vOption INT) BEGIN @@ -67741,104 +67539,104 @@ BEGIN DECLARE vComponentFk INT; DECLARE vRenewComponents BOOLEAN; DECLARE vKeepPrices BOOLEAN; - + CASE vOption - WHEN 1 THEN + WHEN 1 THEN SET vRenewComponents = TRUE; SET vKeepPrices = FALSE; WHEN 2 THEN - SELECT id INTO vComponentFk FROM component WHERE `code` = 'debtCollection'; + SELECT id INTO vComponentFk FROM component WHERE `code` = 'debtCollection'; SET vRenewComponents = TRUE; SET vKeepPrices = TRUE; - WHEN 3 THEN - SELECT id INTO vComponentFk FROM component WHERE `code` = 'mana'; - SET vRenewComponents = TRUE; - SET vKeepPrices = TRUE; - WHEN 4 THEN - SELECT id INTO vComponentFk FROM component WHERE `code` = 'buyerDiscount'; + WHEN 3 THEN + SELECT id INTO vComponentFk FROM component WHERE `code` = 'mana'; SET vRenewComponents = TRUE; SET vKeepPrices = TRUE; - /* WHEN 5 THEN + WHEN 4 THEN + SELECT id INTO vComponentFk FROM component WHERE `code` = 'buyerDiscount'; + SET vRenewComponents = TRUE; + SET vKeepPrices = TRUE; + /* WHEN 5 THEN SET vComponentFk = 35; SET vRenewComponents = TRUE; SET vKeepPrices = TRUE;*/ - WHEN 6 THEN + WHEN 6 THEN SELECT id INTO vComponentFk FROM component WHERE `code` = 'imbalance'; SET vRenewComponents = TRUE; SET vKeepPrices = TRUE; WHEN 7 THEN REPLACE INTO saleComponent(saleFk, componentFk, value) - SELECT s.id, 28, ROUND(((s.price * (100 - s.discount) / 100) - SUM(IFNULL(sc.value, 0))) * 0.8, 3) + SELECT s.id, 28, ROUND(((s.price * (100 - s.discount) / 100) - SUM(IFNULL(sc.value, 0))) * 0.8, 3) FROM sale s JOIN tmp.sale tmps ON tmps.saleFk = s.id - LEFT JOIN saleComponent sc ON sc.saleFk = s.id + LEFT JOIN saleComponent sc ON sc.saleFk = s.id AND sc.componentFk NOT IN (28, 29) GROUP BY s.id; - + REPLACE INTO saleComponent(saleFk, componentFk, value) - SELECT s.id, 29, ROUND(((s.price * (100 - s.discount) / 100) - SUM(IFNULL(sc.value, 0))) * 0.2, 3) + SELECT s.id, 29, ROUND(((s.price * (100 - s.discount) / 100) - SUM(IFNULL(sc.value, 0))) * 0.2, 3) FROM sale s JOIN tmp.sale tmps ON tmps.saleFk = s.id - LEFT JOIN saleComponent sc ON sc.saleFk = s.id + LEFT JOIN saleComponent sc ON sc.saleFk = s.id AND sc.componentFk NOT IN (28, 29) GROUP BY s.id; - + SET vRenewComponents = FALSE; SET vKeepPrices = FALSE; WHEN 8 THEN - DELETE sc.* + DELETE sc.* FROM tmp.sale tmps JOIN saleComponent sc ON sc.saleFk = tmps.saleFk; - + REPLACE INTO saleComponent(saleFk, componentFk, value) - SELECT s.id, 28, ROUND(((s.price * (100 - s.discount) / 100)), 3) + SELECT s.id, 28, ROUND(((s.price * (100 - s.discount) / 100)), 3) FROM sale s JOIN tmp.sale tmps ON tmps.saleFk = s.id; - + SET vRenewComponents = FALSE; SET vKeepPrices = FALSE; - WHEN 9 THEN + WHEN 9 THEN SET vRenewComponents = TRUE; SET vKeepPrices = TRUE; END CASE; IF vRenewComponents THEN - DELETE sc.* - FROM tmp.sale tmps + DELETE sc.* + FROM tmp.sale tmps JOIN saleComponent sc ON sc.saleFk = tmps.saleFk JOIN `component` c ON c.id = sc.componentFk WHERE c.isRenewable; - + REPLACE INTO saleComponent(saleFk, componentFk, value) SELECT s.id, tc.componentFk, tc.cost - FROM sale s + FROM sale s JOIN tmp.sale tmps ON tmps.saleFk = s.id JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk AND tc.warehouseFk = tmps.warehouseFk - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - AND sc.componentFk = tc.componentFk - LEFT JOIN `component` c ON c.id = tc.componentFk + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + AND sc.componentFk = tc.componentFk + LEFT JOIN `component` c ON c.id = tc.componentFk WHERE IF(sc.componentFk IS NULL AND NOT c.isRenewable, FALSE, TRUE); - - -- Añadir componente venta por paquete + + -- Añadir componente venta por paquete DROP TEMPORARY TABLE IF EXISTS tmp.sale2; CREATE TEMPORARY TABLE tmp.sale2 (PRIMARY KEY (saleFk)) - ENGINE = MEMORY + ENGINE = MEMORY SELECT * FROM tmp.sale; - + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent2; CREATE TEMPORARY TABLE tmp.ticketComponent2 - SELECT * FROM tmp.ticketComponent; - - REPLACE INTO saleComponent(saleFk, componentFk, value) + SELECT * FROM tmp.ticketComponent; + + REPLACE INTO saleComponent(saleFk, componentFk, value) SELECT t.id, t.componentFk, t.cost FROM ( SELECT s.id, tc.componentFk, tc.cost, MOD(s.quantity, b.packing) as resto FROM vn.sale s JOIN tmp.sale tmps ON tmps.saleFk = s.id - JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND tmps.warehouseFk = lb.warehouse_id + JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND tmps.warehouseFk = lb.warehouse_id JOIN vn.buy b ON b.id = buy_id JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk AND tc.warehouseFk = tmps.warehouseFk - JOIN `component` c ON c.id = tc.componentFk AND c.code = 'salePerPackage' + JOIN `component` c ON c.id = tc.componentFk AND c.code = 'salePerPackage' LEFT JOIN ( SELECT s.id FROM vn.sale s @@ -67849,8 +67647,8 @@ BEGIN ) tp ON tp.id = s.id WHERE tp.id IS NULL HAVING resto <> 0) t; - - DROP TEMPORARY TABLE IF EXISTS + + DROP TEMPORARY TABLE IF EXISTS tmp.sale2, tmp.ticketComponent2; END IF; @@ -67868,26 +67666,26 @@ BEGIN UPDATE sale s JOIN item i on i.id = s.itemFk JOIN itemType it on it.id = i.typeFk - JOIN (SELECT SUM(sc.value) sumValue, sc.saleFk + JOIN (SELECT SUM(sc.value) sumValue, sc.saleFk 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 / ((100 - s.discount) / 100) - WHERE it.code != 'PRT' ; - + WHERE it.code != 'PRT' ; + REPLACE INTO saleComponent(saleFk, componentFk, value) SELECT s.id, 21, ROUND((s.price * (100 - s.discount) / 100) - SUM(value), 3) saleValue FROM sale s JOIN tmp.sale tmps ON tmps.saleFk = s.id LEFT JOIN saleComponent sc ON sc.saleFk = s.id WHERE sc.componentFk != 21 - GROUP BY s.id + GROUP BY s.id HAVING ROUND(saleValue, 4) <> 0; END IF; - + UPDATE sale s JOIN ( - SELECT SUM(sc.value) sumValue, sc.saleFk + SELECT SUM(sc.value) sumValue, sc.saleFk FROM saleComponent sc JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk JOIN `component` c ON c.id = sc.componentFk @@ -67901,10 +67699,10 @@ BEGIN JOIN sale s on s.id = sc.saleFk JOIN item i ON i.id = s.itemFk JOIN itemType it ON it.id = i.typeFk - WHERE it.code = 'PRT'; - + WHERE it.code = 'PRT'; + INSERT INTO saleComponent(saleFk, componentFk, value) - SELECT s.id, 15, s.price + SELECT s.id, 15, s.price FROM sale s JOIN tmp.sale tmps ON tmps.saleFk = s.id JOIN item i ON i.id = s.itemFK @@ -67916,8 +67714,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketCreate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67925,6 +67721,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCreate`( vClientId INT @@ -67944,8 +67742,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketCreateWithUser` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67953,6 +67749,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCreateWithUser`( vClientId INT @@ -67985,8 +67783,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketDown_PrintableSelection` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67994,6 +67790,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketDown_PrintableSelection`(vSectorFk INT) BEGIN @@ -68020,8 +67818,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketGetTaxAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68029,6 +67825,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetTaxAdd`(vTicketFk INT) BEGIN @@ -68040,32 +67838,30 @@ BEGIN CREATE TEMPORARY TABLE tmp.ticket ENGINE = MEMORY SELECT vTicketFk ticketFk; - + CALL vn.ticket_getTax(NULL); - SELECT + SELECT tt.ticketFk, CAST(tt.taxableBase AS DECIMAL(10, 2)) AS taxableBase, CAST(tt.rate * tt.taxableBase / 100 AS DECIMAL(10, 2)) AS tax, - pgc.*, + pgc.*, CAST(IF(pe.equFk IS NULL, taxableBase, 0) AS DECIMAL(10, 2)) AS Base, pgc.rate / 100 as vatPercent FROM tmp.ticketTax tt JOIN vn.pgc ON pgc.code = tt.pgcFk LEFT JOIN vn.pgcEqu pe ON pe.equFk = pgc.code; - + DROP TEMPORARY TABLE tmp.ticket; DROP TEMPORARY TABLE tmp.ticketTax; DROP TEMPORARY TABLE tmp.ticketAmount; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketGetTax_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68073,6 +67869,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetTax_new`() READS SQL DATA @@ -68095,29 +67893,29 @@ BEGIN JOIN ticket t ON t.id = tmpTicket.ticketFk; CALL addressTaxArea (); - + DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax; CREATE TEMPORARY TABLE tmp.ticketTax (INDEX (ticketFk)) ENGINE = MEMORY SELECT tmpTicket.ticketFk, bp.pgcFk, - SUM(ROUND(s.quantity * s.price * (100 - s.discount)/100,2) + SUM(ROUND(s.quantity * s.price * (100 - s.discount)/100,2) ) AS taxableBase, SUM(ROUND(s.quantity * s.price * (100 - s.discount)/100,2) ) * pgc.rate / 100 AS tax, tc.code - + FROM tmp.ticket tmpTicket JOIN sale s ON s.ticketFk = tmpTicket.ticketFk JOIN item i ON i.id = s.itemFk JOIN ticket t ON t.id = tmpTicket.ticketFk JOIN supplier su ON su.id = t.companyFk - JOIN tmp.addressTaxArea ata + JOIN tmp.addressTaxArea ata ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk - JOIN itemTaxCountry itc + JOIN itemTaxCountry itc ON itc.itemFk = i.id AND itc.countryFk = su.countryFk - JOIN bookingPlanner bp + JOIN bookingPlanner bp ON bp.countryFk = su.countryFk AND bp.taxAreaFk = ata.areaFk AND bp.taxClassFk = itc.taxClassFk @@ -68125,7 +67923,7 @@ BEGIN JOIN taxClass tc ON tc.id = bp.taxClassFk GROUP BY tmpTicket.ticketFk, pgc.code HAVING taxableBase != 0; - + DROP TEMPORARY TABLE IF EXISTS tmp.ticketAmount; CREATE TEMPORARY TABLE tmp.ticketAmount (INDEX (ticketFk)) @@ -68136,15 +67934,13 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; DROP TEMPORARY TABLE IF EXISTS tmp.addressTaxArea; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketGetTotal` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68152,6 +67948,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetTotal`() BEGIN @@ -68173,7 +67971,7 @@ BEGIN FROM tmp.ticket t LEFT JOIN tmp.ticketAmount ta ON t.ticketFk = ta.ticketFk GROUP BY ticketFk; - + DROP TEMPORARY TABLE IF EXISTS tmp.ticketAmount; DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax; END ;; @@ -68182,8 +67980,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketGetVisibleAvailable` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68191,6 +67987,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetVisibleAvailable`( vTicket INT) @@ -68207,10 +68005,10 @@ BEGIN WHERE t.id = vTicket; IF vAlertLevel IS NULL OR vAlertLevel = 0 THEN - IF vShipped >= CURDATE() THEN + IF vShipped >= util.VN_CURDATE() THEN CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped); END IF; - IF vShipped = CURDATE() THEN + IF vShipped = util.VN_CURDATE() THEN CALL cache.visible_refresh(vVisibleCalc, FALSE, vWarehouse); END IF; END IF; @@ -68228,8 +68026,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketManaToPromo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68237,24 +68033,26 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketManaToPromo`(vTicketFk INT) BEGIN - + DECLARE vManaComponent INT; - + DECLARE vPromoComponent INT; SELECT id INTO vManaComponent - FROM vn.component c + FROM vn.component c WHERE c.code = 'mana'; - + SELECT id INTO vPromoComponent - FROM vn.component c + FROM vn.component c WHERE c.code = 'floramondoPromo'; - + UPDATE vn.saleComponent sc - JOIN vn.sale s ON s.id = sc.saleFk + JOIN vn.sale s ON s.id = sc.saleFk SET componentFk = vPromoComponent WHERE componentFk = vManaComponent AND s.ticketFk = vTicketFk; @@ -68264,8 +68062,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketMissed_List` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68273,6 +68069,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketMissed_List`(vTicketFk INT) BEGIN @@ -68281,18 +68079,18 @@ BEGIN DECLARE vParked DATETIME; DECLARE vLevel INT; DECLARE vCollectionFk INT; - - SELECT IFNULL(`level`,0), IFNULL(collectionFk,0) + + SELECT IFNULL(`level`,0), IFNULL(collectionFk,0) INTO vLevel, vCollectionFk FROM vn.ticketCollection WHERE ticketFk = vTicketFk LIMIT 1; - - SELECT created, parkingFk + + SELECT created, parkingFk INTO vParked, vParkingFk FROM vn.ticketParking WHERE ticketFk = vTicketFk; - + SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia FROM vn.ticketParking tp JOIN vn.parking p ON p.id = tp.parkingFk @@ -68319,15 +68117,13 @@ BEGIN AND sc.isPackagingArea AND tp.created < vParked AND t.packages <=> 0); - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketNotInvoicedByClient` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68335,12 +68131,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketNotInvoicedByClient`(vClientFk INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - + CREATE TEMPORARY TABLE tmp.ticket SELECT id ticketFk FROM ticket @@ -68350,7 +68148,7 @@ BEGIN CALL vn.ticketGetTotal; - SELECT c.id, + SELECT c.id, c.name as Cliente, t.shipped as Fecha, t.id as Id_Ticket, @@ -68361,7 +68159,7 @@ BEGIN DROP TEMPORARY TABLE tmp.ticket, - tmp.ticketTotal; + tmp.ticketTotal; END ;; DELIMITER ; @@ -68369,8 +68167,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketObservation_addNewBorn` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68378,32 +68174,32 @@ DELIMITER ; /*!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`@`localhost` PROCEDURE `ticketObservation_addNewBorn`(vTicketFk INT) BEGIN - + /** * Inserta observaciones para los tickets con clientes nuevos o recuperados - * + * * @param vTicketFk Identificador de vn.ticket */ - + DECLARE vDescription VARCHAR(20) DEFAULT '¡Cliente NUEVO! '; INSERT INTO vn.ticketObservation(ticketFk, observationTypeFk, description) SELECT vTicketFk, ot.id, vDescription FROM vn.observationType ot WHERE ot.hasNewBornMessage - ON DUPLICATE KEY UPDATE description = CONCAT(vDescription, ticketObservation.description); - + ON DUPLICATE KEY UPDATE description = CONCAT(vDescription, ticketObservation.description); + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketParking_findSkipped` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68411,40 +68207,42 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketParking_findSkipped`(vTicketFk INT, vItemPackingTypeFk VARCHAR(1)) BEGIN - + /** * Averigua los tickets que se han saltado por un error en el proceso encajado * @param vTicketFk Ticket * @param vItemPackingTypeFk Modo de encajado * @return un select con los tickets afectados - */ + */ DECLARE vParkingFk INT; DECLARE vParked DATETIME; DECLARE vLevel INT; DECLARE vWagon INT; DECLARE vCollectionFk INT; - - SELECT IFNULL(`level`,0), IFNULL(`wagon`,0),IFNULL(collectionFk,0) + + SELECT IFNULL(`level`,0), IFNULL(`wagon`,0),IFNULL(collectionFk,0) INTO vLevel, vWagon, vCollectionFk FROM vn.ticketCollection tc JOIN vn.collection c ON c.id = tc.collectionFk AND c.itemPackingTypeFk = vItemPackingTypeFk WHERE ticketFk = vTicketFk ORDER BY c.id DESC LIMIT 1; - - SELECT created, parkingFk + + SELECT created, parkingFk INTO vParked, vParkingFk FROM vn.ticketParking tp - JOIN vn.parking p ON p.id = tp.parkingFk - JOIN vn.sector s ON s.id = p.sectorFk + JOIN vn.parking p ON p.id = tp.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk WHERE ticketFk = vTicketFk AND s.itemPackingTypeFk = vItemPackingTypeFk AND s.isPackagingArea ; - + SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' ', tc.wagon, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia FROM vn.ticketParking tp JOIN vn.parking p ON p.id = tp.parkingFk @@ -68461,9 +68259,9 @@ BEGIN AND ( ( IFNULL(tc.collectionFk,-1) != IFNULL(@vCollectionFk,0) AND tp.created < vParked ) OR - ( tc.collectionFk = vCollectionFk + ( tc.collectionFk = vCollectionFk AND (LEFT(tc.wagon,1) < LEFT(vWagon,1) - OR (LEFT(tc.wagon,1) = LEFT(vWagon,1) AND LEFT(tc.level,1) < LEFT(vLevel,1))) + OR (LEFT(tc.wagon,1) = LEFT(vWagon,1) AND LEFT(tc.level,1) < LEFT(vLevel,1))) ) ) ) -- Etiquetas que no se han escaneado y ya estamos con una posterior @@ -68471,7 +68269,7 @@ BEGIN (s.alertLevel > 1 AND tp.parkingFk = vParkingFk AND sc.isPackagingArea - AND tp.created < vParked + AND tp.created < vParked AND t.packages <=> 0); END ;; DELIMITER ; @@ -68479,8 +68277,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketRefund_beforeUpsert` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68488,19 +68284,21 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketRefund_beforeUpsert`(vRefundTicketFk INT, vOriginalTicketFk INT) BEGIN - DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE; + DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE; IF vRefundTicketFk = vOriginalTicketFk THEN CALL util.throw('Original ticket and refund ticket has same id'); END IF; - SELECT COUNT(*) INTO vAlreadyExists - FROM ticketRefund - WHERE refundTicketFk = vOriginalTicketFk; - + SELECT COUNT(*) INTO vAlreadyExists + FROM ticketRefund + WHERE originalTicketFk = vOriginalTicketFk; + IF vAlreadyExists > 0 THEN CALL util.throw('This ticket is already a refund'); END IF; @@ -68510,8 +68308,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketRequest_Add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68519,15 +68315,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketRequest_Add`(vDescription VARCHAR(255), vQuantity INT, vPrice DOUBLE, vTicketFk INT, vBuyerCode VARCHAR(3)) BEGIN - INSERT INTO vn.ticketRequest(description, - quantity, - price, - ticketFk, - buyerCode, + INSERT INTO vn.ticketRequest(description, + quantity, + price, + ticketFk, + buyerCode, requesterFk) VALUES(vDescription, vQuantity, @@ -68535,15 +68333,13 @@ BEGIN vTicketFk, vBuyerCode, vn.getUser()); - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketStateToday_setState` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68551,29 +68347,31 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketStateToday_setState`(vTicketFk INT, vStateCode VARCHAR(45)) BEGIN - + /* Modifica el estado de un ticket de hoy - * + * * @param vTicketFk el id del ticket * @param vStateCode estado a modificar del ticket - * + * */ - + DECLARE vAlertLevel INT; - - SELECT s.alertLevel INTO vAlertLevel - FROM state s - JOIN ticketStateToday tst ON tst.state = s.id + + SELECT s.alertLevel INTO vAlertLevel + FROM state s + JOIN ticketStateToday tst ON tst.state = s.id WHERE tst.ticket = vTicketFk LIMIT 1; - + IF vAlertLevel < 2 THEN - + CALL vn.ticket_setState(vTicketFk, vStateCode); - + END IF; END ;; @@ -68582,8 +68380,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketStateUpdate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68591,28 +68387,30 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketStateUpdate`(vTicketFk INT, vStateCode VARCHAR(45)) BEGIN - + /* * @deprecated:utilizar ticket_setState */ - + DECLARE vAlertLevel INT; - SELECT s.alertLevel INTO vAlertLevel + SELECT s.alertLevel INTO vAlertLevel FROM vn.state s JOIN vn.ticketState ts ON ts.stateFk = s.id WHERE ts.ticketFk = vTicketFk; - - IF !(vStateCode = 'ON_CHECKING' AND vAlertLevel > 1) THEN - + + IF !(vStateCode = 'ON_CHECKING' AND vAlertLevel > 1) THEN + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) SELECT id, vTicketFk, account.myUser_getId() - FROM vn.state + FROM vn.state WHERE `code` = vStateCode collate utf8_unicode_ci; - + END IF; END ;; @@ -68621,8 +68419,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketToInvoiceByAddress` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68630,6 +68426,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketToInvoiceByAddress`( vStarted DATE, @@ -68657,8 +68455,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketToInvoiceByDate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68666,6 +68462,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketToInvoiceByDate`( vStarted DATE, @@ -68693,8 +68491,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketToInvoiceByRef` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68702,6 +68498,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketToInvoiceByRef`(IN vInvoiceRef VARCHAR(15)) BEGIN @@ -68715,36 +68513,36 @@ BEGIN DECLARE vCountry INT; DECLARE vTaxArea VARCHAR(15); DECLARE vSpainCountryCode INT DEFAULT 1; - - SELECT id - INTO vInvoice - FROM vn.invoiceOut + + SELECT id + INTO vInvoice + FROM vn.invoiceOut WHERE ref = vInvoiceRef; - - SELECT s.countryFk + + SELECT s.countryFk INTO vCountry FROM vn.supplier s JOIN vn.invoiceOut io ON io.companyFk = s.id WHERE io.id = vInvoice; - + SELECT IF( - c.isEqualizated - AND c.countryFk = vSpainCountryCode + c.isEqualizated + AND c.countryFk = vSpainCountryCode AND i.taxAreaFk = 'NATIONAL', 'EQU', i.taxAreaFk ) INTO vTaxArea FROM vn.invoiceOutSerial i - JOIN vn.invoiceOut io ON io.serial = i.code + JOIN vn.invoiceOut io ON io.serial = i.code JOIN vn.client c ON c.id = io.clientFk WHERE io.id = vInvoice; - + DROP TEMPORARY TABLE IF EXISTS vn.ticketToInvoice; CREATE TEMPORARY TABLE vn.ticketToInvoice - SELECT id - FROM vn.ticket + SELECT id + FROM vn.ticket WHERE refFk = vInvoiceRef; END ;; @@ -68753,8 +68551,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketTrackingAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68762,6 +68558,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketTrackingAdd`(vTicketFk INT, vState VARCHAR(25) CHARSET UTF8, vWorkerFk INT) BEGIN @@ -68779,8 +68577,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68788,6 +68584,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_add`( vClientId INT @@ -68902,8 +68700,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_administrativeCopy` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68911,31 +68707,31 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_administrativeCopy`(vOriginalTicket INT, OUT vNewTicket INT) BEGIN - + INSERT INTO vn.ticket(clientFk, addressFk, shipped, warehouseFk, companyFk, landed) - SELECT t.clientFk , t.addressFk , t.shipped ,w.id, t.companyFk , t.landed + SELECT t.clientFk , t.addressFk , t.shipped ,w.id, t.companyFk , t.landed FROM vn.ticket t JOIN vn.warehouse w ON w.name = 'INVENTARIO' WHERE t.id = vOriginalTicket; - + SELECT LAST_INSERT_ID() INTO vNewTicket; INSERT INTO vn.sale(ticketFk, itemFk, concept, quantity, price, discount) - SELECT vNewTicket, s.itemFk , s.concept , s.quantity , s.price , s.discount + SELECT vNewTicket, s.itemFk , s.concept , s.quantity , s.price , s.discount 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_canAdvance` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68943,12 +68739,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_canAdvance`(vDated DATE, vWarehouseFk INT) BEGIN /** * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. - * + * * @param vDated Fecha de los tickets que se quieren adelantar. * @param vWarehouseFk Almacén */ @@ -68956,7 +68754,7 @@ BEGIN DECLARE vDateToAdvance DATE; SELECT inventoried INTO vDateInventory FROM vn.config; - + SET vDateToAdvance = TIMESTAMPADD(DAY,-1,vDated); DROP TEMPORARY TABLE IF EXISTS tmp.stock; @@ -68971,7 +68769,7 @@ BEGIN SELECT itemFk, quantity FROM vn.itemTicketOut WHERE shipped >= vDateInventory - AND shipped < vDated + AND shipped < vDated AND warehouseFk = vWarehouseFk UNION ALL SELECT itemFk, quantity @@ -68983,8 +68781,8 @@ BEGIN UNION ALL SELECT itemFk, quantity FROM vn.itemEntryOut - WHERE shipped >= vDateInventory - AND shipped < vDated + WHERE shipped >= vDateInventory + AND shipped < vDated AND warehouseOutFk = vWarehouseFk ) t GROUP BY itemFk HAVING amount != 0; @@ -68999,9 +68797,9 @@ BEGIN t2.ipt FROM vn.ticket t JOIN vn.ticketState ts ON ts.ticketFk = t.id - JOIN vn.state st ON st.id = ts.stateFk - LEFT JOIN (SELECT - t2.id ticketFk, + JOIN vn.state st ON st.id = ts.stateFk + LEFT JOIN (SELECT + t2.id ticketFk, t2.addressFk, st.name state, GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt @@ -69009,17 +68807,17 @@ BEGIN JOIN vn.sale s ON s.ticketFk = t2.id JOIN vn.item i ON i.id = s.itemFk JOIN vn.ticketState ts ON ts.ticketFk = t2.id - JOIN vn.state st ON st.id = ts.stateFk + JOIN vn.state st ON st.id = ts.stateFk WHERE t2.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) AND t2.warehouseFk = vWarehouseFk GROUP BY t2.id) t2 ON t2.addressFk = t.addressFk JOIN vn.sale s ON s.ticketFk = t.id JOIN vn.item i ON i.id = s.itemFk - LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk + LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk WHERE t.shipped BETWEEN vDated AND util.dayend(vDated) AND t.warehouseFk = vWarehouseFk GROUP BY t.id; - + DROP TEMPORARY TABLE tmp.stock; END ;; DELIMITER ; @@ -69027,8 +68825,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_canMerge` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -69036,64 +68832,66 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` 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 , - GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, - CAST(sum(litros) AS DECIMAL(10,0)) liters, - CAST(count(*) AS DECIMAL(10,0)) `lines`, + SELECT sv.ticketFk , + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, + CAST(sum(litros) AS DECIMAL(10,0)) liters, + CAST(count(*) AS DECIMAL(10,0)) `lines`, st.name state, sub2.id ticketFuture, sub2.shipped, sub2.iptd tfIpt, sub2.state tfState - FROM vn.saleVolume sv - JOIN vn.sale s ON s.id = sv.saleFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.ticket t ON t.id = sv.ticketFk - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.province p ON p.id = a.provinceFk - JOIN vn.country c ON c.id = p.countryFk + FROM vn.saleVolume sv + JOIN vn.sale s ON s.id = sv.saleFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.ticket t ON t.id = sv.ticketFk + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.province p ON p.id = a.provinceFk + JOIN vn.country c ON c.id = p.countryFk JOIN vn.ticketState ts ON ts.ticketFk = t.id - JOIN vn.state st ON st.id = ts.stateFk - JOIN vn.alertLevel al ON al.id = ts.alertLevel + JOIN vn.state st ON st.id = ts.stateFk + JOIN vn.alertLevel al ON al.id = ts.alertLevel LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id LEFT JOIN ( SELECT * FROM ( - SELECT - t.addressFk , - t.id, - t.shipped, + SELECT + t.addressFk , + t.id, + t.shipped, st.name state, GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd - FROM vn.ticket t + FROM vn.ticket t JOIN vn.ticketState ts ON ts.ticketFk = t.id - JOIN vn.state st ON st.id = ts.stateFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - WHERE t.shipped BETWEEN TIMESTAMPADD(DAY, vScopeDays,vDated) - AND util.dayend(TIMESTAMPADD(DAY, vScopeDays,vDated)) + JOIN vn.state st ON st.id = ts.stateFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + WHERE t.shipped BETWEEN TIMESTAMPADD(DAY, vScopeDays,vDated) + AND util.dayend(TIMESTAMPADD(DAY, vScopeDays,vDated)) AND t.warehouseFk = vWarehouseFk GROUP BY t.id - ) sub + ) 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 AND al.code = 'FREE' AND tp.ticketFk IS NULL - GROUP BY sv.ticketFk + GROUP BY sv.ticketFk HAVING liters <= vLitersMax AND `lines` <= vLinesMax AND ticketFuture; END ;; DELIMITER ; @@ -69101,8 +68899,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_changeClient` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -69110,46 +68906,46 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_changeClient`(vNewClient INT, vUserFk INT) BEGIN - + /** * Dado un conjunto de tickets * cambia el cliente al nuevo cliente dado - * + * * params @vNewClient nuevo cliente * params @vUserFk usuario que realiza el cambio - * + * * table @tmp.ticket(ticketFk) conjunto de tickets */ - + INSERT INTO ticketLog (originFk, userFk, `action`, changedModel, oldInstance, newInstance) SELECT t.id, vUserFk, 'update', 'Ticket', CONCAT('{"clientFk":',t.clientFk,'}'), CONCAT('{"clientFk":',vNewClient,'}') FROM ticket t - JOIN tmp.ticket tt + JOIN tmp.ticket tt ON t.id = tt.ticketFk; - + UPDATE ticket t JOIN tmp.ticket tt ON t.id = tt.ticketFk SET t.clientFk = vNewClient; - + UPDATE ticket t JOIN tmp.ticket tt ON t.id = tt.ticketFk JOIN stowaway s 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_checkFullyControlled` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -69157,47 +68953,47 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` 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 + * 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 + 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 (SELECT tc.collectionFk + FROM ticketState ts JOIN ticketCollection tc ON tc.ticketFk = ts.ticketFk - LEFT JOIN (SELECT tc.collectionFk - FROM ticketCollection tc + LEFT JOIN (SELECT tc.collectionFk + FROM ticketCollection tc WHERE ticketFk = vTicketFk - AND tc.created >= CURDATE() + AND tc.created >= util.VN_CURDATE() )sub ON sub.collectionFk = tc.collectionFk WHERE ts.workerFk = vWorkerFk AND sub.collectionFk IS NULL - AND tc.created >= CURDATE() + AND tc.created >= util.VN_CURDATE() GROUP BY tc.collectionFk - )sub ON sub.collectionFk = 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() + WHERE ts.code IN ('ON_PREPARATION', 'PREPARED', 'PREVIOUS_PREPARATION', 'OK PREVIOUS') + AND t.shipped >= util.VN_CURDATE() AND s.quantity <>0 LIMIT 1; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_checkNoComponents` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -69205,6 +69001,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_checkNoComponents`(vShippedFrom DATETIME, vShippedTo DATETIME) BEGIN @@ -69212,7 +69010,7 @@ BEGIN /** * Comprueba que los tickets entre un rango de fechas tienen componentes * - * @param vShippedFrom rango inicial de fecha + * @param vShippedFrom rango inicial de fecha * @param vShippedTo rango final de fecha */ DECLARE v_done BOOL DEFAULT FALSE; @@ -69231,9 +69029,9 @@ BEGIN AND clt.isActive != 0 AND ic.merchandise != 0 GROUP BY s.id; - + DECLARE CONTINUE HANDLER FOR NOT FOUND - SET v_done = TRUE; + SET v_done = TRUE; DROP TEMPORARY TABLE IF EXISTS tmp.coste; @@ -69252,7 +69050,7 @@ BEGIN JOIN componentType ct ON ct.id = c.typeFk AND ct.id = 1 WHERE t.shipped >= vShippedFrom AND ic.merchandise != 0; - + OPEN vCur; l: LOOP @@ -69266,16 +69064,14 @@ BEGIN CALL sale_calculateComponent(vSaleFk, 1); END LOOP; - CLOSE vCur; - DROP TEMPORARY TABLE tmp.coste; + CLOSE vCur; + DROP TEMPORARY TABLE tmp.coste; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_Clone` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -69283,6 +69079,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT) BEGIN @@ -69291,7 +69089,7 @@ BEGIN * * @param vOriginalTicket ticket Original * @param vNewTicket ticket creado - */ + */ DECLARE vStateFk INT; INSERT INTO ticket ( @@ -69308,7 +69106,7 @@ BEGIN zoneBonus, routeFk, priority, - hasPriority + hasPriority ) SELECT clientFk, @@ -69324,29 +69122,29 @@ BEGIN zoneBonus, routeFk, priority, - hasPriority + hasPriority FROM ticket WHERE id = vOriginalTicket; SET vNewTicket = LAST_INSERT_ID(); - + INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) SELECT vNewTicket, ao.observationTypeFk, ao.description FROM addressObservation ao JOIN ticket t ON t.addressFk = ao.addressFk WHERE t.id = vNewTicket; - + INSERT INTO ticketLog - SET originFk = vNewTicket, userFk = account.myUser_getId(), `action` = 'insert', + SET originFk = vNewTicket, userFk = account.myUser_getId(), `action` = 'insert', description = CONCAT('Ha creado el ticket:', ' ', vNewTicket, ' clonando el ', vOriginalTicket); - + INSERT INTO ticketLog - SET originFk = vOriginalTicket, userFk = account.myUser_getId(), `action` = 'insert', + SET originFk = vOriginalTicket, userFk = account.myUser_getId(), `action` = 'insert', description = CONCAT('Ha creado el ticket:', ' ', vNewTicket, ' clonando el ', vOriginalTicket); INSERT INTO vncontrol.inter(Id_Ticket, state_id, Id_Trabajador, odbc_date) SELECT vNewTicket, state_id, Id_Trabajador , odbc_date - FROM vncontrol.inter + FROM vncontrol.inter WHERE Id_Ticket = vOriginalTicket ORDER BY odbc_date; END ;; @@ -69355,8 +69153,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_cloneWeekly` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -69364,6 +69160,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_cloneWeekly`(IN vWeek INT) BEGIN @@ -69379,16 +69177,16 @@ BEGIN DECLARE vAgencyModeFk INT; DECLARE vNewTicket INT; DECLARE vYear INT; - + DECLARE rsTicket CURSOR FOR SELECT tt.ticketFk, tt.weekDay, t.clientFk, t.warehouseFk, t.companyFk, t.addressFk, tt.agencyModeFk - FROM vn.ticketWeekly tt + FROM vn.ticketWeekly tt JOIN vn.ticket t ON tt.ticketFk = t.id; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE; - SET vYear = YEAR(CURDATE()) + IF(vWeek < WEEK(CURDATE()),1, 0); - + SET vYear = YEAR(util.VN_CURDATE()) + IF(vWeek < WEEK(util.VN_CURDATE()),1, 0); + OPEN rsTicket; myLoop: LOOP BEGIN @@ -69404,7 +69202,7 @@ BEGIN LEAVE myLoop; END IF; - SELECT dated INTO vShipment + SELECT dated INTO vShipment FROM `time` WHERE `year` = vYear AND `week` = vWeek AND WEEKDAY(dated) = vWeekDay; @@ -69415,52 +69213,52 @@ BEGIN JOIN vn.saleCloned sc ON sc.saleOriginalFk = saleOrig.id JOIN vn.sale saleClon ON saleClon.id = sc.saleClonedFk JOIN vn.ticket tClon ON tClon.id = saleClon.ticketFk - WHERE tOrig.id = vTicketFk AND tClon.isDeleted = FALSE AND DATE(tClon.shipped) = vShipment) > 0 + WHERE tOrig.id = vTicketFk AND tClon.isDeleted = FALSE AND DATE(tClon.shipped) = vShipment) > 0 THEN ITERATE myLoop; END IF; - + IF vAgencyModeFk IS NULL THEN - SELECT agencyModeFk INTO vAgencyModeFk + SELECT agencyModeFk INTO vAgencyModeFk FROM address WHERE clientFk = vClientFk AND isDefaultAddress; END IF; - + CALL vn.zone_getLanded(vShipment, vAddressFk, vAgencyModeFk, vWarehouseFk,FALSE); SET vLanding = NULL; SELECT landed INTO vLanding from tmp.zoneGetLanded LIMIT 1; - + CALL ticket_add( - vClientFk, - vShipment, - vWarehouseFk, - vCompanyFk, - vAddressFk, - vAgencyModeFk, - NULL, - vLanding, - account.myUser_getId(), - FALSE, + vClientFk, + vShipment, + vWarehouseFk, + vCompanyFk, + vAddressFk, + vAgencyModeFk, + NULL, + vLanding, + account.myUser_getId(), + FALSE, vNewTicket); IF (vLanding IS NULL) THEN - + SELECT e.email INTO vSalesPersonEmail FROM vn.client c JOIN vn.worker sp ON sp.id = c.salesPersonFk JOIN account.emailUser e ON e.userFk = sp.userFk WHERE c.id = vClientFk; - + SET vSubject = CONCAT('Turnos - No se ha podido clonar correctamente el ticket ', vTicketFk, ' para el dia: ', vShipment); - SET vMessage = CONCAT('No se ha podido clonar el ticket ', vTicketFk, - ' para el dia: ', vShipment, - ' porque no hay una zona de envío disponible. Se ha creado el ticket: ', vNewTicket, + SET vMessage = CONCAT('No se ha podido clonar el ticket ', vTicketFk, + ' para el dia: ', vShipment, + ' porque no hay una zona de envío disponible. Se ha creado el ticket: ', vNewTicket, ' pero ha que revisar las fechas y la agencia'); - + SELECT COUNT(*) INTO vMailSent - FROM vn.mail - WHERE receiver = vSalesPersonEmail + FROM vn.mail + WHERE receiver = vSalesPersonEmail AND subject = vSubject; IF NOT vMailSent THEN @@ -69468,45 +69266,43 @@ BEGIN END IF; CALL vn.ticketStateUpdate (vNewTicket, 'FIXING'); END IF; - + INSERT INTO vn.sale (ticketFk, itemFk, concept, quantity, price, discount, priceFixed, isPriceFixed) SELECT vNewTicket, saleOrig.itemFk , saleOrig.concept , saleOrig.quantity, saleOrig.price , saleOrig.discount, saleOrig.priceFixed, saleOrig.isPriceFixed - FROM vn.sale saleOrig - WHERE saleOrig.ticketFk = vTicketFk; - + FROM vn.sale saleOrig + WHERE saleOrig.ticketFk = vTicketFk; + INSERT IGNORE INTO vn.saleCloned(saleOriginalFk, saleClonedFk) - SELECT saleOriginal.id, saleClon.id + SELECT saleOriginal.id, saleClon.id FROM vn.sale saleOriginal JOIN vn.sale saleClon ON saleOriginal.itemFk = saleClon.itemFk AND saleOriginal.quantity = saleClon.quantity WHERE saleOriginal.ticketFk = vTicketFk AND saleClon.ticketFk = vNewTicket; - + INSERT INTO ticketRequest (description,ordered,shipped,quantity,price,itemFk,clientFk,response, - total,buyed,requesterFk,attenderFk,ticketFk) + total,buyed,requesterFk,attenderFk,ticketFk) SELECT description,ordered,shipped,quantity,price,itemFk,clientFk,response, - total,buyed,requesterFk,attenderFk,vNewTicket + total,buyed,requesterFk,attenderFk,vNewTicket FROM ticketRequest WHERE ticketFk =vTicketFk; - + INSERT INTO ticketObservation(ticketFk,observationTypeFk,description) VALUES(vNewTicket,4,CONCAT('turno desde ticket: ',vTicketFk)) - ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); - + ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); + INSERT INTO ticketObservation(ticketFk,observationTypeFk,description) VALUES(vNewTicket,1,'ATENCION: Contiene lineas de TURNO') - ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); - + ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); + CALL vn.ticketCalculateClon(vNewTicket, vTicketFk); END; END LOOP; CLOSE rsTicket; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_close` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -69514,11 +69310,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_close`() BEGIN /** - * Realiza el cierre de todos los + * Realiza el cierre de todos los * tickets de la tabla tmp.ticket_close. * * @table tmp.ticket_close(ticketFk) Identificadores de los tickets a cerrar @@ -69536,7 +69334,7 @@ BEGIN 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; @@ -69546,7 +69344,7 @@ BEGIN proc: LOOP SET vDone = FALSE; - + FETCH cur INTO vCurTicketFk; IF vDone THEN @@ -69564,12 +69362,12 @@ BEGIN c.hasToInvoice INTO vClientFk, vIsTaxDataChecked, - vCompanyFk, + vCompanyFk, vShipped, vHasDailyInvoice, vWithPackage, vHasToInvoice - FROM ticket t + 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 @@ -69578,22 +69376,22 @@ BEGIN INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity) (SELECT vCurTicketFk, p.id, COUNT(*) - FROM expedition e + 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 + 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); - + IF(vHasDailyInvoice) AND vHasToInvoice THEN -- Facturacion rapida @@ -69601,10 +69399,10 @@ BEGIN -- Facturar si está contabilizado IF vIsTaxDataChecked THEN CALL invoiceOut_newFromClient( - vClientFk, - (SELECT invoiceSerial(vClientFk, vCompanyFk, 'M')), - vShipped, - vCompanyFk, + vClientFk, + (SELECT invoiceSerial(vClientFk, vCompanyFk, 'M')), + vShipped, + vCompanyFk, NULL, NULL, vNewInvoiceId); @@ -69621,8 +69419,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_closeByTicket` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -69630,6 +69426,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_closeByTicket`(IN vTicketFk int) BEGIN @@ -69643,18 +69441,18 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_close; CREATE TEMPORARY TABLE tmp.ticket_close ENGINE = MEMORY ( - SELECT + 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 + 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; @@ -69664,8 +69462,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_componentMakeUpdate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -69673,6 +69469,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_componentMakeUpdate`(IN vTicketFk INT, IN vClientFk INT, IN vNickname VARCHAR(50), IN vAgencyModeFk INT, @@ -69681,11 +69479,11 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_componentMakeUpdate`(IN vTic 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 @@ -69700,29 +69498,29 @@ BEGIN * @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 + + UPDATE ticket t JOIN address a ON a.id = vAddressFk SET t.nickname = a.nickname WHERE t.id = vTicketFk; - + END IF; CALL zone_getShipped(vLanded, vAddressFk, vAgencyModeFk, TRUE); - SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus + 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 + SET t.clientFk = vClientFk, t.nickname = vNickname, t.agencyModeFk = vAgencyModeFk, @@ -69737,12 +69535,12 @@ BEGIN 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 @@ -69768,8 +69566,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_componentPreview` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -69777,10 +69573,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_componentPreview`( vTicketFk INT, - vLanded DATE, + vLanded DATE, vAddressFk INT, vZoneFk INT, vWarehouseFk SMALLINT) @@ -69796,7 +69594,7 @@ BEGIN * * @return tmp.ticketComponentPreview (warehouseFk, itemFk, componentFk, cost) */ - DECLARE vHasDataChanged BOOL DEFAULT FALSE; + DECLARE vHasDataChanged BOOL DEFAULT FALSE; DECLARE vHasAddressChanged BOOL; DECLARE vHasZoneChanged BOOL DEFAULT FALSE; DECLARE vHasWarehouseChanged BOOL DEFAULT FALSE; @@ -69807,8 +69605,8 @@ BEGIN DECLARE vHasChangeAll BOOL DEFAULT FALSE; - SELECT DATE(landed) <> vLanded, - addressFk <> vAddressFk, + SELECT DATE(landed) <> vLanded, + addressFk <> vAddressFk, zoneFk <> vZoneFk, warehouseFk <> vWarehouseFk INTO @@ -69831,15 +69629,15 @@ BEGIN SET vAgencyModeTypeRateFk = 6; END IF; - SELECT TIMESTAMPADD(DAY, -travelingDays, vLanded) INTO vShipped + SELECT TIMESTAMPADD(DAY, -travelingDays, vLanded) INTO vShipped FROM zone WHERE id = vZoneFk; - + CALL buyUltimate(vWarehouseFk, vShipped); - + DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY ( - SELECT + CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY ( + SELECT vWarehouseFk AS warehouseFk, NULL AS available, s.itemFk, @@ -69859,9 +69657,9 @@ BEGIN JOIN sale s ON s.id = sc.saleFk JOIN ticket t ON t.id = s.ticketFk JOIN `component` c ON c.id = sc.componentFk - WHERE s.ticketFk = vTicketFk - AND (c.isRenewable = FALSE - OR + WHERE s.ticketFk = vTicketFk + AND (c.isRenewable = FALSE + OR (NOT vHasChangeAll AND (NOT (c.typeFk <=> vAddressTypeRateFk OR c.typeFk <=> vAgencyModeTypeRateFk)))); @@ -69882,8 +69680,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_DelayTruck` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -69891,10 +69687,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_DelayTruck`(vWarehouserFk INT, vHour INT, vMinute INT) BEGIN - + DECLARE done INT DEFAULT FALSE; DECLARE vTicketFk INT; DECLARE cur1 CURSOR FOR SELECT ticketFk FROM tmp.ticket; @@ -69907,7 +69705,7 @@ BEGIN CREATE TEMPORARY TABLE tmp.ticket SELECT ticketFk FROM tmp.productionBuffer - WHERE shipped = curdate() + WHERE shipped = util.VN_CURDATE() AND problem LIKE '%I:%' AND (HH <= vHour OR HH = vHour AND mm < vMinute) AND alertLevel = 0; @@ -69915,27 +69713,25 @@ BEGIN OPEN cur1; read_loop: LOOP - + FETCH cur1 INTO vTicketFk; - + IF done THEN LEAVE read_loop; END IF; - + CALL vn.ticket_DelayTruckSplit(vTicketFk); - + END LOOP; CLOSE cur1; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_DelayTruckSplit` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -69943,55 +69739,57 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_DelayTruckSplit`(vTicketFk INT) BEGIN - + /* * Splita las lineas de ticket que no estan ubicadas - * + * */ - + DECLARE vNewTicketFk INT; DECLARE vTotalLines INT; DECLARE vLinesToSplit INT; DROP TEMPORARY TABLE IF EXISTS tmp.SalesToSplit; - + SELECT COUNT(*) INTO vTotalLines - FROM vn.sale + FROM vn.sale WHERE ticketFk = vTicketFk; - + CREATE TEMPORARY TABLE tmp.SalesToSplit SELECT s.id saleFk FROM vn.ticket t - JOIN vn.sale s ON t.id = s.ticketFk - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = s.itemFk AND issw.warehouseFk = t.warehouseFk + JOIN vn.sale s ON t.id = s.ticketFk + LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = s.itemFk 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 t.id = vTicketFk; - + SELECT COUNT(*) INTO vLinesToSplit FROM tmp.SalesToSplit; - + IF vLinesToSplit = vTotalLines AND vLinesToSplit > 0 THEN - + SET vNewTicketFk = vTicketFk; - + ELSE - + CALL vn.ticket_Clone(vTicketFk, vNewTicketFk); - - UPDATE vn.sale s - JOIN tmp.SalesToSplit sts ON sts.saleFk = s.id + + UPDATE vn.sale s + JOIN tmp.SalesToSplit sts ON sts.saleFk = s.id SET s.ticketFk = vNewTicketFk; - + END IF; - + CALL vn.ticketStateUpdate(vNewTicketFk, 'FIXING'); - + DROP TEMPORARY TABLE tmp.SalesToSplit; END ;; @@ -70000,8 +69798,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_doRecalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70009,6 +69805,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_doRecalc`() proc: BEGIN @@ -70035,7 +69833,7 @@ proc: BEGIN CALL `vn`.`mail_insert`('cau@verdnatura.es', NULL, 'Problema al recalcular el total de ticket', - CONCAT('Se ha detectado un problema en ticket_doRecalc al calcular el total del ticket : ', + CONCAT('Se ha detectado un problema en ticket_doRecalc al calcular el total del ticket : ', vTicketFk,' el error es el: ', CONCAT('ERROR ', IFNULL(@errno, 0), ': ', ifnull(@text, ''))) ); @@ -70078,8 +69876,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_doRefund` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70087,6 +69883,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_doRefund`(OUT vNewTicket INT) BEGIN @@ -70159,13 +69957,13 @@ BEGIN ) SELECT vClientFk, - CURDATE(), + util.VN_CURDATE(), vAddress, vRefundAgencyMode, a.nickname, vWarehouse, vCompany, - CURDATE(), + util.VN_CURDATE(), vZoneFk FROM address a WHERE a.id = vAddress; @@ -70212,8 +70010,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_getFromFloramondo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70221,6 +70017,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getFromFloramondo`(vDateFrom DATE, vDateTo DATE) BEGIN @@ -70352,8 +70150,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_getMovable` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70361,6 +70157,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getMovable`(vTicketFk INT, vDatedNew DATETIME, vWarehouseFk INT) BEGIN @@ -70372,45 +70170,43 @@ BEGIN * @param vTicketFk -> Ticket * @param vDatedNew -> Nueva fecha * @return Sales con Movible -*/ +*/ DECLARE vDatedOld DATETIME; SET vDatedNew = DATE_ADD(vDatedNew, INTERVAL 1 DAY); SELECT t.shipped INTO vDatedOld - FROM ticket t + FROM ticket t WHERE t.id = vTicketFk; - CALL itemStock(vWarehouseFk, vDatedNew, NULL); + CALL itemStock(vWarehouseFk, vDatedNew, NULL); CALL item_getMinacum(vWarehouseFk, vDatedNew, DATEDIFF(DATE_SUB(vDatedOld, INTERVAL 1 DAY), vDatedNew), NULL); - - SELECT s.id, - s.itemFk, - s.quantity, - s.concept, - s.price, + + SELECT s.id, + s.itemFk, + s.quantity, + s.concept, + s.price, s.reserved, - s.discount, - i.image, - i.subName, + s.discount, + i.image, + i.subName, il.stock + IFNULL(im.amount, 0) AS movable FROM ticket t JOIN sale s ON s.ticketFk = t.id - JOIN item i ON i.id = s.itemFk + JOIN item i ON i.id = s.itemFk LEFT JOIN tmp.itemMinacum im ON im.itemFk = s.itemFk AND im.warehouseFk = vWarehouseFk LEFT JOIN tmp.itemList il ON il.itemFk = s.itemFk WHERE t.id = vTicketFk; DROP TEMPORARY TABLE IF EXISTS tmp.itemList; - DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum; - + DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_getProblems` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70418,6 +70214,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getProblems`(IN vIsTodayRelative tinyint(1)) BEGIN @@ -70431,10 +70229,10 @@ BEGIN CALL sale_getProblems(vIsTodayRelative); DROP TEMPORARY TABLE IF EXISTS tmp.ticket_problems; - CREATE TEMPORARY TABLE tmp.ticket_problems + CREATE TEMPORARY TABLE tmp.ticket_problems (PRIMARY KEY (ticketFk)) ENGINE = MEMORY - SELECT + SELECT ticketFk, MAX(p.isFreezed) AS isFreezed, MAX(p.risk) AS risk, @@ -70452,7 +70250,7 @@ BEGIN GROUP BY ticketFk; UPDATE tmp.ticket_problems tp - SET tp.totalProblems = + SET tp.totalProblems = ( (tp.isFreezed) + IF(tp.risk, TRUE, FALSE) + @@ -70474,8 +70272,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_getShip` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70483,6 +70279,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getShip`(vTicketFk INT) BEGIN @@ -70494,8 +70292,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_getSplitList` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70503,6 +70299,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getSplitList`(vDated DATE, vHour TIME, vWarehouseFk INT) BEGIN @@ -70516,7 +70314,7 @@ BEGIN DECLARE vAvailableCache INT; DECLARE vVisibleCache INT; - CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouseFk, CURDATE()); + CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouseFk, util.VN_CURDATE()); CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouseFk); CALL `vn`.`zoneClosure_recalc`(); @@ -70526,46 +70324,46 @@ BEGIN (saleFk INT PRIMARY KEY, ticketFk INT, problem VARCHAR(1)) ENGINE = MEMORY; - + INSERT INTO tmp.salesToSplit(saleFk, ticketFk, problem) SELECT s.id, s.ticketFk, 'F' FROM vn.ticket t 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 - JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = i.id AND v.calc_id = vVisibleCache LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk + LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk WHERE IFNULL(v.visible,0) < s.quantity AND IFNULL(av.available ,0) < s.quantity AND IFNULL(issw.visible, 0) < s.quantity AND s.isPicked = FALSE AND s.reserved = FALSE AND ic.merchandise = TRUE - AND t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + AND t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) AND NOT i.generic AND t.warehouseFk = vWarehouseFk; - + INSERT IGNORE INTO tmp.salesToSplit(saleFk, ticketFk, problem) SELECT s.id, s.ticketFk, 'I' - FROM vn.ticket t + FROM vn.ticket t 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 JOIN vn.itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk + LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk WHERE IFNULL(v.visible,0) >= s.quantity AND IFNULL(issw.visible, 0) < s.quantity AND s.quantity > 0 AND s.isPicked = FALSE AND s.reserved = FALSE AND ic.merchandise = TRUE - AND t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + AND t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) AND NOT i.generic AND t.warehouseFk = vWarehouseFk; - + INSERT IGNORE INTO tmp.salesToSplit(saleFk, ticketFk, problem) SELECT s.id, s.ticketFk, 'R' FROM vn.ticket t @@ -70575,7 +70373,7 @@ BEGIN JOIN vn.itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk + LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk WHERE IFNULL(v.visible,0) < s.quantity AND IFNULL(av.available ,0) >= s.quantity AND IFNULL(issw.visible, 0) < s.quantity @@ -70583,10 +70381,10 @@ BEGIN AND s.isPicked = FALSE AND s.reserved = FALSE AND ic.merchandise = TRUE - AND t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + AND t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) AND NOT i.generic AND t.warehouseFk = vWarehouseFk; - + DROP TEMPORARY TABLE IF EXISTS tmp.ticketsToSplit; CREATE TEMPORARY TABLE tmp.ticketsToSplit @@ -70607,11 +70405,11 @@ BEGIN JOIN vn.ticket t ON t.id = ss.ticketFk JOIN vn.sale s ON s.id = ss.saleFk JOIN vn.item i ON i.id = s.itemFk - LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk + LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk GROUP BY ss.ticketFk; - - SELECT - ts.*, + + SELECT + ts.*, t.id ticketFuture, st.name state, zc.`hour` tfEtd, @@ -70620,23 +70418,23 @@ BEGIN FROM tmp.ticketsToSplit ts LEFT JOIN vn.ticketState ts2 ON ts2.ticketFk = ts.ticketFk LEFT JOIN vn.state st ON st.id = ts2.stateFk - LEFT JOIN vn.ticket t - ON t.id != ts.ticketFk + LEFT JOIN vn.ticket t + ON t.id != ts.ticketFk AND t.addressFk = ts.addressFk AND t.shipped BETWEEN vDated AND util.dayend(vDated) LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = vDated LEFT JOIN vn.sale s ON s.ticketFk = t.id LEFT JOIN vn.item i ON i.id = s.itemFk - LEFT JOIN vn.ticketState tst ON tst.ticketFk = t.id + LEFT JOIN vn.ticketState tst ON tst.ticketFk = t.id LEFT JOIN vn.state st2 ON st2.id = tst.stateFk - WHERE (t.id IS NULL - OR (vDated > CURDATE()) - OR (vDated = CURDATE() AND vHour >= zc.`hour`)) + WHERE (t.id IS NULL + OR (vDated > util.VN_CURDATE()) + OR (vDated = util.VN_CURDATE() AND vHour >= zc.`hour`)) AND ts.etd <= vHour GROUP BY ts.ticketFk, t.id ORDER BY ts.etd, ts.ticketFk; - - DROP TEMPORARY TABLE + + DROP TEMPORARY TABLE tmp.ticketsToSplit; END ;; DELIMITER ; @@ -70644,8 +70442,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_getTax` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70653,6 +70449,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getTax`(IN vTaxArea VARCHAR(25)) BEGIN @@ -70673,7 +70471,7 @@ BEGIN JOIN ticket t ON t.id = tmpTicket.ticketFk; CALL addressTaxArea (); - + IF vTaxArea > '' THEN UPDATE tmp.addressTaxArea SET areaFk = vTaxArea; @@ -70745,8 +70543,8 @@ BEGIN CREATE TEMPORARY TABLE tmp.ticketAmount (INDEX (ticketFk)) ENGINE = MEMORY - SELECT ticketFk, - taxableBase, + SELECT ticketFk, + taxableBase, SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax, code FROM tmp.ticketTax @@ -70760,8 +70558,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_insertZone` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70769,6 +70565,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_insertZone`() BEGIN @@ -70778,24 +70576,24 @@ BEGIN DECLARE vAddressFk INT; DECLARE vAgencyModeFk INT; DECLARE vWarehouseFk INT; - DECLARE vCursor CURSOR FOR + DECLARE vCursor CURSOR FOR SELECT id, landed, addressFk, agencyModeFk, warehouseFk FROM vn.ticket WHERE shipped > '2020-01-01' AND zoneFk is null; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET vDone = 1; - + OPEN vCursor; REPEAT FETCH vCursor INTO vFechedTicket, vLanded, vAddressFk, vAgencyModeFk, vWarehouseFk; CALL vn.zone_getShipped (vlanded, vAddressFk, vAgencyModeFk, TRUE); - + UPDATE vn.ticket t JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = vWarehouseFk SET t.zoneFk = zgs.zoneFk WHERE t.id = vFechedTicket; - + UNTIL vDone END REPEAT; DROP TEMPORARY TABLE tmp.zoneGetShipped; - + CLOSE vCursor; END ;; DELIMITER ; @@ -70803,8 +70601,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_merge` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70812,34 +70608,34 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` 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 + + 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 ) + + UPDATE vn.ticket t + SET t.shipped = TIMESTAMPADD(YEAR, - YEAR(util.VN_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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_priceDifference` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70847,17 +70643,19 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_priceDifference`( vTicketFk INT, - vLanded DATE, + vLanded DATE, vAddressFk INT, vZoneFk INT, vWarehouseFk INT) BEGIN /** * Devuelve las diferencias de precio de los movimientos de un ticket. - * + * * @param vTicketFk Id del ticket * @param vLanded Fecha de recepcion * @param vAddressFk Id del consignatario @@ -70866,26 +70664,26 @@ BEGIN */ CALL vn.ticket_componentPreview(vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk); - SELECT s.itemFk, - i.name, - i.size, - i.category, - IFNULL(s.quantity, 0) AS quantity, - IFNULL(s.price, 0) AS price, + SELECT s.itemFk, + i.name, + i.size, + i.category, + IFNULL(s.quantity, 0) AS quantity, + IFNULL(s.price, 0) AS price, ROUND(SUM(tc.cost), 2) AS newPrice, s.quantity * (s.price - ROUND(SUM(tc.cost), 2)) difference, s.id AS saleFk FROM sale s - JOIN item i ON i.id = s.itemFk - JOIN ticket t ON t.id = s.ticketFk - LEFT JOIN tmp.ticketComponentPreview tc ON tc.itemFk = s.itemFk + JOIN item i ON i.id = s.itemFk + JOIN ticket t ON t.id = s.ticketFk + LEFT JOIN tmp.ticketComponentPreview tc ON tc.itemFk = s.itemFk AND tc.warehouseFk = vWarehouseFk - LEFT JOIN saleComponent sc ON sc.saleFk = s.id + LEFT JOIN saleComponent sc ON sc.saleFk = s.id AND sc.componentFk = tc.componentFk - LEFT JOIN `component` c ON c.id = tc.componentFk - WHERE t.id = vTicketFk - AND IF(sc.componentFk IS NULL - AND c.classRate IS NOT NULL, FALSE, TRUE) + LEFT JOIN `component` c ON c.id = tc.componentFk + WHERE t.id = vTicketFk + AND IF(sc.componentFk IS NULL + AND c.classRate IS NOT NULL, FALSE, TRUE) GROUP BY s.id ORDER BY s.id; DROP TEMPORARY TABLE tmp.ticketComponentPreview; @@ -70895,8 +70693,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_recalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70904,6 +70700,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_recalc`(vTicketId INT) BEGIN @@ -70934,8 +70732,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_recalcComponents` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70943,12 +70739,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_recalcComponents`(IN vTicketFk BIGINT, vIsTicketEditable BOOLEAN) proc: BEGIN /** - * Este procedimiento recalcula los componentes de un ticket, + * Este procedimiento recalcula los componentes de un ticket, * eliminando los componentes existentes e insertandolos de nuevo * * @param vTicketFk Id del ticket @@ -70960,7 +70758,7 @@ proc: BEGIN DECLARE vAddressFk INT; DECLARE vLanded DATE; DECLARE vZoneFk INTEGER; - + IF vIsTicketEditable IS NULL THEN SELECT IFNULL(ts.alertLevel,0) = 0 AND IFNULL(t.refFk,'') = '' INTO vIsTicketEditable @@ -70968,10 +70766,10 @@ proc: BEGIN WHERE id = vTicketFk; END IF; - SELECT t.warehouseFk, - t.shipped, - t.addressFk, - t.agencyModeFk, + SELECT t.warehouseFk, + t.shipped, + t.addressFk, + t.agencyModeFk, t.landed, t.zoneFk INTO vWarehouseFk, vShipped, vAddressFk, vAgencyModeFk, vLanded, vZoneFk @@ -70987,7 +70785,7 @@ proc: BEGIN IF vLanded IS NULL OR vZoneFk IS NULL THEN UPDATE ticket t - SET t.landed = (SELECT landed FROM tmp.zoneGetLanded LIMIT 1) + SET t.landed = (SELECT landed FROM tmp.zoneGetLanded LIMIT 1) WHERE t.id = vTicketFk AND t.landed IS NULL; IF vZoneFk IS NULL THEN @@ -70996,23 +70794,23 @@ proc: BEGIN SET t.zoneFk = vZoneFk WHERE t.id = vTicketFk AND t.zoneFk IS NULL; END IF; - + END IF; - + DROP TEMPORARY TABLE tmp.zoneGetLanded; - -- rellena la tabla buyUltimate con la ultima compra - CALL buyUltimate (vWarehouseFk, vShipped); - + -- rellena la tabla buyUltimate con la ultima compra + CALL buyUltimate (vWarehouseFk, vShipped); + DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot + CREATE TEMPORARY TABLE tmp.ticketLot SELECT vWarehouseFk warehouseFk, NULL available, s.itemFk, bu.buyFk, vZoneFk zoneFk FROM sale s LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk - WHERE s.ticketFk = vTicketFk + WHERE s.ticketFk = vTicketFk GROUP BY s.itemFk; - + CALL catalog_componentPrepare(); CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); @@ -71021,14 +70819,14 @@ proc: BEGIN (PRIMARY KEY (saleFk)) ENGINE = MEMORY SELECT id saleFk, vWarehouseFk warehouseFk FROM sale s - WHERE s.ticketFk = vTicketFk; - - -- si el ticket esta facturado, respeta los precios - CALL ticketComponentUpdateSale(IF(vIsTicketEditable, 1, 6)); - + WHERE s.ticketFk = vTicketFk; + + -- si el ticket esta facturado, respeta los precios + CALL ticketComponentUpdateSale(IF(vIsTicketEditable, 1, 6)); + CALL catalog_componentPurge(); - DROP TEMPORARY TABLE - tmp.buyUltimate, + DROP TEMPORARY TABLE + tmp.buyUltimate, tmp.sale; END ;; DELIMITER ; @@ -71036,8 +70834,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_requestRecalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71045,6 +70841,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_requestRecalc`(vSelf INT) proc: BEGIN @@ -71064,8 +70862,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_setNextState` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71073,6 +70869,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setNextState`(vSelf INT) BEGIN @@ -71100,8 +70898,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_setParking` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71109,6 +70905,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setParking`(IN `vTicketFk` VARCHAR(8), IN `vParkingFk` INT) proc: BEGIN @@ -71155,8 +70953,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_setPreviousState` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71164,6 +70960,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setPreviousState`(vTicketFk INT) BEGIN @@ -71200,8 +70998,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_setState` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71209,6 +71005,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setState`(vSelf INT, vStateCode VARCHAR(255)) BEGIN @@ -71251,8 +71049,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_split` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71260,6 +71056,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_split`(vTicketFk INT, vTicketFutureFk INT, vDated DATE) proc:BEGIN @@ -71278,40 +71076,40 @@ proc:BEGIN SELECT COUNT(*) INTO vProblemLines FROM tmp.salesToSplit WHERE ticketFk = vTicketFk; - + SELECT count(*) INTO vTotalLines - FROM vn.sale s + FROM vn.sale s WHERE s.ticketFk = vTicketFk; - + SET vHasFullProblem = (vTotalLines = vProblemLines); -- Ticket completo IF vHasFullProblem THEN - + UPDATE vn.ticket SET landed = vDated + 1, shipped = vDated, - nickname = CONCAT('(',DAY(curdate()),') ', nickname ) + nickname = CONCAT('(',DAY(util.VN_CURDATE()),') ', nickname ) WHERE id = vTicketFk; - + SELECT CONCAT("Se ha cambiado el ticket ", vTicketFk, " al dia ", vDated); LEAVE proc; - + END IF; -- Ticket a futuro existe IF vTicketFutureFk THEN - - UPDATE vn.sale s + + UPDATE vn.sale s JOIN tmp.salesToSplit ss ON s.id = ss.saleFk SET s.ticketFk = vTicketFutureFk, s.concept = CONCAT('(s) ', s.concept) WHERE ss.ticketFk = vTicketFk; - - SELECT CONCAT("Se han movido lineas del ticket ", vTicketFk, + + SELECT CONCAT("Se han movido lineas del ticket ", vTicketFk, " al ticket existente ", vTicketFutureFk,"(", vDated,")"); LEAVE proc; - + END IF; -- Ticket nuevo @@ -71322,18 +71120,18 @@ proc:BEGIN SET t.landed = vDated + 1, t.shipped = vDated, t.agencyModeFk = pc.defautlAgencyMode, - t.zoneFk = pc.defaultZone + t.zoneFk = pc.defaultZone WHERE t.id = vTicketFutureFk; - - UPDATE vn.sale s - JOIN tmp.salesToSplit sts ON sts.saleFk = s.id + + UPDATE vn.sale s + JOIN tmp.salesToSplit sts ON sts.saleFk = s.id SET s.ticketFk = vTicketFutureFk, s.concept = CONCAT('(s) ', s.concept) WHERE sts.ticketFk = vTicketFk; CALL vn.ticketStateUpdate(vTicketFutureFk, 'FIXING'); - SELECT CONCAT("Se han movido lineas del ticket ", vTicketFk, + SELECT CONCAT("Se han movido lineas del ticket ", vTicketFk, " al nuevo ticket ", vTicketFutureFk,"(", vDated,")"); END ;; DELIMITER ; @@ -71341,8 +71139,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_splitItemPackingType` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71350,128 +71146,116 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_splitItemPackingType`(vTicketFk INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_splitItemPackingType`(vTicketFk INT, vOriginalItemPackingTypeFk VARCHAR(1)) proc:BEGIN - - /* - * Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado - * - * @param vTicketFk Identificador de vn.ticket - * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) - */ - - +/** + * Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado. + * Respeta el id inicial para el tipo propuesto. + * + * @param vTicketFk Identificador de vn.ticket + * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original + * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) + */ DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE vNewTicketFk INT; - DECLARE vPackingTypesToSplit INT; - DECLARE vDone INT DEFAULT FALSE; - - DECLARE cur1 CURSOR FOR - SELECT itemPackingTypeFk - FROM tmp.saleGroup - WHERE itemPackingTypeFk IS NOT NULL; + + DECLARE cur1 CURSOR FOR + SELECT itemPackingTypeFk + FROM tmp.saleGroup + WHERE itemPackingTypeFk IS NOT NULL + ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DROP TEMPORARY TABLE IF EXISTS tmp.sale; CREATE TEMPORARY TABLE tmp.sale (PRIMARY KEY (id)) - SELECT s.id, i.itemPackingTypeFk , sv.litros + SELECT s.id, i.itemPackingTypeFk , sv.litros FROM vn.sale s - JOIN vn.item i ON i.id = s.itemFk + JOIN vn.item i ON i.id = s.itemFk JOIN vn.saleVolume sv ON sv.saleFk = s.id LEFT JOIN vn.saleTracking st ON st.saleFk = s.id WHERE s.ticketFk = vTicketFk AND ISNULL(st.id); - + DROP TEMPORARY TABLE IF EXISTS tmp.saleGroup; CREATE TEMPORARY TABLE tmp.saleGroup SELECT itemPackingTypeFk , sum(litros) AS totalLitros FROM tmp.sale - GROUP BY itemPackingTypeFk; - + GROUP BY itemPackingTypeFk; + SELECT COUNT(*) INTO vPackingTypesToSplit FROM tmp.saleGroup WHERE itemPackingTypeFk IS NOT NULL; - + DROP TEMPORARY TABLE IF EXISTS tmp.ticketIPT; CREATE TEMPORARY TABLE tmp.ticketIPT (ticketFk INT, itemPackingTypeFk VARCHAR(1)); CASE vPackingTypesToSplit - WHEN 0 THEN - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) VALUES(vTicketFk, 'H'); - WHEN 1 THEN - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) SELECT vTicketFk, itemPackingTypeFk FROM tmp.saleGroup WHERE itemPackingTypeFk IS NOT NULL; ELSE - OPEN cur1; FETCH cur1 INTO vItemPackingTypeFk; - + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) VALUES(vTicketFk, vItemPackingTypeFk); - - read_loop: LOOP - - FETCH cur1 INTO vItemPackingTypeFk; - - IF vDone THEN - LEAVE read_loop; - END IF; - - CALL vn.ticket_Clone(vTicketFk, vNewTicketFk); - - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) + + read_loop: LOOP + FETCH cur1 INTO vItemPackingTypeFk; + + IF vDone THEN + LEAVE read_loop; + END IF; + + CALL vn.ticket_Clone(vTicketFk, vNewTicketFk); + + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) VALUES(vNewTicketFk, vItemPackingTypeFk); - - END LOOP; - - CLOSE cur1; - - UPDATE vn.sale s - JOIN tmp.sale ts ON ts.id = s.id - JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk - SET s.ticketFk = t.ticketFk; - - SELECT itemPackingTypeFk INTO vItemPackingTypeFk - FROM tmp.saleGroup sg - WHERE NOT ISNULL(sg.itemPackingTypeFk) - ORDER BY sg.totalLitros - LIMIT 1; - - UPDATE vn.sale s - JOIN tmp.sale ts ON ts.id = s.id - JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk - SET s.ticketFk = t.ticketFk - WHERE ISNULL(ts.itemPackingTypeFk); - + END LOOP; + + CLOSE cur1; + + UPDATE vn.sale s + JOIN tmp.sale ts ON ts.id = s.id + JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk + SET s.ticketFk = t.ticketFk; + + SELECT itemPackingTypeFk INTO vItemPackingTypeFk + FROM tmp.saleGroup sg + WHERE NOT ISNULL(sg.itemPackingTypeFk) + ORDER BY sg.totalLitros + LIMIT 1; + + UPDATE vn.sale s + JOIN tmp.sale ts ON ts.id = s.id + JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk + SET s.ticketFk = t.ticketFk + WHERE ts.itemPackingTypeFk IS NULL; END CASE; - + DROP TEMPORARY TABLE tmp.sale; DROP TEMPORARY TABLE tmp.saleGroup; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_splitPackingComplete` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71479,54 +71263,54 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_splitPackingComplete`(vTicketFk INT, vSectorFk INT) BEGIN - + DECLARE vNeedToSplit BOOLEAN; DECLARE vNewTicketFk INT; - + DROP TEMPORARY TABLE IF EXISTS tmpSale; - + CREATE TEMPORARY TABLE tmpSale SELECT DISTINCT s.id - FROM vn.ticket t + FROM vn.ticket t JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk + JOIN vn.item i ON i.id = s.itemFk LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = s.itemFk AND iss.sectorFk = vSectorFk - JOIN vn.packagingConfig pc + JOIN vn.packagingConfig pc WHERE t.id = vTicketFk AND ( s.quantity MOD IFNULL(iss.packing,1) != 0 - OR + OR IFNULL(iss.packing,1) = 1 - OR + OR i.`size` <= pc.previousPreparationMinimumSize ); - - SELECT COUNT(*) + + SELECT COUNT(*) INTO vNeedToSplit - FROM tmpSale; - + FROM tmpSale; + IF vNeedToSplit THEN - + CALL vn.ticket_Clone(vTicketFk, vNewTicketFk); - + UPDATE vn.sale s - JOIN vn.tmpSale ts ON ts.id = s.id + JOIN vn.tmpSale ts ON ts.id = s.id SET s.ticketFk = vNewTicketFk; - + END IF; - + DROP TEMPORARY TABLE tmpSale; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_WeightDeclaration` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71534,6 +71318,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_WeightDeclaration`(vClientFk INT, vDated DATE) BEGIN @@ -71549,7 +71335,7 @@ BEGIN WHERE ot.description = 'Peso Aduana' AND t.clientFk = vClientFk AND t.shipped BETWEEN vDated AND util.dayend(vDated); - + SELECT sum(IF(sv.physicalWeight = 0, sv.weight, sv.physicalWeight)) INTO vTheorycalWeight FROM vn.ticket t JOIN vn.sale s ON s.ticketFk = t.id @@ -71558,9 +71344,9 @@ BEGIN JOIN vn.itemCost ic ON ic.itemFk = i.id AND ic.warehouseFk = t.warehouseFk WHERE t.clientFk = vClientFk AND t.shipped BETWEEN vDated AND util.dayend(vDated); - + SET vRatio = vRealWeight / vTheorycalWeight; - + DROP TEMPORARY TABLE IF EXISTS tmp.ticketWeight; CREATE TEMPORARY TABLE tmp.ticketWeight @@ -71581,15 +71367,13 @@ BEGIN AND t.shipped BETWEEN vDated AND util.dayend(vDated) GROUP BY ib.ediBotanic, o.code; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `timeBusiness_calculate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71597,11 +71381,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** - * Horas que debe trabajar un empleado según contrato y día. + * Horas que debe trabajar un empleado según contrato y día. * @param vDatedFrom workerTimeControl * @param vDatedTo workerTimeControl * @table tmp.user(userFk) @@ -71610,10 +71396,10 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; CREATE TEMPORARY TABLE tmp.timeBusinessCalculate - SELECT dated, + SELECT dated, businessFk, - userFk, - departmentFk, + userFk, + departmentFk, hourStart, hourEnd, timeTable, @@ -71629,69 +71415,63 @@ BEGIN discountRate, isAllowedToWork FROM(SELECT t.dated, - b.business_id businessFk, + b.id businessFk, w.userFk, - bl.department_id departmentFk, - IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5) ORDER BY j.start ASC SEPARATOR ' - ')) hourStart , + b.departmentFk, + IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5) ORDER BY j.start ASC SEPARATOR ' - ')) hourStart , IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) hourEnd, IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,5), " - ", LEFT(j.end,5) ORDER BY j.end ASC SEPARATOR ' - ')) timeTable, - IF(j.start = NULL, 0, IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)),0)) timeWorkSeconds, + IF(j.start = NULL, 0, IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)), 0)) timeWorkSeconds, at2.name, at2.permissionRate, at2.discountRate, cl.hours_week hoursWeek, at2.isAllowedToWork FROM time t - LEFT JOIN postgresql.business b ON t.dated BETWEEN b.date_start AND IFNULL(b.date_end, vDatedTo ) - LEFT JOIN postgresql.profile pr ON b.client_id = pr.profile_id - LEFT JOIN worker w ON w.id = pr.workerFk + LEFT JOIN business b ON t.dated BETWEEN b.started AND IFNULL(b.ended, vDatedTo) + LEFT JOIN worker w ON w.id = b.workerFk JOIN tmp.`user` u ON u.userFK = w.userFK - JOIN postgresql.business_labour bl ON b.business_id = bl.business_id - LEFT JOIN postgresql.business_labour_payroll bp ON bl.business_id = bp.business_id - LEFT JOIN postgresql.professional_category pc ON bl.professional_category_id = pc.professional_category_id - LEFT JOIN workCenter wc ON bl.workcenter_id = wc.id - LEFT JOIN postgresql.calendar_labour_type cl ON bl.calendar_labour_type_id = cl.calendar_labour_type_id - LEFT JOIN postgresql.journey j ON j.business_id = b.business_id AND j.day_id=WEEKDAY(t.dated)+1 - LEFT JOIN postgresql.calendar_employee ce ON ce.business_id=b.business_id AND ce.date = t.dated + LEFT JOIN workCenter wc ON wc.id = b.workcenterFK + LEFT JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = b.calendarTypeFk + LEFT JOIN postgresql.journey j ON j.business_id = b.id AND j.day_id = WEEKDAY(t.dated) + 1 + LEFT JOIN postgresql.calendar_employee ce ON ce.businessFk = b.id AND ce.date = t.dated LEFT JOIN absenceType at2 ON at2.id = ce.calendar_state_id WHERE t.dated BETWEEN vDatedFrom AND vDatedTo - GROUP BY w.userFk,dated + GROUP BY w.userFk, t.dated )sub; UPDATE tmp.timeBusinessCalculate t LEFT JOIN postgresql.journey j ON j.business_id = t.businessFk SET t.timeWorkSeconds = t.hoursWeek / 5 * 3600, - t.timeWorkSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600), - t.timeWorkDecimal = t.hoursWeek / 5, + t.timeWorkSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600), + t.timeWorkDecimal = t.hoursWeek / 5, t.timeBusinessSeconds = t.hoursWeek / 5 * 3600, - t.timeBusinessSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600), + 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; + WHERE permissionRate <> 0; - UPDATE tmp.timeBusinessCalculate t - JOIN calendarHolidays ch ON ch.dated = t.dated - JOIN postgresql.business_labour bl ON bl.business_id = t.businessFk AND bl.workcenter_id = ch.workcenterFk + UPDATE tmp.timeBusinessCalculate t + JOIN calendarHolidays ch ON ch.dated = t.dated + JOIN business b ON b.id = t.businessFk + AND b.workcenterFk = ch.workcenterFk SET t.timeWorkSeconds = 0, - t.timeWorkSexagesimal = 0, + t.timeWorkSexagesimal = 0, t.timeWorkDecimal = 0, t.permissionrate = 1, t.type = 'Festivo' WHERE t.type IS 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `timeBusiness_calculateAll` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71699,6 +71479,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculateAll`(vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN @@ -71710,24 +71492,22 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.`user`; - CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user` + CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user` SELECT userFk FROM vn.worker w JOIN vn.`user` u ON u.id = w.userFk WHERE userFk IS NOT NULL; - + CALL vn.timeBusiness_calculate(vDatedFrom, vDatedTo); 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `timeBusiness_calculateByDepartment` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71735,34 +71515,30 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculateByDepartment`(vDepartmentFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN - /** - * @param vDepartmentFk + * @param vDepartmentFk * @param vDatedFrom workerTimeControl * @param vDatedTo workerTimeControl */ - - DROP TEMPORARY TABLE IF EXISTS tmp.`user`; - - CREATE TEMPORARY TABLE tmp.`user` - SELECT DISTINCT w.userFk - FROM postgresql.business AS b - LEFT JOIN postgresql.profile AS pr ON pr.profile_id = b.client_id - LEFT JOIN postgresql.business_labour AS bl ON b.business_id = bl.business_id - LEFT JOIN worker AS w ON w.id = pr.workerFk - LEFT JOIN department AS d ON bl.department_id = d.id - WHERE (b.date_start BETWEEN vDatedFrom AND vDatedTo - OR IFNULL(b.date_end, vDatedTo) BETWEEN vDatedFrom AND vDatedTo - OR (b.date_start <= vDatedFrom AND b.date_end >= vDatedTo) - ) AND bl.department_id = vDepartmentFk - ORDER BY b.date_end DESC; - - CALL timeBusiness_calculate(vDatedFrom, vDatedTo); - - DROP TEMPORARY TABLE tmp.`user`; + DROP TEMPORARY TABLE IF EXISTS tmp.`user`; + + CREATE TEMPORARY TABLE tmp.`user` + SELECT DISTINCT b.workerFk userFk + FROM business AS b + WHERE (b.started BETWEEN vDatedFrom AND vDatedTo + OR IFNULL(b.ended, vDatedTo) BETWEEN vDatedFrom AND vDatedTo + OR (b.started <= vDatedFrom AND b.ended >= vDatedTo) + ) AND b.departmentFk = vDepartmentFk + ORDER BY b.ended DESC; + + CALL timeBusiness_calculate(vDatedFrom, vDatedTo); + + DROP TEMPORARY TABLE tmp.`user`; END ;; DELIMITER ; @@ -71770,8 +71546,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `timeBusiness_calculateByUser` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71779,24 +71553,26 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculateByUser`(vUserFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** - * @param vUserFk + * @param vUserFk * @param vDatedFrom workerTimeControl * @param vDatedTo workerTimeControl */ - + DROP TEMPORARY TABLE IF EXISTS tmp.`user`; - + CREATE TEMPORARY TABLE tmp.`user` SELECT id userFk - FROM user - WHERE id = vUserFk; + FROM user + WHERE id = vUserFk; CALL vn.timeBusiness_calculate(vDatedFrom, vDatedTo); - + DROP TEMPORARY TABLE tmp.`user`; END ;; @@ -71805,8 +71581,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `timeBusiness_calculateByWorker` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71814,6 +71588,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculateByWorker`(vWorkerFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN @@ -71823,17 +71599,17 @@ BEGIN * @param vDatedFrom workerTimeControl * @param vDatedTo workerTimeControl */ - + DROP TEMPORARY TABLE IF EXISTS tmp.`user`; - + CREATE TEMPORARY TABLE tmp.`user` SELECT u.id userFk FROM vn.user u JOIN vn.worker w ON w.userFk = u.id WHERE w.id = vWorkerFk; - + CALL vn.timeBusiness_calculate(vDatedFrom, vDatedTo); - + DROP TEMPORARY TABLE tmp.`user`; END ;; @@ -71842,8 +71618,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `timeControl_calculate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71851,26 +71625,28 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /* * @param vDatedFrom - * @param vDatedTo + * @param vDatedTo * Calculo de horas trabajadas por empleado y dia, sin tener encuenta los dias con fichadas incorrectas * segun la tabla tmp.timeControlError * @return tmp.timeControlCalculate (workerFk, dated, timeWorkSeconds, timeWorkSexagesimal, timeWorkDecimal, timed) */ DECLARE vHourToSeconds INTEGER; DECLARE vDatedFromYesterday DATETIME; - DECLARE vDatedToTomorrow DATETIME; + DECLARE vDatedToTomorrow DATETIME; DECLARE vTimeToBreakTime INT; DECLARE vBreakTime INT; - - SELECT DATE_SUB(vDatedFrom, INTERVAL 1 DAY), DATE_ADD(vDatedTo, INTERVAL 1 DAY) + + SELECT DATE_SUB(vDatedFrom, INTERVAL 1 DAY), DATE_ADD(vDatedTo, INTERVAL 1 DAY) INTO vDatedFromYesterday, vDatedToTomorrow; - - SELECT timeToBreakTime, breakTime INTO vTimeToBreakTime, vBreakTime + + SELECT timeToBreakTime, breakTime INTO vTimeToBreakTime, vBreakTime FROM workerTimeControlConfig LIMIT 1; CALL timeControl_getError(vDatedFrom, vDatedTo); @@ -71879,9 +71655,9 @@ BEGIN CREATE TEMPORARY TABLE tmp.workerTimeControl (INDEX (userFk), INDEX (timed)) ENGINE = MEMORY - SELECT DISTINCT(wtc.id), - wtc.userFk, - wtc.timed, + SELECT DISTINCT(wtc.id), + wtc.userFk, + wtc.timed, wtc.direction, TRUE isReal FROM workerTimeControl wtc @@ -71891,10 +71667,10 @@ BEGIN AND tce.id IS NULL ORDER BY wtc.userFk, wtc.timed ASC; - SELECT MAX(id) INTO @vCont + SELECT MAX(id) INTO @vCont FROM tmp.workerTimeControl; - DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlAux; + DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlAux; CREATE TEMPORARY TABLE tmp.workerTimeControlAux ( `id` int(11) , `userFk` int(10) unsigned , @@ -71916,6 +71692,7 @@ BEGIN @lastTimed := wtc.timed FROM tmp.workerTimeControl wtc ORDER BY wtc.userFk, wtc.timed + LIMIT 10000000000000000000 )sub WHERE hasBreak; @@ -71931,6 +71708,7 @@ BEGIN @lastTimed := wtc.timed FROM tmp.workerTimeControl wtc ORDER BY wtc.userFk, wtc.timed + LIMIT 10000000000000000000 )sub WHERE hasBreak; @@ -71981,7 +71759,7 @@ BEGIN IF(direction='in', @vDated := DATE(wtc.timed), @vDated) dated, wtc.userFk FROM tmp.workerTimeControl wtc - ORDER BY wtc.userFk, wtc.timed, wtc.id + ORDER BY wtc.userFk, wtc.timed, wtc.id LIMIT 10000000000000000000 )sub GROUP BY sub.userFk, sub.dated @@ -71991,8 +71769,14 @@ BEGIN SET @vDated := 0; SET @vLastTimed := 0; - DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; + DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlAux2; + CREATE TEMPORARY TABLE tmp.workerTimeControlAux2 + SELECT * + FROM tmp.workerTimeControl + WHERE timed BETWEEN vDatedFromYesterday AND vDatedTo + ORDER BY userFk, timed, id; + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; CREATE TEMPORARY TABLE tmp.timeControlCalculate (INDEX (userFk, dated)) ENGINE = MEMORY @@ -72010,9 +71794,7 @@ BEGIN userFk, DATE(timed) dated, IF(isReal, timed, NULL) realTimed - FROM tmp.workerTimeControl - WHERE timed BETWEEN vDatedFromYesterday AND vDatedTo - ORDER BY userFk, timed, id + FROM tmp.workerTimeControlAux2 )sub LEFT JOIN tmp.workerBreakDays wb ON wb.userFk = sub.userFk AND wb.dated = sub.dated WHERE sub.timed BETWEEN vDatedFrom AND vDatedTo @@ -72021,6 +71803,7 @@ BEGIN DROP TEMPORARY TABLE tmp.workerBreakDays; DROP TEMPORARY TABLE tmp.timeControlError; DROP TEMPORARY TABLE tmp.workerTimeControlAux; + DROP TEMPORARY TABLE tmp.workerTimeControlAux2; DROP TEMPORARY TABLE tmp.workerTimeControl; END ;; DELIMITER ; @@ -72028,8 +71811,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `timeControl_calculateAll` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72037,6 +71818,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculateAll`(vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN @@ -72048,24 +71831,22 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.`user`; - CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user` + CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user` SELECT userFk FROM vn.worker w JOIN vn.`user` u ON u.id = w.userFk WHERE userFk IS NOT NULL; - + CALL vn.timeControl_calculate(vDatedFrom, vDatedTo); 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `timeControl_calculateByDepartment` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72073,34 +71854,30 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculateByDepartment`(vDepartmentFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN - /** - * @param vDepartmentFk + * @param vDepartmentFk * @param vDatedFrom workerTimeControl * @param vDatedTo workerTimeControl */ - - DROP TEMPORARY TABLE IF EXISTS tmp.`user`; - - CREATE TEMPORARY TABLE tmp.`user` - SELECT DISTINCT w.userFk - FROM postgresql.business AS b - LEFT JOIN postgresql.profile AS pr ON pr.profile_id = b.client_id - LEFT JOIN postgresql.business_labour AS bl ON b.business_id = bl.business_id - LEFT JOIN worker AS w ON w.id = pr.workerFk - LEFT JOIN department AS d ON bl.department_id = d.id - WHERE (b.date_start BETWEEN vDatedFrom AND vDatedTo - OR IFNULL(b.date_end, vDatedTo) BETWEEN vDatedFrom AND vDatedTo - OR (b.date_start <= vDatedFrom AND b.date_end >= vDatedTo) - ) AND bl.department_id = vDepartmentFk - ORDER BY b.date_end DESC; - - CALL timeControl_calculate(vDatedFrom, vDatedTo); - - DROP TEMPORARY TABLE tmp.`user`; + DROP TEMPORARY TABLE IF EXISTS tmp.`user`; + + CREATE TEMPORARY TABLE tmp.`user` + SELECT DISTINCT b.workerFk userFk + FROM business AS b + WHERE (b.started BETWEEN vDatedFrom AND vDatedTo + OR IFNULL(b.ended, vDatedTo) BETWEEN vDatedFrom AND vDatedTo + OR (b.started <= vDatedFrom AND b.ended >= vDatedTo) + ) AND b.departmentFk = vDepartmentFk + ORDER BY b.ended DESC; + + CALL timeControl_calculate(vDatedFrom, vDatedTo); + + DROP TEMPORARY TABLE tmp.`user`; END ;; DELIMITER ; @@ -72108,8 +71885,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `timeControl_calculateByUser` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72117,24 +71892,26 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculateByUser`(vUserFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** - * @param vUserFk + * @param vUserFk * @param vDatedFrom workerTimeControl * @param vDatedTo workerTimeControl */ - + DROP TEMPORARY TABLE IF EXISTS tmp.`user`; - + CREATE TEMPORARY TABLE tmp.`user` SELECT id userFk - FROM user - WHERE id = vUserFk; + FROM user + WHERE id = vUserFk; CALL vn.timeControl_calculate(vDatedFrom, vDatedTo); - + DROP TEMPORARY TABLE tmp.`user`; END ;; @@ -72143,8 +71920,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `timeControl_calculateByWorker` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72152,26 +71927,28 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculateByWorker`(vWorkerFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** - * @param vWorkerFk + * @param vWorkerFk * @param vDatedFrom workerTimeControl * @param vDatedTo workerTimeControl */ - + DROP TEMPORARY TABLE IF EXISTS tmp.`user`; - + CREATE TEMPORARY TABLE tmp.`user` SELECT u.id userFk FROM vn.user u JOIN vn.worker w ON w.userFk = u.id WHERE w.id = vWorkerFk; - + CALL vn.timeControl_calculate(vDatedFrom, vDatedTo); - + DROP TEMPORARY TABLE tmp.`user`; END ;; @@ -72180,8 +71957,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `timeControl_getError` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72189,17 +71964,19 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_getError`(vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /* * @param vDatedFrom - * @param vDatedTo + * @param vDatedTo * @table tmp.`user`(userFk) * Fichadas incorrectas de las cuales no se puede calcular horas trabajadas * @return tmp.timeControlError (id) */ - DECLARE vDayMaxTime INTEGER; + DECLARE vDayMaxTime INTEGER; SET @journeyCounter := 0; SET @lastUserFk := NULL; @@ -72207,16 +71984,16 @@ BEGIN SELECT dayMaxTime INTO vDayMaxTime FROM workerTimeControlConfig LIMIT 1; - DROP TEMPORARY TABLE IF EXISTS tmp.timeControl; - CREATE TEMPORARY TABLE tmp.timeControl + DROP TEMPORARY TABLE IF EXISTS tmp.timeControl; + CREATE TEMPORARY TABLE tmp.timeControl (INDEX(id), INDEX(journeyCounter)) ENGINE = MEMORY SELECT sub.id, - sub.direction, + sub.direction, sub.timed, IF(sub.direction = 'in' OR @hasOut OR sub.userFk <> @lastUserFk, @journeyCounter := @journeyCounter + 1, @journeyCounter) journeyCounter, - @lastUserFk := sub.userFk workerFk, - IF(sub.direction = 'out', @hasOut:= TRUE, @hasOut:= FALSE) + @lastUserFk := sub.userFk workerFk, + IF(sub.direction = 'out', @hasOut:= TRUE, @hasOut:= FALSE) FROM ( SELECT DISTINCT wtc.id, wtc.direction, @@ -72227,44 +72004,42 @@ BEGIN WHERE wtc.timed BETWEEN DATE_SUB(vDatedFrom, INTERVAL 1 DAY) AND DATE_ADD(vDatedTo, INTERVAL 1 DAY) ORDER BY wtc.userFk, wtc.timed ) sub; - - DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux; CREATE TEMPORARY TABLE tmp.timeControlAux (INDEX(id), INDEX(journeyCounter)) ENGINE = MEMORY SELECT * FROM tmp.timeControl; - DROP TEMPORARY TABLE IF EXISTS tmp.timeControlError; - CREATE TEMPORARY TABLE tmp.timeControlError + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlError; + CREATE TEMPORARY TABLE tmp.timeControlError (INDEX(id)) ENGINE = MEMORY - SELECT id + SELECT id FROM tmp.timeControlAux tca JOIN ( - SELECT journeyCounter, + SELECT journeyCounter, UNIX_TIMESTAMP(MAX(timed)) - UNIX_TIMESTAMP(MIN(timed)) timeWork, - SUM(direction = 'in') totalIn, + SUM(direction = 'in') totalIn, SUM(direction = 'out') totalOut, timed FROM tmp.timeControl GROUP BY journeyCounter - HAVING COUNT(*) MOD 2 = 1 - OR totalIn <> 1 - OR totalOut <> 1 + HAVING COUNT(*) MOD 2 = 1 + OR totalIn <> 1 + OR totalOut <> 1 OR timeWork >= vDayMaxTime )sub ON sub.journeyCounter = tca.journeyCounter WHERE sub.timed BETWEEN vDatedFrom AND vDatedTo; - DROP TEMPORARY TABLE IF EXISTS tmp.timeControl; - DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux; + DROP TEMPORARY TABLE IF EXISTS tmp.timeControl; + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `timeWorkerControl_check` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72272,6 +72047,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `timeWorkerControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) proc: BEGIN @@ -72279,15 +72056,13 @@ proc: BEGIN * deprecated call workerTimeControl_check */ CALL vn.workerTimeControl_check(vUserFk,vDated,vTabletFk); - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `tpvTransaction_checkStatus` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72295,11 +72070,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `tpvTransaction_checkStatus`() BEGIN /** - * + * * Envia mail con los cobros web no * trasladados a la ficha del cliente. * @@ -72315,7 +72092,7 @@ BEGIN FROM hedera.tpvTransaction t WHERE t.receiptFk IS NULL AND t.status = 'ok' - AND t.created < DATE_ADD(NOW(),INTERVAL - 2 DAY) + AND t.created < DATE_ADD(util.VN_NOW(),INTERVAL - 2 DAY) GROUP BY t.clientFk; END ;; @@ -72324,8 +72101,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `travelVolume` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72333,15 +72108,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `travelVolume`(vTravelFk INT) BEGIN - - SELECT w1.name AS ORI, - w2.name AS DES, + + SELECT w1.name AS ORI, + w2.name AS DES, tr.shipped shipment, tr.landed landing, - a.name Agencia, + a.name Agencia, s.name Proveedor, e.id Id_Entrada, e.REF Referencia, @@ -72349,26 +72126,24 @@ BEGIN vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.trolleyM3 / 1000000 ,1) AS DECIMAL(10,2)) AS CC, CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) * vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.palletM3 / 1000000,1) AS DECIMAL(10,2)) AS espais - FROM vn.buy b - JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.supplier s ON s.id = e.supplierFk - JOIN vn.travel tr ON tr.id = e.travelFk + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.supplier s ON s.id = e.supplierFk + JOIN vn.travel tr ON tr.id = e.travelFk JOIN vn.agencyMode a ON a.id = tr.agencyModeFk - JOIN vn.warehouse w1 ON w1.id = tr.warehouseInFk - JOIN vn.warehouse w2 ON w2.id = tr.warehouseOutFk - JOIN vn.volumeConfig vc - JOIN vn.item i ON i.id = b.itemFk + JOIN vn.warehouse w1 ON w1.id = tr.warehouseInFk + JOIN vn.warehouse w2 ON w2.id = tr.warehouseOutFk + JOIN vn.volumeConfig vc + JOIN vn.item i ON i.id = b.itemFk JOIN vn.itemType it ON it.id = i.typeFk WHERE tr.id = 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `travelVolume_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72376,31 +72151,29 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `travelVolume_get`(vFromDated DATE, vToDated DATE, vWarehouseFk INT) BEGIN - SELECT tr.landed Fecha, - a.name Agencia, - count(DISTINCT e.id) numEntradas, + a.name Agencia, + count(DISTINCT e.id) numEntradas, FLOOR(sum(item_getVolume(b.itemFk, b.packageFk) * b.stickers / 1000000 )) AS m3 FROM vn.travel tr - JOIN vn.agencyMode a ON a.id = tr.agencyModeFk - JOIN vn.entry e ON e.travelFk = tr.id - JOIN vn.buy b ON b.entryFk = e.id - WHERE tr.landed BETWEEN vFromDated AND vToDated - AND e.isRaid = FALSE + JOIN vn.agencyMode a ON a.id = tr.agencyModeFk + JOIN vn.entry e ON e.travelFk = tr.id + JOIN vn.buy b ON b.entryFk = e.id + WHERE tr.landed BETWEEN vFromDated AND vToDated + AND e.isRaid = FALSE AND tr.warehouseInFk = vWarehouseFk GROUP BY tr.landed , a.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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `travel_checkDates` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72408,6 +72181,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_checkDates`(vShipped DATE, vLanded DATE) BEGIN @@ -72418,19 +72193,17 @@ BEGIN * @param vShipped The shipment date * @param vLanded The landing date */ - + IF vLanded < vShipped THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Landing cannot be lesser than shipment'; - 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `travel_clone` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72438,29 +72211,27 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_clone`(vSelf INT, vDays INT, OUT vNewTravelFk INT) BEGIN - - /** - * Clona un travel el número de dias indicado y devuelve su Id - * - * @param vSelf Identificador de vn.travel - * @param vDays Número de dias a futuro - * - * @return vNewTravelFk Nuevo número de travel - */ - +/** + * Clona un travel el número de dias indicado y devuelve su id. + * + * @param vSelf Identificador de vn.travel + * @param vDays Número de dias a futuro + * @return vNewTravelFk Nuevo número de travel + */ SELECT tr.id INTO vNewTravelFk FROM vn.travel tr JOIN vn.travel tr2 USING(shipped, warehouseInFk, warehouseOutFk, agencyModeFk, `ref`) WHERE tr2.id = vSelf AND tr.landed = TIMESTAMPADD(DAY, vDays, tr2.landed); - + IF ISNULL(vNewTravelFk) THEN - START TRANSACTION; - + INSERT INTO vn.travel( shipped, shipmentHour, landed, @@ -72479,23 +72250,19 @@ BEGIN agencyModeFk, `ref`, cargoSupplierFk - FROM vn.travel + FROM vn.travel WHERE id = vSelf; - - SELECT LAST_INSERT_ID() INTO vNewTravelFk; - + + SELECT LAST_INSERT_ID() INTO vNewTravelFk; + COMMIT; - END IF; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `travel_cloneWithEntries` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72503,15 +72270,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_cloneWithEntries`( - IN vTravelFk INT, - IN vDateStart DATE, + IN vTravelFk INT, + IN vDateStart DATE, IN vDateEnd DATE, IN vWarehouseOutFk INT, - IN vWarehouseInFk INT, - IN vRef VARCHAR(255), - IN vAgencyModeFk INT, + IN vWarehouseInFk INT, + IN vRef VARCHAR(255), + IN vAgencyModeFk INT, OUT vNewTravelFk INT) BEGIN /** @@ -72532,37 +72301,37 @@ BEGIN DECLARE vRsEntry CURSOR FOR SELECT e.id FROM entry e - JOIN travel t + JOIN travel t ON t.id = e.travelFk WHERE e.travelFk = vTravelFk; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + DECLARE EXIT HANDLER FOR SQLEXCEPTION/*, 1062 Duplicate key*/ - BEGIN + BEGIN ROLLBACK; - + END; - + START TRANSACTION; INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, `ref`, isDelivered, isReceived, m3, kg) SELECT vDateStart, vDateEnd, vWarehouseInFk, vWarehouseOutFk, vAgencyModeFk, vRef, isDelivered, isReceived, m3, kg FROM travel WHERE id = vTravelFk; - + SET vNewTravelFk = LAST_INSERT_ID(); CALL logAdd(vNewTravelFk, 'insert', 'travel', CONCAT('clona travel ',vTravelFk)); SET vDone = FALSE; SET @isModeInventory = TRUE; OPEN vRsEntry ; FETCH vRsEntry INTO vAuxEntryFk; - + WHILE NOT vDone DO INSERT INTO entry ( supplierFk, ref, isExcludedFromAvailable, - isConfirmed, + isConfirmed, isOrdered, isRaid, commission, @@ -72571,12 +72340,12 @@ BEGIN travelFk, currencyFk, companyFk, - gestDocFk, + gestDocFk, invoiceInFk) SELECT supplierFk, ref, isExcludedFromAvailable, - isConfirmed, + isConfirmed, isOrdered, isRaid, commission, @@ -72585,14 +72354,14 @@ BEGIN vNewTravelFk, currencyFk, companyFk, - gestDocFk, + gestDocFk, invoiceInFk FROM entry WHERE id = vAuxEntryFk; - + SET vEntryNew = LAST_INSERT_ID(); - - CALL logAdd(vEntryNew, 'insert', 'entry', CONCAT('clona entrada ',vAuxEntryFk)); + + CALL logAdd(vEntryNew, 'insert', 'entry', CONCAT('clona entrada ',vAuxEntryFk)); INSERT INTO buy ( entryFk, itemFk, @@ -72637,8 +72406,8 @@ BEGIN isChecked, weight FROM buy - WHERE entryFk = vAuxEntryFk; - + WHERE entryFk = vAuxEntryFk; + FETCH vRsEntry INTO vAuxEntryFk; END WHILE; SET @isModeInventory = FALSE; @@ -72650,8 +72419,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `travel_doRecalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72659,6 +72426,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_doRecalc`() BEGIN @@ -72688,11 +72457,11 @@ BEGIN SELECT COUNT(*) INTO vTotalEntries FROM entry WHERE travelFk = vTravelFk; - + UPDATE travel SET totalEntries = vTotalEntries WHERE id = vTravelFk; - + DELETE FROM travelRecalc WHERE travelFk = vTravelFk; END LOOP; @@ -72703,8 +72472,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `travel_moveRaids` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72712,13 +72479,15 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_moveRaids`() BEGIN /* * Desplaza al dia siguiente los travels que contengan redadas y avisa a los compradores - * + * */ DECLARE vDone BOOL DEFAULT FALSE; DECLARE vWorkerName VARCHAR(50); @@ -72730,7 +72499,7 @@ BEGIN SELECT GROUP_CONCAT( DISTINCT CONCAT('https://salix.verdnatura.es/#!/travel/', ttr.id, '/summary ') ORDER BY ttr.id SEPARATOR '\n\r'), u.name FROM tmp.travel ttr - JOIN entry e ON e.travelFk = ttr.id + JOIN entry e ON e.travelFk = ttr.id JOIN buy b ON b.entryFk = e.id JOIN item i ON i.id = b.itemFk JOIN itemType it ON it.id = i.typeFk @@ -72738,19 +72507,19 @@ BEGIN GROUP BY u.name; DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; + SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN ROLLBACK; RESIGNAL; END; - + DROP TEMPORARY TABLE IF EXISTS tmp.travel; CREATE TEMPORARY TABLE tmp.travel SELECT tr.id,tr.landed FROM travel tr - JOIN entry e ON e.travelFk = tr.id + JOIN entry e ON e.travelFk = tr.id WHERE tr.landed = util.tomorrow() AND e.isRaid GROUP BY tr.id; @@ -72792,8 +72561,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `travel_requestRecalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72801,6 +72568,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_requestRecalc`(vSelf INT) proc: BEGIN @@ -72812,7 +72581,7 @@ proc: BEGIN IF vSelf IS NULL THEN LEAVE proc; END IF; - + INSERT IGNORE INTO travelRecalc SET travelFk = vSelf; END ;; DELIMITER ; @@ -72820,8 +72589,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `travel_weeklyClone` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72829,6 +72596,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_weeklyClone`(vSinceWeek INT, vToWeek INT) BEGIN @@ -72850,7 +72619,7 @@ BEGIN DECLARE vDone BOOLEAN DEFAULT FALSE; DECLARE vRsTravel CURSOR FOR SELECT travelFk, - @a := TIMESTAMPADD(DAY,vCounter * 7 - WEEKDAY(CURDATE()) - 1 + weekDay,CURDATE()), + @a := TIMESTAMPADD(DAY,vCounter * 7 - WEEKDAY(util.VN_CURDATE()) - 1 + weekDay,util.VN_CURDATE()), @a := TIMESTAMPADD(DAY,duration,@a), warehouseOutFk, warehouseInFk, @@ -72859,12 +72628,12 @@ BEGIN FROM travelClonedWeekly WHERE travelFk; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; SET vCounter = vSinceWeek; vWeekLoop :LOOP INSERT IGNORE INTO travel (shipped, landed, warehouseOutFk, warehouseInFk, agencyModeFk, ref, cargoSupplierFk, kg) - SELECT @a := TIMESTAMPADD(DAY, vCounter * 7 - WEEKDAY(CURDATE()) - 1 + weekDay,CURDATE()), + SELECT @a := TIMESTAMPADD(DAY, vCounter * 7 - WEEKDAY(util.VN_CURDATE()) - 1 + weekDay,util.VN_CURDATE()), @a := TIMESTAMPADD(DAY, duration, @a), warehouseOutFk, warehouseInFk, @@ -72889,15 +72658,13 @@ BEGIN SET vCounter = vCounter + 1; END LOOP vWeekLoop; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `typeTagMake` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72905,18 +72672,20 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `typeTagMake`(vTypeFk INT) BEGIN /* * Plantilla para modificar reemplazar todos los tags * por los valores que tienen los articulos - * + * * @param vTypeFk tipo a modificar - * + * */ - DELETE it.* - FROM itemTag it + DELETE it.* + FROM itemTag it JOIN item i ON i.id = it.itemFk WHERE i.typeFk = vTypeFk; @@ -72925,40 +72694,40 @@ BEGIN FROM item i JOIN tag t ON t.name = 'Longitud' COLLATE utf8_general_ci WHERE i.typeFk = vTypeFk; - + INSERT INTO itemTag(itemFk, tagFk, value, priority) SELECT i.id, t.id, i.category, 5 FROM item i JOIN tag t ON t.name = 'Categoria' COLLATE utf8_general_ci WHERE i.typeFk = vTypeFk; - + INSERT INTO itemTag(itemFk, tagFk, value, priority) SELECT i.id, t.id, ink.name, 2 FROM item i JOIN tag t ON t.name = 'Color' COLLATE utf8_general_ci JOIN ink ON ink.id = i.inkFk WHERE i.typeFk = vTypeFk; - + INSERT INTO itemTag(itemFk, tagFk, value, priority) SELECT i.id, t.id, p.name, 3 FROM item i JOIN tag t ON t.name = 'Productor' COLLATE utf8_general_ci JOIN producer p ON p.id = i.producerFk - WHERE i.typeFk = vTypeFk; - + WHERE i.typeFk = vTypeFk; + INSERT INTO itemTag(itemFk, tagFk, value, priority) SELECT i.id, t.id, o.name, 4 FROM item i JOIN tag t ON t.name = 'Origen' COLLATE utf8_general_ci JOIN origin o ON o.id = i.originFk WHERE i.typeFk = vTypeFk; - /* + /* INSERT INTO itemTag(itemFk, tagFk, value, priority) SELECT i.id, t.id, i.stems, 6 FROM item i JOIN tag t ON t.name = 'Tallos' COLLATE utf8_general_ci - WHERE i.typeFk = vTypeFk; - */ + WHERE i.typeFk = vTypeFk; + */ -- CALL itemTagArrangedUpdate(NULL); END ;; @@ -72967,8 +72736,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `updatePedidosInternos` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72976,12 +72743,14 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `updatePedidosInternos`(vItemFk INT) BEGIN UPDATE vn.item SET upToDown = 0 WHERE item.id = vItemFk; - + END ;; DELIMITER ; @@ -72989,8 +72758,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `visible_getMisfit` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72998,24 +72765,26 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `visible_getMisfit`(vSectorFk INT) BEGIN - + /* 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 + FROM vn.sector s WHERE s.id = vSectorFk; - + CALL cache.visible_refresh(vCalcVisibleFk, FALSE, vWarehouseFk); DROP TEMPORARY TABLE IF EXISTS tmp.stockMisfit; @@ -73028,17 +72797,17 @@ BEGIN 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 + 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 + 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; @@ -73048,8 +72817,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `warehouseFitting` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73057,22 +72824,24 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `warehouseFitting`(IN vWhOrigin INT , IN vWhDestiny INT) BEGIN DECLARE vCacheVisibleOriginFk INT; DECLARE vCacheVisibleDestinyFk INT; - + CALL cache.visible_refresh(vCacheVisibleOriginFk, FALSE, vWhOrigin); CALL cache.visible_refresh(vCacheVisibleDestinyFk, FALSE, vWhDestiny); - + SELECT i.id itemFk, i.longName, i.size, i.subName, vOrigin.visible AS Origen, vDestiny.visible Destino - + FROM vn.item i JOIN vn.itemType it ON it.id = i.typeFk LEFT JOIN cache.visible vOrigin ON vOrigin.calc_id = vCacheVisibleOriginFk AND vOrigin.item_id = i.id @@ -73086,8 +72855,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `warehouseFitting_byTravel` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73095,27 +72862,27 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `warehouseFitting_byTravel`(IN vTravelFk INT) BEGIN DECLARE vWhOrigin INT; DECLARE vWhDestiny INT; - + SELECT warehouseInFk, warehouseOutFk INTO vWhDestiny, vWhOrigin FROM vn.travel WHERE id = vTravelFk; - + 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerCalculateBoss` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73123,6 +72890,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCalculateBoss`(vWorker INT) BEGIN @@ -73155,8 +72924,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerCalendar_calculateBusiness` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73164,59 +72931,60 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` 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 + * @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 vPayedHolidays 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), + SELECT IF(b.started < CONCAT(vYear,"-01-01"), CONCAT(vYear,"-01-01"),b.started), + IF(b.ended IS NULL OR YEAR(b.ended)>vYear , CONCAT(vYear,"-12-31"), b.ended), IF(wbt.hasHolidayEntitlement, 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 workerBusinessType wbt ON wbt.id = 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 + c.hours_week, + IF(YEAR(b.ended) = vYear, b.payedHolidays, 0) payedHolidays + INTO vStarted, + vEnded, + vDaysHoliday, + vHoursWeek, + vPayedHolidays + FROM business b + JOIN workerBusinessType wbt ON wbt.id = b.workerBusinessTypeFk + JOIN workCenterHoliday w ON w.workcenterFk = b.workcenterFk + LEFT JOIN postgresql.calendar_labour_type c ON c.calendar_labour_type_id = b.calendarTypeFk + WHERE b.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 + SELECT IFNULL(SUM(holidayEntitlementRate), 0), + SUM(-(discountRate - 1)) + vPayedHolidays + 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 + 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, @@ -73228,8 +72996,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerCalendar_calculateYear` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73237,6 +73003,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCalendar_calculateYear`(vYear INT, vWorkerFk INT) BEGIN @@ -73244,33 +73012,32 @@ BEGIN /** * Calcula los días y horas de vacaciones en función de un trabajador y año * - * @param vYear - * @param vWorkerFk + * @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 - WHERE vYear BETWEEN YEAR(b.date_start) AND IFNULL(YEAR(b.date_end), vYear ) - AND pr.workerFk = vWorkerFk; + SELECT b.id + FROM business b + WHERE vYear BETWEEN YEAR(b.started) AND IFNULL(YEAR(b.ended), vYear) + AND b.workerFk = vWorkerFk; DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; - + SET vDone = TRUE; + DROP TEMPORARY TABLE IF EXISTS tmp.workerCalendarCalculateYear; CREATE TEMPORARY TABLE tmp.workerCalendarCalculateYear - (days DEC(5,2), + (days DEC(5,2), hours DEC(5,2), - daysEnjoyed DEC(5,2), - hoursEnjoyed 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 @@ -73283,12 +73050,12 @@ BEGIN CALL workerCalendar_calculateBusiness(vYear, vBusinessFk); UPDATE tmp.workerCalendarCalculateYear w - JOIN tmp.workerCalendarCalculateBusiness wc + 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; @@ -73301,8 +73068,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerCreate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73310,10 +73075,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCreate`( vFirstname VARCHAR(50), - vLastName VARCHAR(50), + vLastName VARCHAR(50), vCode CHAR(3), vBossFk INT, vUserFk INT, @@ -73325,7 +73092,7 @@ BEGIN * Create new worker * */ - INSERT INTO worker(id, code, firstName, lastName, userFk, bossFk, fi, birth) + INSERT INTO worker(id, code, firstName, lastName, userFk, bossFk, fi, birth) VALUES (vUserFk, vCode, vFirstname, vLastName, vUserFk, vBossFk, vFi, vBirth); END ;; DELIMITER ; @@ -73333,8 +73100,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerCreateExternal` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73342,47 +73107,42 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCreateExternal`( - vFirstName VARCHAR(50), - vSurname1 VARCHAR(50), - vSurname2 VARCHAR(50), - vUser VARCHAR(20), - vPassword VARCHAR(50), - vWorkerCode VARCHAR(3), - vRole INT(2) - ) + vFirstName VARCHAR(50), + vSurname1 VARCHAR(50), + vSurname2 VARCHAR(50), + vUser VARCHAR(20), + vPassword VARCHAR(50), + vWorkerCode VARCHAR(3), + vRole INT(2) + ) BEGIN DECLARE vUserId INT; - DECLARE vWorkerPako INT DEFAULT 2; - DECLARE vSurnames VARCHAR(100); + DECLARE vSurnames VARCHAR(100); + + INSERT INTO account.user(name, password, role) + SELECT vUser, MD5(vPassword), vRole; - INSERT INTO account.user(name,password,role) - SELECT vUser,MD5(vPassword),vRole; - SET vUserId = LAST_INSERT_ID(); - /* - INSERT INTO vn.worker(firstName,lastName,bossFk,workerCode,user_id) - SELECT vFirstName,CONCAT(vSurname1,' ',vSurname2),2,vWorkerCode,vUser; - */ - - IF vSurname2 IS NULL THEN + + IF vSurname2 IS NULL THEN SET vSurnames = vSurname1; - ELSE + ELSE SET vSurnames = CONCAT(vSurname1, ' ', vSurname2); - END IF; - - INSERT INTO vn2008.Trabajadores(Nombre, Apellidos, boss, CodigoTrabajador, user_id) - SELECT vFirstName, vSurnames, vWorkerPako, vWorkerCode, vUserId; + END IF; + + INSERT INTO worker(firstName, lastName, code, userFk, isFreelance) + SELECT vFirstName, vSurnames, vWorkerCode, vUserId, TRUE; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerDepartmentByDate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73390,6 +73150,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDepartmentByDate`(vDate DATE) BEGIN @@ -73397,61 +73159,58 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.workerDepartmentByDate; CREATE TEMPORARY TABLE tmp.workerDepartmentByDate ENGINE = MEMORY - SELECT w.userFk, - w.lastName name, - w.firstName firstname, - d.name department, + SELECT w.userFk, + w.lastName name, + w.firstName firstname, + d.name department, d.id departmentFk, - b.date_start, - d.isProduction, - CAST(12 * blp.importepactado / clt.hours_week / 52 AS DECIMAL(10,2)) costeHora, + b.started, + d.isProduction, + CAST(12 * b.amount / clt.hours_week / 52 AS DECIMAL(10,2)) costeHora, w.fi nif - FROM postgresql.profile pr - JOIN postgresql.business b ON b.client_id = pr.profile_id - JOIN postgresql.business_labour bl ON bl.business_id = b.business_id - JOIN postgresql.calendar_labour_type clt ON clt.calendar_labour_type_id = bl.calendar_labour_type_id - JOIN postgresql.business_labour_payroll blp ON blp.business_id = b.business_id - JOIN department d ON d.id = bl.department_id - JOIN worker w ON w.id = pr.workerFk - WHERE b.date_start <= vDate - AND (b.date_end > vDate OR b.date_end IS NULL); + FROM business b + JOIN postgresql.calendar_labour_type clt ON clt.calendar_labour_type_id = b.calendarTypeFk + JOIN department d ON d.id = b.departmentFk + JOIN worker w ON w.id = b.workerFk + WHERE b.started <= vDate + AND (b.ended > vDate OR b.ended IS 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerDisable` */; /*!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 = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDisable`(vUserId int) mainLabel:BEGIN - IF (SELECT COUNT(*) FROM workerDisableExcluded WHERE workerFk = vUserId AND (dated > CURDATE() OR dated IS NULL)) > 0 THEN + IF (SELECT COUNT(*) FROM workerDisableExcluded WHERE workerFk = vUserId AND (dated > util.VN_CURDATE() OR dated IS NULL)) > 0 THEN LEAVE mainLabel; END IF; DELETE FROM account.account WHERE id = vUserId; - UPDATE account.user + UPDATE account.user SET role = 2 - WHERE id = vUserId; + WHERE id = vUserId; - DELETE FROM pbx.sip - WHERE user_id = vUserId; + DELETE FROM pbx.sip + WHERE user_id = vUserId; UPDATE `client` c JOIN payMethod p ON p.name = 'CONTADO' SET c.credit = 0, c.payMethodFk = p.id, hasCoreVnl = FALSE WHERE c.id = vUserId; - + UPDATE `client` c SET c.salesPersonFk = null WHERE c.salesPersonFk = vUserId; @@ -73461,8 +73220,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerDisableAll` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73470,6 +73227,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDisableAll`() BEGIN @@ -73477,19 +73236,27 @@ BEGIN DECLARE vUserFk INT; DECLARE rs CURSOR FOR - SELECT a.id - FROM (SELECT client_id, business_id - FROM (SELECT business_id, client_id - FROM postgresql.business - ORDER BY client_id, date_end IS NULL DESC , date_end DESC - LIMIT 10000000000000000000)sub - GROUP BY client_id)sub2 - JOIN postgresql.business b ON sub2.client_id = b.client_id AND sub2.business_id = b.business_id - JOIN postgresql.profile pr ON b.client_id = pr.profile_id - JOIN account.account a ON pr.workerFk = a.id - WHERE b.date_end IS NOT NULL - AND b.date_end < CURDATE() - AND b.date_end > TIMESTAMPADD(DAY, -70, CURDATE()); + SELECT DISTINCT a.id + FROM vn.business b + LEFT JOIN(SELECT DISTINCT workerFk + FROM business b + WHERE ended IS NULL + OR ended >= util.VN_CURDATE() + )sub ON sub.workerFk = b.workerFk + JOIN account.account a ON a.id = b.workerFk + WHERE sub.workerFk IS NULL + AND b.ended BETWEEN TIMESTAMPADD(DAY, -70, util.VN_CURDATE()) AND util.VN_CURDATE(); + +/* SELECT DISTINCT b.workerFk + FROM business b + JOIN account.account a ON a.id = b.workerFk + LEFT JOIN ( + SELECT DISTINCT workerFk + FROM business + WHERE IFNULL(ended, util.VN_CURDATE())>=util.VN_CURDATE() + )sub ON sub.workerFk = a.id + WHERE sub.workerFk IS NULL +*/ DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; @@ -73504,15 +73271,13 @@ BEGIN END WHILE; CLOSE rs; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerForAllCalculateBoss` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73520,6 +73285,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerForAllCalculateBoss`() BEGIN @@ -73557,8 +73324,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerJourney_replace` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73566,21 +73331,23 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerJourney_replace`( - vDatedFrom DATE, - vDatedTo DATE, + vDatedFrom DATE, + vDatedTo DATE, vWorkerFk INT) BEGIN /** - * Actualiza la tabla workerJourney para que actue como caché permanente revisable + * Actualiza la tabla workerJourney para que actue como caché permanente revisable * de las jornadas laborales. * @param vDatedFrom workerTimeControl * @param vDatedTo workerTimeControl * @param vWorkerFk, en caso de pasar 0 ó NULL se aplica a todos - */ + */ DECLARE vDatedTimeTo DATETIME; - DECLARE vMaxTimePerDay INT; + DECLARE vMaxTimePerDay INT; DECLARE vMinHoursToBreak DECIMAL(10,2); DECLARE vBreakHours DECIMAL(10,2); DECLARE vMonthByYear INT; @@ -73588,57 +73355,57 @@ BEGIN DECLARE vMonthsByYear INT DEFAULT 12; DECLARE vDaysByWeek INT DEFAULT 5; DECLARE vDatedFromYesterday DATETIME; - DECLARE vDatedToTomorrow DATETIME; - - SELECT DATE_SUB(vDatedFrom, INTERVAL 1 DAY), DATE_ADD(vDatedTo, INTERVAL 1 DAY) + DECLARE vDatedToTomorrow DATETIME; + + SELECT DATE_SUB(vDatedFrom, INTERVAL 1 DAY), DATE_ADD(vDatedTo, INTERVAL 1 DAY) INTO vDatedFromYesterday, vDatedToTomorrow; SET vDatedTimeTo = util.dayEnd(vDatedTo); - - SELECT minHoursToBreak, breakHours, maxTimePerDay + + SELECT minHoursToBreak, breakHours, maxTimePerDay INTO vMinHoursToBreak, vBreakHours, vMaxTimePerDay FROM workerTimeControlConfig; DELETE FROM workerJourney - WHERE dated BETWEEN vDatedFrom AND vDatedTo + WHERE dated BETWEEN vDatedFrom AND vDatedTo AND NOT isPaid AND NOT isUpdated - AND (vWorkerFk IS NULL OR userFK = vWorkerFk); + AND (vWorkerFk IS NULL OR userFK = vWorkerFk); - -- Se inserta todos los días del periodo por worker y business en el rango de fechas. + -- Se inserta todos los días del periodo por worker y business en el rango de fechas. INSERT IGNORE INTO workerJourney(userFk, dated, businessFk) - SELECT w.workerFk, t.dated, w.businessFk - FROM workerLabour w - JOIN time t ON t.dated BETWEEN w.started AND IFNULL(w.ended,CURDATE()) + SELECT b.workerFk, t.dated, b.id + FROM business b + JOIN time t ON t.dated BETWEEN b.started AND IFNULL(b.ended,util.VN_CURDATE()) WHERE t.dated BETWEEN vDatedFrom AND vDatedTo - AND (vWorkerFk IS NULL OR w.workerFk = vWorkerFk) - ORDER BY w.workerFk, t.dated, w.businessFk; - + AND (vWorkerFk IS NULL OR b.workerFk = vWorkerFk) + ORDER BY b.workerFk, t.dated, b.id; + DROP TEMPORARY TABLE IF EXISTS tmp.`user`; IF vWorkerFk THEN CALL timeControl_calculateByUser(vWorkerFk, vDatedFrom , vDatedTimeTo); - CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user` - SELECT vWorkerFk userFk; + CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user` + SELECT vWorkerFk userFk; ELSE CALL timeControl_calculateAll(vDatedFrom, vDatedTimeTo); - CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user` + CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user` SELECT id userFk FROM worker w; - END IF; + END IF; UPDATE workerJourney wj JOIN tmp.timeControlCalculate t ON wj.dated = t.dated AND wj.userFk = t.userFk - SET wj.total = CAST(IF(t.timeWorkDecimal >= vMinHoursToBreak, - t.timeWorkDecimal - vBreakHours, + SET wj.total = CAST(IF(t.timeWorkDecimal >= vMinHoursToBreak, + t.timeWorkDecimal - vBreakHours, t.timeWorkDecimal) AS DECIMAL (10,2)), wj.lunch = IF(t.timeWorkDecimal >= vMinHoursToBreak , vBreakHours , 0) WHERE wj.dated BETWEEN vDatedFrom AND vDatedTo AND NOT wj.isPaid AND NOT wj.isUpdated AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk); - - -- NOCTURNIDAD + + -- NOCTURNIDAD CALL timeControl_getError(vDatedFrom, vDatedTimeTo); SET @vIsOdd := TRUE; @@ -73648,9 +73415,9 @@ BEGIN CREATE TEMPORARY TABLE tmp.workerTimeControl (INDEX (userFk), INDEX (timed)) ENGINE = MEMORY - SELECT DISTINCT(wtc.id), - wtc.userFk, - wtc.timed, + SELECT DISTINCT(wtc.id), + wtc.userFk, + wtc.timed, wtc.direction FROM workerTimeControl wtc JOIN tmp.`user` w ON w.userFk = wtc.userFk @@ -73660,10 +73427,10 @@ BEGIN AND (vWorkerFk IS NULL OR wtc.userFk = vWorkerFk) ORDER BY wtc.userFk, wtc.timed ASC; - SELECT MAX(id) INTO @vCont + SELECT MAX(id) INTO @vCont FROM tmp.workerTimeControl; - DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlAux; + DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlAux; CREATE TEMPORARY TABLE tmp.workerTimeControlAux ( `id` int(11) , `userFk` int(10) unsigned , @@ -73685,9 +73452,9 @@ BEGIN DATE(@lastTimed) dated, @lastUserFk lastUserFk, IF(direction ='middle', @vIsOdd := NOT @vIsOdd, FALSE) isOdd, - IF(@vIsOdd - AND @lastDirection = 'middle' - AND (DATE(@lastTimed) <> date(timed) + IF(@vIsOdd + AND @lastDirection = 'middle' + AND (DATE(@lastTimed) <> date(timed) OR @lastUserFk <> userFk), TRUE, FALSE) hasBreak, @lastTimed := wtc.timed, @lastUserFk := userFk, @@ -73701,16 +73468,16 @@ BEGIN SET @lastDirection := NULL; INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction) - SELECT @vCont:= @vCont + 1, - lastUserFk, - DATE_ADD(sub.dated, INTERVAL 1 DAY), + SELECT @vCont:= @vCont + 1, + lastUserFk, + DATE_ADD(sub.dated, INTERVAL 1 DAY), 'middle' FROM (SELECT IF(@lastUserFk <> userFk, @vIsOdd := TRUE, NULL), DATE(@lastTimed) dated, @lastUserFk lastUserFk, IF(direction ='middle', @vIsOdd := NOT @vIsOdd, FALSE) isOdd, - IF(@vIsOdd - AND @lastDirection = 'middle' + IF(@vIsOdd + AND @lastDirection = 'middle' AND (DATE(@lastTimed)<>date(timed) OR @lastUserFk<>userFk), TRUE, FALSE) hasBreak, @lastTimed := wtc.timed, @@ -73723,7 +73490,7 @@ BEGIN -- Cambio de dia INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction) SELECT @vCont:= @vCont + 1, - wtc.userFk, + wtc.userFk, util.dayEnd(date(wtc.timed)), 'out' FROM workerTimeControl wtc @@ -73734,8 +73501,8 @@ BEGIN GROUP BY wtc.userFk, DATE(wtc.timed); INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction) - SELECT @vCont:= @vCont + 1, - wtc.userFk, + SELECT @vCont:= @vCont + 1, + wtc.userFk, DATE_ADD(date(wtc.timed), INTERVAL 1 DAY), 'in' FROM workerTimeControl wtc @@ -73761,8 +73528,8 @@ BEGIN IF(@vIsOdd, @vLastTimed:=UNIX_TIMESTAMP(timed),@vLastTimed), IF(direction='in', @vDated := DATE(wtc.timed), @vDated ) dated, wtc.userFk, - IF(UNIX_TIMESTAMP(timed)- @vLastTimed < vMaxTimePerDay, - workerNigthlyHours_calculate(FROM_UNIXTIME(@vLastTimed), wtc.timed), + IF(UNIX_TIMESTAMP(timed)- @vLastTimed < vMaxTimePerDay, + workerNigthlyHours_calculate(FROM_UNIXTIME(@vLastTimed), wtc.timed), 0) NigthlyHours, @lastUserFk := userFk FROM (SELECT DISTINCT(wtc.id), wtc.userFk, wtc.timed, wtc.direction @@ -73775,7 +73542,7 @@ BEGIN ) wtc ORDER BY wtc.userFk, wtc.timed )sub - WHERE sub.dated BETWEEN vDatedFrom AND vDatedTo + WHERE sub.dated BETWEEN vDatedFrom AND vDatedTo GROUP BY userFk, sub.dated )night ON night.userFk = wj.userFk AND night.dated = wj.dated SET wj.nocturn = night.NigthlyHours @@ -73783,17 +73550,13 @@ BEGIN AND NOT isUpdated AND night.NigthlyHours <> 0; - -- Horas téoricas y precio de la hora ordinaria UPDATE workerJourney wj - JOIN postgresql.business_labour_payroll blp - ON blp.business_id = wj.businessFk - JOIN postgresql.business_labour bl - ON bl.business_id = wj.businessFk - JOIN postgresql.calendar_labour_type cl - ON cl.calendar_labour_type_id = bl.calendar_labour_type_id - SET wj.priceOrdinaryHour = - (vMonthsByYear * blp.importepactado) / + JOIN business b ON b.id = wj.businessFk + JOIN postgresql.calendar_labour_type cl + ON cl.calendar_labour_type_id = b.calendarTypeFk + SET wj.priceOrdinaryHour = + (vMonthsByYear * b.amount) / (vWeeksByYear * cl.hours_week), wj.contractJourney = cl.hours_week / vDaysByWeek WHERE wj.dated BETWEEN vDatedFrom AND vDatedTo @@ -73801,7 +73564,7 @@ BEGIN AND NOT wj.isPaid AND NOT isUpdated; - -- Precio Extras, Vacaciones y Nocturnas + -- Precio Extras, Vacaciones y Nocturnas UPDATE workerJourney wj JOIN(SELECT MAX(w.dated), t.dated, w.holidayInc, w.nightInc, w.extraInc FROM time t @@ -73819,23 +73582,21 @@ BEGIN -- Elimina el precio de las horas extras para los contratos parciales. UPDATE workerJourney wj - JOIN postgresql.business_labour bl - ON bl.business_id = wj.businessFk - JOIN postgresql.calendar_labour_type cl - ON cl.calendar_labour_type_id = bl.calendar_labour_type_id + JOIN business b ON b.id = wj.businessFk + JOIN postgresql.calendar_labour_type cl + ON cl.calendar_labour_type_id = b.calendarTypeFk SET wj.priceExtraHour = 0 WHERE cl.isPartial AND wj.dated BETWEEN vDatedFrom AND vDatedTo AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk) - AND NOT wj.isPaid + AND NOT wj.isPaid AND NOT wj.isUpdated; -- Ausencias UPDATE workerJourney wj - JOIN businessCalendar bc ON bc.businessFk = wj.businessFk + JOIN businessCalendar bc ON bc.businessFk = wj.businessFk AND bc.dated = wj.dated JOIN absenceType ab ON ab.id = bc.absenceTypeFk - JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk SET wj.permission = ab.permissionRate * wj.contractJourney, wj.contractJourney = IF(ab.permissionRate = 1, 0, ab.permissionRate) * wj.contractJourney WHERE ab.permissionRate > 0 @@ -73848,7 +73609,7 @@ BEGIN UPDATE workerJourney SET holiday = IF(DAYNAME(dated)='sábado', 0, total), contractJourney = 0 - WHERE DAYNAME(dated) IN ('sábado', 'domingo') + WHERE DAYNAME(dated) IN ('sábado', 'domingo') AND dated BETWEEN vDatedFrom AND vDatedTo AND (vWorkerFk IS NULL OR userFk = vWorkerFk) AND NOT isPaid @@ -73857,8 +73618,8 @@ BEGIN -- Festivos por centro de trabajo UPDATE workerJourney wj JOIN calendarHolidays ch ON ch.dated = wj.dated - JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk - AND bl.workcenter_id = ch.workcenterFk + JOIN business b ON b.id = wj.businessFk + AND b.workcenterFk = ch.workcenterFk SET wj.holiday = wj.total, wj.permission = wj.contractJourney, wj.contractJourney = 0 @@ -73868,7 +73629,7 @@ BEGIN AND NOT wj.isUpdated; -- Horas extras - UPDATE workerJourney + UPDATE workerJourney SET extra = lunch + total - contractJourney WHERE dated BETWEEN vDatedFrom AND vDatedTo AND (vWorkerFk IS NULL OR userFk = vWorkerFk) @@ -73886,8 +73647,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerMistakeType_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73895,26 +73654,26 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerMistakeType_get`() BEGIN - + /** * Obtiene los tipos de error para los trabajadores */ - - SELECT code, description - FROM workerMistakeType + + SELECT code, description + FROM workerMistakeType ORDER BY description; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerMistake_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73922,6 +73681,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerMistake_add`(vWorkerFk INT, vWorkerMistakeTypeFk VARCHAR(10), vUserFk INT ) BEGIN @@ -73936,7 +73697,7 @@ BEGIN */ DECLARE vWorkerName VARCHAR(255) DEFAULT account.user_getNameFromId(vUserFk); - IF(account.user_hasRole(vWorkerName,'coolerBoss')) + IF(account.user_hasRole(vWorkerName,'coolerBoss')) THEN INSERT INTO vn.workerMistake(userFk, workerMistakeTypeFk) VALUES(vWorkerFk, vWorkerMistakeTypeFk); @@ -73951,8 +73712,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerShelving_Add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73960,6 +73719,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerShelving_Add`(vWorkerFk INT, vBarcode VARCHAR(12)) BEGIN @@ -73971,7 +73732,7 @@ BEGIN DECLARE vIsShelvingFk BOOL; SELECT COUNT(*) > 0 INTO vIsShelvingFk - FROM vn.shelving s + FROM vn.shelving s WHERE s.code = vBarcode COLLATE utf8_general_ci; IF NOT vIsShelvingFk THEN @@ -73979,7 +73740,7 @@ BEGIN SELECT st.shelvingFk INTO vBarcode FROM vn.smartTag st WHERE st.code = vBarcode COLLATE utf8_general_ci; - + END IF; INSERT INTO vn.workerShelving (workerFk, shelvingFk) @@ -73990,8 +73751,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerShelving_delete` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73999,6 +73758,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerShelving_delete`(vWorkerFk INT, vBarcode VARCHAR(12)) BEGIN @@ -74011,20 +73772,20 @@ BEGIN SELECT COUNT(*) > 0 INTO vIsShelvingFk - FROM vn.shelving s + 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 + + DELETE FROM vn.workerShelving + WHERE shelvingFk = vBarcode COLLATE utf8_general_ci AND workerFk = vWorkerFk ; END ;; @@ -74033,8 +73794,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControlAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74042,17 +73801,19 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlAdd`(IN vUserFk INT, IN vWarehouseFk INT, IN vDated DATETIME) BEGIN /*INSERT INTO workerTimeControl(userFk, timed, manual, warehouseFk) VALUES(vUserFk, vDated, FALSE, vWarehouseFk); - + CALL vn.workerTimeControlSOWP(vUserFk , vDated);*/ - - CALL vn.workerTimeControl_add(vUserFk,vWarehouseFk,NOW(),FALSE); - + + CALL vn.workerTimeControl_add(vUserFk,vWarehouseFk,util.VN_NOW(),FALSE); + END ;; DELIMITER ; @@ -74060,8 +73821,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControlPinGenerate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74069,6 +73828,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlPinGenerate`( vWorkerFk INT) @@ -74078,16 +73839,14 @@ BEGIN * */ - - + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControlSetOrder` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74095,6 +73854,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlSetOrder`() BEGIN @@ -74115,8 +73876,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControlSetOrder_by_User_and_dateRange` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74124,6 +73883,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlSetOrder_by_User_and_dateRange`(vUserFk INT, vStarted DATE, vFinished DATE) BEGIN @@ -74143,8 +73904,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControlSOWP` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74152,25 +73911,25 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlSOWP`(IN vUserFk INT, IN vDated DATE) BEGIN SET @order := 0; - - UPDATE workerTimeControl - SET `order` = @order := @order + 1 - WHERE vUserFk =userFk + + UPDATE workerTimeControl + SET `order` = @order := @order + 1 + WHERE vUserFk =userFk AND vDated = DATE(timed) ORDER BY timed; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74178,11 +73937,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_add`(IN vUserFk INT, IN vWarehouseFk INT, IN vTimed DATETIME, IN vIsManual BOOL) BEGIN - - + + SELECT workerTimeControl_add(vUserFk,vWarehouseFk,vTimed,vIsManual); END ;; DELIMITER ; @@ -74190,8 +73951,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_calculateOddDays` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74199,6 +73958,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_calculateOddDays`() BEGIN @@ -74225,7 +73986,7 @@ BEGIN @cont cont, @lastUserFk := userFk FROM workerTimeControl wtc - WHERE wtc.timed BETWEEN TIMESTAMPADD(YEAR,-1,CURDATE()) AND util.dayEnd(CURDATE()) + WHERE wtc.timed BETWEEN TIMESTAMPADD(YEAR,-1,util.VN_CURDATE()) AND util.dayEnd(util.VN_CURDATE()) ORDER BY userFk, timed LIMIT 10000000000000000000)sub GROUP BY cont @@ -74238,8 +73999,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_check` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74247,6 +74006,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) proc: BEGIN @@ -74271,125 +74032,122 @@ proc: BEGIN DECLARE vTo VARCHAR(50) DEFAULT NULL; DECLARE vUserName VARCHAR(50) DEFAULT NULL; DECLARE vBody VARCHAR(255) DEFAULT NULL; - - SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax + + SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax FROM workerTimeControlParams; SELECT MAX(timed) INTO vLastIn - FROM workerTimeControl - WHERE userFk = vUserFk + FROM workerTimeControl + WHERE userFk = vUserFk AND direction = 'in'; - + SELECT MAX(timed) INTO vLastOut - FROM workerTimeControl - WHERE userFk = vUserFk - AND direction = 'out'; + FROM workerTimeControl + WHERE userFk = vUserFk + AND direction = 'out'; SELECT CONCAT(u.name,'@verdnatura.es') INTO vTo FROM account.user u - WHERE u.id = (SELECT bossFk FROM worker WHERE id = vUserFk); - + WHERE u.id = (SELECT bossFk FROM worker WHERE id = vUserFk); + SELECT CONCAT(firstName,' ',lastName) INTO vUserName FROM worker w WHERE w.id = vUserFk; - IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVA JORNADA - - -- VERIFICAR DESCANSO DIARIO - IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN + IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVA JORNADA + + -- VERIFICAR DESCANSO DIARIO + IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN SELECT "Descansos 12 h" AS problem; -- ENVIAMOS CORREO AL BOSSFK SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 12 h") INTO vBody; CALL mail_insert(vTo,vTo,'error al fichar',vBody); LEAVE proc; - END IF; - + END IF; + -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ - IF (SELECT MOD(COUNT(*),2) -- <>0 - FROM workerTimeControl + IF (SELECT MOD(COUNT(*),2) -- <>0 + FROM workerTimeControl WHERE userFk = vUserFk AND timed >= vLastIn - ) THEN + ) THEN SELECT "Dias con fichadas impares" AS problem; -- ENVIAMOS CORREO AL BOSSFK SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody; CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; + LEAVE proc; END IF; - + -- VERIFICAR VACACIONES SELECT at2.name INTO vCalendarStateType - FROM postgresql.calendar_employee ce - JOIN postgresql.business b USING(business_id) - JOIN postgresql.profile pr ON pr.profile_id = b.client_id - JOIN absenceType at2 ON at2.id = ce.calendar_state_id - WHERE ce.date = CURDATE() + FROM calendar c + JOIN business b ON b.id = c.businessFk + JOIN absenceType at2 ON at2.id = c.dayOffTypeFk + WHERE c.dated = util.VN_CURDATE() AND at2.isAllowedToWork = FALSE - AND pr.workerFk = vUserFk + AND b.workerFk = vUserFk LIMIT 1; - + IF(LENGTH(vCalendarStateType)) THEN SELECT vCalendarStateType AS problem; -- ENVIAMOS CORREO AL BOSSFK SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody; CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - + LEAVE proc; + END IF; - - + -- VERIFICAR CONTRATO EN VIGOR IF (SELECT COUNT(*) - FROM postgresql.business b - JOIN postgresql.profile pr ON pr.profile_id = b.client_id - WHERE pr.workerFk = vUserFk - AND b.date_start <= vDated - AND IFNULL(b.date_end,vDated) >= vDated + FROM business b + WHERE b.workerFk = vUserFk + AND b.started <= vDated + AND IFNULL(b.ended, vDated) >= vDated ) = 0 THEN SELECT "No hay un contrato en vigor" AS problem; -- ENVIAMOS CORREO AL BOSSFK SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody; CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - + LEAVE proc; + END IF; -- VERIFICAR DESCANSO SEMANAL SET @vHasBreakWeek:= FALSE; - SET @vLastTimed:= UNIX_TIMESTAMP((NOW() - INTERVAL vWeekScope SECOND)); - + SET @vLastTimed:= UNIX_TIMESTAMP((util.VN_NOW() - INTERVAL vWeekScope SECOND)); + DROP TEMPORARY TABLE IF EXISTS tmp.trash; CREATE TEMPORARY TABLE tmp.trash SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias, @vLastTimed:= UNIX_TIMESTAMP(timed) - FROM workerTimeControl - WHERE timed>= (NOW() - INTERVAL vWeekScope SECOND) + FROM workerTimeControl + WHERE timed>= (util.VN_NOW() - INTERVAL vWeekScope SECOND) AND userFk= vUserFk AND direction IN ('in','out') - ORDER BY timed ASC; - - IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA + ORDER BY timed ASC; + + IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA SELECT "Descansos 36 h" AS problem; -- ENVIAMOS CORREO AL BOSSFK SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 36 h") INTO vBody; CALL mail_insert(vTo,vTo,'error al fichar',vBody); LEAVE proc; END IF; - - DROP TEMPORARY TABLE tmp.trash; - ELSE -- DIA ACTUAL - + DROP TEMPORARY TABLE tmp.trash; + + ELSE -- DIA ACTUAL + -- VERIFICA QUE EL TIEMPO EFECTIVO NO SUPERE EL MÁXIMO - SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(NOW()), 0) INTO vTimedWorked + SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(util.VN_NOW()), 0) INTO vTimedWorked FROM workerTimeControl wtc - WHERE userFk = vUserFk + WHERE userFk = vUserFk AND timed >= vLastIn ORDER BY timed; - IF vTimedWorked > vDayWorkMax THEN + IF vTimedWorked > vDayWorkMax THEN SELECT "Jornadas" AS problem; -- ENVIAMOS CORREO AL BOSSFK SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Jornadas") INTO vBody; @@ -74412,18 +74170,16 @@ proc: BEGIN -- ENVIAMOS CORREO AL BOSSFK SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody; CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; + LEAVE proc; 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_checkBreak` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74431,11 +74187,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_checkBreak`(vStarted DATE) BEGIN /** - * Retorna los trabajadores que no han respetado el descanso semanal de 36/72 horas + * Retorna los trabajadores que no han respetado el descanso semanal de 36/72 horas * El sistema verificará el descanso corto en la siguiente semana * o el largo en las 2 siguientes semanas a partir de la fecha dada * @param vStarted día inicio de la semana en el que se quiere verificar @@ -74446,27 +74204,27 @@ BEGIN DECLARE vShortWeekBreak INT; DECLARE vLongWeekBreak INT; - SELECT util.dayEnd(DATE_ADD(vStarted, INTERVAL shortWeekDays DAY)), + SELECT util.dayEnd(DATE_ADD(vStarted, INTERVAL shortWeekDays DAY)), util.dayEnd(DATE_ADD(vStarted, INTERVAL longWeekDays DAY)), - shortWeekBreak, + shortWeekBreak, longWeekBreak INTO vShortEnded, vLongEnded, vShortWeekBreak, vLongWeekBreak FROM workerTimeControlConfig; - + SET @previousTimed:= UNIX_TIMESTAMP(vStarted); SET @lastUserFk := NULL; - + -- Descanso corto en la semana - + DROP TEMPORARY TABLE IF EXISTS tmp.worker; CREATE TEMPORARY TABLE tmp.worker (PRIMARY KEY(workerFk)) ENGINE = MEMORY SELECT DISTINCT userFk workerFk - FROM workerTimeControl + FROM workerTimeControl WHERE timed BETWEEN vStarted AND vShortEnded AND direction IN ('in', 'out'); - + DROP TEMPORARY TABLE IF EXISTS tmp.worker2; CREATE TEMPORARY TABLE tmp.worker2 (PRIMARY KEY(workerFk)) @@ -74479,28 +74237,28 @@ BEGIN SELECT sub2.userFk workerFk FROM(SELECT sub.userFk, IF(sub.userFk <> @lastUserFk, - @previousTimed:= sub.timed, + @previousTimed:= sub.timed, FALSE), - IF(sub.timed - @previousTimed >= vShortWeekBreak, - TRUE, + IF(sub.timed - @previousTimed >= vShortWeekBreak, + TRUE, FALSE) hasShortWeekBreak, @previousTimed:= sub.timed, @lastUserFk:= sub.userFk FROM ( SELECT userFk, UNIX_TIMESTAMP(timed) timed - FROM workerTimeControl + FROM workerTimeControl WHERE timed BETWEEN vStarted AND vShortEnded AND direction IN ('in', 'out') - UNION + UNION SELECT w.workerFk, UNIX_TIMESTAMP(IFNULL( - MIN(wtc.timed), + MIN(wtc.timed), DATE_ADD(vShortEnded, INTERVAL vShortWeekBreak SECOND))) FROM tmp.worker w - LEFT JOIN workerTimeControl wtc - ON wtc.userFk = w.workerFk - AND wtc.timed BETWEEN vShortEnded - AND DATE_ADD(vShortEnded, INTERVAL vShortWeekBreak SECOND) + LEFT JOIN workerTimeControl wtc + ON wtc.userFk = w.workerFk + AND wtc.timed BETWEEN vShortEnded + AND DATE_ADD(vShortEnded, INTERVAL vShortWeekBreak SECOND) GROUP BY w.workerFk UNION SELECT w.workerFk, @@ -74508,10 +74266,10 @@ BEGIN MAX(wtc.timed), DATE_SUB(vStarted, INTERVAL vShortWeekBreak SECOND))) FROM tmp.worker2 w - LEFT JOIN workerTimeControl wtc - ON wtc.userFk = w.workerFk - AND wtc.timed BETWEEN - DATE_SUB(vStarted, INTERVAL vShortWeekBreak SECOND) + LEFT JOIN workerTimeControl wtc + ON wtc.userFk = w.workerFk + AND wtc.timed BETWEEN + DATE_SUB(vStarted, INTERVAL vShortWeekBreak SECOND) AND vStarted GROUP BY w.workerFk ORDER BY userFk, timed @@ -74521,7 +74279,7 @@ BEGIN GROUP BY sub2.userFk HAVING NOT SUM(hasShortWeekBreak); - -- Descanso largo en las 2 siguientes semanas + -- Descanso largo en las 2 siguientes semanas DROP TEMPORARY TABLE tmp.worker; CREATE TEMPORARY TABLE tmp.worker (PRIMARY KEY(workerFk)) @@ -74541,12 +74299,12 @@ BEGIN (PRIMARY KEY(workerFk)) ENGINE = MEMORY SELECT sub2.userFk workerFk - FROM(SELECT userFk, + FROM(SELECT userFk, IF(userFk <> @lastUserFk, - @previousTimed:= timed, + @previousTimed:= timed, TRUE), - IF(timed - @previousTimed >= vLongWeekBreak, - TRUE, + IF(timed - @previousTimed >= vLongWeekBreak, + TRUE, FALSE) hasLongWeekBreak, @previousTimed:= timed, @lastUserFk:= userFk @@ -74555,24 +74313,24 @@ BEGIN JOIN tmp.workerWithoutShortWeekBreak wws ON wws.workerFk = wtc.userFk WHERE timed BETWEEN vStarted AND vLongEnded AND direction IN ('in', 'out') - UNION + UNION SELECT w.workerFk, - UNIX_TIMESTAMP(IFNULL(MIN(wtc.timed), + UNIX_TIMESTAMP(IFNULL(MIN(wtc.timed), DATE_ADD(vLongEnded, INTERVAL vLongWeekBreak SECOND))) FROM tmp.worker w - LEFT JOIN workerTimeControl wtc - ON wtc.userFk = w.workerFk - AND timed BETWEEN vLongEnded - AND DATE_ADD(vLongEnded, INTERVAL vLongWeekBreak SECOND) + LEFT JOIN workerTimeControl wtc + ON wtc.userFk = w.workerFk + AND timed BETWEEN vLongEnded + AND DATE_ADD(vLongEnded, INTERVAL vLongWeekBreak SECOND) GROUP BY w.workerFk UNION - SELECT w.workerFk, - UNIX_TIMESTAMP(IFNULL(MAX(wtc.timed), + SELECT w.workerFk, + UNIX_TIMESTAMP(IFNULL(MAX(wtc.timed), DATE_SUB(vStarted, INTERVAL vLongWeekBreak SECOND))) FROM tmp.worker2 w - LEFT JOIN workerTimeControl wtc - ON wtc.userFk = w.workerFk - AND timed BETWEEN DATE_SUB(vStarted, INTERVAL vLongWeekBreak SECOND) + LEFT JOIN workerTimeControl wtc + ON wtc.userFk = w.workerFk + AND timed BETWEEN DATE_SUB(vStarted, INTERVAL vLongWeekBreak SECOND) AND vStarted GROUP BY w.workerFk ORDER BY userFk, timed @@ -74589,8 +74347,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_clockIn` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74598,21 +74354,23 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_clockIn`( - vWorker INT, - vTimed DATETIME, + 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. + * @param vTimed valor de la fichada, IF vTimed IS NULL vTimed = util.VN_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á + * 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; @@ -74643,35 +74401,35 @@ BEGIN SELECT UNIX_TIMESTAMP(vTimed) timed UNION SELECT UNIX_TIMESTAMP(timed) - FROM workerTimeControl - WHERE timed BETWEEN (vTimed - INTERVAL vGap SECOND) AND vTimed - AND userFk = vWorker + 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(vTimed) timed UNION SELECT UNIX_TIMESTAMP(timed) - FROM workerTimeControl - WHERE timed BETWEEN vTimed AND (vTimed + INTERVAL vGap SECOND) - AND userFk = vWorker + 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' + DECLARE EXIT HANDLER FOR SQLSTATE '45000' BEGIN - SELECT CONCAT(u.name, '@verdnatura.es'), - CONCAT(w.firstName, ' ', w.lastName) + SELECT CONCAT(u.name, '@verdnatura.es'), + CONCAT(w.firstName, ' ', w.lastName) INTO vMailTo, vUserName FROM account.user u - JOIN worker w ON w.bossFk = u.id + JOIN worker w ON w.bossFk = u.id WHERE w.id = vWorker; - CASE vErrorCode + CASE vErrorCode WHEN 'IS_NOT_ALLOWED_FUTURE' THEN SELECT 'No se permite fichar a futuro' INTO vErrorMessage; WHEN 'INACTIVE_BUSINESS' THEN @@ -74681,183 +74439,182 @@ BEGIN WHEN 'ODD_WORKERTIMECONTROL' THEN SELECT 'Fichadas impares' INTO vErrorMessage; WHEN 'BREAK_DAY' THEN - SELECT CONCAT('Descanso diario ', FORMAT(vDayBreak/3600, 0), 'h.') + SELECT CONCAT('Descanso diario ', FORMAT(vDayBreak/3600, 0), 'h.') INTO vErrorMessage; WHEN 'BREAK_WEEK' THEN - SELECT CONCAT('Descanso semanal ', + 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 + ELSE SELECT 'Error sin definir'INTO vErrorMessage; END CASE; - + SELECT vErrorMessage `error`; - SELECT CONCAT(vUserName, - ' no ha podido fichar por el siguiente problema: ', - vErrorMessage) + 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(); + IF (vTimed IS NULL) THEN + SET vTimed = util.VN_NOW(); SET vManual = FALSE; END IF; - + SET vDated = DATE(vTimed); - - SELECT IF(pc.category_name = 'Conductor +3500kg', - wc.dayBreakDriver, - wc.dayBreak), + + SELECT IF(pc.category_name = 'Conductor +3500kg', + wc.dayBreakDriver, + wc.dayBreak), wc.shortWeekBreak, wc.longWeekBreak, wc.weekScope - INTO vDayBreak, + 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 + FROM business b + JOIN postgresql.professional_category pc + ON pc.professional_category_id = b.workerBusinessProfessionalCategoryFk JOIN workerTimeControlConfig wc ON TRUE - WHERE w.workerFk = vWorker - AND vDated BETWEEN w.started AND IFNULL(w.ended, vDated); + WHERE b.workerFk = vWorker + AND vDated BETWEEN b.started AND IFNULL(b.ended, vDated); SELECT timed INTO vLastIn - FROM workerTimeControl + FROM workerTimeControl WHERE userFk = vWorker - AND direction = 'in' + AND direction = 'in' AND timed < vTimed ORDER BY timed DESC - LIMIT 1; + LIMIT 1; SELECT timed INTO vLastOut - FROM workerTimeControl + FROM workerTimeControl WHERE userFk = vWorker - AND direction = 'out' + AND direction = 'out' AND timed < vTimed ORDER BY timed DESC LIMIT 1; SELECT timed INTO vNextIn - FROM workerTimeControl + FROM workerTimeControl WHERE userFk = vWorker - AND direction = 'in' + AND direction = 'in' AND timed > vTimed ORDER BY timed ASC LIMIT 1; SELECT direction INTO vNextDirection - FROM workerTimeControl + FROM workerTimeControl WHERE userFk = vWorker AND timed > vTimed ORDER BY timed ASC LIMIT 1; - + SELECT direction INTO vLastDirection - FROM workerTimeControl + FROM workerTimeControl WHERE userFk = vWorker AND timed < vTimed ORDER BY timed DESC - LIMIT 1; + LIMIT 1; -- FICHADAS A FUTURO - IF vTimed > DATE_ADD(NOW(), INTERVAL 60 SECOND) THEN + IF vTimed > DATE_ADD(util.VN_NOW(), INTERVAL 60 SECOND) THEN SET vErrorCode = 'IS_NOT_ALLOWED_FUTURE'; - CALL util.throw(vErrorCode); + CALL util.throw(vErrorCode); END IF; - + -- CONTRATO EN VIGOR IF vDayBreak IS NULL THEN SET vErrorCode = 'INACTIVE_BUSINESS'; - CALL util.throw(vErrorCode); + CALL util.throw(vErrorCode); END IF; -- VERIFICAR SI ESTÁ PERMITIDO TRABAJAR CALL timeBusiness_calculateByWorker(vWorker, vDated, vDated); - SELECT isAllowedToWork INTO vIsAllowedToWork + SELECT isAllowedToWork INTO vIsAllowedToWork FROM tmp.timeBusinessCalculate; DROP TEMPORARY TABLE tmp.timeBusinessCalculate; - + IF NOT vIsAllowedToWork THEN - SET vErrorCode = 'IS_NOT_ALLOWED_WORK'; + SET vErrorCode = 'IS_NOT_ALLOWED_WORK'; CALL util.throw(vErrorCode); END IF; - - -- DIRECCION CORRECTA + + -- DIRECCION CORRECTA CALL workerTimeControl_direction(vWorker, vTimed); - IF (SELECT + IF (SELECT IF(IF(option1 IN ('inMiddle', 'outMiddle'), - 'middle', + 'middle', option1) <> vDirection AND IF(option2 IN ('inMiddle', 'outMiddle'), - 'middle', - IFNULL(option2, '')) <> vDirection, - TRUE , - FALSE) + 'middle', + IFNULL(option2, '')) <> vDirection, + TRUE , + FALSE) FROM tmp.workerTimeControlDirection - ) THEN + ) 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); + SET vErrorCode = 'WRONG_DIRECTION'; + CALL util.throw(vErrorCode); END IF; - -- DESCANSO DIARIO + -- 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 + 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 + 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); + 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 + 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 + IF vDone THEN LEAVE l; END IF; - IF vShortWeekBreak - (vTimedLoop - vTimedLoopPrevious) <= 0 THEN + IF vShortWeekBreak - (vTimedLoop - vTimedLoopPrevious) <= 0 THEN SET vHasBreakWeek = TRUE; LEAVE l; END IF; SET vTimedLoopPrevious = vTimedLoop; - END LOOP l; + END LOOP l; CLOSE vCursor; -- VERIFICA DESCANSO LARGO EN LA ÚLTIMAS 2 SEMANAS IF NOT vHasBreakWeek THEN @@ -74867,27 +74624,27 @@ BEGIN OPEN vCursor; l:LOOP FETCH vCursor INTO vTimedLoop; - IF vDone THEN + IF vDone THEN LEAVE l; END IF; IF vLongWeekBreak - (vTimedLoop - vTimedLoopPrevious) <= 0 THEN - SET vHasBreakWeek = TRUE; + SET vHasBreakWeek = TRUE; LEAVE l; END IF; SET vTimedLoopPrevious = vTimedLoop; - END LOOP l; + END LOOP l; CLOSE vCursor; END IF; IF vManual THEN - -- VERIFICA DESCANSO CORTO EN LA PRÓXIMA SEMANA + -- VERIFICA DESCANSO CORTO EN LA PRÓXIMA SEMANA SET vGap = vWeekScope; SET vTimedLoopPrevious = vTimed; SET vDone = FALSE; OPEN vCursor2; l:LOOP FETCH vCursor2 INTO vTimedLoop; - IF vDone THEN + IF vDone THEN LEAVE l; END IF; IF vShortWeekBreak - (vTimedLoop - vTimedLoopPrevious) <= 0 THEN @@ -74895,7 +74652,7 @@ BEGIN LEAVE l; END IF; SET vTimedLoopPrevious = vTimedLoop; - END LOOP l; + END LOOP l; CLOSE vCursor2; -- VERIFICA DESCANSO LARGO EN LAS PRÓXIMAS 2 SEMANAS IF NOT vHasBreakWeek THEN @@ -74905,7 +74662,7 @@ BEGIN OPEN vCursor2; l:LOOP FETCH vCursor2 INTO vTimedLoop; - IF vDone THEN + IF vDone THEN LEAVE l; END IF; IF vShortWeekBreak - (vTimedLoop - vTimedLoopPrevious) <= 0 THEN @@ -74913,20 +74670,20 @@ BEGIN LEAVE l; END IF; SET vTimedLoopPrevious = vTimedLoop; - END LOOP l; + END LOOP l; CLOSE vCursor2; END IF; END IF; IF NOT vHasBreakWeek THEN - SET vErrorCode = 'BREAK_WEEK'; - CALL util.throw(vErrorCode); - END IF; + 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 ; @@ -74934,8 +74691,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_direction` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74943,6 +74698,8 @@ DELIMITER ; /*!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`@`localhost` PROCEDURE `workerTimeControl_direction`(vWorkerFk VARCHAR(10), vTimed DATETIME) BEGIN @@ -74950,28 +74707,28 @@ 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') + * Los valores posibles de retorno son ('in', 'inMiddle', 'outMiddle', 'out') */ DECLARE vLastIn DATETIME ; DECLARE vIsMiddleOdd BOOLEAN ; - IF (vTimed IS NULL) THEN - SET vTimed = NOW(); + IF (vTimed IS NULL) THEN + SET vTimed = util.VN_NOW(); END IF; - + SELECT timed INTO vLastIn - FROM workerTimeControl + FROM workerTimeControl WHERE userFk = vWorkerFk - AND direction = 'in' + AND direction = 'in' AND timed < vTimed ORDER BY timed DESC LIMIT 1; - + SELECT (COUNT(*)mod 2 = 1) INTO vIsMiddleOdd - FROM workerTimeControl + FROM workerTimeControl WHERE userFk = vWorkerFk - AND direction = 'middle' - AND timed BETWEEN vLastIn AND NOW(); + AND direction = 'middle' + AND timed BETWEEN vLastIn AND util.VN_NOW(); DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlDirection; CREATE TEMPORARY TABLE tmp.workerTimeControlDirection @@ -75008,8 +74765,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_getClockIn` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -75017,9 +74772,11 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_getClockIn`( - vUserFk INT, + vUserFk INT, vDated DATE) BEGIN /** @@ -75029,9 +74786,9 @@ BEGIN * @param vDated Fecha proporcionada */ CALL timeControl_calculateByWorker( - vUserFk, + vUserFk, DATE_SUB(vDated, INTERVAL 6 DAY), util.dayEnd(vDated)); - + SET @position := 0; SET @lastDated := NULL; @@ -75048,7 +74805,7 @@ BEGIN MAX(2daysAgoDirection) 2daysAgoDirection, MAX(1daysAgo) 1daysAgo, MAX(1daysAgoDirection) 1daysAgoDirection, - MAX(0daysAgo) 0daysAgo, + MAX(0daysAgo) 0daysAgo, MAX(0daysAgoDirection) 0daysAgoDirection FROM(SELECT IF(daysAgo = 6, timed, '') 6daysAgo, IF(daysAgo = 5, timed, '') 5daysAgo, @@ -75068,7 +74825,7 @@ BEGIN direction, position FROM(SELECT DATEDIFF(vDated, timed) daysAgo, - TIME_FORMAT(timed,'%H:%i') timed, + TIME_FORMAT(timed,'%H:%i') timed, IF(DATE(timed) <> @lastDated, @position := 0, NULL), @position := @position+1 position, @lastDated := DATE(timed), @@ -75080,18 +74837,18 @@ BEGIN LIMIT 10000000000000000000 )sub )sub2 - GROUP BY position) sub3 + GROUP BY position) sub3 JOIN (SELECT MAX(IF(daysAgo = 6, timeWorkSeconds, 0)) 6daysAgoTotal, MAX(IF(daysAgo = 5, timeWorkSeconds, 0)) 5daysAgoTotal, MAX(IF(daysAgo = 4, timeWorkSeconds, 0)) 4daysAgoTotal, MAX(IF(daysAgo = 3, timeWorkSeconds, 0)) 3daysAgoTotal, MAX(IF(daysAgo = 2, timeWorkSeconds, 0)) 2daysAgoTotal, MAX(IF(daysAgo = 1, timeWorkSeconds, 0)) 1daysAgoTotal, - MAX(IF(daysAgo = 0, timeWorkSeconds, 0)) 0daysAgoTotal + MAX(IF(daysAgo = 0, timeWorkSeconds, 0)) 0daysAgoTotal FROM (SELECT DATEDIFF(vDated, dated) daysAgo, timeWorkSeconds FROM tmp.timeControlCalculate) sub4)sub5 ON TRUE; - + DROP TEMPORARY TABLE tmp.timeControlCalculate; END ;; DELIMITER ; @@ -75099,8 +74856,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_login` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -75108,6 +74863,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_login`(vWorkerFk VARCHAR(10)) BEGIN @@ -75118,7 +74875,7 @@ BEGIN * @return (name, surname, userFk, departmentFk, button1, button2) * Los valores posibles para button son ('in', 'inMiddle', 'outMiddle', 'out') */ - CALL vn.workerTimeControl_direction(vWorkerFk, NOW()); + CALL vn.workerTimeControl_direction(vWorkerFk, util.VN_NOW()); SELECT wi.name, wi.surname, @@ -75138,8 +74895,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_remove` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -75147,6 +74902,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_remove`(IN vUserFk INT, IN vTimed DATETIME) BEGIN @@ -75155,53 +74912,51 @@ BEGIN DECLARE vDirectionPrevious VARCHAR(6); DECLARE vTimedPrevious DATETIME; - SELECT direction INTO vDirectionRemove - FROM vn.workerTimeControl - WHERE userFk = vUserFk + SELECT direction INTO vDirectionRemove + FROM vn.workerTimeControl + WHERE userFk = vUserFk AND timed = vTimed ; IF vDirectionRemove = 'out' THEN - + SELECT timed, direction INTO vTimedPrevious, vDirectionPrevious - FROM vn.workerTimeControl - WHERE userFk = vUserFk + FROM vn.workerTimeControl + WHERE userFk = vUserFk AND timed < vTimed ORDER BY timed DESC - LIMIT 1; - + LIMIT 1; + IF vDirectionPrevious = "middle" THEN - UPDATE vn.workerTimeControl + UPDATE vn.workerTimeControl SET direction = "out" WHERE userFk = vUserFk AND timed = vTimedPrevious; END IF; - + ELSE IF vDirectionRemove = 'in' THEN - UPDATE vn.workerTimeControl + UPDATE vn.workerTimeControl SET direction = "in" WHERE userFk = vUserFk AND timed > vTimed ORDER BY timed ASC - LIMIT 1; + LIMIT 1; END IF; - + END IF; - + DELETE FROM vn.workerTimeControl - WHERE userFk = vUserFk + WHERE userFk = vUserFk AND timed = vTimed; - + CALL vn.workerTimeControlSOWP(vUserFk, vTimed); - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_repair` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -75209,6 +74964,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_repair`() proc: BEGIN @@ -75221,39 +74978,37 @@ proc: BEGIN UPDATE vn.workerTimeControl SET direction = 'middle'; /*2- poner los out*/ -UPDATE vn.workerTimeControl wtc - JOIN +UPDATE vn.workerTimeControl wtc + JOIN (SELECT userFk,MAX(timed) maxTimed FROM (SELECT id, userFk, timed, date(timed) dated - FROM vn.workerTimeControl - ) sub + FROM vn.workerTimeControl + ) sub GROUP BY userFk,dated )sub SET direction = "out" - WHERE wtc.userFk = sub.userFk + WHERE wtc.userFk = sub.userFk AND wtc.timed = sub.maxTimed; - - /*3- poner los in*/ -UPDATE vn.workerTimeControl wtc - JOIN + + /*3- poner los in*/ +UPDATE vn.workerTimeControl wtc + JOIN (SELECT userFk,MIN(timed) maxTimed FROM (SELECT id, userFk, timed, date(timed) dated - FROM vn.workerTimeControl - ) sub + FROM vn.workerTimeControl + ) sub GROUP BY userFk,dated )sub SET direction = "in" - WHERE wtc.userFk = sub.userFk - AND wtc.timed = sub.maxTimed ; - + WHERE wtc.userFk = sub.userFk + AND wtc.timed = sub.maxTimed ; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_sendMail` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -75261,15 +75016,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMail`(vWeek INT, vYear INT, vWorkerFk INT) BEGIN /** - * Inserta en la tabla vn.mail para notificar a los empleados que teletrabajan de las jornadas que se han registrado. + * Inserta 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 vWeek + * @param vYear * @param vWorkerFk -> En el caso de querer generarlo para todos los empleados deberá de informarse como NULL */ DECLARE vStarted VARCHAR(25); @@ -75299,39 +75056,50 @@ BEGIN DECLARE vError BOOL DEFAULT FALSE; DECLARE vCursor CURSOR FOR - SELECT CONCAT(u.name, '@verdnatura.es'), u.id, tb.dated, tb.timeWorkDecimal, LEFT(tb.timeWorkSexagesimal,5) timeWorkSexagesimal, - tb.timeTable, tc.timeWorkDecimal timeWorkedDecimal, LEFT(tc.timeWorkSexagesimal,5) timeWorkedSexagesimal, tb.type, tb.businessFk,tb.permissionRate, d.isTeleworking + SELECT CONCAT(u.name, '@verdnatura.es'), + u.id, + tb.dated, + tb.timeWorkDecimal, + LEFT(tb.timeWorkSexagesimal,5) timeWorkSexagesimal, + tb.timeTable, + tc.timeWorkDecimal timeWorkedDecimal, + LEFT(tc.timeWorkSexagesimal,5) timeWorkedSexagesimal, + tb.type, + tb.businessFk, + tb.permissionRate, + d.isTeleworking FROM tmp.timeBusinessCalculate tb - JOIN user u ON u.id = tb.userFk + JOIN 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 business b ON b.id = tb.businessFk LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated LEFT JOIN worker w ON w.id = u.id LEFT JOIN `user` u2 ON u2.id = w.bossFk 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 + SUM(IF(tb.type IS NULL, + IF(tc.timeWorkDecimal > 0, FALSE, IF(tb.timeWorkDecimal > 0, TRUE, FALSE)), + TRUE))isTeleworkingWeek + FROM tmp.timeBusinessCalculate1 tb + LEFT JOIN tmp.timeControlCalculate1 tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated + GROUP BY tb.userFk + HAVING isTeleworkingWeek > 0 )sub ON sub.userFk = u.id - WHERE d.hasToRefill AND - IFNULL(vWorkerFk,u.id) = u.id AND - b.companyCodeFk = 'VNL' - ORDER BY u.id, tb.dated; + WHERE d.hasToRefill + AND IFNULL(vWorkerFk, u.id) = u.id + AND b.companyCodeFk = 'VNL' + AND w.businessFk + ORDER BY u.id, tb.dated; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN SET vError = TRUE; - + INSERT INTO tmp.error(workerFk) SELECT vWorkerFk; END; - + DROP TABLE IF EXISTS tmp.timeControlCalculate; DROP TABLE IF EXISTS tmp.timeBusinessCalculate; DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; @@ -75343,24 +75111,24 @@ BEGIN CREATE TEMPORARY TABLE tmp.error (workerFk INT); SELECT CONCAT (MIN(dated), ' 00:00:00'), CONCAT (MAX(dated), ' 23:59:59') INTO vStarted, vEnded - FROM time - WHERE year = vYear AND + FROM time + WHERE year = vYear AND week = vWeek; - DELETE FROM workerTimeControl + DELETE FROM workerTimeControl WHERE IFNULL(vWorkerFk, userFk) = userFk AND - timed BETWEEN vStarted AND vEnded AND + timed BETWEEN vStarted AND vEnded AND isSendMail; UPDATE workerTimeControlMail - SET updated = NOW(), state = 'SENDED' - WHERE year = vYear AND + SET updated = util.VN_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); + CALL timeBusiness_calculateAll(vStarted,vEnded); ELSE CALL timeControl_calculateByUser(vWorkerFk,vStarted,vEnded); CALL timeBusiness_calculateByUser(vWorkerFk,vStarted,vEnded); @@ -75382,12 +75150,12 @@ proc: LOOP IF vDone THEN LEAVE proc; END IF; - + START TRANSACTION; SET vError = FALSE; IF vTimeWorkDecimal>0 AND vTimeWorkedDecimal IS NULL AND IFNULL(vPermissionRate, TRUE) THEN - IF vTimeTable IS NULL THEN + IF vTimeTable IS NULL THEN INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) SELECT vWorkerFk, CONCAT(vDated,' 08:00'), TRUE, 'in', TRUE; IF vTimeWorkDecimal >= 5 THEN @@ -75400,63 +75168,63 @@ proc: LOOP SELECT vWorkerFk,CONCAT(vDated,' ', LEFT (SEC_TO_TIME(28800 + (vTimeWorkDecimal * 3600)), 5)), TRUE, 'out', TRUE; ELSE SELECT SUM(TIME_TO_SEC(j.end)-TIME_TO_SEC(j.start))/3600 INTO vTimeTableDecimal - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; + 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 + 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; + 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; + 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; - + 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; + 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; + 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 + 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' ; - + SET direction = 'in' ; + UPDATE workerTimeControl wtc - JOIN (SELECT id FROM workerTimeControl - WHERE userFk = vWorkerFk AND + JOIN (SELECT id FROM workerTimeControl + WHERE userFk = vWorkerFk AND timed BETWEEN vDated AND CONCAT(vDated, ' 23:59:59') - ORDER BY timed DESC + ORDER BY timed DESC LIMIT 1)sub on sub.id= wtc.id - SET direction = 'out' ; - + SET direction = 'out' ; + END IF; END IF; @@ -75475,27 +75243,27 @@ proc: LOOP ", IFNULL(vAbsenceType, IF (vTimeWorkedDecimal>0, "Presencial", IF(vTimeWorkDecimal>0, "Teletrabajo", " - "))), " ", IFNULL(vTimeWorkedSexagesimal,IF(IFNULL(vPermissionRate, TRUE), vTimeWorkDecimal, 0)), " ") INTO vBody - FROM workerTimeControl - WHERE userFk = vWorkerFk AND + FROM workerTimeControl + WHERE userFk = vWorkerFk AND timed BETWEEN vDated AND CONCAT(vDated," 23:59:59"); SET vTimeWorkDecimalTotal = vTimeWorkDecimalTotal + IFNULL(vTimeWorkedDecimal, IF( IFNULL(vPermissionRate, TRUE), vTimeWorkDecimal, 0)); SET vDone = FALSE; FETCH vCursor INTO vReceiver, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk, vPermissionRate, vIsTeleworking; - IF vWorkerFk <> vWorkerFkOld OR vDone THEN + IF vWorkerFk <> vWorkerFkOld OR vDone THEN SELECT CONCAT_WS(' ', fi, firstName, lastName) INTO vWorkerInfo FROM worker WHERE id = vWorkerFkOld; SET vHeader = CONCAT("


-

", vWorkerInfo , "

+

", vWorkerInfo , "

@@ -75518,15 +75286,15 @@ proc: LOOP IF vIsTeleworkingOld AND NOT vError THEN CALL mail_insert( - vReceiverOld, + vReceiverOld, 'timecontrol@verdnatura.es', - CONCAT('Registro de horas semana ', vWeek, ' año ', vYear) , + CONCAT('Registro de horas semana ', vWeek, ' año ', vYear) , CONCAT(vHeader, ' ' , vBody, ' ', vFooter) ); INSERT IGNORE INTO workerTimeControlMail (workerFk, year, week) VALUES(vWorkerFkOld, vYear, vWeek); - ELSE + ELSE ROLLBACK; END IF; @@ -75539,16 +75307,16 @@ proc: LOOP COMMIT; END LOOP; CLOSE vCursor; - + INSERT INTO mail (receiver, replyTo, subject, body) - SELECT CONCAT(u.name, '@verdnatura.es'), - CONCAT('Error registro de horas semana ', vWeek, ' año ', vYear) , + SELECT CONCAT(u.name, '@verdnatura.es'), + CONCAT('Error registro de horas semana ', vWeek, ' año ', vYear) , CONCAT('No se ha podido enviar el registro de horas al empleado/s: ', GROUP_CONCAT(DISTINCT CONCAT('
', w.id, ' ', w.firstName, ' ', w.lastName))) FROM tmp.error e JOIN worker w ON w.id = e.workerFk JOIN user u ON u.id = w.bossFk - GROUP BY w.bossFk; - + GROUP BY w.bossFk; + DROP TABLE tmp.timeControlCalculate; DROP TABLE tmp.timeBusinessCalculate; DROP TABLE tmp.timeControlCalculate1; @@ -75560,8 +75328,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_sendMailByDepartment` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -75569,6 +75335,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMailByDepartment`(IN vDatedFrom DATETIME, IN vDatedTo DATETIME, IN vWorkerFk INT) BEGIN @@ -75608,24 +75376,25 @@ BEGIN w.userFk, tm.hoursWeek, tm.type, - wl.started, - wl.ended, + b.started, + b.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 business b ON b.workerFk = tm.userFk AND b.id = tm.businessFk + LEFT JOIN workCenter wc ON wc.id = b.workcenterFk + LEFT JOIN department d ON d.id = b.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 w.businessFk GROUP BY tm.userFk,t.dated ORDER BY tm.userFk,t.dated; - + INSERT INTO vn.mail (receiver, replyTo, subject, body) SELECT eu.email, 'laboral@verdnatura.es', CONCAT('Registro de horas semana ', WEEK(vDatedFrom), ' año ', YEAR(vDatedFrom)) , CONCAT(' @@ -75701,8 +75470,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_sendMailByDepartmentLauncher` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -75710,14 +75477,16 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMailByDepartmentLauncher`() BEGIN DECLARE vDatedFrom, vDatedTo DATETIME; - IF (DAYNAME(CURDATE()) = 'miércoles') THEN - SELECT DATE_SUB(CURDATE(), INTERVAL 9 DAY), CONCAT(DATE_SUB(CURDATE(), INTERVAL 3 DAY), ' 23:59:59') INTO vDatedFrom, vDatedTo; - + IF (DAYNAME(util.VN_CURDATE()) = 'miércoles') THEN + SELECT DATE_SUB(util.VN_CURDATE(), INTERVAL 9 DAY), CONCAT(DATE_SUB(util.VN_CURDATE(), INTERVAL 3 DAY), ' 23:59:59') INTO vDatedFrom, vDatedTo; + CALL vn.workerTimeControl_sendMailByDepartment(vDatedFrom, vDatedTo, NULL); END IF; END ;; @@ -75726,8 +75495,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_setOrder` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -75735,6 +75502,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_setOrder`(vUserFk INT, vStarted DATE, vFinished DATE) BEGIN @@ -75754,8 +75523,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_weekCheckBreak` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -75763,13 +75530,15 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_weekCheckBreak`(vStarted DATE, vEnded DATE) BEGIN /** - * Retorna los trabajadores que no han respetado el descanso semanal de 36/72 horas - * El sistema verificará el descanso corto en la siguiente semana - * o el largo en las 2 siguientes semanas a partir de las fechas dadas + * Retorna los trabajadores que no han respetado el descanso semanal de 36/72 horas + * El sistema verificará el descanso corto en la siguiente semana + * o el largo en las 2 siguientes semanas a partir de las fechas dadas * @param vStarted día inicio para verificar * @param vEnded día final para verificar * @return tmp.workerWithoutWeekBreak (workerFk) @@ -75791,10 +75560,10 @@ BEGIN CALL workerTimeControl_checkBreak(vStarted); INSERT IGNORE INTO tmp.workerWithoutWeekBreakInWeek - SELECT workerFk + SELECT workerFk FROM tmp.workerWithoutWeekBreak; DROP TEMPORARY TABLE IF EXISTS tmp.workerWithoutWeekBreak; - SET vStarted = DATE_ADD(vStarted, INTERVAL 1 DAY); + SET vStarted = DATE_ADD(vStarted, INTERVAL 1 DAY); END WHILE; END ;; @@ -75803,8 +75572,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerWeekControl` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -75812,6 +75579,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerWeekControl`(vUserFk INT, vDated DATE, vTabletFk VARCHAR(100)) BEGIN @@ -75832,11 +75601,11 @@ BEGIN DECLARE vDepartmentFk INT; DECLARE isEnabled BOOLEAN DEFAULT TRUE; - SELECT COUNT(*) INTO vHasSignedToday + SELECT COUNT(*) INTO vHasSignedToday FROM workerTimeControl WHERE timed >= vDated AND userFk = vUserFk; SET @day := 0; - SET @lastTimed := NOW(); + SET @lastTimed := util.VN_NOW(); SELECT SUM(IF(interval_in_minutes >= v12hoursInMinutes,1,0)), SUM(FLOOR(interval_in_minutes/ v36hoursInMinutes)) , SUM(jornadas) INTO vDescansos12h, vDescansos36h, vJornadas @@ -75845,35 +75614,35 @@ BEGIN SELECT fichada_anterior, fichada_actual, interval_in_minutes, jornadas FROM ( - SELECT @lastTimed fichada_anterior, + SELECT @lastTimed fichada_anterior, timed, CAST(time_to_sec(timediff(timed,@lastTimed )) / 60 AS UNSIGNED) as interval_in_minutes, IF(day(timed) != @day, 1, 0) as jornadas, @day := day(timed) dia_del_mes, - @lastTimed := timed fichada_actual + @lastTimed := timed fichada_actual FROM ( SELECT day(timed) as dayNumber, dayname(timed) as dayName, timed - FROM - (SELECT TIMESTAMPADD(DAY, -11, NOW()) as timed, vUserFk as userFk -- Fichada virtual para los en los que no se ha trabajado la semana anterior + FROM + (SELECT TIMESTAMPADD(DAY, -11, util.VN_NOW()) as timed, vUserFk as userFk -- Fichada virtual para los en los que no se ha trabajado la semana anterior UNION ALL SELECT timed, userFk FROM vn.workerTimeControl wtc WHERE userFk = vUserFk AND timed >= TIMESTAMPADD(DAY, -10,vDated) UNION ALL - SELECT IF(vHasSignedToday, '2000-01-01 00:00', NOW()) as timed, vUserFk + SELECT IF(vHasSignedToday, '2000-01-01 00:00', util.VN_NOW()) as timed, vUserFk ) sub4 ORDER BY timed ) sub - + ) sub2 WHERE fichada_actual >= TIMESTAMPADD(WEEK, -1, vDated) ) sub3 ; SELECT IFNULL(SUM(impar),0) into vImpares FROM ( - SELECT day(timed) as dayNumber, + SELECT day(timed) as dayNumber, count(*) mod 2 as impar FROM vn.workerTimeControl wtc WHERE userFk = vUserFk @@ -75882,39 +75651,37 @@ BEGIN ) sub; -- Vacaciones - SELECT at2.name INTO vCantWork - FROM postgresql.calendar_employee ce - JOIN postgresql.business b USING(business_id) - JOIN postgresql.profile pr ON pr.profile_id = b.client_id - JOIN absenceType at2 ON at2.id = ce.calendar_state_id - WHERE ce.date = CURDATE() + SELECT at2.name INTO vCantWork + FROM calendar c + JOIN business b ON b.id = c.businessFk + JOIN absenceType at2 ON at2.id = c.dayOffTypeFk + WHERE c.dated = util.VN_CURDATE() AND at2.isAllowedToWork = FALSE - AND pr.workerFk = vUserFk + AND b.workerFk = vUserFk LIMIT 1; - + -- Contrato en vigor SELECT IF(COUNT(*),vCantWork,'Sin contrato') INTO vCantWork - FROM postgresql.business b - JOIN postgresql.profile pr ON pr.profile_id = b.client_id - WHERE pr.workerFk = vUserFk - AND b.date_start <= vDated - AND IFNULL(b.date_end,vDated) >= vDated; - + FROM business b + WHERE b.workerFk = vUserFk + AND b.started <= vDated + AND IFNULL(b.ended, vDated) >= vDated; + -- Departamento si vTabletFk es 0 no hacemos comprobacion (Madrid y Vilassar) IF vTabletFk <> '0' THEN -- 1 Obtener el departamento del usuario SELECT wtcu.departmentFk INTO vDepartmentFk FROM workerTimeControlUserInfo wtcu WHERE wtcu.userFk = vUserFk; - -- 2 Comprobar si la tablet pertenece al departamento + -- 2 Comprobar si la tablet pertenece al departamento SELECT COUNT(td.tabletFk) INTO isEnabled FROM tabletDepartment td WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk; - + END IF; - + IF vJornadas IS NOT NULL THEN - + SELECT 'Jornadas' as Item, vJornadas as Cantidad, 'Correcto' AS Análisis UNION ALL SELECT 'Descansos 12 h' as Item, vDescansos12h as Cantidad, IF(vDescansos12h >= vJornadas, 'Correcto','Error: 1 por jornada') as Análisis @@ -75923,9 +75690,9 @@ BEGIN UNION ALL SELECT 'Dias con fichadas impares' as Item, vImpares as Cantidad, IF(vImpares = 0, 'Correcto','Error') as Análisis UNION ALL - SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item, - '' as Cantidad, - IF(LENGTH(vCantWork),'Error', 'Correcto') as Análisis + SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item, + '' as Cantidad, + IF(LENGTH(vCantWork),'Error', 'Correcto') as Análisis UNION ALL SELECT 'El fichador no pertenece a tu departamento.' as Item, '' as Cantidad, IF(isEnabled, 'Correcto','Error') as Análisis; @@ -75939,7 +75706,7 @@ BEGIN UNION ALL SELECT 'Dias con fichadas impares' as Item, vImpares as Cantidad, 'Correcto' as Análisis UNION ALL - SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item, + SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item, '' as Cantidad, IF(LENGTH(vCantWork),'Error', 'Correcto') as Análisis UNION ALL SELECT 'El fichador no pertenece a tu departamento.' as Item, '' as Cantidad, IF(isEnabled, 'Correcto','Error') as Análisis; @@ -75951,8 +75718,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerWeekTiming` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -75960,6 +75725,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerWeekTiming`(vUserFk INT, vDated DATE) BEGIN @@ -75975,7 +75742,7 @@ CALL vn.workerTimeControlSetOrder_by_User_and_dateRange(vUserFk,TIMESTAMPADD(DAY DROP TEMPORARY TABLE IF EXISTS tmp.workerWeekTiming; CREATE TEMPORARY TABLE tmp.workerWeekTiming SELECT orden `orden`, - max(hace7dias) 7_dias_antes, + max(hace7dias) 7_dias_antes, max(hace6dias) 6_dias_antes, max(hace5dias) 5_dias_antes, max(hace4dias) 4_dias_antes, @@ -76005,16 +75772,16 @@ SELECT orden `orden`, )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, +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'),''), @@ -76024,7 +75791,7 @@ SELECT 0, 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) + @@ -76036,14 +75803,14 @@ SELECT 0, ROUND(( IFNULL(TIME_TO_SEC(1_dia_antes),0) ) / 3600,1) FROM tmp.workerWeekTiming - WHERE orden = 0; + 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; @@ -76055,8 +75822,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `worker_calculateCommission` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76064,6 +75829,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_calculateCommission`(vYear INT, vQuarter INT) BEGIN @@ -76085,28 +75852,28 @@ BEGIN JOIN vn.worker wb ON ww.id = wb.bossFk GROUP BY wb.bossFk; */ - + SELECT plusTeamAmount, plusNewBornAmount, plusSalesAmount, minimumSalesByQuarter, plusTeamRange, plusNewBornRange, rankingSalesRange INTO vPlusTeamAmount, vPlusNewBornAmount, vPlusSalesAmount, vMinimumSalesByQuarter, vPlusTeamRange, vPlusNewBornRange, vRankingSalesRange FROM commissionConfig; -- Ventas DROP TEMPORARY TABLE IF EXISTS rankingSale; CREATE TEMPORARY TABLE rankingSale - (PRIMARY KEY(workerFk)) ENGINE = MEMORY - SELECT IF(SUM(v.importe) > vMinimumSalesByQuarter, + (PRIMARY KEY(workerFk)) ENGINE = MEMORY + SELECT IF(SUM(v.importe) > vMinimumSalesByQuarter, SUM(IFNULL(v.comision,0)), 0) as commission, SUM(v.importe) sales, v.Id_Trabajador workerFk - FROM bs.vendedores v + FROM bs.vendedores v WHERE v.año = vYear AND CEIL(mes/3) = vQuarter GROUP BY v.Id_Trabajador; - + -- Ranking ventas SET @position:= 0; DROP TEMPORARY TABLE IF EXISTS rankingSelling; CREATE TEMPORARY TABLE rankingSelling - (PRIMARY KEY(userFk)) ENGINE = MEMORY + (PRIMARY KEY(userFk)) ENGINE = MEMORY SELECT userFk, @position:= @position + 1 position FROM ( SELECT SUM(`v`.`importe`) AS `importe`, @@ -76123,29 +75890,29 @@ BEGIN ORDER BY SUM(`v`.`importe`) DESC LIMIT vRankingSalesRange ) t; - - CALL rankingTeamByQuarter(vYear, vQuarter); - + + CALL rankingTeamByQuarter(vYear, vQuarter); + -- comerciales que computan / total integrantes DROP TEMPORARY TABLE IF EXISTS teamNames; CREATE TEMPORARY TABLE teamNames - (PRIMARY KEY(departmentFk)) ENGINE = MEMORY + (PRIMARY KEY(departmentFk)) ENGINE = MEMORY SELECT DISTINCT departmentFk, teamPeople FROM tmp.rankingTeam; - - -- Ranking por equipos + + -- Ranking por equipos DROP TEMPORARY TABLE IF EXISTS rankingTeam; CREATE TEMPORARY TABLE rankingTeam - (PRIMARY KEY(departmentFk)) ENGINE = MEMORY + (PRIMARY KEY(departmentFk)) ENGINE = MEMORY SELECT DISTINCT departmentFk FROM teamNames LIMIT vPlusTeamRange; - + -- Ranking por nuevos clientes SET @position:= 0; DROP TEMPORARY TABLE IF EXISTS rankingNewBorn; CREATE TEMPORARY TABLE rankingNewBorn - (PRIMARY KEY(userFk)) ENGINE = MEMORY + (PRIMARY KEY(userFk)) ENGINE = MEMORY SELECT userFk, @position:= @position + 1 position FROM ( SELECT SUM(amount) AS total, @@ -76157,10 +75924,10 @@ BEGIN ORDER BY SUM(amount) DESC LIMIT vPlusNewBornRange ) t; - + -- Sumatorio de ventas - SELECT uBoss.`name` as team, - u.`name`, + SELECT uBoss.`name` as team, + u.`name`, r.commission, -- IF(rh.bossFk, 200 + (teamMembers * 30), 0) plusResponsibility, @plusRankingSellers := ((vRankingSalesRange + 1) - rs.position) * 40 plusRankingSellers, @@ -76178,11 +75945,11 @@ BEGIN LEFT JOIN rankingSelling rs ON rs.userFk = r.workerFk LEFT JOIN workerDepartment wd ON wd.workerFk = r.workerFk LEFT JOIN rankingTeam rt ON rt.departmentFk = wd.departmentFk AND r.commission - LEFT JOIN teamNames tn ON tn.departmentFk = wd.departmentFk + LEFT JOIN teamNames tn ON tn.departmentFk = wd.departmentFk LEFT JOIN vn.rankingNewBorn rnb ON rnb.userFk = r.workerFk; - + DROP TEMPORARY TABLE tmp.rankingTeam; - DROP TEMPORARY TABLE + DROP TEMPORARY TABLE rankingSelling, rankingTeam, teamNames, @@ -76194,266 +75961,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!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_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` 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*r.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, - IF(v.isKmTruckRate, rc.kmTruckRate, 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 route r - LEFT JOIN ticket t ON t.routeFk = r.id - LEFT JOIN vehicle v ON v.id = r.vehicleFk - 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, - 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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `worker_getFromHasMistake` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76461,6 +75968,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_getFromHasMistake`(vDepartmentFk INT) BEGIN @@ -76470,11 +75979,11 @@ BEGIN * @param vDepartmentFk id del departamento * */ - - SELECT w.id,w.firstName, w.lastName,d.name - FROM worker w - JOIN workerDepartment wd ON wd.workerFk = w.id - JOIN department d ON d.id = wd.departmentFk + + SELECT w.id,w.firstName, w.lastName,d.name + FROM worker w + JOIN workerDepartment wd ON wd.workerFk = w.id + JOIN department d ON d.id = wd.departmentFk WHERE d.id = vDepartmentFk ORDER BY firstName; @@ -76484,8 +75993,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `worker_getHierarchy` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76493,6 +76000,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_getHierarchy`(vBoss INT) BEGIN @@ -76505,7 +76014,7 @@ BEGIN (PRIMARY KEY (workerFk)) ENGINE = MEMORY SELECT vBoss AS workerFk; - + DROP TEMPORARY TABLE IF EXISTS tmp.workerHierarchyList; CREATE TEMPORARY TABLE tmp.workerHierarchyList (PRIMARY KEY (workerFk)) @@ -76516,7 +76025,7 @@ BEGIN WHILE (SELECT COUNT(*) FROM tmp.workerHierarchyList WHERE NOT isChecked) > 0 DO INSERT INTO tmp.workerHierarchyList - SELECT w.id, 0 + SELECT w.id, 0 FROM worker w JOIN workerHierarchy wh ON wh.workerFk = w.bossFk; @@ -76527,12 +76036,12 @@ BEGIN TRUNCATE workerHierarchy; INSERT INTO workerHierarchy - SELECT workerFk + SELECT workerFk FROM tmp.workerHierarchyList WHERE NOT isChecked; END WHILE; - + DROP TEMPORARY TABLE IF EXISTS workerHierarchy; END ;; DELIMITER ; @@ -76540,8 +76049,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `worker_getSector` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76549,6 +76056,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_getSector`() BEGIN @@ -76559,7 +76068,7 @@ BEGIN SELECT s.id,s.description,s.warehouseFk FROM sector s - JOIN worker w ON w.sectorFk = s.id + JOIN worker w ON w.sectorFk = s.id WHERE w.id = account.myUser_getId(); END ;; @@ -76568,8 +76077,87 @@ 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_updateBusiness` */; +/*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_updateBusiness`(vSelf INT) +BEGIN +/** + * Actualiza en la tabla @worker el contrato actual del trabajador. + * + * @param vSelf Id del trabajador + */ + UPDATE worker w + LEFT JOIN business b ON b.workerFk = w.id + AND util.VN_CURDATE() BETWEEN b.started AND IFNULL(b.ended, util.VN_CURDATE()) + SET w.businessFk = b.id + WHERE w.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 `worker_updateChangedBusiness` */; +/*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_updateChangedBusiness`() +BEGIN +/** + * Actualiza el contrato actual de todos los trabajadores cuyo contracto ha + * empezado/vencido. + */ + DECLARE vBusinessUpdated DATE; + DECLARE vCurdate DATE DEFAULT util.VN_CURDATE(); + DECLARE vWorkerFk INT; + DECLARE vDone BOOL; + + DECLARE vCursor CURSOR FOR + SELECT DISTINCT b.workerFk + FROM business b + WHERE b.started > vBusinessUpdated AND b.started <= vCurdate + OR b.ended >= vBusinessUpdated AND b.ended < vCurdate; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + SELECT businessUpdated INTO vBusinessUpdated + FROM workerConfig; + + OPEN vCursor; + + l: LOOP + SET vDone = FALSE; + + FETCH vCursor INTO vWorkerFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL worker_updateBusiness(vWorkerFk); + END LOOP; + + UPDATE workerConfig SET businessUpdated = vCurdate; +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_updateSector` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76577,6 +76165,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_updateSector`(vSectorFk INT) BEGIN @@ -76584,12 +76174,12 @@ BEGIN /** * ACtualiza el sector del usuario conectado * - * @param vSectorFk id del sector + * @param vSectorFk id del sector */ UPDATE worker SET sectorFk = vSectorFk WHERE id = account.myUser_getId(); - + END ;; DELIMITER ; @@ -76597,8 +76187,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workingHours` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76606,14 +76194,16 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workingHours`(username varchar(255), logon boolean) BEGIN DECLARE userid int(11); - + SELECT vn.getUserId(username) INTO userid; SELECT username, userid; - IF userid IS NOT NULL THEN + IF userid IS NOT NULL THEN IF (logon) THEN CALL vn.workingHoursTimeIn(userid); ELSE @@ -76626,8 +76216,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workingHoursTimeIn` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76635,19 +76223,19 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workingHoursTimeIn`(vUserId INT(11)) BEGIN INSERT INTO vn.workingHours (timeIn, userId) - VALUES (NOW(),vUserId); + VALUES (util.VN_NOW(),vUserId); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workingHoursTimeOut` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76655,21 +76243,21 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workingHoursTimeOut`(vUserId INT(11)) BEGIN UPDATE vn.workingHours - SET timeOut = NOW() + SET timeOut = util.VN_NOW() WHERE userId = vUserId - AND DATE(timeIn) = CURDATE(); + AND DATE(timeIn) = util.VN_CURDATE(); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `wrongEqualizatedClient` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76677,22 +76265,24 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `wrongEqualizatedClient`() BEGIN SELECT clientFk, c.name, c.isActive, c.isTaxDataChecked, count(ie) as num FROM vn.client c - JOIN + JOIN ( - SELECT DISTINCT + SELECT DISTINCT `a`.`clientFk` , a.isEqualizated = 0 as ie - + FROM `vn`.`address` `a` ) sub ON sub.clientFk = c.id WHERE c.hasToInvoiceByAddress = FALSE - + GROUP BY clientFk HAVING num > 1 UNION ALL @@ -76708,8 +76298,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zoneClosure_recalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76717,6 +76305,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneClosure_recalc`() proc: BEGIN @@ -76725,7 +76315,7 @@ proc: BEGIN */ DECLARE vScope INT; DECLARE vCounter INT DEFAULT 0; - DECLARE vShipped DATE DEFAULT CURDATE(); + DECLARE vShipped DATE DEFAULT util.VN_CURDATE(); DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN @@ -76739,27 +76329,27 @@ proc: BEGIN SELECT scope INTO vScope FROM zoneConfig; - + DROP TEMPORARY TABLE IF EXISTS tmp.zone; CREATE TEMPORARY TABLE tmp.zone (INDEX (id)) ENGINE = MEMORY SELECT id FROM zone; - + TRUNCATE TABLE zoneClosure; - + WHILE vCounter <= vScope DO - + CALL zone_getOptionsForShipment(vShipped, TRUE); - + REPLACE zoneClosure(zoneFk, dated, `hour`) - SELECT zoneFk, vShipped, `hour` + SELECT zoneFk, vShipped, `hour` FROM tmp.zoneOption; - + SET vCounter = vCounter + 1; SET vShipped = TIMESTAMPADD(DAY, 1, vShipped); END WHILE; - + -- DROP TEMPORARY TABLE tmp.zone; DO RELEASE_LOCK('vn.zoneClosure_recalc'); END ;; @@ -76768,8 +76358,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zoneGeo_calcTree` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76777,6 +76365,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_calcTree`() BEGIN @@ -76812,8 +76402,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zoneGeo_calcTreeRec` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76821,6 +76409,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_calcTreeRec`( vSelf INT, @@ -76853,7 +76443,7 @@ BEGIN OR (vSelf IS NOT NULL AND parentFk = vSelf); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + SET vSons = 0; OPEN vChildren; @@ -76864,11 +76454,11 @@ BEGIN IF vDone THEN LEAVE myLoop; END IF; - + SET vIndex = vIndex + 1; SET vLft = vIndex; SET vSons = vSons + 1; - + CALL zoneGeo_calcTreeRec( vChildFk, CONCAT(vPath, vChildFk, '/'), @@ -76894,8 +76484,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zoneGeo_checkName` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76903,6 +76491,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_checkName`(vName VARCHAR(255)) BEGIN @@ -76916,8 +76506,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zoneGeo_delete` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76925,6 +76513,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_delete`(vSelf INT) BEGIN @@ -76942,8 +76532,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zoneGeo_doCalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76951,6 +76539,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_doCalc`() proc: BEGIN @@ -76971,7 +76561,7 @@ proc: BEGIN SELECT isChanged INTO vIsChanged FROM zoneGeoRecalc; - + IF vIsChanged THEN UPDATE zoneGeoRecalc SET isChanged = FALSE; CALL vn.zoneGeo_calcTree; @@ -76984,8 +76574,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zoneGeo_setParent` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -76993,6 +76581,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_setParent`(vSelf INT, vParentFk INT) BEGIN @@ -77013,8 +76603,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zoneGeo_throwNotEditable` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -77022,6 +76610,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_throwNotEditable`() BEGIN @@ -77033,42 +76623,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `zone_ETD_byTime` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_ETD_byTime`() -BEGIN - - SET @m := 0; - - DROP TEMPORARY TABLE IF EXISTS tmpZone; - CREATE TEMPORARY TABLE tmpZone - SELECT remainingVolume, - hourTheoretical, - @m := @m + minutesLess totalMinutes - FROM zoneEstimatedDelivery ze - WHERE ze.remainingVolume - ORDER BY ze.hourTheoretical DESC; - - SELECT * FROM tmpZone; - - DROP TABLE tmpZone; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_excludeFromGeo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -77076,6 +76630,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_excludeFromGeo`(vZoneGeo INT) BEGIN @@ -77085,22 +76641,21 @@ BEGIN * @table tmp.zoneOption(zoneFk, hour, travelingDays, price, bonus, landed, shipped) The computed options * @param vZoneGeo The zone geo * @return tmp.zoneOption The computed options - */ - DELETE t FROM tmp.zoneOption t - JOIN zoneExclusion e ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed - LEFT JOIN zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id - JOIN zoneGeo zg1 ON zg1.id = eg.geoFk - JOIN zoneGeo zg2 ON zg2.id = vZoneGeo - WHERE zg2.`path` LIKE CONCAT(zg1.`path`,'%'); - + */ + DELETE t + FROM tmp.zoneOption t + JOIN zoneExclusion e ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed + LEFT JOIN zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id + JOIN zoneGeo zg1 ON zg1.id = eg.geoFk + JOIN zoneGeo zg2 ON zg2.id = vZoneGeo + WHERE zg2.`path` LIKE CONCAT(zg1.`path`, zg1.id,'/%') + OR zg2.id = zg1.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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_getAgency` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -77108,11 +76663,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getAgency`(vAddress INT, vLanded DATE) BEGIN /** - * Devuelve el listado de agencias disponibles para la fecha + * Devuelve el listado de agencias disponibles para la fecha * y dirección pasadas. * * @param vAddress Id de dirección de envío, %NULL si es recogida @@ -77125,9 +76682,9 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetAgency; CREATE TEMPORARY TABLE tmp.zoneGetAgency (INDEX (agencyModeFk)) ENGINE = MEMORY - SELECT am.name agencyMode, + SELECT am.name agencyMode, am.description, - z.agencyModeFk, + z.agencyModeFk, am.deliveryMethodFk, TIMESTAMPADD(DAY,-zo.travelingDays, vLanded) shipped, TRUE isIncluded, @@ -77137,7 +76694,7 @@ BEGIN JOIN zone z ON z.id = zo.zoneFk JOIN agencyMode am ON am.id = z.agencyModeFk GROUP BY agencyModeFk; - + DROP TEMPORARY TABLE tmp.zone, tmp.zoneOption; @@ -77147,8 +76704,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_getAvailable` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -77156,6 +76711,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getAvailable`(vAddress INT, vLanded DATE) BEGIN @@ -77173,8 +76730,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_getClosed` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -77182,6 +76737,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getClosed`() proc:BEGIN @@ -77191,7 +76748,7 @@ proc:BEGIN * @table tmp.closedZones(zoneFk, warehouseFk); */ DROP TEMPORARY TABLE IF EXISTS tmp.closedZones; - + CREATE TEMPORARY TABLE tmp.closedZones ( `zoneFk` int(11) NOT NULL, `warehouseFk` smallint(6) unsigned NOT NULL, @@ -77211,7 +76768,7 @@ proc:BEGIN JOIN vn.productionConfig pc WHERE a.isOwn AND pc.isZoneClosedByExpeditionActivated - AND e.created >= CURDATE() + AND e.created >= util.VN_CURDATE() GROUP BY t.zoneFk, t.warehouseFk HAVING numTickets >= minTicketsToCloseZone) sub; END ;; @@ -77220,8 +76777,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_getCollisions` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -77229,11 +76784,13 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getCollisions`() BEGIN /** - * Calcula si para un mismo codigo postal y dia + * Calcula si para un mismo codigo postal y dia * hay mas de una zona configurada y manda correo * */ @@ -77242,18 +76799,18 @@ BEGIN 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; DROP TEMPORARY TABLE IF EXISTS tmp.zone; CREATE TEMPORARY TABLE tmp.zone - SELECT z.id + SELECT z.id FROM zone z JOIN agencyMode am ON am.id = z.agencyModeFk JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE dm.code IN ('AGENCY','DELIVERY'); + WHERE dm.code IN ('AGENCY','DELIVERY'); - CALL zone_getOptionsForShipment(CURDATE(),FALSE); + CALL zone_getOptionsForShipment(util.VN_CURDATE(),FALSE); DROP TEMPORARY TABLE IF EXISTS tmp.zoneNodes; CREATE TEMPORARY TABLE tmp.zoneNodes ( @@ -77266,7 +76823,7 @@ BEGIN PRIMARY KEY zoneFkk (zoneFk, geoFk), INDEX(geoFk)) ENGINE = MEMORY; - + OPEN cur1; cur1Loop: LOOP SET vIsDone = FALSE; @@ -77274,40 +76831,40 @@ BEGIN IF vIsDone THEN LEAVE cur1Loop; END IF; - + CALL zone_getLeaves2(vZoneFk, NULL, NULL); - myLoop: LOOP + myLoop: LOOP SET vGeoFk = NULL; - SELECT geoFk INTO vGeoFk + SELECT geoFk INTO vGeoFk FROM tmp.zoneNodes zn WHERE NOT isChecked LIMIT 1; - + IF vGeoFk IS NULL THEN LEAVE myLoop; END IF; - + CALL zone_getLeaves2(vZoneFk, vGeoFk, NULL); UPDATE tmp.zoneNodes - SET isChecked = TRUE + SET isChecked = TRUE WHERE geoFk = vGeoFk; END LOOP; END LOOP; CLOSE cur1; - DELETE FROM tmp.zoneNodes + DELETE FROM tmp.zoneNodes WHERE sons > 0; - + DROP TEMPORARY TABLE IF EXISTS geoCollision; CREATE TEMPORARY TABLE geoCollision SELECT z.agencyModeFk, zn.geoFk, zw.warehouseFk FROM tmp.zoneNodes zn JOIN zone z ON z.id = zn.zoneFk - JOIN zoneWarehouse zw ON z.id = zw.zoneFk + JOIN zoneWarehouse zw ON z.id = zw.zoneFk GROUP BY z.agencyModeFk, zn.geoFk, zw.warehouseFk HAVING count(*) > 1; - + SELECT '
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. + Rogamos nos conteste lo antes posible.

@@ -77317,39 +76874,39 @@ BEGIN ' INTO vTableCollisions; - - INSERT INTO mail (receiver,replyTo,subject,body) + + INSERT INTO mail (receiver,replyTo,subject,body) SELECT 'pepe@verdnatura.es' receiver, 'noreply@verdnatura.es' replyTo, - CONCAT('Colisiones en zonas ', CURDATE()) subject, + CONCAT('Colisiones en zonas ', util.VN_CURDATE()) subject, CONCAT(vTableCollisions, GROUP_CONCAT(sub.td SEPARATOR ''), '
C.PostalAlmacén Salix
') body - FROM(SELECT + FROM(SELECT CONCAT(' ', zn.name, ' ', zoneFk,' ', z.price,' ', z.name,' ', w.name, ' - ', CONCAT('' - 'https://salix.verdnatura.es/#!/zone/', + 'https://salix.verdnatura.es/#!/zone/', zoneFk, '/location?q=%7B%22search%22:%22', - zn.name, + 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, + + DROP TEMPORARY TABLE + geoCollision, tmp.zone, tmp.zoneNodes; END ;; @@ -77358,8 +76915,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_getEvents` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -77367,6 +76922,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getEvents`( vGeoFk INT, @@ -77379,17 +76936,17 @@ BEGIN * @param vAgencyModeFk The agency mode id */ DECLARE vDeliveryMethodFk VARCHAR(255); - + DROP TEMPORARY TABLE IF EXISTS tZone; CREATE TEMPORARY TABLE tZone (id INT PRIMARY KEY) ENGINE = MEMORY; - + SELECT dm.`code` INTO vDeliveryMethodFk FROM agencyMode am JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk WHERE am.id = vAgencyModeFk; - + IF vDeliveryMethodFk = 'PICKUP' THEN INSERT INTO tZone SELECT id @@ -77406,16 +76963,16 @@ BEGIN WHERE z.agencyModeFk = vAgencyModeFk; ELSE INSERT INTO tZone - SELECT t.id + SELECT t.id FROM tmp.zone t JOIN zone z ON z.id = t.id - JOIN agencyMode am ON am.id = z.agencyModeFk + JOIN agencyMode am ON am.id = z.agencyModeFk JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk WHERE dm.`code` IN ('AGENCY', 'DELIVERY'); END IF; DROP TEMPORARY TABLE tmp.zone; END IF; - + SELECT e.zoneFk, e.`type`, e.dated, e.`started`, e.`ended`, e.weekDays FROM tZone t JOIN zoneEvent e ON e.zoneFk = t.id; @@ -77427,7 +76984,7 @@ BEGIN JOIN zoneGeo zg1 ON zg1.id = eg.geoFk JOIN zoneGeo zg2 ON zg2.id = vGeoFk WHERE eg.zoneExclusionFk IS NULL OR zg2.`path` LIKE CONCAT(zg1.`path`,'%'); - + DROP TEMPORARY TABLE tZone; END ;; DELIMITER ; @@ -77435,8 +76992,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_getFromGeo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -77444,6 +76999,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getFromGeo`(vGeoFk INT) BEGIN @@ -77456,18 +77013,18 @@ BEGIN DECLARE vChildFk INT DEFAULT vGeoFk; DECLARE vParentFk INT; DECLARE vLevel INT DEFAULT 1; - + DROP TEMPORARY TABLE IF EXISTS tNodes; CREATE TEMPORARY TABLE tNodes (PRIMARY KEY (id)) ENGINE = MEMORY SELECT vGeoFk id, vLevel `level`; - + myLoop: LOOP SELECT parentFk INTO vParentFk FROM zoneGeo WHERE id = vChildFk; - + SET vChildFk = vParentFk; SET vLevel = vLevel + 1; @@ -77475,7 +77032,7 @@ BEGIN SELECT vChildFk, vLevel FROM DUAL WHERE vChildFk IS NOT NULL; - + IF ROW_COUNT() = 0 THEN LEAVE myLoop; END IF; @@ -77504,8 +77061,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_getLanded` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -77513,6 +77068,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT, vShowExpiredZones BOOLEAN) BEGIN @@ -77544,10 +77101,10 @@ BEGIN FROM tmp.zoneOption zo JOIN vn.`zone` z ON z.id = zo.zoneFk JOIN vn.zoneWarehouse zw ON zw.zoneFk = z.id - LEFT JOIN tmp.closedZones cz + LEFT JOIN tmp.closedZones cz ON cz.warehouseFk = zw.warehouseFk AND cz.zoneFk = zw.zoneFk - AND zo.shipped = CURDATE() + AND zo.shipped = util.VN_CURDATE() WHERE z.agencyModeFk = vAgencyModeFk AND zw.warehouseFk = vWarehouseFk AND (ISNULL(cz.zoneFk) OR vShowExpiredZones); @@ -77562,8 +77119,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_getLeaves` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -77571,9 +77126,11 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getLeaves`(vSelf INT, vParentFk INT, vSearch VARCHAR(255)) -BEGIN +BEGIN /** * Devuelve las ubicaciones incluidas en la ruta y que sean hijos de parentFk. * @param vSelf Id de la zona @@ -77587,23 +77144,23 @@ BEGIN CREATE TEMPORARY TABLE tNodes (UNIQUE (id)) ENGINE = MEMORY - SELECT id - FROM zoneGeo + SELECT id + FROM zoneGeo LIMIT 0; IF vIsSearch THEN SET vIsNumber = vSearch REGEXP '^[0-9]+$'; - + INSERT INTO tNodes - SELECT id + SELECT id FROM zoneGeo WHERE (vIsNumber AND `name` = vSearch) OR (!vIsNumber AND `name` LIKE CONCAT('%', vSearch, '%')) LIMIT 1000; - + ELSEIF vParentFk IS NULL THEN INSERT INTO tNodes - SELECT geoFk + SELECT geoFk FROM zoneIncluded WHERE zoneFk = vSelf; END IF; @@ -77612,14 +77169,14 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tChilds; CREATE TEMPORARY TABLE tChilds ENGINE = MEMORY - SELECT id + SELECT id FROM tNodes; DROP TEMPORARY TABLE IF EXISTS tParents; CREATE TEMPORARY TABLE tParents ENGINE = MEMORY - SELECT id - FROM zoneGeo + SELECT id + FROM zoneGeo LIMIT 0; myLoop: LOOP @@ -77629,27 +77186,27 @@ BEGIN FROM zoneGeo g JOIN tChilds c ON c.id = g.id WHERE g.parentFk IS NOT NULL; - + INSERT IGNORE INTO tNodes - SELECT id + SELECT id FROM tParents; - + IF ROW_COUNT() = 0 THEN LEAVE myLoop; END IF; - + DELETE FROM tChilds; INSERT INTO tChilds - SELECT id + SELECT id FROM tParents; END LOOP; - + DROP TEMPORARY TABLE tChilds, tParents; END IF; IF !vIsSearch THEN INSERT IGNORE INTO tNodes - SELECT id + SELECT id FROM zoneGeo WHERE parentFk <=> vParentFk; END IF; @@ -77671,8 +77228,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_getLeaves2` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -77680,15 +77235,17 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getLeaves2`(vSelf INT, vParentFk INT, vSearch VARCHAR(255)) -BEGIN +BEGIN /** * Devuelve los geoFk incluidos en la ruta y que sean hijos de parentFk * @param vSelf Id de la zona * @param vParentFk Id del geo a calcular * @param vSearch cadena a buscar - * + * * @return tmp.zoneNodes(geoFk, name, parentFk, sons, isChecked, zoneFk) * */ @@ -77699,23 +77256,23 @@ BEGIN CREATE TEMPORARY TABLE tNodes (UNIQUE (id)) ENGINE = MEMORY - SELECT id - FROM zoneGeo + SELECT id + FROM zoneGeo LIMIT 0; IF vIsSearch THEN SET vIsNumber = vSearch REGEXP '^[0-9]+$'; INSERT INTO tNodes - SELECT id + SELECT id FROM zoneGeo WHERE (vIsNumber AND `name` = vSearch) OR (!vIsNumber AND `name` LIKE CONCAT('%', vSearch, '%')) LIMIT 1000; - + ELSEIF vParentFk IS NULL THEN INSERT INTO tNodes - SELECT geoFk + SELECT geoFk FROM zoneIncluded WHERE zoneFk = vSelf; END IF; @@ -77725,15 +77282,15 @@ BEGIN CREATE TEMPORARY TABLE tChilds (INDEX(id)) ENGINE = MEMORY - SELECT id + SELECT id FROM tNodes; DROP TEMPORARY TABLE IF EXISTS tParents; CREATE TEMPORARY TABLE tParents (INDEX(id)) ENGINE = MEMORY - SELECT id - FROM zoneGeo + SELECT id + FROM zoneGeo LIMIT 0; myLoop: LOOP @@ -77743,27 +77300,27 @@ BEGIN FROM zoneGeo g JOIN tChilds c ON c.id = g.id WHERE g.parentFk IS NOT NULL; - + INSERT IGNORE INTO tNodes - SELECT id + SELECT id FROM tParents; - + IF ROW_COUNT() = 0 THEN LEAVE myLoop; END IF; - + DELETE FROM tChilds; INSERT INTO tChilds - SELECT id + SELECT id FROM tParents; END LOOP; - + DROP TEMPORARY TABLE tChilds, tParents; END IF; IF !vIsSearch THEN INSERT IGNORE INTO tNodes - SELECT id + SELECT id FROM zoneGeo WHERE parentFk <=> vParentFk; END IF; @@ -77778,9 +77335,9 @@ BEGIN FROM zoneGeo g JOIN tNodes n ON n.id = g.id LEFT JOIN zoneIncluded i ON i.geoFk = g.id AND i.zoneFk = vSelf - WHERE i.isIncluded = TRUE + WHERE i.isIncluded = TRUE OR (i.isIncluded IS NULL AND vParentFk IS NOT NULL); - + DROP TEMPORARY TABLE tNodes; END ;; DELIMITER ; @@ -77788,8 +77345,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_getOptionsForLanding` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -77797,6 +77352,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getOptionsForLanding`(vLanded DATE, vShowExpiredZones BOOLEAN) BEGIN @@ -77806,7 +77363,7 @@ BEGIN * @table tmp.zone(id) The zones ids * @param vLanded The delivery date * @return tmp.zoneOption The computed options - */ + */ DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption; CREATE TEMPORARY TABLE tmp.zoneOption ENGINE = MEMORY @@ -77847,17 +77404,17 @@ BEGIN END LIMIT 10000000000000000000 ) t - GROUP BY zoneFk; - + GROUP BY zoneFk; + DELETE t FROM tmp.zoneOption t JOIN zoneExclusion e ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed LEFT JOIN zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id WHERE eg.zoneExclusionFk IS NULL; - + IF NOT vShowExpiredZones THEN DELETE FROM tmp.zoneOption - WHERE shipped < CURDATE() - OR (shipped = CURDATE() AND CURTIME() > `hour`); + WHERE shipped < util.VN_CURDATE() + OR (shipped = util.VN_CURDATE() AND util.VN_CURTIME() > `hour`); END IF; END ;; DELIMITER ; @@ -77865,8 +77422,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_getOptionsForShipment` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -77874,6 +77429,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getOptionsForShipment`(vShipped DATE, vShowExpiredZones BOOLEAN) BEGIN @@ -77884,8 +77441,8 @@ BEGIN * @param vShipped The shipping date * @return tmp.zoneOption(zoneFk, hour, travelingDays, price, bonus, specificity) The computed options */ - DECLARE vHour TIME DEFAULT TIME(NOW()); - + DECLARE vHour TIME DEFAULT TIME(util.VN_NOW()); + DROP TEMPORARY TABLE IF EXISTS tLandings; CREATE TEMPORARY TABLE tLandings (INDEX (eventFk)) @@ -77944,8 +77501,8 @@ BEGIN IF NOT vShowExpiredZones THEN DELETE FROM tmp.zoneOption - WHERE vShipped < CURDATE() - OR (vShipped = CURDATE() AND CURTIME() > `hour`); + WHERE vShipped < util.VN_CURDATE() + OR (vShipped = util.VN_CURDATE() AND util.VN_CURTIME() > `hour`); END IF; END ;; DELIMITER ; @@ -77953,8 +77510,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_getShipped` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -77962,6 +77517,8 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getShipped`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vShowExpiredZones BOOLEAN) BEGIN @@ -77977,7 +77534,7 @@ BEGIN DECLARE vZoneGeo INT; SELECT address_getGeo(vAddressFk) INTO vZoneGeo; - + CALL vn.zone_getFromGeo(vZoneGeo); CALL vn.zone_getOptionsForLanding(vLanded, vShowExpiredZones); CALL vn.zone_excludeFromGeo(vZoneGeo); @@ -77997,10 +77554,10 @@ BEGIN FROM tmp.zoneOption zo JOIN vn.zoneWarehouse zw ON zw.zoneFk = zo.zoneFk JOIN vn.`zone` z ON z.id = zo.zoneFk - LEFT JOIN tmp.closedZones cz + LEFT JOIN tmp.closedZones cz ON cz.warehouseFk = zw.warehouseFk AND cz.zoneFk = zw.zoneFk - AND zo.shipped = CURDATE() + AND zo.shipped = util.VN_CURDATE() WHERE z.agencyModeFk = vAgencyModeFk AND (ISNULL(cz.zoneFk) OR vShowExpiredZones) ORDER BY shipped @@ -78017,8 +77574,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_getState` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -78026,14 +77581,16 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getState`(vDated DATE) BEGIN /** * Devuelve las zonas y el estado para la fecha solicitada - * + * * @param vDated Fecha en cuestión - */ + */ DROP TEMPORARY TABLE IF EXISTS tmp.zone; CREATE TEMPORARY TABLE tmp.zone ( @@ -78047,21 +77604,21 @@ BEGIN CALL vn.zone_getOptionsForShipment(vDated, TRUE); CALL vn.zone_getClosed(); - + SELECT zo.zoneFk, zo.`hour`etd, - (zo.`hour` <= TIME(now())) isLate, + (zo.`hour` <= TIME(util.VN_NOW())) isLate, !ISNULL(cz.zoneFk) isFull, zw.warehouseFk, zo.landed FROM tmp.zoneOption zo JOIN vn.zone z ON z.id = zo.zoneFk JOIN vn.zoneWarehouse zw ON zw.zoneFk = z.id - LEFT JOIN tmp.closedZones cz - ON cz.warehouseFk = zw.warehouseFk + LEFT JOIN tmp.closedZones cz + ON cz.warehouseFk = zw.warehouseFk AND cz.zoneFk = zo.zoneFk; - - DROP TEMPORARY TABLE + + DROP TEMPORARY TABLE tmp.closedZones, tmp.zoneOption, tmp.zone; @@ -78072,8 +77629,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 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_getWarehouse` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -78081,27 +77636,29 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT) BEGIN /** * Devuelve el listado de agencias disponibles para la fecha, * dirección y almacén pasados. - * + * * @param vAddress * @param vWarehouse warehouse * @param vLanded Fecha de recogida * @select Listado de agencias disponibles */ - + CALL zone_getFromGeo(address_getGeo(vAddress)); CALL zone_getOptionsForLanding(vLanded, FALSE); - - SELECT am.id agencyModeFk, - am.name agencyMode, - am.description, + + SELECT am.id agencyModeFk, + am.name agencyMode, + am.description, am.deliveryMethodFk, - TIMESTAMPADD(DAY, -zo.travelingDays, vLanded) shipped, + TIMESTAMPADD(DAY, -zo.travelingDays, vLanded) shipped, zw.warehouseFk, z.id zoneFk FROM tmp.zoneOption zo @@ -78111,19 +77668,17 @@ BEGIN WHERE zw.warehouseFk = vWarehouse GROUP BY z.agencyModeFk ORDER BY agencyMode; - + DROP TEMPORARY TABLE tmp.zone, tmp.zoneOption; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_upcomingDeliveries` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -78131,14 +77686,16 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_upcomingDeliveries`() BEGIN DECLARE vForwardDays INT; - + SELECT forwardDays INTO vForwardDays FROM zoneConfig; - CALL util.time_createTable(CURDATE(), DATE_ADD(CURDATE(), INTERVAL vForwardDays DAY)); + CALL util.time_createTable(util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL vForwardDays DAY)); DROP TEMPORARY TABLE IF EXISTS tLandings; CREATE TEMPORARY TABLE tLandings @@ -78150,9 +77707,9 @@ BEGIN ti.dated shipped FROM zone z JOIN zoneEvent e ON e.zoneFk = z.id - JOIN tmp.time ti ON ti.dated BETWEEN curdate() AND TIMESTAMPADD(DAY, vForwardDays, curdate()); + JOIN tmp.time ti ON ti.dated BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY, vForwardDays, util.VN_CURDATE()); - DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption; + DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption; CREATE TEMPORARY TABLE tmp.zoneOption ENGINE = MEMORY SELECT * @@ -78193,7 +77750,7 @@ BEGIN JOIN zoneExclusion e ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed LEFT JOIN zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id WHERE eg.zoneExclusionFk IS NULL; - + SELECT MAX(zo.`hour`) `hour`, zg.`name`, zo.shipped, zo.zoneFk FROM tmp.zoneOption zo JOIN `zone` z ON z.id = zo.zoneFk @@ -78204,7 +77761,7 @@ BEGIN WHERE dm.code = 'DELIVERY' GROUP BY shipped, zg.`name` ORDER BY shipped, zg.`name`; - + DROP TEMPORARY TABLE tmp.time, tLandings; END ;; DELIMITER ; @@ -78217,7 +77774,7 @@ DELIMITER ; -- Current Database: `vncontrol` -- -CREATE DATABASE /*!32312 IF NOT EXISTS*/ `vncontrol` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `vncontrol` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci */; USE `vncontrol`; @@ -78230,9 +77787,9 @@ DROP TABLE IF EXISTS `accion`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `accion` ( `accion_id` int(11) NOT NULL AUTO_INCREMENT, - `accion` varchar(15) COLLATE utf8_unicode_ci NOT NULL, + `accion` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL, PRIMARY KEY (`accion_id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -78249,7 +77806,7 @@ CREATE TABLE `fallo__` ( KEY `accion` (`accion_id`,`queja_id`), KEY `fallo` (`queja_id`), CONSTRAINT `accion` FOREIGN KEY (`accion_id`) REFERENCES `accion` (`accion_id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -78262,9 +77819,9 @@ DROP TABLE IF EXISTS `inter`; CREATE TABLE `inter` ( `inter_id` int(11) NOT NULL AUTO_INCREMENT, `state_id` tinyint(3) unsigned NOT NULL, - `fallo_id` int(10) unsigned NOT NULL DEFAULT '21', - `nota` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `odbc_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `fallo_id` int(10) unsigned NOT NULL DEFAULT 21, + `nota` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `odbc_date` timestamp NULL DEFAULT current_timestamp(), `Id_Ticket` int(11) DEFAULT NULL, `Id_Trabajador` int(11) DEFAULT NULL, `Id_Supervisor` int(10) unsigned DEFAULT NULL, @@ -78277,7 +77834,7 @@ CREATE TABLE `inter` ( CONSTRAINT `inter_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inter_state` FOREIGN KEY (`state_id`) REFERENCES `vn`.`state` (`id`) ON UPDATE CASCADE, CONSTRAINT `responsable` FOREIGN KEY (`Id_Supervisor`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_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 */ ; @@ -78296,19 +77853,19 @@ BEGIN DECLARE vZoneFk INT; DECLARE vHasStowAway BOOLEAN; DECLARE vBoardingStateFk INT; - + SELECT s.code INTO vState FROM vn.state s WHERE s.id = NEW.state_id; - + SELECT t.zonefk INTO vZoneFk FROM vn.ticket t - WHERE t.id = NEW.Id_Ticket; - + WHERE t.id = NEW.Id_Ticket; + IF vState = 'OK' AND vZoneFk IS NULL THEN CALL util.throw("ASSIGN_ZONE_FIRST"); - END IF; - + END IF; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -78330,12 +77887,12 @@ DELIMITER ;; BEGIN DECLARE vNumTicketsPrepared INT; - + REPLACE vn.ticketLastState(ticketFk, ticketTrackingFk, name) SELECT NEW.Id_Ticket, NEW.inter_id, `name` FROM vn.state - WHERE id = NEW.state_id; - + WHERE id = NEW.state_id; + END */;; DELIMITER ; @@ -78359,21 +77916,21 @@ BEGIN DECLARE vTicketFk INT; DECLARE vTicketTrackingFk INT; DECLARE vStateName VARCHAR(15); - + IF NEW.state_id <> OLD.state_id THEN REPLACE vn.ticketLastState(ticketFk, ticketTrackingFk, name) SELECT NEW.Id_Ticket, NEW.inter_id, `name` FROM vn.state WHERE id = NEW.state_id; END IF; - + IF NEW.Id_Ticket <> OLD.Id_Ticket THEN SELECT i.Id_Ticket, i.inter_id, s.`name` - INTO vTicketFk, vTicketTrackingFk, vStateName - FROM vncontrol.inter i - JOIN vn.state s ON i.state_id = s.id - WHERE Id_Ticket = NEW.Id_Ticket - ORDER BY odbc_date DESC + INTO vTicketFk, vTicketTrackingFk, vStateName + FROM vncontrol.inter i + JOIN vn.state s ON i.state_id = s.id + WHERE Id_Ticket = NEW.Id_Ticket + ORDER BY odbc_date DESC LIMIT 1; IF vTicketFk > 0 THEN @@ -78411,11 +77968,11 @@ BEGIN END; SELECT i.Id_Ticket, i.inter_id, s.`name` - INTO vTicketFk, vTicketTrackingFk, vStateName - FROM vncontrol.inter i - JOIN vn.state s ON i.state_id = s.id - WHERE Id_Ticket = OLD.Id_Ticket - ORDER BY odbc_date DESC + INTO vTicketFk, vTicketTrackingFk, vStateName + FROM vncontrol.inter i + JOIN vn.state s ON i.state_id = s.id + WHERE Id_Ticket = OLD.Id_Ticket + ORDER BY odbc_date DESC LIMIT 1; IF vTicketFk > 0 THEN @@ -78436,8 +77993,6 @@ DELIMITER ; -- -- Dumping routines for database 'vncontrol' -- -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -78445,10 +78000,12 @@ DELIMITER ; /*!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 = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`() BEGIN - DECLARE vDate DATETIME DEFAULT TIMESTAMPADD(MONTH, -2, CURDATE()); + DECLARE vDate DATETIME DEFAULT TIMESTAMPADD(MONTH, -2, util.VN_CURDATE()); DELETE i FROM inter i JOIN vn.ticket t ON i.Id_Ticket = t.id WHERE t.shipped <= vDate; END ;; @@ -78478,7 +78035,7 @@ USE `account`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `accountDovecot` AS select `u`.`name` AS `name`,`u`.`password` AS `password` from (`user` `u` join `account` `a` on((`a`.`id` = `u`.`id`))) where `u`.`active` */; +/*!50001 VIEW `accountDovecot` AS select `u`.`name` AS `name`,`u`.`password` AS `password` from (`user` `u` join `account` `a` on(`a`.`id` = `u`.`id`)) where `u`.`active` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78516,7 +78073,7 @@ USE `account`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myRole` AS select `r`.`inheritsFrom` AS `id` from (`roleRole` `r` join `user` `u` on((`u`.`role` = `r`.`role`))) where (`u`.`id` = `myUser_getId`()) */; +/*!50001 VIEW `myRole` AS select `r`.`inheritsFrom` AS `id` from (`roleRole` `r` join `user` `u` on(`u`.`role` = `r`.`role`)) where `u`.`id` = `myUser_getId`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78535,7 +78092,7 @@ USE `account`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myUser` AS select `u`.`id` AS `id`,`u`.`name` AS `name`,`u`.`active` AS `active`,`u`.`email` AS `email`,`u`.`nickname` AS `nickname`,`u`.`lang` AS `lang`,`u`.`role` AS `role`,`u`.`recoverPass` AS `recoverPass` from `user` `u` where (`u`.`name` = `myUser_getName`()) */ +/*!50001 VIEW `myUser` AS select `u`.`id` AS `id`,`u`.`name` AS `name`,`u`.`active` AS `active`,`u`.`email` AS `email`,`u`.`nickname` AS `nickname`,`u`.`lang` AS `lang`,`u`.`role` AS `role`,`u`.`recoverPass` AS `recoverPass` from `user` `u` where `u`.`name` = `myUser_getName`() */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -78561,7 +78118,7 @@ USE `bs`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `bajasLaborales` AS select `w`.`firstName` AS `firstname`,`w`.`lastName` AS `name`,`b`.`business_id` AS `business_id`,max(`ce`.`date`) AS `lastDate`,max(ifnull(`b`.`date_end`,curdate())) AS `endContract`,`at`.`name` AS `type`,cast(count(0) as decimal(10,0)) AS `dias`,`w`.`id` AS `userFk` from ((((`postgresql`.`calendar_employee` `ce` join `postgresql`.`business` `b` on((`b`.`business_id` = `ce`.`business_id`))) join `postgresql`.`profile` `pr` on((`pr`.`profile_id` = `b`.`client_id`))) join `vn`.`worker` `w` on((`w`.`id` = `pr`.`workerFk`))) join `vn`.`absenceType` `at` on((`at`.`id` = `ce`.`calendar_state_id`))) where ((`ce`.`date` >= (curdate() + interval -(1) year)) and (`at`.`name` not in ('Vacaciones','Vacaciones 1/2 día','Compensar','Festivo'))) group by `w`.`firstName`,`w`.`lastName`,`at`.`name` having (`endContract` >= curdate()) */; +/*!50001 VIEW `bajasLaborales` AS select `w`.`firstName` AS `firstname`,`w`.`lastName` AS `name`,`b`.`id` AS `businessFk`,max(`ce`.`date`) AS `lastDate`,max(ifnull(`b`.`ended`,util.VN_CURDATE())) AS `endContract`,`at`.`name` AS `type`,cast(count(0) as decimal(10,0)) AS `dias`,`w`.`id` AS `userFk` from (((`postgresql`.`calendar_employee` `ce` join `vn`.`business` `b` on(`b`.`id` = `ce`.`businessFk`)) join `vn`.`worker` `w` on(`w`.`id` = `b`.`workerFk`)) join `vn`.`absenceType` `at` on(`at`.`id` = `ce`.`calendar_state_id`)) where `ce`.`date` >= util.VN_CURDATE() + interval -1 year and `at`.`name` not in ('Vacaciones','Vacaciones 1/2 día','Compensar','Festivo') group by `w`.`firstName`,`w`.`lastName`,`at`.`name` having `endContract` >= util.VN_CURDATE() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78580,7 +78137,7 @@ USE `bs`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` 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 */; @@ -78599,7 +78156,7 @@ USE `bs`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `packingSpeed` AS select hour(`e`.`created`) AS `hora`,minute(`e`.`created`) AS `minuto`,ifnull(`p`.`volume`,((`p`.`width` * `p`.`height`) * `p`.`depth`)) AS `cm3`,`t`.`warehouseFk` AS `warehouse_id`,`e`.`created` AS `odbc_date` from ((`vn`.`expedition` `e` join `vn`.`packaging` `p` on((`p`.`id` = `e`.`packagingFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) where (`e`.`created` between curdate() and `util`.`dayend`(curdate())) */; +/*!50001 VIEW `packingSpeed` AS select hour(`e`.`created`) AS `hora`,minute(`e`.`created`) AS `minuto`,ifnull(`p`.`volume`,`p`.`width` * `p`.`height` * `p`.`depth`) AS `cm3`,`t`.`warehouseFk` AS `warehouse_id`,`e`.`created` AS `odbc_date` from ((`vn`.`expedition` `e` join `vn`.`packaging` `p` on(`p`.`id` = `e`.`packagingFk`)) join `vn`.`ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) where `e`.`created` between `util`.`VN_CURDATE`() and `util`.`dayend`(`util`.`VN_CURDATE`()) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78618,7 +78175,7 @@ USE `bs`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` 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 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 */; @@ -78637,7 +78194,7 @@ USE `bs`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` 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 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` <> 0 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 */; @@ -78692,6 +78249,25 @@ USE `cache`; USE `edi`; +-- +-- Final view structure for view `ektRecent` +-- + +/*!50001 DROP TABLE IF EXISTS `ektRecent`*/; +/*!50001 DROP VIEW IF EXISTS `ektRecent`*/; +/*!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_unicode_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `ektRecent` AS select `e`.`id` AS `id`,`e`.`barcode` AS `barcode`,`e`.`entryYear` AS `entryYear`,`e`.`batchNumber` AS `batchNumber`,`e`.`deliveryNumber` AS `deliveryNumber`,`e`.`vendorOrderNumber` AS `vendorOrderNumber`,`e`.`fec` AS `fec`,`e`.`hor` AS `hor`,`e`.`util.VN_NOW` AS `util.VN_NOW`,`e`.`ptj` AS `ptj`,`e`.`ref` AS `ref`,`e`.`item` AS `item`,`e`.`pac` AS `pac`,`e`.`qty` AS `qty`,`e`.`ori` AS `ori`,`e`.`cat` AS `cat`,`e`.`agj` AS `agj`,`e`.`kop` AS `kop`,`e`.`ptd` AS `ptd`,`e`.`sub` AS `sub`,`e`.`pro` AS `pro`,`e`.`pri` AS `pri`,`e`.`package` AS `package`,`e`.`auction` AS `auction`,`e`.`klo` AS `klo`,`e`.`k1` AS `k1`,`e`.`k2` AS `k2`,`e`.`k3` AS `k3`,`e`.`k4` AS `k4`,`e`.`s1` AS `s1`,`e`.`s2` AS `s2`,`e`.`s3` AS `s3`,`e`.`s4` AS `s4`,`e`.`s5` AS `s5`,`e`.`s6` AS `s6`,`e`.`ok` AS `ok`,`e`.`trolleyFk` AS `trolleyFk`,`e`.`putOrderFk` AS `putOrderFk`,`e`.`scanned` AS `scanned`,`e`.`cps` AS `cps`,`e`.`dp` AS `dp`,`e`.`sender` AS `sender`,`ec`.`usefulAuctionLeftSegmentLength` AS `usefulAuctionLeftSegmentLength`,`ec`.`standardBarcodeLength` AS `standardBarcodeLength`,`ec`.`floridayBarcodeLength` AS `floridayBarcodeLength`,`ec`.`floramondoBarcodeLength` AS `floramondoBarcodeLength`,`ec`.`defaultKlo` AS `defaultKlo`,`ec`.`ektRecentScopeDays` AS `ektRecentScopeDays` from (`ekt` `e` join `ektConfig` `ec`) where `e`.`entryYear` = year(`util`.`VN_CURDATE`()) and `e`.`fec` >= `util`.`VN_CURDATE`() + interval -`ec`.`ektRecentScopeDays` day */; +/*!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 `errorList` -- @@ -78706,7 +78282,7 @@ USE `edi`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `errorList` AS select `po`.`id` AS `id`,`c`.`name` AS `name`,`i`.`longName` AS `longName`,`po`.`quantity` AS `quantity`,left(`po`.`error`,4) AS `stock`,`po`.`error` AS `error`,`po`.`deliveryInformationID` AS `deliveryInformationID`,`po`.`supplyResponseID` AS `supplyResponseID`,`po`.`OrderTradeLineDateTime` AS `OrderTradeLineDateTime`,`po`.`EndUserPartyGLN` AS `EndUserPartyGLN` from ((`edi`.`putOrder` `po` left join `vn`.`client` `c` on((`c`.`id` = `po`.`EndUserPartyGLN`))) left join `vn`.`item` `i` on((`i`.`supplyResponseFk` = `po`.`supplyResponseID`))) where ((`po`.`OrderTradeLineDateTime` > (curdate() + interval -(12) hour)) and (`po`.`OrderStatus` = 3) and (left(`po`.`error`,4) <> '(0) ')) */; +/*!50001 VIEW `errorList` AS select `po`.`id` AS `id`,`c`.`name` AS `name`,`i`.`longName` AS `longName`,`po`.`quantity` AS `quantity`,left(`po`.`error`,4) AS `stock`,`po`.`error` AS `error`,`po`.`deliveryInformationID` AS `deliveryInformationID`,`po`.`supplyResponseID` AS `supplyResponseID`,`po`.`OrderTradeLineDateTime` AS `OrderTradeLineDateTime`,`po`.`EndUserPartyGLN` AS `EndUserPartyGLN` from ((`edi`.`putOrder` `po` left join `vn`.`client` `c` on(`c`.`id` = `po`.`EndUserPartyGLN`)) left join `vn`.`item` `i` on(`i`.`supplyResponseFk` = `po`.`supplyResponseID`)) where `po`.`OrderTradeLineDateTime` > `util`.`VN_CURDATE`() + interval -12 hour and `po`.`OrderStatus` = 3 and left(`po`.`error`,4) <> '(0) ' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78725,7 +78301,7 @@ USE `edi`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `supplyOffer` AS select `sr`.`vmpID` AS `vmpID`,`di`.`ID` AS `diId`,`sr`.`ID` AS `srId`,`sr`.`Item_ArticleCode` AS `Item_ArticleCode`,`sr`.`VBNOmschrijving` AS `product_name`,`s`.`company_name` AS `company_name`,cast(`sr`.`Price` as decimal(10,3)) AS `Price`,`sr`.`Quality` AS `Quality`,`sr`.`s1` AS `s1`,`sr`.`s2` AS `s2`,`sr`.`s3` AS `s3`,`sr`.`s4` AS `s4`,`sr`.`s5` AS `s5`,`sr`.`s6` AS `s6`,`sr`.`NumberOfUnits` AS `NumberOfUnits`,least(if((`sr`.`EmbalageCode` = 800),((`sr`.`EmbalageCode` * 10) + `sr`.`NumberOfItemsPerCask`),`sr`.`EmbalageCode`),ifnull(`idt`.`bucket_id`,'999')) AS `EmbalageCode`,`di`.`LatestDeliveryDateTime` AS `LatestDeliveryDateTime`,`di`.`EarliestDespatchDateTime` AS `EarliestDespatchDateTime`,`di`.`FirstOrderDateTime` AS `FirstOrderDateTime`,`di`.`LatestOrderDateTime` AS `LatestOrderDateTime`,`sr`.`NumberOfItemsPerCask` AS `NumberOfItemsPerCask`,`sr`.`NumberOfLayersPerTrolley` AS `NumberOfLayersPerTrolley`,`sr`.`MinimumNumberToOrder` AS `MinimumNumberToOrder`,`sr`.`MaximumNumberToOrder` AS `MaximumNumberToOrder`,`sr`.`IncrementalOrderableQuantity` AS `IncrementalOrderableQuantity`,`sr`.`PackingPrice` AS `PackingPrice`,`sr`.`MarketPlaceID` AS `MarketPlaceID`,`sr`.`PictureReference` AS `PictureReference`,`sr`.`updated` AS `supplyResponseUpdated`,`i`.`group_id` AS `group_id`,`mp`.`name` AS `marketPlace`,`di`.`DeliveryPrice` AS `DeliveryPrice`,`di`.`ChargeAmount` AS `ChargeAmount`,`di`.`MinimumQuantity` AS `MinimumQuantity`,`di`.`MaximumQuantity Integer` AS `MaximumQuantity`,cast((`sr`.`MinimumNumberToOrder` * (case `sr`.`MinimumOrderUnitType` when 1 then 1 when 2 then (`sr`.`NumberOfItemsPerCask` / `sr`.`NumberBunchesPerCask`) when 3 then `sr`.`NumberOfItemsPerCask` when 4 then (floor(((128 * 56) / (`b`.`x_size` * `b`.`y_size`))) * `sr`.`NumberOfItemsPerCask`) when 5 then ((floor(((128 * 56) / (`b`.`x_size` * `b`.`y_size`))) * `sr`.`NumberOfItemsPerCask`) * `sr`.`NumberOfLayersPerTrolley`) end)) as decimal(10,0)) AS `OrderUnit`,cast((`sr`.`IncrementalOrderableQuantity` * (case `sr`.`IncrementalOrderableQuantityType` when 1 then 1 when 2 then (`sr`.`NumberOfItemsPerCask` / `sr`.`NumberBunchesPerCask`) when 3 then `sr`.`NumberOfItemsPerCask` when 4 then (floor(((128 * 56) / (`b`.`x_size` * `b`.`y_size`))) * `sr`.`NumberOfItemsPerCask`) when 5 then ((floor(((128 * 56) / (`b`.`x_size` * `b`.`y_size`))) * `sr`.`NumberOfItemsPerCask`) * `sr`.`NumberOfLayersPerTrolley`) end)) as decimal(10,0)) AS `IncrementalOrderUnit`,`mp`.`isEarlyBird` AS `isEarlyBird`,`v`.`isVNHSupplier` AS `isVNHSupplier`,`igo`.`expenseFk` AS `expenseFk`,`igo`.`intrastatFk` AS `intrastatFk`,`igo`.`originFk` AS `originFk`,ifnull(`idt`.`itemTypeFk`,`igo`.`itemTypeFk`) AS `itemTypeFk` from (((((((((`edi`.`deliveryInformation` `di` join `edi`.`supplyResponse` `sr` on((`sr`.`ID` = `di`.`supplyResponseID`))) left join `edi`.`supplier` `s` on((`s`.`glnAddressCode` = `sr`.`SupplierGLN`))) join `edi`.`bucket` `b` on((`b`.`bucket_id` = `sr`.`EmbalageCode`))) join `edi`.`item` `i` on((`i`.`id` = `sr`.`Item_ArticleCode`))) join `edi`.`marketPlace` `mp` on((`mp`.`id` = `sr`.`MarketPlaceID`))) join `vn`.`floramondoConfig` `fm`) left join `edi`.`item_defaultType` `idt` on((`idt`.`item_id` = `i`.`id`))) join `edi`.`VMPSettings` `v` on((`v`.`VMPID` = `sr`.`vmpID`))) join `edi`.`item_groupToOffer` `igo` on((`igo`.`group_code` = `i`.`group_id`))) where ((`v`.`isBlocked` = 0) and (`s`.`isBanned` = 0) and (`sr`.`NumberOfUnits` > 0) and (now() between `di`.`FirstOrderDateTime` and `di`.`LatestOrderDateTime`) and (`mp`.`isOffered` = 1) and (`di`.`LatestDeliveryDateTime` between cast(`fm`.`nextLanded` as date) and concat(cast(`fm`.`nextLanded` as date),' ',`fm`.`MaxLatestDeliveryHour`))) group by `sr`.`ID` having (`EmbalageCode` <> 999) */; +/*!50001 VIEW `supplyOffer` AS select `sr`.`vmpID` AS `vmpID`,`di`.`ID` AS `diId`,`sr`.`ID` AS `srId`,`sr`.`Item_ArticleCode` AS `Item_ArticleCode`,`sr`.`VBNOmschrijving` AS `product_name`,`s`.`company_name` AS `company_name`,cast(`sr`.`Price` as decimal(10,3)) AS `Price`,`sr`.`Quality` AS `Quality`,`sr`.`s1` AS `s1`,`sr`.`s2` AS `s2`,`sr`.`s3` AS `s3`,`sr`.`s4` AS `s4`,`sr`.`s5` AS `s5`,`sr`.`s6` AS `s6`,`sr`.`NumberOfUnits` AS `NumberOfUnits`,least(if(`sr`.`EmbalageCode` = 800,`sr`.`EmbalageCode` * 10 + `sr`.`NumberOfItemsPerCask`,`sr`.`EmbalageCode`),ifnull(`idt`.`bucket_id`,'999')) AS `EmbalageCode`,`di`.`LatestDeliveryDateTime` AS `LatestDeliveryDateTime`,`di`.`EarliestDespatchDateTime` AS `EarliestDespatchDateTime`,`di`.`FirstOrderDateTime` AS `FirstOrderDateTime`,`di`.`LatestOrderDateTime` AS `LatestOrderDateTime`,`sr`.`NumberOfItemsPerCask` AS `NumberOfItemsPerCask`,`sr`.`NumberOfLayersPerTrolley` AS `NumberOfLayersPerTrolley`,`sr`.`MinimumNumberToOrder` AS `MinimumNumberToOrder`,`sr`.`MaximumNumberToOrder` AS `MaximumNumberToOrder`,`sr`.`IncrementalOrderableQuantity` AS `IncrementalOrderableQuantity`,`sr`.`PackingPrice` AS `PackingPrice`,`sr`.`MarketPlaceID` AS `MarketPlaceID`,`sr`.`PictureReference` AS `PictureReference`,`sr`.`updated` AS `supplyResponseUpdated`,`i`.`group_id` AS `group_id`,`mp`.`name` AS `marketPlace`,`di`.`DeliveryPrice` AS `DeliveryPrice`,`di`.`ChargeAmount` AS `ChargeAmount`,`di`.`MinimumQuantity` AS `MinimumQuantity`,`di`.`MaximumQuantity Integer` AS `MaximumQuantity`,cast(`sr`.`MinimumNumberToOrder` * case `sr`.`MinimumOrderUnitType` when 1 then 1 when 2 then `sr`.`NumberOfItemsPerCask` / `sr`.`NumberBunchesPerCask` when 3 then `sr`.`NumberOfItemsPerCask` when 4 then floor(128 * 56 / (`b`.`x_size` * `b`.`y_size`)) * `sr`.`NumberOfItemsPerCask` when 5 then floor(128 * 56 / (`b`.`x_size` * `b`.`y_size`)) * `sr`.`NumberOfItemsPerCask` * `sr`.`NumberOfLayersPerTrolley` end as decimal(10,0)) AS `OrderUnit`,cast(`sr`.`IncrementalOrderableQuantity` * case `sr`.`IncrementalOrderableQuantityType` when 1 then 1 when 2 then `sr`.`NumberOfItemsPerCask` / `sr`.`NumberBunchesPerCask` when 3 then `sr`.`NumberOfItemsPerCask` when 4 then floor(128 * 56 / (`b`.`x_size` * `b`.`y_size`)) * `sr`.`NumberOfItemsPerCask` when 5 then floor(128 * 56 / (`b`.`x_size` * `b`.`y_size`)) * `sr`.`NumberOfItemsPerCask` * `sr`.`NumberOfLayersPerTrolley` end as decimal(10,0)) AS `IncrementalOrderUnit`,`mp`.`isEarlyBird` AS `isEarlyBird`,`v`.`isVNHSupplier` AS `isVNHSupplier`,`igo`.`expenseFk` AS `expenseFk`,`igo`.`intrastatFk` AS `intrastatFk`,`igo`.`originFk` AS `originFk`,ifnull(`idt`.`itemTypeFk`,`igo`.`itemTypeFk`) AS `itemTypeFk` from (((((((((`edi`.`deliveryInformation` `di` join `edi`.`supplyResponse` `sr` on(`sr`.`ID` = `di`.`supplyResponseID`)) left join `edi`.`supplier` `s` on(`s`.`glnAddressCode` = `sr`.`SupplierGLN`)) join `edi`.`bucket` `b` on(`b`.`bucket_id` = `sr`.`EmbalageCode`)) join `edi`.`item` `i` on(`i`.`id` = `sr`.`Item_ArticleCode`)) join `edi`.`marketPlace` `mp` on(`mp`.`id` = `sr`.`MarketPlaceID`)) join `vn`.`floramondoConfig` `fm`) left join `edi`.`item_defaultType` `idt` on(`idt`.`item_id` = `i`.`id`)) join `edi`.`VMPSettings` `v` on(`v`.`VMPID` = `sr`.`vmpID`)) join `edi`.`item_groupToOffer` `igo` on(`igo`.`group_code` = `i`.`group_id`)) where `v`.`isBlocked` = 0 and `s`.`isBanned` = 0 and `sr`.`NumberOfUnits` > 0 and current_timestamp() between `di`.`FirstOrderDateTime` and `di`.`LatestOrderDateTime` and `mp`.`isOffered` = 1 and `di`.`LatestDeliveryDateTime` between cast(`fm`.`nextLanded` as date) and concat(cast(`fm`.`nextLanded` as date),' ',`fm`.`MaxLatestDeliveryHour`) and `sr`.`NumberOfItemsPerCask` > 1 group by `sr`.`ID` having `EmbalageCode` <> 999 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78750,7 +78326,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `mainAccountBank` AS select `e`.`name` AS `name`,`a`.`iban` AS `iban` from ((`hedera`.`mainAccount` `c` join `vn`.`supplierAccount` `a` on((`a`.`id` = `c`.`accountFk`))) join `vn`.`bankEntity` `e` on((`e`.`id` = `a`.`bankEntityFk`))) */; +/*!50001 VIEW `mainAccountBank` AS select `e`.`name` AS `name`,`a`.`iban` AS `iban` from ((`hedera`.`mainAccount` `c` join `vn`.`supplierAccount` `a` on(`a`.`id` = `c`.`accountFk`)) join `vn`.`bankEntity` `e` on(`e`.`id` = `a`.`bankEntityFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78769,7 +78345,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myAddress` AS select `t`.`id` AS `id`,`t`.`clientFk` AS `clientFk`,`t`.`street` AS `street`,`t`.`city` AS `city`,`t`.`postalCode` AS `postalCode`,`t`.`provinceFk` AS `provinceFk`,`t`.`nickname` AS `nickname`,`t`.`isDefaultAddress` AS `isDefaultAddress`,`t`.`isActive` AS `isActive`,`t`.`longitude` AS `longitude`,`t`.`latitude` AS `latitude`,`t`.`agencyModeFk` AS `agencyModeFk` from `vn`.`address` `t` where (`t`.`clientFk` = `account`.`myUser_getId`()) */ +/*!50001 VIEW `myAddress` AS select `t`.`id` AS `id`,`t`.`clientFk` AS `clientFk`,`t`.`street` AS `street`,`t`.`city` AS `city`,`t`.`postalCode` AS `postalCode`,`t`.`provinceFk` AS `provinceFk`,`t`.`nickname` AS `nickname`,`t`.`isDefaultAddress` AS `isDefaultAddress`,`t`.`isActive` AS `isActive`,`t`.`longitude` AS `longitude`,`t`.`latitude` AS `latitude`,`t`.`agencyModeFk` AS `agencyModeFk` from `vn`.`address` `t` where `t`.`clientFk` = `account`.`myUser_getId`() */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -78789,7 +78365,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myBasket` AS select `o`.`id` AS `id`,`o`.`date_make` AS `made`,`o`.`date_send` AS `sent`,`o`.`customer_id` AS `clientFk`,`o`.`delivery_method_id` AS `deliveryMethodFk`,`o`.`agency_id` AS `agencyModeFk`,`o`.`address_id` AS `addressFk`,`o`.`company_id` AS `companyFk`,`o`.`note` AS `notes` from `hedera`.`order` `o` where (`o`.`id` = `MYBASKET_GETID`()) */ +/*!50001 VIEW `myBasket` AS select `o`.`id` AS `id`,`o`.`date_make` AS `made`,`o`.`date_send` AS `sent`,`o`.`customer_id` AS `clientFk`,`o`.`delivery_method_id` AS `deliveryMethodFk`,`o`.`agency_id` AS `agencyModeFk`,`o`.`address_id` AS `addressFk`,`o`.`company_id` AS `companyFk`,`o`.`note` AS `notes` from `hedera`.`order` `o` where `o`.`id` = `MYBASKET_GETID`() */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -78809,7 +78385,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myBasketDefaults` AS select coalesce(`dm`.`code`,`cm`.`code`) AS `deliveryMethod`,coalesce(`ad`.`agencyModeFk`,`oc`.`defaultAgencyFk`) AS `agencyModeFk`,`c`.`defaultAddressFk` AS `addressFk`,`oc`.`defaultAgencyFk` AS `defaultAgencyFk` from ((((((`hedera`.`orderConfig` `oc` join `vn`.`agencyMode` `ca` on((`ca`.`id` = `oc`.`defaultAgencyFk`))) join `vn`.`deliveryMethod` `cm` on((`cm`.`id` = `ca`.`deliveryMethodFk`))) left join `vn`.`client` `c` on((`c`.`id` = `account`.`myUser_getId`()))) left join `vn`.`address` `ad` on((`ad`.`id` = `c`.`defaultAddressFk`))) left join `vn`.`agencyMode` `a` on((`a`.`id` = `ad`.`agencyModeFk`))) left join `vn`.`deliveryMethod` `dm` on((`dm`.`id` = `a`.`deliveryMethodFk`))) */; +/*!50001 VIEW `myBasketDefaults` AS select coalesce(`dm`.`code`,`cm`.`code`) AS `deliveryMethod`,coalesce(`ad`.`agencyModeFk`,`oc`.`defaultAgencyFk`) AS `agencyModeFk`,`c`.`defaultAddressFk` AS `addressFk`,`oc`.`defaultAgencyFk` AS `defaultAgencyFk` from ((((((`hedera`.`orderConfig` `oc` join `vn`.`agencyMode` `ca` on(`ca`.`id` = `oc`.`defaultAgencyFk`)) join `vn`.`deliveryMethod` `cm` on(`cm`.`id` = `ca`.`deliveryMethodFk`)) left join `vn`.`client` `c` on(`c`.`id` = `account`.`myUser_getId`())) left join `vn`.`address` `ad` on(`ad`.`id` = `c`.`defaultAddressFk`)) left join `vn`.`agencyMode` `a` on(`a`.`id` = `ad`.`agencyModeFk`)) left join `vn`.`deliveryMethod` `dm` on(`dm`.`id` = `a`.`deliveryMethodFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78828,7 +78404,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myBasketItem` AS select `r`.`id` AS `id`,`r`.`orderFk` AS `orderFk`,`r`.`warehouseFk` AS `warehouseFk`,`r`.`itemFk` AS `itemFk`,`r`.`amount` AS `amount`,`r`.`price` AS `price` from `hedera`.`orderRow` `r` where (`r`.`orderFk` = `MYBASKET_GETID`()) */ +/*!50001 VIEW `myBasketItem` AS select `r`.`id` AS `id`,`r`.`orderFk` AS `orderFk`,`r`.`warehouseFk` AS `warehouseFk`,`r`.`itemFk` AS `itemFk`,`r`.`amount` AS `amount`,`r`.`price` AS `price` from `hedera`.`orderRow` `r` where `r`.`orderFk` = `MYBASKET_GETID`() */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -78848,7 +78424,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myClient` AS select `c`.`id` AS `id`,`c`.`isToBeMailed` AS `isToBeMailed`,`c`.`defaultAddressFk` AS `defaultAddressFk`,`c`.`credit` AS `credit` from `vn`.`client` `c` where (`c`.`id` = `account`.`myUser_getId`()) */ +/*!50001 VIEW `myClient` AS select `c`.`id` AS `id`,`c`.`isToBeMailed` AS `isToBeMailed`,`c`.`defaultAddressFk` AS `defaultAddressFk`,`c`.`credit` AS `credit` from `vn`.`client` `c` where `c`.`id` = `account`.`myUser_getId`() */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -78868,7 +78444,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myInvoice` AS select `i`.`id` AS `id`,`i`.`ref` AS `ref`,`i`.`issued` AS `issued`,`i`.`amount` AS `amount`,`i`.`hasPdf` AS `hasPdf` from `vn`.`invoiceOut` `i` where (`i`.`clientFk` = `account`.`myUser_getId`()) */; +/*!50001 VIEW `myInvoice` AS select `i`.`id` AS `id`,`i`.`ref` AS `ref`,`i`.`issued` AS `issued`,`i`.`amount` AS `amount`,`i`.`hasPdf` AS `hasPdf` from `vn`.`invoiceOut` `i` where `i`.`clientFk` = `account`.`myUser_getId`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78887,7 +78463,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myMenu` AS select `t`.`id` AS `id`,`t`.`path` AS `path`,`t`.`description` AS `description`,`t`.`parentFk` AS `parentFk` from (`hedera`.`menu` `t` join `account`.`myRole` `r` on((`r`.`id` = `t`.`roleFk`))) order by `t`.`parentFk`,`t`.`displayOrder`,`t`.`id` */; +/*!50001 VIEW `myMenu` AS select `t`.`id` AS `id`,`t`.`path` AS `path`,`t`.`description` AS `description`,`t`.`parentFk` AS `parentFk` from (`hedera`.`menu` `t` join `account`.`myRole` `r` on(`r`.`id` = `t`.`roleFk`)) order by `t`.`parentFk`,`t`.`displayOrder`,`t`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78906,7 +78482,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myOrder` AS select `o`.`id` AS `id`,`o`.`date_send` AS `landed`,`o`.`customer_id` AS `clientFk`,`o`.`delivery_method_id` AS `deliveryMethodFk`,`o`.`agency_id` AS `agencyModeFk`,`o`.`address_id` AS `addressFk`,`o`.`company_id` AS `companyFk`,`o`.`note` AS `note`,`o`.`source_app` AS `sourceApp`,`o`.`confirmed` AS `isConfirmed`,`o`.`date_make` AS `created`,`o`.`first_row_stamp` AS `firstRowStamp`,`o`.`confirm_date` AS `confirmed` from `hedera`.`order` `o` where (`o`.`customer_id` = `account`.`myUser_getId`()) */; +/*!50001 VIEW `myOrder` AS select `o`.`id` AS `id`,`o`.`date_send` AS `landed`,`o`.`customer_id` AS `clientFk`,`o`.`delivery_method_id` AS `deliveryMethodFk`,`o`.`agency_id` AS `agencyModeFk`,`o`.`address_id` AS `addressFk`,`o`.`company_id` AS `companyFk`,`o`.`note` AS `note`,`o`.`source_app` AS `sourceApp`,`o`.`confirmed` AS `isConfirmed`,`o`.`date_make` AS `created`,`o`.`first_row_stamp` AS `firstRowStamp`,`o`.`confirm_date` AS `confirmed` from `hedera`.`order` `o` where `o`.`customer_id` = `account`.`myUser_getId`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78925,7 +78501,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myOrderRow` AS select `orw`.`id` AS `id`,`orw`.`order_id` AS `Fk`,`orw`.`item_id` AS `itemFk`,`orw`.`warehouse_id` AS `warehouseFk`,`orw`.`shipment` AS `shipped`,`orw`.`amount` AS `amount`,`orw`.`price` AS `price`,`orw`.`rate` AS `rate`,`orw`.`created` AS `created`,`orw`.`Id_Movimiento` AS `saleFk` from (`hedera`.`order_row` `orw` join `hedera`.`myOrder` `o` on((`o`.`id` = `orw`.`order_id`))) */ +/*!50001 VIEW `myOrderRow` AS select `orw`.`id` AS `id`,`orw`.`order_id` AS `Fk`,`orw`.`item_id` AS `itemFk`,`orw`.`warehouse_id` AS `warehouseFk`,`orw`.`shipment` AS `shipped`,`orw`.`amount` AS `amount`,`orw`.`price` AS `price`,`orw`.`rate` AS `rate`,`orw`.`created` AS `created`,`orw`.`Id_Movimiento` AS `saleFk` from (`hedera`.`order_row` `orw` join `hedera`.`myOrder` `o` on(`o`.`id` = `orw`.`order_id`)) */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -78945,7 +78521,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myOrderTicket` AS select `o`.`id` AS `orderFk`,`ot`.`ticketFk` AS `ticketFk` from (`hedera`.`myOrder` `o` join `hedera`.`orderTicket` `ot` on((`ot`.`orderFk` = `o`.`id`))) */; +/*!50001 VIEW `myOrderTicket` AS select `o`.`id` AS `orderFk`,`ot`.`ticketFk` AS `ticketFk` from (`hedera`.`myOrder` `o` join `hedera`.`orderTicket` `ot` on(`ot`.`orderFk` = `o`.`id`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78964,7 +78540,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myTicket` AS select `t`.`id` AS `id`,`t`.`clientFk` AS `clientFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`t`.`nickname` AS `nickname`,`t`.`agencyModeFk` AS `agencyModeFk`,`t`.`refFk` AS `refFk`,`t`.`addressFk` AS `addressFk`,`t`.`location` AS `location`,`t`.`companyFk` AS `companyFk` from `vn`.`ticket` `t` where (`t`.`clientFk` = `account`.`myUser_getId`()) */; +/*!50001 VIEW `myTicket` AS select `t`.`id` AS `id`,`t`.`clientFk` AS `clientFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`t`.`nickname` AS `nickname`,`t`.`agencyModeFk` AS `agencyModeFk`,`t`.`refFk` AS `refFk`,`t`.`addressFk` AS `addressFk`,`t`.`location` AS `location`,`t`.`companyFk` AS `companyFk` from `vn`.`ticket` `t` where `t`.`clientFk` = `account`.`myUser_getId`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78983,7 +78559,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myTicketRow` AS select `s`.`id` AS `id`,`s`.`itemFk` AS `itemFk`,`s`.`ticketFk` AS `ticketFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`s`.`reserved` AS `reserved`,`s`.`isPicked` AS `isPicked` from (`vn`.`sale` `s` join `hedera`.`myTicket` `t` on((`s`.`ticketFk` = `t`.`id`))) */ +/*!50001 VIEW `myTicketRow` AS select `s`.`id` AS `id`,`s`.`itemFk` AS `itemFk`,`s`.`ticketFk` AS `ticketFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`s`.`reserved` AS `reserved`,`s`.`isPicked` AS `isPicked` from (`vn`.`sale` `s` join `hedera`.`myTicket` `t` on(`s`.`ticketFk` = `t`.`id`)) */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -79003,7 +78579,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myTicketService` AS select `s`.`id` AS `id`,`s`.`description` AS `description`,`s`.`quantity` AS `quantity`,`s`.`price` AS `price`,`s`.`taxClassFk` AS `taxClassFk`,`s`.`ticketFk` AS `ticketFk`,`s`.`ticketServiceTypeFk` AS `ticketServiceTypeFk` from (`vn`.`ticketService` `s` join `hedera`.`myTicket` `t` on((`s`.`ticketFk` = `t`.`id`))) */ +/*!50001 VIEW `myTicketService` AS select `s`.`id` AS `id`,`s`.`description` AS `description`,`s`.`quantity` AS `quantity`,`s`.`price` AS `price`,`s`.`taxClassFk` AS `taxClassFk`,`s`.`ticketFk` AS `ticketFk`,`s`.`ticketServiceTypeFk` AS `ticketServiceTypeFk` from (`vn`.`ticketService` `s` join `hedera`.`myTicket` `t` on(`s`.`ticketFk` = `t`.`id`)) */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -79023,7 +78599,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myTicketState` AS select `t`.`id` AS `id`,`t`.`clientFk` AS `clientFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`t`.`nickname` AS `nickname`,`t`.`agencyModeFk` AS `agencyModeFk`,`t`.`refFk` AS `refFk`,`t`.`addressFk` AS `addressFk`,`t`.`location` AS `location`,`t`.`companyFk` AS `companyFk`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`code` AS `code` from (`vn`.`ticket` `t` left join `vn`.`ticketState` `ts` on((`ts`.`ticketFk` = `t`.`id`))) where (`t`.`clientFk` = `account`.`myUser_getId`()) */; +/*!50001 VIEW `myTicketState` AS select `t`.`id` AS `id`,`t`.`clientFk` AS `clientFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`t`.`nickname` AS `nickname`,`t`.`agencyModeFk` AS `agencyModeFk`,`t`.`refFk` AS `refFk`,`t`.`addressFk` AS `addressFk`,`t`.`location` AS `location`,`t`.`companyFk` AS `companyFk`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`code` AS `code` from (`vn`.`ticket` `t` left join `vn`.`ticketState` `ts` on(`ts`.`ticketFk` = `t`.`id`)) where `t`.`clientFk` = `account`.`myUser_getId`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79042,7 +78618,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `myTpvTransaction` AS select `t`.`id` AS `id`,`t`.`merchantFk` AS `merchantFk`,`t`.`clientFk` AS `clientFk`,`t`.`receiptFk` AS `receiptFk`,`t`.`amount` AS `amount`,`t`.`response` AS `response`,`t`.`status` AS `status`,`t`.`created` AS `created` from `hedera`.`tpvTransaction` `t` where (`t`.`clientFk` = `account`.`myUser_getId`()) */; +/*!50001 VIEW `myTpvTransaction` AS select `t`.`id` AS `id`,`t`.`merchantFk` AS `merchantFk`,`t`.`clientFk` AS `clientFk`,`t`.`receiptFk` AS `receiptFk`,`t`.`amount` AS `amount`,`t`.`response` AS `response`,`t`.`status` AS `status`,`t`.`created` AS `created` from `hedera`.`tpvTransaction` `t` where `t`.`clientFk` = `account`.`myUser_getId`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79187,7 +78763,7 @@ USE `pbx`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `queueConf` AS select `q`.`name` AS `name`,`c`.`strategy` AS `strategy`,`c`.`timeout` AS `timeout`,`c`.`retry` AS `retry`,`c`.`weight` AS `weight`,`c`.`maxLen` AS `maxlen`,`c`.`ringInUse` AS `ringinuse` from (`queue` `q` join `queueConfig` `c` on((`q`.`config` = `c`.`id`))) */; +/*!50001 VIEW `queueConf` AS select `q`.`name` AS `name`,`c`.`strategy` AS `strategy`,`c`.`timeout` AS `timeout`,`c`.`retry` AS `retry`,`c`.`weight` AS `weight`,`c`.`maxLen` AS `maxlen`,`c`.`ringInUse` AS `ringinuse` from (`queue` `q` join `queueConfig` `c` on(`q`.`config` = `c`.`id`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79225,7 +78801,7 @@ USE `pbx`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `sipConf` AS select `s`.`user_id` AS `id`,`s`.`extension` AS `name`,NULL AS `callbackextension`,`s`.`md5Secret` AS `md5secret`,`u`.`nickname` AS `callerid`,`c`.`host` AS `host`,`c`.`deny` AS `deny`,`c`.`permit` AS `permit`,`c`.`type` AS `type`,`c`.`context` AS `context`,`c`.`incomingLimit` AS `incominglimit`,`c`.`pickupGroup` AS `pickupgroup`,`c`.`careInvite` AS `careinvite`,`c`.`insecure` AS `insecure`,`c`.`transport` AS `transport`,`c`.`nat` AS `nat`,`r`.`ipAddr` AS `ipaddr`,`r`.`regSeconds` AS `regseconds`,`r`.`port` AS `port`,`r`.`defaultUser` AS `defaultuser`,`r`.`userAgent` AS `useragent`,`r`.`lastMs` AS `lastms`,`r`.`fullContact` AS `fullcontact`,`r`.`regServer` AS `regserver` from (((`pbx`.`sip` `s` join `account`.`user` `u` on((`u`.`id` = `s`.`user_id`))) left join `pbx`.`sipReg` `r` on((`s`.`user_id` = `r`.`userId`))) join `pbx`.`sipConfig` `c`) */; +/*!50001 VIEW `sipConf` AS select `s`.`user_id` AS `id`,`s`.`extension` AS `name`,NULL AS `callbackextension`,`s`.`md5Secret` AS `md5secret`,`u`.`nickname` AS `callerid`,`c`.`host` AS `host`,`c`.`deny` AS `deny`,`c`.`permit` AS `permit`,`c`.`type` AS `type`,`c`.`context` AS `context`,`c`.`incomingLimit` AS `incominglimit`,`c`.`pickupGroup` AS `pickupgroup`,`c`.`careInvite` AS `careinvite`,`c`.`insecure` AS `insecure`,`c`.`transport` AS `transport`,`c`.`nat` AS `nat`,`r`.`ipAddr` AS `ipaddr`,`r`.`regSeconds` AS `regseconds`,`r`.`port` AS `port`,`r`.`defaultUser` AS `defaultuser`,`r`.`userAgent` AS `useragent`,`r`.`lastMs` AS `lastms`,`r`.`fullContact` AS `fullcontact`,`r`.`regServer` AS `regserver` from (((`pbx`.`sip` `s` join `account`.`user` `u` on(`u`.`id` = `s`.`user_id`)) left join `pbx`.`sipReg` `r` on(`s`.`user_id` = `r`.`userId`)) join `pbx`.`sipConfig` `c`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79247,10 +78823,10 @@ USE `postgresql`; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = utf8mb4 */; /*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_unicode_ci */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `calendar_employee` AS select `ce`.`id` AS `id`,`ce`.`businessFk` AS `business_id`,`ce`.`dayOffTypeFk` AS `calendar_state_id`,`ce`.`dated` AS `date` from `vn`.`calendar` `ce` */; +/*!50001 VIEW `calendar_employee` AS select `ce`.`id` AS `id`,`ce`.`businessFk` AS `businessFk`,`ce`.`dayOffTypeFk` AS `calendar_state_id`,`ce`.`dated` AS `date` from `vn`.`calendar` `ce` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79275,7 +78851,7 @@ USE `sage`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `clientLastTwoMonths` AS select `vn`.`invoiceOut`.`clientFk` AS `clientFk`,`vn`.`invoiceOut`.`companyFk` AS `companyFk` from `vn`.`invoiceOut` where (`vn`.`invoiceOut`.`issued` > (curdate() - interval 2 month)) union select `vn`.`receipt`.`clientFk` AS `clientFk`,`vn`.`receipt`.`companyFk` AS `companyFk` from `vn`.`receipt` where (`vn`.`receipt`.`payed` > (curdate() - interval 2 month)) */; +/*!50001 VIEW `clientLastTwoMonths` AS select `vn`.`invoiceOut`.`clientFk` AS `clientFk`,`vn`.`invoiceOut`.`companyFk` AS `companyFk` from `vn`.`invoiceOut` where `vn`.`invoiceOut`.`issued` > `util`.`VN_CURDATE`() - interval 2 month union select `vn`.`receipt`.`clientFk` AS `clientFk`,`vn`.`receipt`.`companyFk` AS `companyFk` from `vn`.`receipt` where `vn`.`receipt`.`payed` > `util`.`VN_CURDATE`() - interval 2 month */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79294,7 +78870,7 @@ USE `sage`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `invoiceInList` AS select `vn`.`invoiceIn`.`id` AS `id`,`vn`.`invoiceIn`.`supplierRef` AS `supplierRef`,`vn`.`invoiceIn`.`serial` AS `serial`,`vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,`vn`.`invoiceIn`.`issued` AS `issued`,if((`vn`.`invoiceIn`.`expenceFkDeductible` > 0),1,0) AS `isVatDeductible`,`vn`.`invoiceIn`.`serialNumber` AS `serialNumber` from `vn`.`invoiceIn` where (`vn`.`invoiceIn`.`issued` >= (date_format(curdate(),'%Y-01-01') + interval -(1) year)) union all select `vn`.`dua`.`id` AS `id`,`vn`.`dua`.`code` AS `code`,'D' AS `D`,`c`.`id` AS `supplierFk`,`vn`.`dua`.`issued` AS `issued`,0 AS `FALSE`,`vn`.`dua`.`id` AS `serialNumber` from (`vn`.`dua` join `vn`.`company` `c` on((`c`.`code` = 'VNL'))) */; +/*!50001 VIEW `invoiceInList` AS select `vn`.`invoiceIn`.`id` AS `id`,`vn`.`invoiceIn`.`supplierRef` AS `supplierRef`,`vn`.`invoiceIn`.`serial` AS `serial`,`vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,`vn`.`invoiceIn`.`issued` AS `issued`,if(`vn`.`invoiceIn`.`expenceFkDeductible` > 0,1,0) AS `isVatDeductible`,`vn`.`invoiceIn`.`serialNumber` AS `serialNumber` from `vn`.`invoiceIn` where `vn`.`invoiceIn`.`issued` >= date_format(`util`.`VN_CURDATE`(),'%Y-01-01') + interval -1 year union all select `vn`.`dua`.`id` AS `id`,`vn`.`dua`.`code` AS `code`,'D' AS `D`,`c`.`id` AS `supplierFk`,`vn`.`dua`.`issued` AS `issued`,0 AS `FALSE`,`vn`.`dua`.`id` AS `serialNumber` from (`vn`.`dua` join `vn`.`company` `c` on(`c`.`code` = 'VNL')) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79313,7 +78889,7 @@ USE `sage`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `supplierLastThreeMonths` AS select `vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,`vn`.`invoiceIn`.`companyFk` AS `companyFk` from `vn`.`invoiceIn` where (`vn`.`invoiceIn`.`issued` > (curdate() - interval 3 month)) union select `vn`.`payment`.`supplierFk` AS `supplierFk`,`vn`.`payment`.`companyFk` AS `companyFk` from `vn`.`payment` where (`vn`.`payment`.`received` > (curdate() + interval -(3) month)) */; +/*!50001 VIEW `supplierLastThreeMonths` AS select `vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,`vn`.`invoiceIn`.`companyFk` AS `companyFk` from `vn`.`invoiceIn` where `vn`.`invoiceIn`.`issued` > `util`.`VN_CURDATE`() - interval 3 month union select `vn`.`payment`.`supplierFk` AS `supplierFk`,`vn`.`payment`.`companyFk` AS `companyFk` from `vn`.`payment` where `vn`.`payment`.`received` > `util`.`VN_CURDATE`() + interval -3 month */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79376,7 +78952,7 @@ USE `salix`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `RoleMapping` AS select ((`u`.`id` * 1000) + `r`.`inheritsFrom`) AS `id`,'USER' AS `principalType`,`u`.`id` AS `principalId`,`r`.`inheritsFrom` AS `roleId` from (`account`.`user` `u` join `account`.`roleRole` `r` on((`r`.`role` = `u`.`role`))) */; +/*!50001 VIEW `RoleMapping` AS select `u`.`id` * 1000 + `r`.`inheritsFrom` AS `id`,'USER' AS `principalType`,`u`.`id` AS `principalId`,`r`.`inheritsFrom` AS `roleId` from (`account`.`user` `u` join `account`.`roleRole` `r` on(`r`.`role` = `u`.`role`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79412,6 +78988,25 @@ USE `stock`; USE `util`; +-- +-- Final view structure for view `eventLogGrouped` +-- + +/*!50001 DROP TABLE IF EXISTS `eventLogGrouped`*/; +/*!50001 DROP VIEW IF EXISTS `eventLogGrouped`*/; +/*!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 = utf8mb3 */; +/*!50001 SET character_set_results = utf8mb3 */; +/*!50001 SET collation_connection = utf8mb3_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `eventLogGrouped` AS select max(`t`.`date`) AS `lastHappened`,count(0) AS `nErrors`,`t`.`event` AS `event`,`t`.`error` AS `error` from `eventLog` `t` group by `t`.`event`,`t`.`error` order by max(`t`.`date`) desc */; +/*!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: `vn` -- @@ -79432,26 +79027,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `NewView` AS select `c`.`id` AS `clientFk`,max(`t`.`shipped`) AS `lastShipped`,`pc`.`notBuyingMonths` AS `notBuyingMonths` from ((`client` `c` join `productionConfig` `pc`) left join `ticket` `t` on(((`c`.`id` = `t`.`clientFk`) and (`t`.`shipped` < (curdate() + interval -(`pc`.`rookieDays`) day))))) group by `c`.`id` having (isnull(`lastShipped`) or (`lastShipped` < (curdate() + interval -(`notBuyingMonths`) month))) */; -/*!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 `__coolerPathDetail` --- - -/*!50001 DROP TABLE IF EXISTS `__coolerPathDetail`*/; -/*!50001 DROP VIEW IF EXISTS `__coolerPathDetail`*/; -/*!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_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `__coolerPathDetail` AS select `c`.`cooler_path_detail_id` AS `id`,`c`.`cooler_path_id` AS `coolerPathFk`,`c`.`pasillo` AS `hallway` from `vn2008`.`cooler_path_detail` `c` */; +/*!50001 VIEW `NewView` AS select `c`.`id` AS `clientFk`,max(`t`.`shipped`) AS `lastShipped`,`pc`.`notBuyingMonths` AS `notBuyingMonths` from ((`client` `c` join `productionConfig` `pc`) left join `ticket` `t` on(`c`.`id` = `t`.`clientFk` and `t`.`shipped` < `util`.`VN_CURDATE`() + interval -`pc`.`rookieDays` day)) group by `c`.`id` having `lastShipped` is null or `lastShipped` < `util`.`VN_CURDATE`() + interval -`notBuyingMonths` month */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79465,9 +79041,9 @@ 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 = utf8mb3 */; +/*!50001 SET character_set_results = utf8mb3 */; +/*!50001 SET collation_connection = utf8mb3_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `agencyTerm` AS select `sat`.`agencyFk` AS `agencyFk`,`sat`.`minimumPackages` AS `minimumPackages`,`sat`.`kmPrice` AS `kmPrice`,`sat`.`packagePrice` AS `packagePrice`,`sat`.`routePrice` AS `routePrice`,`sat`.`minimumKm` AS `minimumKm`,`sat`.`minimumM3` AS `minimumM3`,`sat`.`m3Price` AS `m3Price` from `supplierAgencyTerm` `sat` */; @@ -79508,7 +79084,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `awbVolume` AS select `d`.`awbFk` AS `awbFk`,(((`b`.`stickers` * `i`.`density`) * if((`p`.`volume` > 0),`p`.`volume`,((`p`.`width` * `p`.`depth`) * if((`p`.`height` = 0),(`i`.`size` + 10),`p`.`height`)))) / 167000) AS `volume`,`b`.`id` AS `buyFk` from (((((((`buy` `b` join `item` `i` on((`b`.`itemFk` = `i`.`id`))) join `itemType` `it` on((`i`.`typeFk` = `it`.`id`))) join `packaging` `p` on((`p`.`id` = `b`.`packageFk`))) join `entry` `e` on((`b`.`entryFk` = `e`.`id`))) join `travel` `t` on((`t`.`id` = `e`.`travelFk`))) join `duaEntry` `de` on((`de`.`entryFk` = `e`.`id`))) join `dua` `d` on((`d`.`id` = `de`.`duaFk`))) where (`t`.`shipped` > makedate((year(curdate()) - 1),1)) */; +/*!50001 VIEW `awbVolume` AS select `d`.`awbFk` AS `awbFk`,`b`.`stickers` * `i`.`density` * if(`p`.`volume` > 0,`p`.`volume`,`p`.`width` * `p`.`depth` * if(`p`.`height` = 0,`i`.`size` + 10,`p`.`height`)) / (`vc`.`aerealVolumetricDensity` * 1000) AS `volume`,`b`.`id` AS `buyFk` from ((((((((`buy` `b` join `item` `i` on(`b`.`itemFk` = `i`.`id`)) join `itemType` `it` on(`i`.`typeFk` = `it`.`id`)) join `packaging` `p` on(`p`.`id` = `b`.`packageFk`)) join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`t`.`id` = `e`.`travelFk`)) join `duaEntry` `de` on(`de`.`entryFk` = `e`.`id`)) join `dua` `d` on(`d`.`id` = `de`.`duaFk`)) join `volumeConfig` `vc`) where `t`.`shipped` > makedate(year(`util`.`VN_CURDATE`()) - 1,1) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79532,25 +79108,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `bankPolicy` --- - -/*!50001 DROP TABLE IF EXISTS `bankPolicy`*/; -/*!50001 DROP VIEW IF EXISTS `bankPolicy`*/; -/*!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_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `bankPolicy` AS select `bp`.`poliza_id` AS `id`,`bp`.`referencia` AS `ref`,`bp`.`importe` AS `amount`,`bp`.`com_dispuesto` AS `balanceInterestDrawn`,`bp`.`com_no_dispuesto` AS `commissionAvailableBalances`,`bp`.`com_anual` AS `openingCommission`,`bp`.`apertura` AS `started`,`bp`.`cierre` AS `ended`,`bp`.`Id_Banco` AS `bankFk`,`bp`.`empresa_id` AS `companyFk`,`bp`.`supplierFk` AS `supplierFk`,`bp`.`description` AS `description`,`bp`.`hasGuarantee` AS `hasGuarantee`,`bp`.`dmsFk` AS `dmsFk`,`bp`.`notaryFk` AS `notaryFk`,`bp`.`currencyFk` AS `currencyFk`,`bp`.`amortizationTypeFk` AS `amortizationTypeFk`,`bp`.`periodicityTypeFk` AS `periodicityTypeFk`,`bp`.`insuranceExpired` AS `insuranceExpired` from `vn2008`.`Bancos_poliza` `bp` order by `bp`.`poliza_id` desc */; -/*!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 `businessCalendar` -- @@ -79565,7 +79122,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `businessCalendar` AS select `ce`.`id` AS `id`,`ce`.`business_id` AS `businessFk`,`ce`.`calendar_state_id` AS `absenceTypeFk`,`ce`.`date` AS `dated` from `postgresql`.`calendar_employee` `ce` */; +/*!50001 VIEW `businessCalendar` AS select `ce`.`id` AS `id`,`ce`.`businessFk` AS `businessFk`,`ce`.`calendar_state_id` AS `absenceTypeFk`,`ce`.`date` AS `dated` from `postgresql`.`calendar_employee` `ce` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79584,7 +79141,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `buyer` AS select distinct `u`.`id` AS `userFk`,`u`.`nickname` AS `nickname` from (`account`.`user` `u` join `vn`.`itemType` `it` on((`it`.`workerFk` = `u`.`id`))) where `u`.`active` order by `u`.`nickname` */; +/*!50001 VIEW `buyer` AS select distinct `u`.`id` AS `userFk`,`u`.`nickname` AS `nickname` from (`account`.`user` `u` join `vn`.`itemType` `it` on(`it`.`workerFk` = `u`.`id`)) where `u`.`active` <> 0 order by `u`.`nickname` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79603,7 +79160,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `buyerSales` AS select `v`.`importe` AS `importe`,`w`.`code` AS `comprador`,`t`.`year` AS `año`,`t`.`week` AS `semana` from (((`bs`.`ventas` `v` join `vn`.`time` `t` on((`t`.`dated` = `v`.`fecha`))) join `vn`.`itemType` `it` on((`it`.`id` = `v`.`tipo_id`))) join `vn`.`worker` `w` on((`w`.`id` = `it`.`workerFk`))) */; +/*!50001 VIEW `buyerSales` AS select `v`.`importe` AS `importe`,`w`.`code` AS `comprador`,`t`.`year` AS `año`,`t`.`week` AS `semana` from (((`bs`.`ventas` `v` join `vn`.`time` `t` on(`t`.`dated` = `v`.`fecha`)) join `vn`.`itemType` `it` on(`it`.`id` = `v`.`tipo_id`)) join `vn`.`worker` `w` on(`w`.`id` = `it`.`workerFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79622,7 +79179,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `clientLost` AS select `c`.`id` AS `clientFk`,max(`t`.`shipped`) AS `lastShipped`,`pc`.`notBuyingMonths` AS `notBuyingMonths` from ((`client` `c` join `productionConfig` `pc`) left join `ticket` `t` on(((`c`.`id` = `t`.`clientFk`) and (`t`.`shipped` < (curdate() + interval -(`pc`.`rookieDays`) day))))) group by `c`.`id` having (isnull(`lastShipped`) or (`lastShipped` < (curdate() + interval -(`notBuyingMonths`) month))) */; +/*!50001 VIEW `clientLost` AS select `c`.`id` AS `clientFk`,max(`t`.`shipped`) AS `lastShipped`,`pc`.`notBuyingMonths` AS `notBuyingMonths` from ((`client` `c` join `productionConfig` `pc`) left join `ticket` `t` on(`c`.`id` = `t`.`clientFk` and `t`.`shipped` < `util`.`VN_CURDATE`() + interval -`pc`.`rookieDays` day)) group by `c`.`id` having `lastShipped` is null or `lastShipped` < `util`.`VN_CURDATE`() + interval -`notBuyingMonths` month */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79641,7 +79198,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` 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 VIEW `clientPhoneBook` AS select `c`.`id` AS `clientFk`,trim(`c`.`phone`) AS `phone` from `client` `c` where `c`.`phone` <> 0 and `c`.`isActive` <> 0 union select `c`.`id` AS `clientFk`,trim(`c`.`mobile`) AS `phone` from `client` `c` where `c`.`mobile` <> 0 and `c`.`isActive` <> 0 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` <> 0 and `c`.`isActive` <> 0 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` <> 0 and `c`.`isActive` <> 0 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` <> 0 and `c`.`isActive` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79660,45 +79217,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `cmr_list` AS select `cmr`.`id` AS `cmrFk`,`cmr`.`ticketFk` AS `ticketFk`,`cmr`.`truckPlate` AS `truckPlate`,`cmr`.`observations` AS `observations`,`cmr`.`senderInstruccions` AS `senderInstruccions`,`cmr`.`paymentInstruccions` AS `paymentInstruccions`,`cmr`.`specialAgreements` AS `specialAgreements`,`cmr`.`created` AS `created`,`cmr`.`packagesList` AS `packagesList`,`aTo`.`nickname` AS `clientName`,`aTo`.`postalCode` AS `clientPostalCode`,`aTo`.`street` AS `clientStreet`,`aTo`.`city` AS `clientCity`,`pTo`.`name` AS `clientProvince`,`cTo`.`country` AS `clientCountry`,`su`.`name` AS `companyName`,`su`.`street` AS `companyStreet`,`su`.`postCode` AS `companyPostCode`,`su`.`city` AS `companyCity`,`cSu`.`country` AS `companyCountry`,concat(`aFrom`.`street`,' ',`aFrom`.`postalCode`,' ',`aFrom`.`city`,' (',`cFrom`.`country`,')') AS `warehouseAddress`,`cmr`.`created` AS `shipped`,`aTo`.`nickname` AS `clientOficialName`,`cmr`.`supplierFk` AS `supplierFk`,`aSu`.`name` AS `carrierName`,`aSu`.`street` AS `carrierStreet`,`aSu`.`postCode` AS `carrierPostCode`,`aSu`.`city` AS `carrierCity`,`cAs`.`country` AS `carrierCountry`,ifnull(`aTo`.`phone`,`client`.`phone`) AS `phone`,ifnull(`aTo`.`mobile`,`client`.`mobile`) AS `mobile`,`aTo`.`id` AS `addressFk`,`c`.`stamp` AS `stamp`,`cmr`.`merchandiseDetail` AS `merchandiseDetail` from ((((((((((((`cmr` left join `address` `aTo` on((`aTo`.`id` = `cmr`.`addressToFk`))) left join `province` `pTo` on((`pTo`.`id` = `aTo`.`provinceFk`))) left join `country` `cTo` on((`cTo`.`id` = `pTo`.`countryFk`))) left join `client` on((`client`.`id` = `aTo`.`clientFk`))) left join `supplier` `su` on((`su`.`id` = `cmr`.`companyFk`))) left join `country` `cSu` on((`cSu`.`id` = `su`.`countryFk`))) left join `address` `aFrom` on((`aFrom`.`id` = `cmr`.`addressFromFk`))) left join `province` `pFrom` on((`pFrom`.`id` = `aFrom`.`provinceFk`))) left join `country` `cFrom` on((`cFrom`.`id` = `pFrom`.`countryFk`))) left join `supplier` `aSu` on((`aSu`.`id` = `cmr`.`supplierFk`))) left join `country` `cAs` on((`cAs`.`id` = `aSu`.`countryFk`))) join `company` `c` on((`c`.`id` = `cmr`.`companyFk`))) */; -/*!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 `collectionSmartTag` --- - -/*!50001 DROP TABLE IF EXISTS `collectionSmartTag`*/; -/*!50001 DROP VIEW IF EXISTS `collectionSmartTag`*/; -/*!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_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `collectionSmartTag` AS select `st`.`code` AS `code`,`tc`.`ticketFk` AS `ticketFk`,`tc`.`level` AS `level`,`tc`.`wagon` AS `wagon`,`st`.`shelvingFk` AS `shelvingFk`,`tc`.`collectionFk` AS `collectionFk`,`am`.`name` AS `agencyFk`,`t`.`clientFk` AS `clientFk` from (((((`ticketCollection` `tc` join `smartTag` `st` on((`st`.`code` = (`tc`.`smartTagFk` collate utf8_general_ci)))) join `ticket` `t` on((`t`.`id` = `tc`.`ticketFk`))) join `collection` `c` on((`c`.`id` = `tc`.`collectionFk`))) join `worker` `w` on((`w`.`id` = `c`.`workerFk`))) join `agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) */; -/*!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 `collectionSmartTag2` --- - -/*!50001 DROP TABLE IF EXISTS `collectionSmartTag2`*/; -/*!50001 DROP VIEW IF EXISTS `collectionSmartTag2`*/; -/*!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_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `collectionSmartTag2` AS select `st`.`code` AS `code`,`tc`.`ticketFk` AS `ticketFk`,`tc`.`level` AS `level`,`tc`.`wagon` AS `wagon`,`st`.`shelvingFk` AS `shelvingFk`,`tc`.`collectionFk` AS `collectionFk`,`am`.`name` AS `agencyFk`,`t`.`clientFk` AS `clientFk`,`u`.`name` AS `worker`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed` from ((((((`vn`.`ticketCollection` `tc` join `vn`.`smartTag` `st` on((`st`.`code` = (`tc`.`smartTagFk` collate utf8_general_ci)))) join `vn`.`ticket` `t` on((`t`.`id` = `tc`.`ticketFk`))) join `vn`.`collection` `c` on((`c`.`id` = `tc`.`collectionFk`))) join `vn`.`worker` `w` on((`w`.`id` = `c`.`workerFk`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `account`.`user` `u` on((`u`.`id` = `w`.`id`))) */; +/*!50001 VIEW `cmr_list` AS select `cmr`.`id` AS `cmrFk`,`cmr`.`ticketFk` AS `ticketFk`,`cmr`.`truckPlate` AS `truckPlate`,`cmr`.`observations` AS `observations`,`cmr`.`senderInstruccions` AS `senderInstruccions`,`cmr`.`paymentInstruccions` AS `paymentInstruccions`,`cmr`.`specialAgreements` AS `specialAgreements`,`cmr`.`created` AS `created`,`cmr`.`packagesList` AS `packagesList`,`aTo`.`nickname` AS `clientName`,`aTo`.`postalCode` AS `clientPostalCode`,`aTo`.`street` AS `clientStreet`,`aTo`.`city` AS `clientCity`,`pTo`.`name` AS `clientProvince`,`cTo`.`country` AS `clientCountry`,`su`.`name` AS `companyName`,`su`.`street` AS `companyStreet`,`su`.`postCode` AS `companyPostCode`,`su`.`city` AS `companyCity`,`cSu`.`country` AS `companyCountry`,concat(`aFrom`.`street`,' ',`aFrom`.`postalCode`,' ',`aFrom`.`city`,' (',`cFrom`.`country`,')') AS `warehouseAddress`,`cmr`.`created` AS `shipped`,`aTo`.`nickname` AS `clientOficialName`,`cmr`.`supplierFk` AS `supplierFk`,`aSu`.`name` AS `carrierName`,`aSu`.`street` AS `carrierStreet`,`aSu`.`postCode` AS `carrierPostCode`,`aSu`.`city` AS `carrierCity`,`cAs`.`country` AS `carrierCountry`,ifnull(`aTo`.`phone`,`client`.`phone`) AS `phone`,ifnull(`aTo`.`mobile`,`client`.`mobile`) AS `mobile`,`aTo`.`id` AS `addressFk`,`c`.`stamp` AS `stamp`,`cmr`.`merchandiseDetail` AS `merchandiseDetail` from ((((((((((((`cmr` left join `address` `aTo` on(`aTo`.`id` = `cmr`.`addressToFk`)) left join `province` `pTo` on(`pTo`.`id` = `aTo`.`provinceFk`)) left join `country` `cTo` on(`cTo`.`id` = `pTo`.`countryFk`)) left join `client` on(`client`.`id` = `aTo`.`clientFk`)) left join `supplier` `su` on(`su`.`id` = `cmr`.`companyFk`)) left join `country` `cSu` on(`cSu`.`id` = `su`.`countryFk`)) left join `address` `aFrom` on(`aFrom`.`id` = `cmr`.`addressFromFk`)) left join `province` `pFrom` on(`pFrom`.`id` = `aFrom`.`provinceFk`)) left join `country` `cFrom` on(`cFrom`.`id` = `pFrom`.`countryFk`)) left join `supplier` `aSu` on(`aSu`.`id` = `cmr`.`supplierFk`)) left join `country` `cAs` on(`cAs`.`id` = `aSu`.`countryFk`)) join `company` `c` on(`c`.`id` = `cmr`.`companyFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79736,7 +79255,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `departmentTree` AS select `node`.`id` AS `id`,concat(convert(repeat(repeat(' ',5),(count(`parent`.`id`) - 1)) using utf8),`node`.`name`) AS `dep` from (`department` `node` join `department` `parent`) where (`node`.`lft` between `parent`.`lft` and `parent`.`rgt`) group by `node`.`id` order by `node`.`lft` */; +/*!50001 VIEW `departmentTree` AS select `node`.`id` AS `id`,concat(convert(repeat(repeat(' ',5),count(`parent`.`id`) - 1) using utf8mb3),`node`.`name`) AS `dep` from (`department` `node` join `department` `parent`) where `node`.`lft` between `parent`.`lft` and `parent`.`rgt` group by `node`.`id` order by `node`.`lft` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79793,7 +79312,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ektSubAddress` AS select `eea`.`sub` AS `sub`,`a`.`clientFk` AS `clientFk`,`a`.`nickname` AS `nickname`,`eea`.`addressFk` AS `addressFk` from (`ektEntryAssign` `eea` join `address` `a` on((`a`.`id` = `eea`.`addressFk`))) group by `eea`.`sub` */; +/*!50001 VIEW `ektSubAddress` AS select `eea`.`sub` AS `sub`,`a`.`clientFk` AS `clientFk`,`a`.`nickname` AS `nickname`,`eea`.`addressFk` AS `addressFk` from (`ektEntryAssign` `eea` join `address` `a` on(`a`.`id` = `eea`.`addressFk`)) group by `eea`.`sub` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79812,26 +79331,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `exchangeInsuranceEntry` AS select max(`tr`.`landed`) AS `dated`,cast(sum(((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`)) as decimal(10,2)) AS `Dolares`,cast((sum(((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`)) / sum(((((100 + `e`.`commission`) / 100) * (`b`.`buyingValue` + `b`.`freightValue`)) * `b`.`quantity`))) as decimal(10,4)) AS `rate` from ((`entry` `e` join `buy` `b` on((`e`.`id` = `b`.`entryFk`))) join `travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) where ((`tr`.`landed` between '2016-01-31' and curdate()) and (`e`.`commission` < 0) and (`e`.`currencyFk` = 2)) group by month(`tr`.`landed`),year(`tr`.`landed`) */; -/*!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 `exchangeInsuranceIn` --- - -/*!50001 DROP TABLE IF EXISTS `exchangeInsuranceIn`*/; -/*!50001 DROP VIEW IF EXISTS `exchangeInsuranceIn`*/; -/*!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_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `exchangeInsuranceIn` AS select `exchangeInsuranceInPrevious`.`dated` AS `dated`,sum(`exchangeInsuranceInPrevious`.`amount`) AS `amount`,cast((sum((`exchangeInsuranceInPrevious`.`amount` * `exchangeInsuranceInPrevious`.`rate`)) / sum(`exchangeInsuranceInPrevious`.`amount`)) as decimal(10,4)) AS `rate` from `vn`.`exchangeInsuranceInPrevious` group by `exchangeInsuranceInPrevious`.`dated` */; +/*!50001 VIEW `exchangeInsuranceEntry` AS select max(`tr`.`landed`) AS `dated`,cast(sum((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`) as decimal(10,2)) AS `Dolares`,cast(sum((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`) / sum((100 + `e`.`commission`) / 100 * (`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`) as decimal(10,4)) AS `rate` from ((`entry` `e` join `buy` `b` on(`e`.`id` = `b`.`entryFk`)) join `travel` `tr` on(`tr`.`id` = `e`.`travelFk`)) where `tr`.`landed` between '2016-01-31' and `util`.`VN_CURDATE`() and `e`.`commission` < 0 and `e`.`currencyFk` = 2 group by month(`tr`.`landed`),year(`tr`.`landed`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79850,26 +79350,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `exchangeInsuranceOut` AS select `p`.`received` AS `received`,sum(`p`.`divisa`) AS `divisa`,(sum(`p`.`divisa`) / sum(`p`.`amount`)) AS `rate` from ((`payment` `p` join `bank` `b` on((`b`.`id` = `p`.`bankFk`))) join `accountingType` `at2` on((`at2`.`id` = `b`.`cash`))) where ((`p`.`currencyFk` = 2) and (`at2`.`code` = 'wireTransfer') and (`p`.`supplierFk` <> 2213)) group by `p`.`received` */; -/*!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 `exchangeReportSourcePrevious` --- - -/*!50001 DROP TABLE IF EXISTS `exchangeReportSourcePrevious`*/; -/*!50001 DROP VIEW IF EXISTS `exchangeReportSourcePrevious`*/; -/*!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_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `exchangeReportSourcePrevious` AS select `exchangeInsuranceIn`.`dated` AS `dated`,`exchangeInsuranceIn`.`amount` AS `amountIn`,`exchangeInsuranceIn`.`rate` AS `rateIn`,0.00 AS `amountOut`,0.00 AS `rateOut`,0.00 AS `amountEntry`,0.00 AS `rateEntry` from `vn`.`exchangeInsuranceIn` union all select `exchangeInsuranceOut`.`received` AS `received`,0.00 AS `amountIn`,0.00 AS `ratedIn`,`exchangeInsuranceOut`.`divisa` AS `amountOut`,`exchangeInsuranceOut`.`rate` AS `ratedOut`,0.00 AS `amountEntry`,0.00 AS `rateEntry` from `vn`.`exchangeInsuranceOut` union all select `exchangeInsuranceEntry`.`dated` AS `dated`,0.00 AS `amountIn`,0.00 AS `ratedIn`,0.00 AS `amountOut`,0.00 AS `ratedOut`,`exchangeInsuranceEntry`.`Dolares` AS `amountEntry`,`exchangeInsuranceEntry`.`rate` AS `rateEntry` from `vn`.`exchangeInsuranceEntry` */; +/*!50001 VIEW `exchangeInsuranceOut` AS select `p`.`received` AS `received`,sum(`p`.`divisa`) AS `divisa`,sum(`p`.`divisa`) / sum(`p`.`amount`) AS `rate` from ((`payment` `p` join `bank` `b` on(`b`.`id` = `p`.`bankFk`)) join `accountingType` `at2` on(`at2`.`id` = `b`.`cash`)) where `p`.`currencyFk` = 2 and `at2`.`code` = 'wireTransfer' and `p`.`supplierFk` <> 2213 group by `p`.`received` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79888,26 +79369,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionCommon` AS select `et`.`id` AS `truckFk`,`et`.`ETD` AS `etd`,ifnull(ucase(`et`.`description`),'SIN ESCANEAR') AS `description`,`es`.`palletFk` AS `palletFk`,`t`.`routeFk` AS `routeFk`,`es`.`id` AS `scanFk`,`e`.`id` AS `expeditionFk`,`r`.`expeditionTruckFk` AS `expeditionTruckFk`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `lastPacked`,`t`.`id` AS `ticketFk` from (((((`expeditionTruck` `et` left join `routesMonitor` `r` on((`et`.`id` = `r`.`expeditionTruckFk`))) left join `ticket` `t` on((`r`.`routeFk` = `t`.`routeFk`))) left join `expedition` `e` on((`t`.`id` = `e`.`ticketFk`))) left join `expeditionScan` `es` on((`e`.`id` = `es`.`expeditionFk`))) left join `expeditionPallet` `ep` on((`es`.`palletFk` = `ep`.`id`))) where (`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 `expeditionPallet_Print` --- - -/*!50001 DROP TABLE IF EXISTS `expeditionPallet_Print`*/; -/*!50001 DROP VIEW IF EXISTS `expeditionPallet_Print`*/; -/*!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_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionPallet_Print` AS select `et2`.`description` AS `truck`,`t`.`routeFk` AS `routeFk`,`r`.`description` AS `zone`,count(`es`.`id`) AS `eti`,`ep`.`id` AS `palletFk`,(`et`.`id` <=> `rm`.`expeditionTruckFk`) AS `isMatch`,`t`.`warehouseFk` AS `warehouseFk`,if((`r`.`created` > (curdate() + interval 1 day)),ucase(dayname(`r`.`created`)),NULL) AS `nombreDia` from (((((((`vn`.`expeditionTruck` `et` join `vn`.`expeditionPallet` `ep` on((`ep`.`truckFk` = `et`.`id`))) join `vn`.`expeditionScan` `es` on((`es`.`palletFk` = `ep`.`id`))) join `vn`.`expedition` `e` on((`e`.`id` = `es`.`expeditionFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) join `vn`.`route` `r` on((`r`.`id` = `t`.`routeFk`))) left join `vn2008`.`Rutas_monitor` `rm` on((`rm`.`Id_Ruta` = `r`.`id`))) left join `vn`.`expeditionTruck` `et2` on((`et2`.`id` = `rm`.`expeditionTruckFk`))) where (`ep`.`isPrint` = 0) group by `ep`.`id`,`t`.`routeFk` */; +/*!50001 VIEW `expeditionCommon` AS select `et`.`id` AS `truckFk`,`et`.`ETD` AS `etd`,ifnull(ucase(`et`.`description`),'SIN ESCANEAR') AS `description`,`es`.`palletFk` AS `palletFk`,`t`.`routeFk` AS `routeFk`,`es`.`id` AS `scanFk`,`e`.`id` AS `expeditionFk`,`r`.`expeditionTruckFk` AS `expeditionTruckFk`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `lastPacked`,`t`.`id` AS `ticketFk` from (((((`expeditionTruck` `et` left join `routesMonitor` `r` on(`et`.`id` = `r`.`expeditionTruckFk`)) left join `ticket` `t` on(`r`.`routeFk` = `t`.`routeFk`)) left join `expedition` `e` on(`t`.`id` = `e`.`ticketFk`)) left join `expeditionScan` `es` on(`e`.`id` = `es`.`expeditionFk`)) left join `expeditionPallet` `ep` on(`es`.`palletFk` = `ep`.`id`)) where `et`.`ETD` >= `util`.`VN_CURDATE`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79926,7 +79388,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionRoute_Monitor` AS select `r`.`id` AS `routeFk`,count(distinct if(isnull(`e`.`id`),`t`.`id`,NULL)) AS `tickets`,count(distinct `e`.`id`) AS `expeditions`,count(distinct `es`.`id`) AS `scanned`,max(`e`.`created`) AS `lastPacked`,`r`.`created` AS `created` from ((((((`route` `r` left join `routesMonitor` `rm` on((`r`.`id` = `rm`.`routeFk`))) left join `expeditionTruck` `et` on((`et`.`id` = `rm`.`expeditionTruckFk`))) join `ticket` `t` on((`t`.`routeFk` = `r`.`id`))) left join `expedition` `e` on((`e`.`ticketFk` = `t`.`id`))) left join `expeditionScan` `es` on((`es`.`expeditionFk` = `e`.`id`))) left join `stowaway` `st` on((`st`.`id` = `t`.`id`))) where ((`r`.`created` >= `util`.`yesterday`()) and isnull(`st`.`id`)) group by `r`.`id` */; +/*!50001 VIEW `expeditionRoute_Monitor` AS select `r`.`id` AS `routeFk`,count(distinct if(`e`.`id` is null,`t`.`id`,NULL)) AS `tickets`,count(distinct `e`.`id`) AS `expeditions`,count(distinct `es`.`id`) AS `scanned`,max(`e`.`created`) AS `lastPacked`,`r`.`created` AS `created` from ((((((`route` `r` left join `routesMonitor` `rm` on(`r`.`id` = `rm`.`routeFk`)) left join `expeditionTruck` `et` on(`et`.`id` = `rm`.`expeditionTruckFk`)) join `ticket` `t` on(`t`.`routeFk` = `r`.`id`)) left join `expedition` `e` on(`e`.`ticketFk` = `t`.`id`)) left join `expeditionScan` `es` on(`es`.`expeditionFk` = `e`.`id`)) left join `stowaway` `st` on(`st`.`id` = `t`.`id`)) where `r`.`created` >= `util`.`yesterday`() and `st`.`id` is null group by `r`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79945,7 +79407,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionRoute_freeTickets` AS select `t`.`routeFk` AS `routeFk`,`tss`.`ticket` AS `ticket`,`s`.`name` AS `code`,`w`.`name` AS `almacen`,`tss`.`updated` AS `updated`,`p`.`code` AS `parkingCode` from ((((((`vn`.`ticketState` `tss` join `vn`.`ticket` `t` on((`t`.`id` = `tss`.`ticket`))) join `vn`.`warehouse` `w` on((`w`.`id` = `t`.`warehouseFk`))) join `vn`.`state` `s` on((`s`.`id` = `tss`.`state`))) left join `vn`.`stowaway` `st` on((`st`.`id` = `t`.`id`))) left join `vn`.`ticketParking` `tp` on((`tp`.`ticketFk` = `t`.`id`))) left join `vn`.`parking` `p` on((`p`.`id` = `tp`.`parkingFk`))) where ((ifnull(`t`.`packages`,0) = 0) and isnull(`st`.`id`)) */; +/*!50001 VIEW `expeditionRoute_freeTickets` AS select `t`.`routeFk` AS `routeFk`,`tss`.`ticket` AS `ticket`,`s`.`name` AS `code`,`w`.`name` AS `almacen`,`tss`.`updated` AS `updated`,`p`.`code` AS `parkingCode` from ((((((`vn`.`ticketState` `tss` join `vn`.`ticket` `t` on(`t`.`id` = `tss`.`ticket`)) join `vn`.`warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) join `vn`.`state` `s` on(`s`.`id` = `tss`.`state`)) left join `vn`.`stowaway` `st` on(`st`.`id` = `t`.`id`)) left join `vn`.`ticketParking` `tp` on(`tp`.`ticketFk` = `t`.`id`)) left join `vn`.`parking` `p` on(`p`.`id` = `tp`.`parkingFk`)) where ifnull(`t`.`packages`,0) = 0 and `st`.`id` is null */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79964,7 +79426,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionScan_Monitor` AS select `et`.`id` AS `truckFk`,`et`.`ETD` AS `ETD`,`et`.`description` AS `description`,`ep`.`id` AS `palletFk`,`ep`.`position` AS `position`,`ep`.`built` AS `built`,`es`.`id` AS `scanFk`,`es`.`expeditionFk` AS `expeditionFk`,`es`.`scanned` AS `scanned` from ((`expeditionTruck` `et` left join `expeditionPallet` `ep` on((`ep`.`truckFk` = `et`.`id`))) left join `expeditionScan` `es` on((`es`.`palletFk` = `ep`.`id`))) */; +/*!50001 VIEW `expeditionScan_Monitor` AS select `et`.`id` AS `truckFk`,`et`.`ETD` AS `ETD`,`et`.`description` AS `description`,`ep`.`id` AS `palletFk`,`ep`.`position` AS `position`,`ep`.`built` AS `built`,`es`.`id` AS `scanFk`,`es`.`expeditionFk` AS `expeditionFk`,`es`.`scanned` AS `scanned` from ((`expeditionTruck` `et` left join `expeditionPallet` `ep` on(`ep`.`truckFk` = `et`.`id`)) left join `expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79983,7 +79445,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` 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`,3) using utf8mb4),')') AS `routeFk`,`rm`.`beachFk` AS `beachFk`,if(`t`.`routeFk`,ifnull(`et`.`description`,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 `expeditionTruck` `et` on((`et`.`id` = `rm`.`expeditionTruckFk`))) left join `beach` `b` on((`b`.`code` = `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 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(',right(`t`.`routeFk`,3),')') AS `routeFk`,`rm`.`beachFk` AS `beachFk`,if(`t`.`routeFk`,ifnull(`et`.`description`,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 `expeditionTruck` `et` on(`et`.`id` = `rm`.`expeditionTruckFk`)) left join `beach` `b` on(`b`.`code` = `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 */; @@ -80002,7 +79464,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` 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 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 `e`.`id` is null and `et`.`ETD` > `util`.`VN_CURDATE`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80021,7 +79483,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTimeExpended` AS select `e`.`ticketFk` AS `ticketFk`,min(`e`.`created`) AS `started`,max(`e`.`created`) AS `finished`,max(`e`.`counter`) AS `cajas`,`w`.`code` AS `code`,`t`.`warehouseFk` AS `warehouseFk` from ((`expedition` `e` join `worker` `w` on((`w`.`id` = `e`.`workerFk`))) join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) where (`e`.`created` > curdate()) group by `e`.`ticketFk` */; +/*!50001 VIEW `expeditionTimeExpended` AS select `e`.`ticketFk` AS `ticketFk`,min(`e`.`created`) AS `started`,max(`e`.`created`) AS `finished`,max(`e`.`counter`) AS `cajas`,`w`.`code` AS `code`,`t`.`warehouseFk` AS `warehouseFk` from ((`expedition` `e` join `worker` `w` on(`w`.`id` = `e`.`workerFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) where `e`.`created` > `util`.`VN_CURDATE`() group by `e`.`ticketFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80040,7 +79502,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTruck_Control` AS select `e`.`truckFk` AS `id`,`e`.`etd` AS `ETD`,`e`.`description` AS `description`,count(distinct if(isnull(`e`.`expeditionFk`),`e`.`ticketFk`,NULL)) AS `ticketsSinBultos`,count(distinct `e`.`palletFk`) AS `pallets`,count(distinct `e`.`routeFk`) AS `routes`,count(distinct `e`.`scanFk`) AS `scans`,count(distinct `e`.`expeditionFk`) AS `expeditions`,sum((`e`.`truckFk` <> `e`.`expeditionTruckFk`)) AS `fallos`,max(`e`.`lastPacked`) AS `lastPacked` from `expeditionCommon` `e` group by `e`.`truckFk` order by `fallos` desc,`e`.`etd` */; +/*!50001 VIEW `expeditionTruck_Control` AS select `e`.`truckFk` AS `id`,`e`.`etd` AS `ETD`,`e`.`description` AS `description`,count(distinct if(`e`.`expeditionFk` is null,`e`.`ticketFk`,NULL)) AS `ticketsSinBultos`,count(distinct `e`.`palletFk`) AS `pallets`,count(distinct `e`.`routeFk`) AS `routes`,count(distinct `e`.`scanFk`) AS `scans`,count(distinct `e`.`expeditionFk`) AS `expeditions`,sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,max(`e`.`lastPacked`) AS `lastPacked` from `expeditionCommon` `e` group by `e`.`truckFk` order by sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) desc,`e`.`etd` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80059,7 +79521,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTruck_Control_Detail` AS select `e`.`truckFk` AS `id`,`e`.`etd` AS `ETD`,`e`.`description` AS `destino`,`e`.`palletFk` AS `pallet`,count(distinct `e`.`routeFk`) AS `routes`,count(distinct `e`.`scanFk`) AS `scans`,count(distinct `e`.`expeditionTruckFk`) AS `destinos`,sum((`e`.`truckFk` <> `e`.`expeditionTruckFk`)) AS `fallos`,max(`e`.`lastPacked`) AS `lastPacked` from `expeditionCommon` `e` group by `e`.`truckFk`,`e`.`palletFk` order by `fallos` desc,`e`.`etd`,`e`.`truckFk` */; +/*!50001 VIEW `expeditionTruck_Control_Detail` AS select `e`.`truckFk` AS `id`,`e`.`etd` AS `ETD`,`e`.`description` AS `destino`,`e`.`palletFk` AS `pallet`,count(distinct `e`.`routeFk`) AS `routes`,count(distinct `e`.`scanFk`) AS `scans`,count(distinct `e`.`expeditionTruckFk`) AS `destinos`,sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,max(`e`.`lastPacked`) AS `lastPacked` from `expeditionCommon` `e` group by `e`.`truckFk`,`e`.`palletFk` order by sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) desc,`e`.`etd`,`e`.`truckFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80078,7 +79540,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTruck_Control_Detail_Pallet` AS select `e`.`truckFk` AS `id`,`e`.`etd` AS `ETD`,`e`.`description` AS `destino`,`e`.`palletFk` AS `pallet`,`e`.`routeFk` AS `route`,count(distinct `e`.`scanFk`) AS `scans`,`et`.`description` AS `destinos`,sum((`e`.`truckFk` <> `e`.`expeditionTruckFk`)) AS `fallos`,`e`.`expeditionTruckFk` AS `expeditionTruckFk`,max(`e`.`lastPacked`) AS `lastPacked` from (`expeditionCommon` `e` left join `expeditionTruck` `et` on((`et`.`id` = `e`.`expeditionTruckFk`))) group by `e`.`truckFk`,`e`.`palletFk`,`e`.`routeFk` order by `fallos` desc,`e`.`palletFk` */; +/*!50001 VIEW `expeditionTruck_Control_Detail_Pallet` AS select `e`.`truckFk` AS `id`,`e`.`etd` AS `ETD`,`e`.`description` AS `destino`,`e`.`palletFk` AS `pallet`,`e`.`routeFk` AS `route`,count(distinct `e`.`scanFk`) AS `scans`,`et`.`description` AS `destinos`,sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,`e`.`expeditionTruckFk` AS `expeditionTruckFk`,max(`e`.`lastPacked`) AS `lastPacked` from (`expeditionCommon` `e` left join `expeditionTruck` `et` on(`et`.`id` = `e`.`expeditionTruckFk`)) group by `e`.`truckFk`,`e`.`palletFk`,`e`.`routeFk` order by sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) desc,`e`.`palletFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80097,7 +79559,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `firstTicketShipped` AS select min(`ticket`.`shipped`) AS `shipped`,`ticket`.`clientFk` AS `clientFk` from `ticket` where (`ticket`.`shipped` > '2001-01-01') group by `ticket`.`clientFk` */; +/*!50001 VIEW `firstTicketShipped` AS select min(`ticket`.`shipped`) AS `shipped`,`ticket`.`clientFk` AS `clientFk` from `ticket` where `ticket`.`shipped` > '2001-01-01' group by `ticket`.`clientFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80116,7 +79578,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `floraHollandBuyedItems` AS select `b`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`b`.`quantity` AS `quantity`,`b`.`buyingValue` AS `buyingValue`,`tr`.`landed` AS `landed`,`e`.`companyFk` AS `companyFk` from (((((`buy` `b` join `item` `i` on((`b`.`itemFk` = `i`.`id`))) join `itemType` `it` on((`it`.`id` = `i`.`typeFk`))) join `itemCategory` `ic` on((`ic`.`id` = `it`.`categoryFk`))) join `entry` `e` on((`e`.`id` = `b`.`entryFk`))) join `travel` `tr` on(((`tr`.`id` = `e`.`travelFk`) and (`ic`.`id` not in (8,6)) and (`b`.`buyingValue` <> 0) and (`b`.`quantity` <> 0) and (`e`.`supplierFk` in (1664,1665,1666,1465,1433))))) */; +/*!50001 VIEW `floraHollandBuyedItems` AS select `b`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`b`.`quantity` AS `quantity`,`b`.`buyingValue` AS `buyingValue`,`tr`.`landed` AS `landed`,`e`.`companyFk` AS `companyFk` from (((((`buy` `b` join `item` `i` on(`b`.`itemFk` = `i`.`id`)) join `itemType` `it` on(`it`.`id` = `i`.`typeFk`)) join `itemCategory` `ic` on(`ic`.`id` = `it`.`categoryFk`)) join `entry` `e` on(`e`.`id` = `b`.`entryFk`)) join `travel` `tr` on(`tr`.`id` = `e`.`travelFk` and `ic`.`id` not in (8,6) and `b`.`buyingValue` <> 0 and `b`.`quantity` <> 0 and `e`.`supplierFk` in (1664,1665,1666,1465,1433))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80135,7 +79597,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `inkL10n` AS select `k`.`id` AS `id`,ifnull(`i`.`name`,`k`.`name`) AS `name` from (`ink` `k` left join `inkI18n` `i` on(((`i`.`inkFk` = `k`.`id`) and (`i`.`lang` = `util`.`lang`())))) */; +/*!50001 VIEW `inkL10n` AS select `k`.`id` AS `id`,ifnull(`i`.`name`,`k`.`name`) AS `name` from (`ink` `k` left join `inkI18n` `i` on(`i`.`inkFk` = `k`.`id` and `i`.`lang` = `util`.`lang`())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80154,7 +79616,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `invoiceCorrectionDataSource` AS select `s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`t`.`shipped` AS `shipped` from (`sale` `s` join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) where (`t`.`shipped` > (curdate() + interval -(3) year)) */; +/*!50001 VIEW `invoiceCorrectionDataSource` AS select `s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`t`.`shipped` AS `shipped` from (`sale` `s` join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) where `t`.`shipped` > `util`.`VN_CURDATE`() + interval -3 year */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80173,7 +79635,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!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 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 */; @@ -80192,7 +79654,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemCategoryL10n` AS select `c`.`id` AS `id`,ifnull(`i`.`name`,`c`.`name`) AS `name` from (`itemCategory` `c` left join `itemCategoryI18n` `i` on(((`i`.`categoryFk` = `c`.`id`) and (`i`.`lang` = `util`.`lang`())))) */; +/*!50001 VIEW `itemCategoryL10n` AS select `c`.`id` AS `id`,ifnull(`i`.`name`,`c`.`name`) AS `name` from (`itemCategory` `c` left join `itemCategoryI18n` `i` on(`i`.`categoryFk` = `c`.`id` and `i`.`lang` = `util`.`lang`())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80211,7 +79673,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemColor` AS select `it`.`itemFk` AS `itemFk`,`it`.`value` AS `color` from (`itemTag` `it` join `tag` `t` on((`t`.`id` = `it`.`tagFk`))) where (`t`.`code` = 'COLOR') */; +/*!50001 VIEW `itemColor` AS select `it`.`itemFk` AS `itemFk`,`it`.`value` AS `color` from (`itemTag` `it` join `tag` `t` on(`t`.`id` = `it`.`tagFk`)) where `t`.`code` = 'COLOR' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80230,7 +79692,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemEntryIn` AS select `t`.`warehouseInFk` AS `warehouseInFk`,`t`.`landed` AS `landed`,`b`.`itemFk` AS `itemFk`,`b`.`quantity` AS `quantity`,`t`.`isReceived` AS `isReceived`,`e`.`isRaid` AS `isVirtualStock`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on((`b`.`entryFk` = `e`.`id`))) join `travel` `t` on((`e`.`travelFk` = `t`.`id`))) where ((`e`.`isExcludedFromAvailable` = 0) and (`b`.`quantity` <> 0)) */; +/*!50001 VIEW `itemEntryIn` AS select `t`.`warehouseInFk` AS `warehouseInFk`,`t`.`landed` AS `landed`,`b`.`itemFk` AS `itemFk`,`b`.`quantity` AS `quantity`,`t`.`isReceived` AS `isReceived`,`e`.`isRaid` AS `isVirtualStock`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`e`.`travelFk` = `t`.`id`)) where `e`.`isExcludedFromAvailable` = 0 and `b`.`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 */; @@ -80249,7 +79711,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemEntryOut` AS select `t`.`warehouseOutFk` AS `warehouseOutFk`,`t`.`shipped` AS `shipped`,`b`.`itemFk` AS `itemFk`,-(`b`.`quantity`) AS `quantity`,`t`.`isDelivered` AS `isDelivered`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on((`b`.`entryFk` = `e`.`id`))) join `travel` `t` on((`e`.`travelFk` = `t`.`id`))) where ((`e`.`isExcludedFromAvailable` = 0) and (`e`.`isRaid` = 0) and (`b`.`quantity` <> 0)) */; +/*!50001 VIEW `itemEntryOut` AS select `t`.`warehouseOutFk` AS `warehouseOutFk`,`t`.`shipped` AS `shipped`,`b`.`itemFk` AS `itemFk`,-`b`.`quantity` AS `quantity`,`t`.`isDelivered` AS `isDelivered`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`e`.`travelFk` = `t`.`id`)) where `e`.`isExcludedFromAvailable` = 0 and `e`.`isRaid` = 0 and `b`.`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 */; @@ -80268,7 +79730,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemInk` AS select `i`.`longName` AS `longName`,`i`.`inkFk` AS `inkFk`,`ink`.`name` AS `color` from (`item` `i` join `ink` on((`ink`.`id` = `i`.`inkFk`))) where `ink`.`isRealColor` group by `i`.`longName` */; +/*!50001 VIEW `itemInk` AS select `i`.`longName` AS `longName`,`i`.`inkFk` AS `inkFk`,`ink`.`name` AS `color` from (`item` `i` join `ink` on(`ink`.`id` = `i`.`inkFk`)) where `ink`.`isRealColor` <> 0 group by `i`.`longName` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80287,7 +79749,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,ifnull(`isps`.`created`,`ips`.`created`) AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,(`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0))) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,`ips`.`sectorFk` AS `sectorFk` from ((((`itemPlacementSupply` `ips` join `item` `i` on((`i`.`id` = `ips`.`itemFk`))) left join `worker` `w` on((`w`.`userFk` = `ips`.`userFk`))) left join `worker` `rw` on((`rw`.`userFk` = `ips`.`repoUserFk`))) left join `itemShelvingPlacementSupply` `isps` on((`isps`.`itemPlacementSupplyFk` = `ips`.`id`))) where (`ips`.`created` >= curdate()) group by `ips`.`priority`,`ips`.`id`,`ips`.`sectorFk` */; +/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,ifnull(`isps`.`created`,`ips`.`created`) AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0)) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,`ips`.`sectorFk` AS `sectorFk` from ((((`itemPlacementSupply` `ips` join `item` `i` on(`i`.`id` = `ips`.`itemFk`)) left join `worker` `w` on(`w`.`userFk` = `ips`.`userFk`)) left join `worker` `rw` on(`rw`.`userFk` = `ips`.`repoUserFk`)) left join `itemShelvingPlacementSupply` `isps` on(`isps`.`itemPlacementSupplyFk` = `ips`.`id`)) where `ips`.`created` >= `util`.`VN_CURDATE`() group by `ips`.`priority`,`ips`.`id`,`ips`.`sectorFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80306,7 +79768,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemProductor` AS select `it`.`itemFk` AS `itemFk`,`it`.`value` AS `productor` from (`itemTag` `it` join `tag` `t` on((`t`.`id` = `it`.`tagFk`))) where (`t`.`code` = 'PRODUCER') */; +/*!50001 VIEW `itemProductor` AS select `it`.`itemFk` AS `itemFk`,`it`.`value` AS `productor` from (`itemTag` `it` join `tag` `t` on(`t`.`id` = `it`.`tagFk`)) where `t`.`code` = 'PRODUCER' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80325,7 +79787,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemSearch` AS select `s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`t`.`nickname` AS `nickname`,`t`.`shipped` AS `shipped` from ((`sale` `s` join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `warehouse` `w` on((`w`.`id` = `t`.`warehouseFk`))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`tomorrow`()) and (`w`.`name` in ('VNH','Floramondo'))) */; +/*!50001 VIEW `itemSearch` AS select `s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`t`.`nickname` AS `nickname`,`t`.`shipped` AS `shipped` from ((`sale` `s` join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) where `t`.`shipped` between `util`.`yesterday`() and `util`.`tomorrow`() and `w`.`name` in ('VNH','Floramondo') */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80344,7 +79806,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume`,`t`.`warehouseFk` AS `warehouseFk` from (((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `tst`.`state`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemShelvingStock` `stock` on((`stock`.`itemFk` = `i`.`id`))) left join `vn`.`saleTracking` `stk` on((`stk`.`saleFk` = `s`.`id`))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) and isnull(`stk`.`id`) and (`stock`.`visible` > 0) and isnull(`stk`.`saleFk`) and `st`.`isPreviousPreparable`) */; +/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume`,`t`.`warehouseFk` AS `warehouseFk` from (((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `vn`.`agencyMode` `am` on(`am`.`id` = `t`.`agencyModeFk`)) join `vn`.`ticketStateToday` `tst` on(`tst`.`ticket` = `t`.`id`)) join `vn`.`state` `st` on(`st`.`id` = `tst`.`state`)) join `vn`.`item` `i` on(`i`.`id` = `s`.`itemFk`)) join `vn`.`itemShelvingStock` `stock` on(`stock`.`itemFk` = `i`.`id`)) left join `vn`.`saleTracking` `stk` on(`stk`.`saleFk` = `s`.`id`)) left join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `vn`.`saleVolume` `sv` on(`sv`.`saleFk` = `s`.`id`)) where `t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(`util`.`VN_CURDATE`()) and `stk`.`id` is null and `stock`.`visible` > 0 and `stk`.`saleFk` is null and `st`.`isPreviousPreparable` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80363,7 +79825,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingList` AS select `ish`.`shelvingFk` AS `shelvingFk`,`ish`.`visible` AS `visible`,`ish`.`created` AS `created`,`pk`.`code` AS `parking`,`ish`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`parked` AS `parked`,`pk`.`sectorFk` AS `sectorFk` from (((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `parking` `pk` on((`pk`.`id` = `sh`.`parkingFk`))) order by `ish`.`created` */; +/*!50001 VIEW `itemShelvingList` AS select `ish`.`shelvingFk` AS `shelvingFk`,`ish`.`visible` AS `visible`,`ish`.`created` AS `created`,`pk`.`code` AS `parking`,`ish`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`parked` AS `parked`,`pk`.`sectorFk` AS `sectorFk` from (((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) join `item` `i` on(`i`.`id` = `ish`.`itemFk`)) left join `parking` `pk` on(`pk`.`id` = `sh`.`parkingFk`)) order by `ish`.`created` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80382,7 +79844,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingPlacementSupplyStock` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority`,`p`.`id` AS `parkingFk`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `item` `i` on((`i`.`id` = `ish`.`itemFk`))) group by `ish`.`id` */; +/*!50001 VIEW `itemShelvingPlacementSupplyStock` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority`,`p`.`id` AS `parkingFk`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) left join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) join `item` `i` on(`i`.`id` = `ish`.`itemFk`)) 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 */; @@ -80401,7 +79863,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingSaleSum` AS select `iss`.`id` AS `id`,`iss`.`itemShelvingFk` AS `itemShelvingFk`,`iss`.`saleFk` AS `saleFk`,sum(`iss`.`quantity`) AS `quantity`,`iss`.`created` AS `created`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelvingSale` `iss` join `itemShelving` `ish` on((`ish`.`id` = `iss`.`itemShelvingFk`))) join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) group by `iss`.`saleFk` */; +/*!50001 VIEW `itemShelvingSaleSum` AS select `iss`.`id` AS `id`,`iss`.`itemShelvingFk` AS `itemShelvingFk`,`iss`.`saleFk` AS `saleFk`,sum(`iss`.`quantity`) AS `quantity`,`iss`.`created` AS `created`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelvingSale` `iss` join `itemShelving` `ish` on(`ish`.`id` = `iss`.`itemShelvingFk`)) join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) group by `iss`.`saleFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80420,7 +79882,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` 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`,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`,`s`.`isPreviousPrepared` AS `isPreviousPrepared` 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 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`,`s`.`isPreviousPrepared` AS `isPreviousPrepared` 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` <> 0 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 */; @@ -80439,7 +79901,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingStockFull` AS select `ish`.`itemFk` AS `itemFk`,`ish`.`visible` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`grouping` AS `grouping`,`s`.`description` AS `sector`,`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` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) left join `itemShelvingStockRemoved` `issr` on((`issr`.`itemShelvingFk` = `ish`.`id`))) */; +/*!50001 VIEW `itemShelvingStockFull` AS select `ish`.`itemFk` AS `itemFk`,`ish`.`visible` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`grouping` AS `grouping`,`s`.`description` AS `sector`,`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` join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) join `sector` `s` on(`s`.`id` = `p`.`sectorFk`)) left join `itemShelvingStockRemoved` `issr` on(`issr`.`itemShelvingFk` = `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 */; @@ -80458,7 +79920,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!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 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 */; @@ -80477,7 +79939,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingStock_byWarehouse` AS select `ish`.`itemFk` AS `itemFk`,sum(`ish`.`visible`) AS `visible`,`s`.`warehouseFk` AS `warehouseFk` from (((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) group by `ish`.`itemFk`,`s`.`warehouseFk` */; +/*!50001 VIEW `itemShelvingStock_byWarehouse` AS select `ish`.`itemFk` AS `itemFk`,sum(`ish`.`visible`) AS `visible`,`s`.`warehouseFk` AS `warehouseFk` from (((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) join `sector` `s` on(`s`.`id` = `p`.`sectorFk`)) group by `ish`.`itemFk`,`s`.`warehouseFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80515,7 +79977,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemTicketOut` AS select `t`.`warehouseFk` AS `warehouseFk`,`t`.`shipped` AS `shipped`,`s`.`itemFk` AS `itemFk`,-(`s`.`quantity`) AS `quantity`,`s`.`isPicked` AS `isPicked`,`s`.`reserved` AS `reserved`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`s`.`ticketFk` AS `ticketFk` from (`sale` `s` join `ticket` `t` on((`s`.`ticketFk` = `t`.`id`))) where (`s`.`quantity` <> 0) */; +/*!50001 VIEW `itemTicketOut` AS select `t`.`warehouseFk` AS `warehouseFk`,`t`.`shipped` AS `shipped`,`s`.`itemFk` AS `itemFk`,-`s`.`quantity` AS `quantity`,`s`.`isPicked` AS `isPicked`,`s`.`reserved` AS `reserved`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`s`.`ticketFk` AS `ticketFk` from (`sale` `s` join `ticket` `t` on(`s`.`ticketFk` = `t`.`id`)) where `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 */; @@ -80534,7 +79996,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemTypeL10n` AS select `t`.`id` AS `id`,ifnull(`i`.`name`,`t`.`name`) AS `name` from (`itemType` `t` left join `itemTypeI18n` `i` on(((`i`.`typeFk` = `t`.`id`) and (`i`.`lang` = `util`.`LANG`())))) */; +/*!50001 VIEW `itemTypeL10n` AS select `t`.`id` AS `id`,ifnull(`i`.`name`,`t`.`name`) AS `name` from (`itemType` `t` left join `itemTypeI18n` `i` on(`i`.`typeFk` = `t`.`id` and `i`.`lang` = `util`.`LANG`())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80553,7 +80015,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `item_Free_Id` AS select (`i1`.`id` + 1) AS `newId` from (`item` `i1` left join `item` `i2` on(((`i1`.`id` + 1) = `i2`.`id`))) where (isnull(`i2`.`id`) and (`i1`.`id` > 400000)) */; +/*!50001 VIEW `item_Free_Id` AS select `i1`.`id` + 1 AS `newId` from (`item` `i1` left join `item` `i2` on(`i1`.`id` + 1 = `i2`.`id`)) where `i2`.`id` is null and `i1`.`id` > 400000 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80572,7 +80034,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `labelInfo` AS select `i`.`id` AS `itemId`,`i`.`name` AS `itemName`,`b`.`stickers` AS `stickers`,`b`.`printedStickers` AS `life`,`i`.`inkFk` AS `colorCode`,`i`.`stems` AS `stems`,`i`.`category` AS `category`,`i`.`subName` AS `productor`,`b`.`packing` AS `packing`,`clb`.`warehouse_id` AS `warehouse_id`,`i`.`size` AS `size`,`b`.`isPickedOff` AS `isPickedOff`,`e`.`evaNotes` AS `notes`,`w`.`name` AS `wh_in`,`e`.`id` AS `entryId`,`b`.`id` AS `buyId` from (((((`vn`.`buy` `b` join `vn`.`item` `i` on((`i`.`id` = `b`.`itemFk`))) join `cache`.`last_buy` `clb` on((`clb`.`item_id` = `i`.`id`))) join `vn`.`entry` `e` on((`e`.`id` = `b`.`entryFk`))) left join `vn`.`travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) join `vn`.`warehouse` `w` on((`w`.`id` = `tr`.`warehouseInFk`))) */; +/*!50001 VIEW `labelInfo` AS select `i`.`id` AS `itemId`,`i`.`name` AS `itemName`,`b`.`stickers` AS `stickers`,`b`.`printedStickers` AS `life`,`i`.`inkFk` AS `colorCode`,`i`.`stems` AS `stems`,`i`.`category` AS `category`,`i`.`subName` AS `productor`,`b`.`packing` AS `packing`,`clb`.`warehouse_id` AS `warehouse_id`,`i`.`size` AS `size`,`b`.`isPickedOff` AS `isPickedOff`,`e`.`evaNotes` AS `notes`,`w`.`name` AS `wh_in`,`e`.`id` AS `entryId`,`b`.`id` AS `buyId` from (((((`vn`.`buy` `b` join `vn`.`item` `i` on(`i`.`id` = `b`.`itemFk`)) join `cache`.`last_buy` `clb` on(`clb`.`item_id` = `i`.`id`)) join `vn`.`entry` `e` on(`e`.`id` = `b`.`entryFk`)) left join `vn`.`travel` `tr` on(`tr`.`id` = `e`.`travelFk`)) join `vn`.`warehouse` `w` on(`w`.`id` = `tr`.`warehouseInFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80591,7 +80053,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `lastHourProduction` AS select `t`.`warehouseFk` AS `warehouseFk`,cast(sum((ifnull(`p`.`volume`,((`p`.`width` * `p`.`height`) * `p`.`depth`)) / 1000000)) as decimal(5,1)) AS `m3` from (((`warehouse` `w` join `ticket` `t` on((`t`.`warehouseFk` = `w`.`id`))) left join `expedition` `e` on((`t`.`id` = `e`.`ticketFk`))) left join `packaging` `p` on((`p`.`id` = `e`.`packagingFk`))) where (`e`.`created` between (now() - interval 1 hour) and now()) group by `t`.`warehouseFk` */; +/*!50001 VIEW `lastHourProduction` AS select `t`.`warehouseFk` AS `warehouseFk`,cast(sum(ifnull(`p`.`volume`,`p`.`width` * `p`.`height` * `p`.`depth`) / 1000000) as decimal(5,1)) AS `m3` from (((`warehouse` `w` join `ticket` `t` on(`t`.`warehouseFk` = `w`.`id`)) left join `expedition` `e` on(`t`.`id` = `e`.`ticketFk`)) left join `packaging` `p` on(`p`.`id` = `e`.`packagingFk`)) where `e`.`created` between current_timestamp() - interval 1 hour and current_timestamp() group by `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 */; @@ -80610,7 +80072,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` 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`,`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 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 */; @@ -80629,7 +80091,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `lastTopClaims` AS select `s`.`itemFk` AS `itemFk`,`i`.`longName` AS `itemName`,`it`.`name` AS `itemTypeName`,count(0) AS `claimsNumber`,round(sum(((((`cb`.`quantity` * `s`.`price`) * (1 - ((`c`.`responsibility` - 1) / 4))) * (100 - `s`.`discount`)) / 100)),2) AS `claimedAmount`,round(sum((((`cb`.`quantity` * `s`.`price`) * (100 - `s`.`discount`)) / 100)),2) AS `totalAmount` from ((((`claim` `c` join `claimBeginning` `cb` on((`cb`.`claimFk` = `c`.`id`))) join `sale` `s` on((`s`.`id` = `cb`.`saleFk`))) join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `itemType` `it` on((`it`.`id` = `i`.`typeFk`))) where (`c`.`created` >= (curdate() + interval -(1) week)) group by `s`.`itemFk` having (((`claimedAmount` > 100) and (`claimsNumber` > 2)) or (`claimsNumber` > 4)) order by `claimsNumber` desc */; +/*!50001 VIEW `lastTopClaims` AS select `s`.`itemFk` AS `itemFk`,`i`.`longName` AS `itemName`,`it`.`name` AS `itemTypeName`,count(0) AS `claimsNumber`,round(sum(`cb`.`quantity` * `s`.`price` * (1 - (`c`.`responsibility` - 1) / 4) * (100 - `s`.`discount`) / 100),2) AS `claimedAmount`,round(sum(`cb`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100),2) AS `totalAmount` from ((((`claim` `c` join `claimBeginning` `cb` on(`cb`.`claimFk` = `c`.`id`)) join `sale` `s` on(`s`.`id` = `cb`.`saleFk`)) join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `itemType` `it` on(`it`.`id` = `i`.`typeFk`)) where `c`.`created` >= `util`.`VN_CURDATE`() + interval -1 week group by `s`.`itemFk` having `claimedAmount` > 100 and `claimsNumber` > 2 or `claimsNumber` > 4 order by count(0) desc */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80648,7 +80110,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `mistake` AS select `wr`.`code` AS `revisador`,`s`.`concept` AS `concept`,`w`.`code` AS `sacador`,`w`.`firstName` AS `firstName`,`w`.`lastName` AS `lastName`,`mt`.`description` AS `description`,cast(`iss`.`created` as date) AS `created`,`w`.`id` AS `workerFk` from (((((`saleMistake` `sm` join `mistakeType` `mt` on((`mt`.`id` = `sm`.`typeFk`))) join `worker` `wr` on((`wr`.`id` = `sm`.`userFk`))) join `sale` `s` on((`s`.`id` = `sm`.`saleFk`))) join `itemShelvingSale` `iss` on((`iss`.`saleFk` = `sm`.`saleFk`))) join `worker` `w` on((`w`.`id` = `iss`.`userFk`))) */; +/*!50001 VIEW `mistake` AS select `wr`.`code` AS `revisador`,`s`.`concept` AS `concept`,`w`.`code` AS `sacador`,`w`.`firstName` AS `firstName`,`w`.`lastName` AS `lastName`,`mt`.`description` AS `description`,cast(`iss`.`created` as date) AS `created`,`w`.`id` AS `workerFk` from (((((`saleMistake` `sm` join `mistakeType` `mt` on(`mt`.`id` = `sm`.`typeFk`)) join `worker` `wr` on(`wr`.`id` = `sm`.`userFk`)) join `sale` `s` on(`s`.`id` = `sm`.`saleFk`)) join `itemShelvingSale` `iss` on(`iss`.`saleFk` = `sm`.`saleFk`)) join `worker` `w` on(`w`.`id` = `iss`.`userFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80667,7 +80129,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `mistakeRatio` AS select `wr`.`code` AS `revisador`,`w`.`code` AS `sacador`,`w`.`firstName` AS `firstName`,`w`.`lastName` AS `lastName`,`mt`.`description` AS `description`,cast(`iss`.`created` as date) AS `created`,`w`.`id` AS `workerFk`,`sm`.`saleFk` AS `saleFk` from ((((`itemShelvingSale` `iss` join `worker` `w` on((`w`.`id` = `iss`.`userFk`))) left join `saleMistake` `sm` on((`iss`.`saleFk` = `sm`.`saleFk`))) left join `mistakeType` `mt` on((`mt`.`id` = `sm`.`typeFk`))) left join `worker` `wr` on((`wr`.`id` = `sm`.`userFk`))) */; +/*!50001 VIEW `mistakeRatio` AS select `wr`.`code` AS `revisador`,`w`.`code` AS `sacador`,`w`.`firstName` AS `firstName`,`w`.`lastName` AS `lastName`,`mt`.`description` AS `description`,cast(`iss`.`created` as date) AS `created`,`w`.`id` AS `workerFk`,`sm`.`saleFk` AS `saleFk` from ((((`itemShelvingSale` `iss` join `worker` `w` on(`w`.`id` = `iss`.`userFk`)) left join `saleMistake` `sm` on(`iss`.`saleFk` = `sm`.`saleFk`)) left join `mistakeType` `mt` on(`mt`.`id` = `sm`.`typeFk`)) left join `worker` `wr` on(`wr`.`id` = `sm`.`userFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80686,7 +80148,26 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `newBornSales` AS select `v`.`importe` AS `amount`,`v`.`Id_Cliente` AS `clientFk`,`c`.`salesPersonFk` AS `userFk`,`v`.`fecha` AS `dated`,`cn`.`firstShipped` AS `firstShipped` from ((((`bs`.`clientNewBorn` `cn` join `bs`.`ventas` `v` on((((`cn`.`firstShipped` + interval 1 year) > `v`.`fecha`) and (`v`.`Id_Cliente` = `cn`.`clientFk`)))) join `vn`.`client` `c` on((`c`.`id` = `v`.`Id_Cliente`))) join `account`.`user` `u` on((`u`.`id` = `c`.`salesPersonFk`))) join `account`.`role` `r` on((`r`.`id` = `u`.`role`))) where ((`r`.`name` = 'salesPerson') and (`u`.`name` not in ('ismaelalcolea','ruben'))) */; +/*!50001 VIEW `newBornSales` AS select `v`.`importe` AS `amount`,`v`.`Id_Cliente` AS `clientFk`,`c`.`salesPersonFk` AS `userFk`,`v`.`fecha` AS `dated`,`cn`.`firstShipped` AS `firstShipped` from ((((`bs`.`clientNewBorn` `cn` join `bs`.`ventas` `v` on(`cn`.`firstShipped` + interval 1 year > `v`.`fecha` and `v`.`Id_Cliente` = `cn`.`clientFk`)) join `vn`.`client` `c` on(`c`.`id` = `v`.`Id_Cliente`)) join `account`.`user` `u` on(`u`.`id` = `c`.`salesPersonFk`)) join `account`.`role` `r` on(`r`.`id` = `u`.`role`)) where `r`.`name` = 'salesPerson' and `u`.`name` not in ('ismaelalcolea','ruben') */; +/*!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 `operatorWorkerCode` +-- + +/*!50001 DROP TABLE IF EXISTS `operatorWorkerCode`*/; +/*!50001 DROP VIEW IF EXISTS `operatorWorkerCode`*/; +/*!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_unicode_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `operatorWorkerCode` AS select `o`.`workerFk` AS `workerFk`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `fullName`,`w`.`code` AS `code`,`o`.`numberOfWagons` AS `numberOfWagons` from ((`worker` `w` join `operator` `o` on(`o`.`workerFk` = `w`.`id`)) join `sector` `s` on(`w`.`sectorFk` = `s`.`id`)) where `w`.`sectorFk` is not null and `s`.`code` in ('H2','H2','PEQUES_H','ALTILLO COMP','ALTILLO ARTI') */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80705,7 +80186,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `originL10n` AS select `o`.`id` AS `id`,ifnull(`i`.`name`,`o`.`name`) AS `name` from (`origin` `o` left join `originI18n` `i` on(((`i`.`originFk` = `o`.`id`) and (`i`.`lang` = `util`.`lang`())))) */; +/*!50001 VIEW `originL10n` AS select `o`.`id` AS `id`,ifnull(`i`.`name`,`o`.`name`) AS `name` from (`origin` `o` left join `originI18n` `i` on(`i`.`originFk` = `o`.`id` and `i`.`lang` = `util`.`lang`())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80724,7 +80205,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `packageEquivalentItem` AS select `p`.`itemFk` AS `itemFk`,`p2`.`itemFk` AS `equivalentFk` from ((`packageEquivalent` `pe` join `packaging` `p` on((`p`.`id` = `pe`.`packagingFk`))) join `packaging` `p2` on((`p2`.`id` = `pe`.`equivalentFk`))) */; +/*!50001 VIEW `packageEquivalentItem` AS select `p`.`itemFk` AS `itemFk`,`p2`.`itemFk` AS `equivalentFk` from ((`packageEquivalent` `pe` join `packaging` `p` on(`p`.`id` = `pe`.`packagingFk`)) join `packaging` `p2` on(`p2`.`id` = `pe`.`equivalentFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80743,7 +80224,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `personMedia` AS select `po`.`workerFk` AS `workerFk`,`m`.`value` AS `mediaValue` from (((`postgresql`.`profile` `po` join `postgresql`.`profile_media` `pom` on((`pom`.`profile_id` = `po`.`profile_id`))) join `postgresql`.`media` `m` on((`m`.`media_id` = `pom`.`media_id`))) join `postgresql`.`media_type` `mt` on((`mt`.`media_type_id` = `m`.`media_type_id`))) where (`mt`.`name` = 'movil personal') */; +/*!50001 VIEW `personMedia` AS select `c`.`id` AS `workerFk`,ifnull(`c`.`mobile`,`c`.`phone`) AS `mediaValue` from (`client` `c` join `worker` `w` on(`w`.`id` = `c`.`id`)) having `mediaValue` is not null */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80762,7 +80243,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `phoneBook` AS select 'C' AS `Tipo`,`client`.`id` AS `Id`,`client`.`name` AS `Cliente`,`client`.`phone` AS `Telefono` from `client` where (`client`.`phone` is not null) union select 'C' AS `Tipo`,`client`.`id` AS `Id`,`client`.`name` AS `Cliente`,`client`.`mobile` AS `Movil` from `client` where (`client`.`mobile` is not null) union select 'C' AS `Tipo`,`clientContact`.`clientFk` AS `clientFk`,`clientContact`.`name` AS `name`,`clientContact`.`phone` AS `phone` from `clientContact` */; +/*!50001 VIEW `phoneBook` AS select 'C' AS `Tipo`,`client`.`id` AS `Id`,`client`.`name` AS `Cliente`,`client`.`phone` AS `Telefono` from `client` where `client`.`phone` is not null union select 'C' AS `Tipo`,`client`.`id` AS `Id`,`client`.`name` AS `Cliente`,`client`.`mobile` AS `Movil` from `client` where `client`.`mobile` is not null union select 'C' AS `Tipo`,`clientContact`.`clientFk` AS `clientFk`,`clientContact`.`name` AS `name`,`clientContact`.`phone` AS `phone` from `clientContact` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80781,7 +80262,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `productionVolume` AS select hour(`e`.`created`) AS `hora`,minute(`e`.`created`) AS `minuto`,ifnull(`p`.`volume`,ifnull(((`p`.`width` * `p`.`height`) * `p`.`depth`),94500)) AS `cm3`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `created` from (((`expedition` `e` left join `packaging` `p` on((`p`.`itemFk` = `e`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) join `client` `c` on((`c`.`id` = `t`.`clientFk`))) where ((`e`.`created` between curdate() and `util`.`dayend`(curdate())) and `c`.`isRelevant`) */; +/*!50001 VIEW `productionVolume` AS select hour(`e`.`created`) AS `hora`,minute(`e`.`created`) AS `minuto`,ifnull(`p`.`volume`,ifnull(`p`.`width` * `p`.`height` * `p`.`depth`,94500)) AS `cm3`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `created` from (((`expedition` `e` left join `packaging` `p` on(`p`.`id` = `e`.`packagingFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `client` `c` on(`c`.`id` = `t`.`clientFk`)) where `e`.`created` between `util`.`VN_CURDATE`() and `util`.`dayend`(`util`.`VN_CURDATE`()) and `c`.`isRelevant` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80800,26 +80281,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `productionVolume_LastHour` AS select cast(sum((`productionVolume`.`cm3` / 1000000)) as decimal(10,0)) AS `m3`,`productionVolume`.`warehouseFk` AS `warehouseFk` from `productionVolume` where ((`productionVolume`.`created` > (now() + interval -(1) hour)) and (`productionVolume`.`warehouseFk` in (1,44,60))) group by `productionVolume`.`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 `returnBuckets` --- - -/*!50001 DROP TABLE IF EXISTS `returnBuckets`*/; -/*!50001 DROP VIEW IF EXISTS `returnBuckets`*/; -/*!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_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `returnBuckets` AS select `cr`.`idCubos_Retorno` AS `id`,`cr`.`Soporte` AS `freightContainerType`,`cr`.`Vacio` AS `freightPackagingEmpty`,`cr`.`Lleno` AS `freightPackagingFull` from `vn2008`.`Cubos_Retorno` `cr` */; +/*!50001 VIEW `productionVolume_LastHour` AS select cast(sum(`productionVolume`.`cm3` / 1000000) as decimal(10,0)) AS `m3`,`productionVolume`.`warehouseFk` AS `warehouseFk` from `productionVolume` where `productionVolume`.`created` > current_timestamp() + interval -1 hour and `productionVolume`.`warehouseFk` in (1,44,60) group by `productionVolume`.`warehouseFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80857,7 +80319,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `routesReduced` AS select `et`.`description` AS `description`,`rm`.`name` AS `name`,`t`.`routeFk` AS `routeFk`,`et`.`ETD` AS `ETD`,`rm`.`bufferFk` AS `bufferFk`,`rm`.`beachFk` AS `beachFk`,`i`.`itemPackingTypeFk` AS `itempackingTypeFk` from (((((((`vn`.`expeditionTruck` `et` join `vn`.`routesMonitor` `rm` on((`rm`.`expeditionTruckFk` = `et`.`id`))) join `vn`.`ticket` `t` on((`t`.`routeFk` = `rm`.`routeFk`))) join `vn`.`ticketState` `ts` on((`ts`.`ticketFk` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `ts`.`stateFk`))) join `vn`.`sale` `s` on((`s`.`ticketFk` = `t`.`id`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`config` `c`) where (`et`.`ETD` > `util`.`yesterday`()) group by `t`.`routeFk` order by `et`.`ETD`,`t`.`routeFk` */; +/*!50001 VIEW `routesReduced` AS select `et`.`description` AS `description`,`rm`.`name` AS `name`,`t`.`routeFk` AS `routeFk`,`et`.`ETD` AS `ETD`,`rm`.`bufferFk` AS `bufferFk`,`rm`.`beachFk` AS `beachFk`,`i`.`itemPackingTypeFk` AS `itempackingTypeFk` from (((((((`vn`.`expeditionTruck` `et` join `vn`.`routesMonitor` `rm` on(`rm`.`expeditionTruckFk` = `et`.`id`)) join `vn`.`ticket` `t` on(`t`.`routeFk` = `rm`.`routeFk`)) join `vn`.`ticketState` `ts` on(`ts`.`ticketFk` = `t`.`id`)) join `vn`.`state` `st` on(`st`.`id` = `ts`.`stateFk`)) join `vn`.`sale` `s` on(`s`.`ticketFk` = `t`.`id`)) join `vn`.`item` `i` on(`i`.`id` = `s`.`itemFk`)) join `vn`.`config` `c`) where `et`.`ETD` > `util`.`yesterday`() group by `t`.`routeFk` order by `et`.`ETD`,`t`.`routeFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80876,26 +80338,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleCost` AS select `s`.`itemFk` AS `itemFk`,`s`.`ticketFk` AS `ticketFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`s`.`discount` AS `discount`,`s`.`price` AS `price`,`c`.`name` AS `component`,`sc`.`value` AS `coste` from (((`sale` `s` join `saleComponent` `sc` on((`sc`.`saleFk` = `s`.`id`))) join `component` `c` on((`c`.`id` = `sc`.`componentFk`))) join `componentType` `ct` on((`ct`.`id` = `c`.`typeFk`))) where (`ct`.`type` = 'coste') */; -/*!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 `saleLabel` --- - -/*!50001 DROP TABLE IF EXISTS `saleLabel`*/; -/*!50001 DROP VIEW IF EXISTS `saleLabel`*/; -/*!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_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleLabel` AS select `ml`.`Id_movimiento` AS `saleFk`,`ml`.`label` AS `label`,`ml`.`stem` AS `stem`,`ml`.`created` AS `created` from `vn2008`.`movement_label` `ml` */; +/*!50001 VIEW `saleCost` AS select `s`.`itemFk` AS `itemFk`,`s`.`ticketFk` AS `ticketFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`s`.`discount` AS `discount`,`s`.`price` AS `price`,`c`.`name` AS `component`,`sc`.`value` AS `coste` from (((`sale` `s` join `saleComponent` `sc` on(`sc`.`saleFk` = `s`.`id`)) join `component` `c` on(`c`.`id` = `sc`.`componentFk`)) join `componentType` `ct` on(`ct`.`id` = `c`.`typeFk`)) where `ct`.`type` = 'coste' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80914,7 +80357,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleMistakeList` AS select `st`.`saleFk` AS `saleFk`,`st`.`workerFk` AS `workerFk`,concat(`w2`.`firstName`,' ',`w2`.`lastName`) AS `sacador`,`st`.`created` AS `created`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `revisador`,`mt`.`description` AS `description`,`sm`.`created` AS `controlled` from (((((`vn`.`saleTracking` `st` join `vn`.`worker` `w2` on((`w2`.`id` = `st`.`workerFk`))) join `vncontrol`.`accion` `a` on(((`a`.`accion_id` = `st`.`actionFk`) and (`a`.`accion` = 'SACAR')))) left join `vn`.`saleMistake` `sm` on((`st`.`saleFk` = `sm`.`saleFk`))) left join `vn`.`mistakeType` `mt` on((`mt`.`id` = `sm`.`typeFk`))) left join `vn`.`worker` `w` on((`w`.`id` = `sm`.`userFk`))) */; +/*!50001 VIEW `saleMistakeList` AS select `st`.`saleFk` AS `saleFk`,`st`.`workerFk` AS `workerFk`,concat(`w2`.`firstName`,' ',`w2`.`lastName`) AS `sacador`,`st`.`created` AS `created`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `revisador`,`mt`.`description` AS `description`,`sm`.`created` AS `controlled` from (((((`vn`.`saleTracking` `st` join `vn`.`worker` `w2` on(`w2`.`id` = `st`.`workerFk`)) join `vncontrol`.`accion` `a` on(`a`.`accion_id` = `st`.`actionFk` and `a`.`accion` = 'SACAR')) left join `vn`.`saleMistake` `sm` on(`st`.`saleFk` = `sm`.`saleFk`)) left join `vn`.`mistakeType` `mt` on(`mt`.`id` = `sm`.`typeFk`)) left join `vn`.`worker` `w` on(`w`.`id` = `sm`.`userFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80933,7 +80376,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleMistake_list__2` AS select `st`.`saleFk` AS `saleFk`,`st`.`workerFk` AS `workerFk`,concat(`w2`.`firstName`,' ',`w2`.`lastName`) AS `sacador`,`st`.`created` AS `created`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `revisador`,`mt`.`description` AS `description`,`sm`.`created` AS `controlled` from (((((`vn`.`saleTracking` `st` join `vn`.`worker` `w2` on((`w2`.`id` = `st`.`workerFk`))) join `vncontrol`.`accion` `a` on(((`a`.`accion_id` = `st`.`actionFk`) and (`a`.`accion` = 'SACAR')))) left join `vn`.`saleMistake` `sm` on((`st`.`saleFk` = `sm`.`saleFk`))) left join `vn`.`mistakeType` `mt` on((`mt`.`id` = `sm`.`typeFk`))) left join `vn`.`worker` `w` on((`w`.`id` = `sm`.`userFk`))) */; +/*!50001 VIEW `saleMistake_list__2` AS select `st`.`saleFk` AS `saleFk`,`st`.`workerFk` AS `workerFk`,concat(`w2`.`firstName`,' ',`w2`.`lastName`) AS `sacador`,`st`.`created` AS `created`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `revisador`,`mt`.`description` AS `description`,`sm`.`created` AS `controlled` from (((((`vn`.`saleTracking` `st` join `vn`.`worker` `w2` on(`w2`.`id` = `st`.`workerFk`)) join `vncontrol`.`accion` `a` on(`a`.`accion_id` = `st`.`actionFk` and `a`.`accion` = 'SACAR')) left join `vn`.`saleMistake` `sm` on(`st`.`saleFk` = `sm`.`saleFk`)) left join `vn`.`mistakeType` `mt` on(`mt`.`id` = `sm`.`typeFk`)) left join `vn`.`worker` `w` on(`w`.`id` = `sm`.`userFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80952,7 +80395,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleSaleTracking` AS select distinct `st`.`saleFk` AS `saleFk` from `saleTracking` `st` where (`st`.`created` >= (curdate() + interval -(1) day)) */; +/*!50001 VIEW `saleSaleTracking` AS select distinct `st`.`saleFk` AS `saleFk` from `saleTracking` `st` where `st`.`created` >= `util`.`VN_CURDATE`() + interval -1 day */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80971,7 +80414,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleValue` AS select `wh`.`name` AS `warehouse`,`c`.`name` AS `client`,`c`.`typeFk` AS `clientTypeFk`,`u`.`name` AS `buyer`,`it`.`id` AS `itemTypeFk`,`it`.`name` AS `family`,`s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,(((`b`.`buyingValue` + `b`.`freightValue`) + `b`.`comissionValue`) + `b`.`packageValue`) AS `cost`,((((`b`.`buyingValue` + `b`.`freightValue`) + `b`.`comissionValue`) + `b`.`packageValue`) * `s`.`quantity`) AS `value`,`tm`.`year` AS `year`,`tm`.`week` AS `week` from (((((((((`vn`.`sale` `s` join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemType` `it` on((`it`.`id` = `i`.`typeFk`))) join `account`.`user` `u` on((`u`.`id` = `it`.`workerFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`client` `c` on((`c`.`id` = `t`.`clientFk`))) join `vn`.`warehouse` `wh` on((`wh`.`id` = `t`.`warehouseFk`))) join `vn`.`time` `tm` on((`tm`.`dated` = cast(`t`.`shipped` as date)))) join `cache`.`last_buy` `lb` on(((`lb`.`item_id` = `i`.`id`) and (`lb`.`warehouse_id` = `wh`.`id`)))) join `vn`.`buy` `b` on((`b`.`id` = `lb`.`buy_id`))) where (`wh`.`isManaged` <> 0) */; +/*!50001 VIEW `saleValue` AS select `wh`.`name` AS `warehouse`,`c`.`name` AS `client`,`c`.`typeFk` AS `clientTypeFk`,`u`.`name` AS `buyer`,`it`.`id` AS `itemTypeFk`,`it`.`name` AS `family`,`s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`b`.`buyingValue` + `b`.`freightValue` + `b`.`comissionValue` + `b`.`packageValue` AS `cost`,(`b`.`buyingValue` + `b`.`freightValue` + `b`.`comissionValue` + `b`.`packageValue`) * `s`.`quantity` AS `value`,`tm`.`year` AS `year`,`tm`.`week` AS `week` from (((((((((`vn`.`sale` `s` join `vn`.`item` `i` on(`i`.`id` = `s`.`itemFk`)) join `vn`.`itemType` `it` on(`it`.`id` = `i`.`typeFk`)) join `account`.`user` `u` on(`u`.`id` = `it`.`workerFk`)) join `vn`.`ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `vn`.`client` `c` on(`c`.`id` = `t`.`clientFk`)) join `vn`.`warehouse` `wh` on(`wh`.`id` = `t`.`warehouseFk`)) join `vn`.`time` `tm` on(`tm`.`dated` = cast(`t`.`shipped` as date))) join `cache`.`last_buy` `lb` on(`lb`.`item_id` = `i`.`id` and `lb`.`warehouse_id` = `wh`.`id`)) join `vn`.`buy` `b` on(`b`.`id` = `lb`.`buy_id`)) where `wh`.`isManaged` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80990,7 +80433,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,round(((`ic`.`cm3delivery` * `s`.`quantity`) / 1000),0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,((`s`.`quantity` * `ic`.`cm3delivery`) / 1000000) AS `volume`,((`s`.`quantity` * `ic`.`grams`) / 1000) AS `physicalWeight`,(((`s`.`quantity` * `ic`.`cm3delivery`) * greatest(`i`.`density`,167)) / 1000000) AS `weight`,((`s`.`quantity` * `ic`.`cm3delivery`) / 1000000) AS `physicalVolume`,(((`s`.`quantity` * `ic`.`cm3delivery`) * ifnull(`t`.`zonePrice`,`z`.`price`)) / (`vc`.`standardFlowerBox` * 1000)) AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk`,`s`.`isPicked` AS `isPicked`,(((`s`.`quantity` * `s`.`price`) * (100 - `s`.`discount`)) / 100) AS `eurosValue`,`i`.`itemPackingTypeFk` AS `itemPackingTypeFk` from (((((`sale` `s` join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `zone` `z` on((`z`.`id` = `t`.`zoneFk`))) join `volumeConfig` `vc`) join `itemCost` `ic` on(((`ic`.`itemFk` = `s`.`itemFk`) and (`ic`.`warehouseFk` = `t`.`warehouseFk`)))) where (`s`.`quantity` > 0) */; +/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,round(`ic`.`cm3delivery` * `s`.`quantity` / 1000,0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `volume`,`s`.`quantity` * `ic`.`grams` / 1000 AS `physicalWeight`,`s`.`quantity` * `ic`.`cm3delivery` * greatest(`ic`.`grams` / `ic`.`cm3delivery`,`vc`.`aerealVolumetricDensity`) / 1000000 AS `weight`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `physicalVolume`,`s`.`quantity` * `ic`.`cm3delivery` * ifnull(`t`.`zonePrice`,`z`.`price`) / (`vc`.`standardFlowerBox` * 1000) AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk`,`s`.`isPicked` AS `isPicked`,`s`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100 AS `eurosValue`,`i`.`itemPackingTypeFk` AS `itemPackingTypeFk` from (((((`sale` `s` join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) join `volumeConfig` `vc`) join `itemCost` `ic` on(`ic`.`itemFk` = `s`.`itemFk` and `ic`.`warehouseFk` = `t`.`warehouseFk`)) where `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 */; @@ -81009,7 +80452,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume_Today_VNH` AS select `t`.`nickname` AS `Cliente`,`p`.`name` AS `Provincia`,`c`.`country` AS `Pais`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `volume` from (((((`saleVolume` `sv` join `ticket` `t` on((`t`.`id` = `sv`.`ticketFk`))) join `address` `a` on((`a`.`id` = `t`.`addressFk`))) join `province` `p` on((`p`.`id` = `a`.`provinceFk`))) join `country` `c` on((`c`.`id` = `p`.`countryFk`))) join `warehouse` `w` on((`w`.`id` = `t`.`warehouseFk`))) where ((`w`.`name` = 'VNH') and (`t`.`shipped` between curdate() and `util`.`dayend`(curdate()))) group by `t`.`nickname`,`p`.`name` */; +/*!50001 VIEW `saleVolume_Today_VNH` AS select `t`.`nickname` AS `Cliente`,`p`.`name` AS `Provincia`,`c`.`country` AS `Pais`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `volume` from (((((`saleVolume` `sv` join `ticket` `t` on(`t`.`id` = `sv`.`ticketFk`)) join `address` `a` on(`a`.`id` = `t`.`addressFk`)) join `province` `p` on(`p`.`id` = `a`.`provinceFk`)) join `country` `c` on(`c`.`id` = `p`.`countryFk`)) join `warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) where `w`.`name` = 'VNH' and `t`.`shipped` between `util`.`VN_CURDATE`() and `util`.`dayend`(`util`.`VN_CURDATE`()) group by `t`.`nickname`,`p`.`name` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81028,7 +80471,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `sale_freightComponent` AS select `t`.`id` AS `ticketFk`,(`sc`.`value` * `s`.`quantity`) AS `amount`,`t`.`shipped` AS `shipped` from ((((`ticket` `t` straight_join `sale` `s` on((`t`.`id` = `s`.`ticketFk`))) 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`.`type` = 'agencia')))) */; +/*!50001 VIEW `sale_freightComponent` AS select `t`.`id` AS `ticketFk`,`sc`.`value` * `s`.`quantity` AS `amount`,`t`.`shipped` AS `shipped` from ((((`ticket` `t` straight_join `sale` `s` on(`t`.`id` = `s`.`ticketFk`)) 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`.`type` = 'agencia')) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81047,7 +80490,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `salesPersonSince` AS select `pr`.`workerFk` AS `workerFk`,min(`b`.`date_start`) AS `started` from (((`postgresql`.`profile` `pr` left join `postgresql`.`business` `b` on((`pr`.`profile_id` = `b`.`client_id`))) left join `postgresql`.`business_labour` `bl` on((`b`.`business_id` = `bl`.`business_id`))) join `postgresql`.`professional_category` `pc` on((`pc`.`professional_category_id` = `bl`.`professional_category_id`))) where (`pc`.`category_name` = 'Aux ventas') group by `pr`.`workerFk` */; +/*!50001 VIEW `salesPersonSince` AS select `b`.`workerFk` AS `workerFk`,min(`b`.`started`) AS `started` from ((`vn`.`business` `b` join `vn`.`worker` `w` on(`w`.`id` = `b`.`workerFk`)) left join `postgresql`.`professional_category` `pc` on(`pc`.`professional_category_id` = `b`.`workerBusinessProfessionalCategoryFk`)) where `pc`.`category_name` = 'Aux ventas' group by `b`.`workerFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81066,7 +80509,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `salesPreparedLastHour` AS select `t`.`warehouseFk` AS `warehouseFk`,`st`.`saleFk` AS `saleFk`,`st`.`isChecked` AS `isChecked`,`st`.`originalQuantity` AS `originalQuantity`,`a`.`accion` AS `accion`,`st`.`created` AS `created`,`e`.`code` AS `code`,`w`.`firstName` AS `firstname`,`w`.`lastName` AS `lastName`,`w`.`code` AS `workerCode`,((`ic`.`cm3delivery` * `s`.`quantity`) / 1000) AS `litros`,`s`.`concept` AS `concept`,`d`.`name` AS `departmentName` from (((((((((`vn`.`saleTracking` `st` left join `vn`.`salesPreviousPreparated` `prevPrepSales` on((`prevPrepSales`.`saleFk` = `st`.`saleFk`))) join `vn`.`sale` `s` on((`s`.`id` = `st`.`saleFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`itemCost` `ic` on(((`ic`.`warehouseFk` = `t`.`warehouseFk`) and (`ic`.`itemFk` = `s`.`itemFk`)))) join `vn`.`worker` `w` on((`w`.`id` = `st`.`workerFk`))) join `vn`.`state` `e` on((`e`.`id` = `st`.`stateFk`))) join `vncontrol`.`accion` `a` on((`a`.`accion_id` = `st`.`actionFk`))) join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `st`.`workerFk`))) join `vn`.`department` `d` on((`d`.`id` = `wd`.`departmentFk`))) where ((`st`.`created` > (now() + interval -(1) hour)) and isnull(`prevPrepSales`.`saleFk`) and (not((`d`.`name` like 'EQUIPO%')))) */; +/*!50001 VIEW `salesPreparedLastHour` AS select `t`.`warehouseFk` AS `warehouseFk`,`st`.`saleFk` AS `saleFk`,`st`.`isChecked` AS `isChecked`,`st`.`originalQuantity` AS `originalQuantity`,`a`.`accion` AS `accion`,`st`.`created` AS `created`,`e`.`code` AS `code`,`w`.`firstName` AS `firstname`,`w`.`lastName` AS `lastName`,`w`.`code` AS `workerCode`,`ic`.`cm3delivery` * `s`.`quantity` / 1000 AS `litros`,`s`.`concept` AS `concept`,`d`.`name` AS `departmentName` from (((((((((`vn`.`saleTracking` `st` left join `vn`.`salesPreviousPreparated` `prevPrepSales` on(`prevPrepSales`.`saleFk` = `st`.`saleFk`)) join `vn`.`sale` `s` on(`s`.`id` = `st`.`saleFk`)) join `vn`.`ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `vn`.`itemCost` `ic` on(`ic`.`warehouseFk` = `t`.`warehouseFk` and `ic`.`itemFk` = `s`.`itemFk`)) join `vn`.`worker` `w` on(`w`.`id` = `st`.`workerFk`)) join `vn`.`state` `e` on(`e`.`id` = `st`.`stateFk`)) join `vncontrol`.`accion` `a` on(`a`.`accion_id` = `st`.`actionFk`)) join `vn`.`workerDepartment` `wd` on(`wd`.`workerFk` = `st`.`workerFk`)) join `vn`.`department` `d` on(`d`.`id` = `wd`.`departmentFk`)) where `st`.`created` > current_timestamp() + interval -1 hour and `prevPrepSales`.`saleFk` is null and `d`.`name` not like 'EQUIPO%' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81085,7 +80528,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `salesPreviousPreparated` AS select `st`.`saleFk` AS `saleFk` from (`saleTracking` `st` join `state` `e` on((`e`.`id` = `st`.`stateFk`))) where ((`st`.`created` > curdate()) and (`e`.`code` like 'PREVIOUS_PREPARATION')) */; +/*!50001 VIEW `salesPreviousPreparated` AS select `st`.`saleFk` AS `saleFk` from (`saleTracking` `st` join `state` `e` on(`e`.`id` = `st`.`stateFk`)) where `st`.`created` > `util`.`VN_CURDATE`() and `e`.`code` like 'PREVIOUS_PREPARATION' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81104,7 +80547,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `supplierPackaging` AS select `e`.`supplierFk` AS `supplierFk`,`b`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`s`.`name` AS `supplier`,`b`.`entryFk` AS `entryFk`,`tr`.`landed` AS `landed`,-(least(`b`.`quantity`,0)) AS `out`,greatest(`b`.`quantity`,0) AS `in`,`w`.`name` AS `warehouse`,`b`.`buyingValue` AS `buyingValue` from ((((((`buy` `b` join `item` `i` on((`i`.`id` = `b`.`itemFk`))) join `packaging` `p` on((`p`.`itemFk` = `i`.`id`))) join `entry` `e` on((`e`.`id` = `b`.`entryFk`))) join `supplier` `s` on((`s`.`id` = `e`.`supplierFk`))) join `travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) join `warehouse` `w` on((`w`.`id` = `tr`.`warehouseInFk`))) where `p`.`isPackageReturnable` */; +/*!50001 VIEW `supplierPackaging` AS select `e`.`supplierFk` AS `supplierFk`,`b`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`s`.`name` AS `supplier`,`b`.`entryFk` AS `entryFk`,`tr`.`landed` AS `landed`,-least(`b`.`quantity`,0) AS `out`,greatest(`b`.`quantity`,0) AS `in`,`w`.`name` AS `warehouse`,`b`.`buyingValue` AS `buyingValue` from ((((((`buy` `b` join `item` `i` on(`i`.`id` = `b`.`itemFk`)) join `packaging` `p` on(`p`.`itemFk` = `i`.`id`)) join `entry` `e` on(`e`.`id` = `b`.`entryFk`)) join `supplier` `s` on(`s`.`id` = `e`.`supplierFk`)) join `travel` `tr` on(`tr`.`id` = `e`.`travelFk`)) join `warehouse` `w` on(`w`.`id` = `tr`.`warehouseInFk`)) where `p`.`isPackageReturnable` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81123,7 +80566,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `tagL10n` AS select `t`.`id` AS `id`,ifnull(`i`.`name`,`t`.`name`) AS `name` from (`tag` `t` left join `tagI18n` `i` on(((`i`.`tagFk` = `t`.`id`) and (`i`.`lang` = `util`.`LANG`())))) */; +/*!50001 VIEW `tagL10n` AS select `t`.`id` AS `id`,ifnull(`i`.`name`,`t`.`name`) AS `name` from (`tag` `t` left join `tagI18n` `i` on(`i`.`tagFk` = `t`.`id` and `i`.`lang` = `util`.`LANG`())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81161,45 +80604,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketLastUpdatedList` AS select `s`.`ticketFk` AS `ticketFk`,`st`.`created` AS `created` from (`vn`.`saleTracking` `st` join `vn`.`sale` `s` on((`s`.`id` = `st`.`saleFk`))) where (`st`.`created` > curdate()) union all select `i`.`Id_Ticket` AS `Id_Ticket`,`i`.`odbc_date` AS `odbc_date` from `vncontrol`.`inter` `i` where (`i`.`odbc_date` > curdate()) union all select `s`.`ticketFk` AS `ticketFk`,`iss`.`created` AS `created` from (`vn`.`itemShelvingSale` `iss` join `vn`.`sale` `s` on((`s`.`id` = `iss`.`saleFk`))) where (`iss`.`created` > 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 `ticketLocation` --- - -/*!50001 DROP TABLE IF EXISTS `ticketLocation`*/; -/*!50001 DROP VIEW IF EXISTS `ticketLocation`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketLocation` AS select `tl`.`Id_Ticket` AS `ticketFk`,`tl`.`longitude` AS `longitude`,`tl`.`latitude` AS `latitude` from `vn2008`.`ticket_location` `tl` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `ticketMRW` --- - -/*!50001 DROP TABLE IF EXISTS `ticketMRW`*/; -/*!50001 DROP VIEW IF EXISTS `ticketMRW`*/; -/*!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_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` 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`,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 VIEW `ticketLastUpdatedList` AS select `s`.`ticketFk` AS `ticketFk`,`st`.`created` AS `created` from (`vn`.`saleTracking` `st` join `vn`.`sale` `s` on(`s`.`id` = `st`.`saleFk`)) where `st`.`created` > `util`.`VN_CURDATE`() union all select `i`.`Id_Ticket` AS `Id_Ticket`,`i`.`odbc_date` AS `odbc_date` from `vncontrol`.`inter` `i` where `i`.`odbc_date` > `util`.`VN_CURDATE`() union all select `s`.`ticketFk` AS `ticketFk`,`iss`.`created` AS `created` from (`vn`.`itemShelvingSale` `iss` join `vn`.`sale` `s` on(`s`.`id` = `iss`.`saleFk`)) where `iss`.`created` > `util`.`VN_CURDATE`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81218,7 +80623,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketNotInvoiced` AS select `t`.`companyFk` AS `companyFk`,`cm`.`code` AS `companyCode`,`t`.`clientFk` AS `clientFk`,`c`.`name` AS `clientName`,`t`.`shipped` AS `shipped`,cast(sum((((`s`.`quantity` * `s`.`price`) * (100 - `s`.`discount`)) / 100)) as decimal(10,2)) AS `value` from (((`ticket` `t` join `sale` `s` on((`s`.`ticketFk` = `t`.`id`))) join `client` `c` on((`c`.`id` = `t`.`clientFk`))) join `company` `cm` on((`cm`.`id` = `t`.`companyFk`))) where (isnull(`t`.`refFk`) and (`t`.`shipped` > '2017-01-01')) group by `t`.`id` */; +/*!50001 VIEW `ticketNotInvoiced` AS select `t`.`companyFk` AS `companyFk`,`cm`.`code` AS `companyCode`,`t`.`clientFk` AS `clientFk`,`c`.`name` AS `clientName`,`t`.`shipped` AS `shipped`,cast(sum(`s`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100) as decimal(10,2)) AS `value` from (((`ticket` `t` join `sale` `s` on(`s`.`ticketFk` = `t`.`id`)) join `client` `c` on(`c`.`id` = `t`.`clientFk`)) join `company` `cm` on(`cm`.`id` = `t`.`companyFk`)) where `t`.`refFk` is null and `t`.`shipped` > '2017-01-01' group by `t`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81237,7 +80642,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketPackingList` AS select `t`.`nickname` AS `nickname`,`t`.`id` AS `ticketFk`,`am`.`name` AS `agencyMode`,`am`.`flag` AS `flag`,`p`.`name` AS `province`,`s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`sv`.`litros` AS `litros`,`to`.`description` AS `observaciones` from (((((((`ticket` `t` join `address` `a` on((`a`.`id` = `t`.`addressFk`))) join `province` `p` on((`p`.`id` = `a`.`provinceFk`))) join `agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) left join `sale` `s` on((`s`.`ticketFk` = `t`.`id`))) left join `saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) join `observationType` `ot` on((`ot`.`code` = 'packager'))) left join `ticketObservation` `to` on(((`to`.`ticketFk` = `t`.`id`) and (`ot`.`id` = `to`.`observationTypeFk`)))) */; +/*!50001 VIEW `ticketPackingList` AS select `t`.`nickname` AS `nickname`,`t`.`id` AS `ticketFk`,`am`.`name` AS `agencyMode`,`am`.`flag` AS `flag`,`p`.`name` AS `province`,`s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`sv`.`litros` AS `litros`,`to`.`description` AS `observaciones` from (((((((`ticket` `t` join `address` `a` on(`a`.`id` = `t`.`addressFk`)) join `province` `p` on(`p`.`id` = `a`.`provinceFk`)) join `agencyMode` `am` on(`am`.`id` = `t`.`agencyModeFk`)) left join `sale` `s` on(`s`.`ticketFk` = `t`.`id`)) left join `saleVolume` `sv` on(`sv`.`saleFk` = `s`.`id`)) join `observationType` `ot` on(`ot`.`code` = 'packager')) left join `ticketObservation` `to` on(`to`.`ticketFk` = `t`.`id` and `ot`.`id` = `to`.`observationTypeFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81256,7 +80661,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketPreviousPreparingList` AS select `s`.`ticketFk` AS `ticketFk`,`w`.`code` AS `code`,count(`s`.`id`) AS `saleLines`,sum((`s`.`isPicked` <> 0)) AS `alreadyMadeSaleLines`,(sum((`s`.`isPicked` <> 0)) / count(`s`.`id`)) AS `madeRate`,`sg`.`created` AS `created`,`p`.`code` AS `parking`,`iss`.`sectorFk` AS `sectorFk`,`al`.`code` AS `alertCode` from (((((((`vn`.`saleGroup` `sg` join `vn`.`saleGroupDetail` `sgd` on((`sgd`.`saleGroupFk` = `sg`.`id`))) join `vn`.`sale` `s` on((`s`.`id` = `sgd`.`saleFk`))) join `vn`.`ticketState` `tls` on((`tls`.`ticketFk` = `s`.`ticketFk`))) join `vn`.`alertLevel` `al` on((`al`.`id` = `tls`.`alertLevel`))) join `vn`.`worker` `w` on((`w`.`id` = `sg`.`userFk`))) left join `vn`.`parking` `p` on((`p`.`id` = `sg`.`parkingFk`))) join `vn`.`itemShelvingStock` `iss` on((`iss`.`itemFk` = `s`.`itemFk`))) where (`sg`.`created` >= (curdate() + interval 0.1 day)) group by `sg`.`id` */; +/*!50001 VIEW `ticketPreviousPreparingList` AS select `s`.`ticketFk` AS `ticketFk`,`w`.`code` AS `code`,count(`s`.`id`) AS `saleLines`,sum(`s`.`isPicked` <> 0) AS `alreadyMadeSaleLines`,sum(`s`.`isPicked` <> 0) / count(`s`.`id`) AS `madeRate`,`sg`.`created` AS `created`,`p`.`code` AS `parking`,`iss`.`sectorFk` AS `sectorFk`,`al`.`code` AS `alertCode` from (((((((`vn`.`saleGroup` `sg` join `vn`.`saleGroupDetail` `sgd` on(`sgd`.`saleGroupFk` = `sg`.`id`)) join `vn`.`sale` `s` on(`s`.`id` = `sgd`.`saleFk`)) join `vn`.`ticketState` `tls` on(`tls`.`ticketFk` = `s`.`ticketFk`)) join `vn`.`alertLevel` `al` on(`al`.`id` = `tls`.`alertLevel`)) join `vn`.`worker` `w` on(`w`.`id` = `sg`.`userFk`)) left join `vn`.`parking` `p` on(`p`.`id` = `sg`.`parkingFk`)) join `vn`.`itemShelvingStock` `iss` on(`iss`.`itemFk` = `s`.`itemFk`)) where `sg`.`created` >= `util`.`VN_CURDATE`() + interval 0.1 day group by `sg`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81275,7 +80680,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketState` AS select `i`.`odbc_date` AS `updated`,`i`.`state_id` AS `stateFk`,`i`.`Id_Trabajador` AS `workerFk`,`tls`.`ticketFk` AS `ticketFk`,`s`.`id` AS `state`,`s`.`order` AS `productionOrder`,`s`.`alertLevel` AS `alertLevel`,`s`.`code` AS `code`,`tls`.`ticketFk` AS `ticket`,`i`.`Id_Trabajador` AS `worker`,`s`.`isPreviousPreparable` AS `isPreviousPreparable`,`s`.`isPicked` AS `isPicked` from ((`vn`.`ticketLastState` `tls` join `vncontrol`.`inter` `i` on((`i`.`inter_id` = `tls`.`ticketTrackingFk`))) join `vn`.`state` `s` on((`s`.`id` = `i`.`state_id`))) */; +/*!50001 VIEW `ticketState` AS select `i`.`odbc_date` AS `updated`,`i`.`state_id` AS `stateFk`,`i`.`Id_Trabajador` AS `workerFk`,`tls`.`ticketFk` AS `ticketFk`,`s`.`id` AS `state`,`s`.`order` AS `productionOrder`,`s`.`alertLevel` AS `alertLevel`,`s`.`code` AS `code`,`tls`.`ticketFk` AS `ticket`,`i`.`Id_Trabajador` AS `worker`,`s`.`isPreviousPreparable` AS `isPreviousPreparable`,`s`.`isPicked` AS `isPicked` from ((`vn`.`ticketLastState` `tls` join `vncontrol`.`inter` `i` on(`i`.`inter_id` = `tls`.`ticketTrackingFk`)) join `vn`.`state` `s` on(`s`.`id` = `i`.`state_id`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81294,7 +80699,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketStateToday` AS select `ts`.`ticket` AS `ticket`,`ts`.`state` AS `state`,`ts`.`productionOrder` AS `productionOrder`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`worker` AS `worker`,`ts`.`code` AS `code`,`ts`.`updated` AS `updated`,`ts`.`isPicked` AS `isPicked` from (`vn`.`ticketState` `ts` join `vn`.`ticket` `t` on((`t`.`id` = `ts`.`ticket`))) where (`t`.`shipped` between curdate() and `MIDNIGHT`(curdate())) */; +/*!50001 VIEW `ticketStateToday` AS select `ts`.`ticket` AS `ticket`,`ts`.`state` AS `state`,`ts`.`productionOrder` AS `productionOrder`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`worker` AS `worker`,`ts`.`code` AS `code`,`ts`.`updated` AS `updated`,`ts`.`isPicked` AS `isPicked` from (`vn`.`ticketState` `ts` join `vn`.`ticket` `t` on(`t`.`id` = `ts`.`ticket`)) where `t`.`shipped` between `util`.`VN_CURDATE`() and `MIDNIGHT`(`util`.`VN_CURDATE`()) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81351,7 +80756,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `traceabilityBuy` AS select `b`.`id` AS `buyFk`,`b`.`quantity` AS `quantity`,`tr`.`landed` AS `landed`,`w`.`name` AS `warehouseName`,`b`.`entryFk` AS `entryFk`,`s`.`name` AS `supplierName`,ifnull(`b`.`itemOriginalFk`,`b`.`itemFk`) AS `itemFk` from ((((`buy` `b` join `entry` `e` on((`e`.`id` = `b`.`entryFk`))) join `travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) join `supplier` `s` on((`s`.`id` = `e`.`supplierFk`))) join `warehouse` `w` on((`w`.`id` = `tr`.`warehouseInFk`))) */; +/*!50001 VIEW `traceabilityBuy` AS select `b`.`id` AS `buyFk`,`b`.`quantity` AS `quantity`,`tr`.`landed` AS `landed`,`w`.`name` AS `warehouseName`,`b`.`entryFk` AS `entryFk`,`s`.`name` AS `supplierName`,ifnull(`b`.`itemOriginalFk`,`b`.`itemFk`) AS `itemFk` from ((((`buy` `b` join `entry` `e` on(`e`.`id` = `b`.`entryFk`)) join `travel` `tr` on(`tr`.`id` = `e`.`travelFk`)) join `supplier` `s` on(`s`.`id` = `e`.`supplierFk`)) join `warehouse` `w` on(`w`.`id` = `tr`.`warehouseInFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81370,7 +80775,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `traceabilitySale` AS select `s`.`ticketFk` AS `ticketFk`,`sb`.`buyFk` AS `buyFk`,`t`.`shipped` AS `shipped`,`t`.`nickname` AS `nickname`,`s`.`quantity` AS `quantity`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `worker` from (((`saleBuy` `sb` join `sale` `s` on((`s`.`id` = `sb`.`saleFk`))) join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `worker` `w` on((`w`.`id` = `sb`.`workerFk`))) */; +/*!50001 VIEW `traceabilitySale` AS select `s`.`ticketFk` AS `ticketFk`,`sb`.`buyFk` AS `buyFk`,`t`.`shipped` AS `shipped`,`t`.`nickname` AS `nickname`,`s`.`quantity` AS `quantity`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `worker` from (((`saleBuy` `sb` join `sale` `s` on(`s`.`id` = `sb`.`saleFk`)) join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `worker` `w` on(`w`.`id` = `sb`.`workerFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81408,7 +80813,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerBusinessDated` AS select `t`.`dated` AS `dated`,`b`.`business_id` AS `business_id`,`pr`.`workerFk` AS `workerFk` from ((`vn`.`time` `t` left join `postgresql`.`business` `b` on((`t`.`dated` between `b`.`date_start` and ifnull(`b`.`date_end`,curdate())))) left join `postgresql`.`profile` `pr` on((`b`.`client_id` = `pr`.`profile_id`))) where (`t`.`dated` > (curdate() + interval -(2) year)) */; +/*!50001 VIEW `workerBusinessDated` AS select `t`.`dated` AS `dated`,`b`.`id` AS `businessFk`,`b`.`workerFk` AS `workerFk` from (`time` `t` left join `business` `b` on(`t`.`dated` between `b`.`started` and ifnull(`b`.`ended`,util.VN_CURDATE()))) where `t`.`dated` > util.VN_CURDATE() + interval -2 year */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81427,7 +80832,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerCalendar` AS select `ce`.`business_id` AS `businessFk`,`pr`.`workerFk` AS `workerFk`,`ce`.`calendar_state_id` AS `absenceTypeFk`,`ce`.`date` AS `dated` from ((`postgresql`.`profile` `pr` join `postgresql`.`business` `b` on((`b`.`client_id` = `pr`.`profile_id`))) join `postgresql`.`calendar_employee` `ce` on((`ce`.`business_id` = `b`.`business_id`))) */; +/*!50001 VIEW `workerCalendar` AS select `b`.`id` AS `businessFk`,`b`.`workerFk` AS `workerFk`,`ce`.`calendar_state_id` AS `absenceTypeFk`,`ce`.`date` AS `dated` from (`vn`.`business` `b` join `postgresql`.`calendar_employee` `ce` on(`ce`.`businessFk` = `b`.`id`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81446,7 +80851,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerDepartment` AS select `pr`.`workerFk` AS `workerFk`,`bl`.`department_id` AS `departmentFk` from (`postgresql`.`profile` `pr` left join (`postgresql`.`business` `b` left join `postgresql`.`business_labour` `bl` on((`b`.`business_id` = `bl`.`business_id`))) on((`pr`.`profile_id` = `b`.`client_id`))) where ((isnull(`b`.`date_end`) and (`b`.`date_start` <= curdate())) or ((`b`.`date_end` >= curdate()) and (`b`.`date_start` <= curdate()))) */; +/*!50001 VIEW `workerDepartment` AS select `b`.`workerFk` AS `workerFk`,`b`.`departmentFk` AS `departmentFk` from `business` `b` where `b`.`ended` is null and `b`.`started` <= util.VN_CURDATE() or `b`.`ended` >= util.VN_CURDATE() and `b`.`started` <= util.VN_CURDATE() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81465,7 +80870,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerLabour` AS select `b`.`business_id` AS `businessFk`,`pr`.`workerFk` AS `workerFk`,`bl`.`workcenter_id` AS `workCenterFk`,`b`.`date_start` AS `started`,`b`.`date_end` AS `ended`,`d`.`id` AS `departmentFk`,`b`.`payedHolidays` AS `payedHolidays` from (((`postgresql`.`profile` `pr` join `postgresql`.`business` `b` on((`b`.`client_id` = `pr`.`profile_id`))) join `postgresql`.`business_labour` `bl` on((`b`.`business_id` = `bl`.`business_id`))) join `vn`.`department` `d` on((`d`.`id` = `bl`.`department_id`))) order by `b`.`date_start` desc */; +/*!50001 VIEW `workerLabour` AS select `b`.`id` AS `businessFk`,`b`.`workerFk` AS `workerFk`,`b`.`workcenterFk` AS `workCenterFk`,`b`.`started` AS `started`,`b`.`ended` AS `ended`,`b`.`departmentFk` AS `departmentFk`,`b`.`payedHolidays` AS `payedHolidays` from `business` `b` order by `b`.`started` desc */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81484,7 +80889,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerMedia` AS select `po`.`workerFk` AS `workerFk`,`m`.`value` AS `mediaValue` from (((`postgresql`.`profile` `po` join `postgresql`.`profile_media` `pom` on((`pom`.`profile_id` = `po`.`profile_id`))) join `postgresql`.`media` `m` on((`m`.`media_id` = `pom`.`media_id`))) join `postgresql`.`media_type` `mt` on((`mt`.`media_type_id` = `m`.`media_type_id`))) where (`mt`.`name` = 'movil empresa') */; +/*!50001 VIEW `workerMedia` AS select `w`.`id` AS `workerFk`,`w`.`phone` AS `mediaValue` from `worker` `w` where `w`.`phone` is not null */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81503,7 +80908,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerSpeedExpedition` AS select `sv`.`ticketFk` AS `ticketFk`,sum(`sv`.`litros`) AS `litros`,sum(if((`sub`.`started` > (now() + interval -(1) hour)),`sv`.`litros`,0)) AS `literLastHour`,cast(((60 * sum(`sv`.`litros`)) / time_to_sec(timediff(max(`sub`.`finished`),min(`sub`.`started`)))) as decimal(10,1)) AS `litersByMinute`,`sub`.`code` AS `workerCode`,`sub`.`cajas` AS `cajas`,`sub`.`warehouseFk` AS `warehouseFk` from (`saleVolume` `sv` join `expeditionTimeExpended` `sub` on((`sub`.`ticketFk` = `sv`.`ticketFk`))) group by `workerCode` */; +/*!50001 VIEW `workerSpeedExpedition` AS select `sv`.`ticketFk` AS `ticketFk`,sum(`sv`.`litros`) AS `litros`,sum(if(`sub`.`started` > current_timestamp() + interval -1 hour,`sv`.`litros`,0)) AS `literLastHour`,cast(60 * sum(`sv`.`litros`) / time_to_sec(timediff(max(`sub`.`finished`),min(`sub`.`started`))) as decimal(10,1)) AS `litersByMinute`,`sub`.`code` AS `workerCode`,`sub`.`cajas` AS `cajas`,`sub`.`warehouseFk` AS `warehouseFk` from (`saleVolume` `sv` join `expeditionTimeExpended` `sub` on(`sub`.`ticketFk` = `sv`.`ticketFk`)) group by `sub`.`code` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81522,7 +80927,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerSpeedSaleTracking` AS select `salesPreparedLastHour`.`warehouseFk` AS `warehouseFk`,`salesPreparedLastHour`.`accion` AS `accion`,`salesPreparedLastHour`.`workerCode` AS `workerCode`,sum(`salesPreparedLastHour`.`litros`) AS `sumaLitros`,min(`salesPreparedLastHour`.`created`) AS `started`,max(`salesPreparedLastHour`.`created`) AS `finished`,sum(if((`salesPreparedLastHour`.`created` >= (now() + interval -(1) hour)),`salesPreparedLastHour`.`litros`,0)) AS `sumaLitrosLastHour`,cast(((60 * sum(`salesPreparedLastHour`.`litros`)) / time_to_sec(timediff(max(`salesPreparedLastHour`.`created`),min(`salesPreparedLastHour`.`created`)))) as decimal(10,1)) AS `litersByMinute`,`salesPreparedLastHour`.`departmentName` AS `departmentName` from `vn`.`salesPreparedLastHour` group by `salesPreparedLastHour`.`warehouseFk`,`salesPreparedLastHour`.`accion`,`salesPreparedLastHour`.`workerCode` */; +/*!50001 VIEW `workerSpeedSaleTracking` AS select `salesPreparedLastHour`.`warehouseFk` AS `warehouseFk`,`salesPreparedLastHour`.`accion` AS `accion`,`salesPreparedLastHour`.`workerCode` AS `workerCode`,sum(`salesPreparedLastHour`.`litros`) AS `sumaLitros`,min(`salesPreparedLastHour`.`created`) AS `started`,max(`salesPreparedLastHour`.`created`) AS `finished`,sum(if(`salesPreparedLastHour`.`created` >= current_timestamp() + interval -1 hour,`salesPreparedLastHour`.`litros`,0)) AS `sumaLitrosLastHour`,cast(60 * sum(`salesPreparedLastHour`.`litros`) / time_to_sec(timediff(max(`salesPreparedLastHour`.`created`),min(`salesPreparedLastHour`.`created`))) as decimal(10,1)) AS `litersByMinute`,`salesPreparedLastHour`.`departmentName` AS `departmentName` from `vn`.`salesPreparedLastHour` group by `salesPreparedLastHour`.`warehouseFk`,`salesPreparedLastHour`.`accion`,`salesPreparedLastHour`.`workerCode` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81541,7 +80946,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerTeamCollegues` AS select distinct `w`.`workerFk` AS `workerFk`,`t`.`workerFk` AS `collegueFk` from (`workerTeam` `w` join `workerTeam` `t` on((`w`.`team` = `t`.`team`))) */; +/*!50001 VIEW `workerTeamCollegues` AS select distinct `w`.`workerFk` AS `workerFk`,`t`.`workerFk` AS `collegueFk` from (`workerTeam` `w` join `workerTeam` `t` on(`w`.`team` = `t`.`team`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81560,26 +80965,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerTimeControlUserInfo` AS select `u`.`id` AS `userFk`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`u`.`name` AS `user`,`u`.`password` AS `password`,`u`.`bcryptPassword` AS `bcryptPassword`,`wd`.`departmentFk` AS `departmentFk`,left(`c`.`fi`,8) AS `dni` from (((`account`.`user` `u` join `vn`.`worker` `w` on((`w`.`userFk` = `u`.`id`))) join `vn`.`client` `c` on((`c`.`id` = `u`.`id`))) left join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `w`.`id`))) */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `workerTimeControlWorking` --- - -/*!50001 DROP TABLE IF EXISTS `workerTimeControlWorking`*/; -/*!50001 DROP VIEW IF EXISTS `workerTimeControlWorking`*/; -/*!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_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerTimeControlWorking` AS select `wtc`.`userFk` AS `userFk`,`wtc`.`timed` AS `timed`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`pm`.`mediaValue` AS `phone`,`wm`.`mediaValue` AS `workerPhone`,`d`.`name` AS `department`,`wc`.`name` AS `workerCenter`,count(`wtc`.`order`) AS `maxOrder` from (((((((`vn`.`workerTimeControl` `wtc` join `vn`.`worker` `w` on((`w`.`userFk` = `wtc`.`userFk`))) left join `vn`.`personMedia` `pm` on((`pm`.`workerFk` = `w`.`id`))) left join `vn`.`workerMedia` `wm` on((`wm`.`workerFk` = `w`.`id`))) left join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `w`.`id`))) left join `vn`.`department` `d` on((`d`.`id` = `wd`.`departmentFk`))) left join `vn`.`workerLabour` `wl` on((`wl`.`businessFk` = (select `wl2`.`businessFk` from `vn`.`workerLabour` `wl2` where (`wl2`.`workerFk` = `w`.`id`) order by `wl2`.`started` desc limit 1)))) left join `vn`.`workCenter` `wc` on((`wc`.`id` = `wl`.`workCenterFk`))) where (cast(`wtc`.`timed` as date) = curdate()) group by `wtc`.`userFk` having ((`maxOrder` % 2) = 1) order by `wtc`.`timed` desc */; +/*!50001 VIEW `workerTimeControlUserInfo` AS select `u`.`id` AS `userFk`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`u`.`name` AS `user`,`u`.`password` AS `password`,`u`.`bcryptPassword` AS `bcryptPassword`,`wd`.`departmentFk` AS `departmentFk`,left(`c`.`fi`,8) AS `dni` from (((`account`.`user` `u` join `vn`.`worker` `w` on(`w`.`userFk` = `u`.`id`)) join `vn`.`client` `c` on(`c`.`id` = `u`.`id`)) left join `vn`.`workerDepartment` `wd` on(`wd`.`workerFk` = `w`.`id`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81598,7 +80984,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerTimeJourneyNG` AS select `wtc`.`userFk` AS `userFk`,cast(`wtc`.`timed` as date) AS `dated`,(if((`wtc`.`order` % 2),-(1),1) * (hour(`wtc`.`timed`) + (minute(`wtc`.`timed`) / 60))) AS `Journey`,dayname(`wtc`.`timed`) AS `dayName`,`w`.`lastName` AS `name`,`w`.`firstName` AS `firstname` from (`workerTimeControl` `wtc` join `worker` `w` on((`w`.`userFk` = `wtc`.`userFk`))) */; +/*!50001 VIEW `workerTimeJourneyNG` AS select `wtc`.`userFk` AS `userFk`,cast(`wtc`.`timed` as date) AS `dated`,if(`wtc`.`order` MOD 2,-1,1) * (hour(`wtc`.`timed`) + minute(`wtc`.`timed`) / 60) AS `Journey`,dayname(`wtc`.`timed`) AS `dayName`,`w`.`lastName` AS `name`,`w`.`firstName` AS `firstname` from (`workerTimeControl` `wtc` join `worker` `w` on(`w`.`userFk` = `wtc`.`userFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81617,7 +81003,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerWithoutTractor` AS select `c`.`workerFk` AS `workerFk`,`cl`.`name` AS `Trabajador`,count(distinct `c`.`id`) AS `Colecciones`,max(`c`.`created`) AS `created` from ((`collection` `c` join `client` `cl` on((`cl`.`id` = `c`.`workerFk`))) left join `machineWorker` `mw` on(((`mw`.`workerFk` = `c`.`workerFk`) and (`mw`.`inTimed` > curdate())))) where ((`c`.`created` > curdate()) and isnull(`mw`.`workerFk`)) group by `c`.`workerFk` */; +/*!50001 VIEW `workerWithoutTractor` AS select `c`.`workerFk` AS `workerFk`,`cl`.`name` AS `Trabajador`,count(distinct `c`.`id`) AS `Colecciones`,max(`c`.`created`) AS `created` from ((`collection` `c` join `client` `cl` on(`cl`.`id` = `c`.`workerFk`)) left join `machineWorker` `mw` on(`mw`.`workerFk` = `c`.`workerFk` and `mw`.`inTimed` > `util`.`VN_CURDATE`())) where `c`.`created` > `util`.`VN_CURDATE`() and `mw`.`workerFk` is null group by `c`.`workerFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81636,7 +81022,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `zoneEstimatedDelivery` AS select `t`.`zoneFk` AS `zoneFk`,cast((curdate() + interval ((hour(ifnull(`zc`.`hour`,`z`.`hour`)) * 60) + minute(ifnull(`zc`.`hour`,`z`.`hour`))) minute) as time) AS `hourTheoretical`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `totalVolume`,cast(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0)) as decimal(5,1)) AS `remainingVolume`,greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) AS `speed`,cast((`zc`.`hour` + interval ((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0))) minute) as time) AS `hourEffective`,floor(((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)))) AS `minutesLess`,cast((`zc`.`hour` + interval ((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0))) minute) as time) AS `etc` from (((((((((`vn`.`ticket` `t` join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `s` on((`s`.`id` = `tst`.`state`))) join `vn`.`saleVolume` `sv` on((`sv`.`ticketFk` = `t`.`id`))) left join `vn`.`lastHourProduction` `lhp` on((`lhp`.`warehouseFk` = `t`.`warehouseFk`))) join `vn`.`warehouse` `w` on((`w`.`id` = `t`.`warehouseFk`))) join `vn`.`warehouseAlias` `wa` on((`wa`.`id` = `w`.`aliasFk`))) join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `vn`.`zoneClosure` `zc` on(((`zc`.`zoneFk` = `t`.`zoneFk`) and (`zc`.`dated` = curdate())))) left join `cache`.`departure_limit` `dl` on(((`dl`.`warehouse_id` = `t`.`warehouseFk`) and (`dl`.`fecha` = curdate())))) where (`w`.`hasProduction` and (cast(`t`.`shipped` as date) = curdate())) group by `t`.`zoneFk` */; +/*!50001 VIEW `zoneEstimatedDelivery` AS select `t`.`zoneFk` AS `zoneFk`,cast(`util`.`VN_CURDATE`() + interval hour(ifnull(`zc`.`hour`,`z`.`hour`)) * 60 + minute(ifnull(`zc`.`hour`,`z`.`hour`)) minute as time) AS `hourTheoretical`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `totalVolume`,cast(sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) as decimal(5,1)) AS `remainingVolume`,greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) AS `speed`,cast(`zc`.`hour` + interval -sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) * 60 / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) minute as time) AS `hourEffective`,floor(-sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) * 60 / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0))) AS `minutesLess`,cast(`zc`.`hour` + interval -sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) * 60 / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) minute as time) AS `etc` from (((((((((`vn`.`ticket` `t` join `vn`.`ticketStateToday` `tst` on(`tst`.`ticket` = `t`.`id`)) join `vn`.`state` `s` on(`s`.`id` = `tst`.`state`)) join `vn`.`saleVolume` `sv` on(`sv`.`ticketFk` = `t`.`id`)) left join `vn`.`lastHourProduction` `lhp` on(`lhp`.`warehouseFk` = `t`.`warehouseFk`)) join `vn`.`warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) join `vn`.`warehouseAlias` `wa` on(`wa`.`id` = `w`.`aliasFk`)) join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `vn`.`zoneClosure` `zc` on(`zc`.`zoneFk` = `t`.`zoneFk` and `zc`.`dated` = `util`.`VN_CURDATE`())) left join `cache`.`departure_limit` `dl` on(`dl`.`warehouse_id` = `t`.`warehouseFk` and `dl`.`fecha` = `util`.`VN_CURDATE`())) where `w`.`hasProduction` <> 0 and cast(`t`.`shipped` as date) = `util`.`VN_CURDATE`() group by `t`.`zoneFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -81656,4 +81042,5 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-08-03 9:39:55 +-- Dump completed on 2022-09-16 10:44:31 + diff --git a/db/tests/vn/workerTimeControlCheck.spec.js b/db/tests/vn/workerTimeControlCheck.spec.js index 6838665f1..9140628e6 100644 --- a/db/tests/vn/workerTimeControlCheck.spec.js +++ b/db/tests/vn/workerTimeControlCheck.spec.js @@ -239,7 +239,7 @@ xdescribe('worker workerTimeControl_check()', () => { stmts.push('START TRANSACTION'); - stmt = new ParameterizedSQL(`INSERT INTO postgresql.calendar_employee(business_id,calendar_state_id,date) + stmt = new ParameterizedSQL(`INSERT INTO postgresql.calendar_employee(businessFk,calendar_state_id,date) VALUES (?,1,CURDATE())`, [ workerId @@ -282,7 +282,7 @@ xdescribe('worker workerTimeControl_check()', () => { stmts.push('START TRANSACTION'); - stmt = new ParameterizedSQL(`UPDATE postgresql.business SET date_end=DATE_ADD(CURDATE(), INTERVAL -1 DAY) WHERE business_id=?`, [ + stmt = new ParameterizedSQL(`UPDATE vn.business SET ended = DATE_ADD(CURDATE(), INTERVAL -1 DAY) WHERE id = ?`, [ workerId ]); stmts.push(stmt); diff --git a/e2e/paths/09-invoice-out/03_manualInvoice.spec.js b/e2e/paths/09-invoice-out/03_manualInvoice.spec.js index 84f0cc8b3..fa7cbed29 100644 --- a/e2e/paths/09-invoice-out/03_manualInvoice.spec.js +++ b/e2e/paths/09-invoice-out/03_manualInvoice.spec.js @@ -22,7 +22,7 @@ describe('InvoiceOut manual invoice path', () => { }); it('should create an invoice from a ticket', async() => { - await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTicket, '7'); + await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTicket, '15'); await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceSerial, 'Global nacional'); await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTaxArea, 'national'); await page.waitToClick(selectors.invoiceOutIndex.saveInvoice); diff --git a/e2e/paths/14-account/01_create_and_basic_data.spec.js b/e2e/paths/14-account/01_create_and_basic_data.spec.js index 0fc657375..0400fb99e 100644 --- a/e2e/paths/14-account/01_create_and_basic_data.spec.js +++ b/e2e/paths/14-account/01_create_and_basic_data.spec.js @@ -150,10 +150,12 @@ describe('Account create and basic data path', () => { describe('Set password', () => { it('should set the password using the descriptor menu', async() => { + const newPassword = 'quantum.12345'; + await page.waitToClick(selectors.accountDescriptor.menuButton); await page.waitToClick(selectors.accountDescriptor.setPassword); - await page.write(selectors.accountDescriptor.newPassword, 'quantum.crypt0graphy'); - await page.write(selectors.accountDescriptor.repeatPassword, 'quantum.crypt0graphy'); + await page.write(selectors.accountDescriptor.newPassword, newPassword); + await page.write(selectors.accountDescriptor.repeatPassword, newPassword); await page.waitToClick(selectors.accountDescriptor.acceptButton); const message = await page.waitForSnackbar(); diff --git a/front/core/components/input-time/index.js b/front/core/components/input-time/index.js index d77ccbec2..0d01fbd32 100644 --- a/front/core/components/input-time/index.js +++ b/front/core/components/input-time/index.js @@ -23,12 +23,15 @@ export default class InputTime extends Field { let date = null; let value = this.input.value; + if (this.field && !this.modelDate) + this.modelDate = this.field; + if (value) { let split = value.split(':').map(i => parseInt(i) || null); - date = this.field instanceof Date - ? this.field - : new Date(this.field || null); + date = this.modelDate + ? new Date(this.modelDate) + : new Date(); date.setHours(split[0], split[1], 0, 0); } diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 58660b404..fdea4ad4f 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -131,5 +131,5 @@ "Fichadas impares": "Odd signs", "Descanso diario 9h.": "Daily rest 9h.", "Descanso semanal 36h. / 72h.": "Weekly rest 36h. / 72h.", - "deliveryNote": "deliveryNote-{{ticketId}}" + "Password does not meet requirements": "Password does not meet requirements" } \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 77f6f0b00..327568685 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -146,7 +146,7 @@ "Choose a date range or days forward": "Selecciona un rango de fechas o días en adelante", "ORDER_ALREADY_CONFIRMED": "ORDER_ALREADY_CONFIRMED", "Invalid password": "Invalid password", - "Password does not meet requirements": "Password does not meet requirements", + "Password does not meet requirements": "La contraseña no cumple los requisitos", "Role already assigned": "Role already assigned", "Invalid role name": "Invalid role name", "Role name must be written in camelCase": "Role name must be written in camelCase", @@ -208,7 +208,7 @@ "Wasn't able to invoice the following clients": "No se han podido facturar los siguientes clientes", "Can't verify data unless the client has a business type": "No se puede verificar datos de un cliente que no tiene tipo de negocio", "You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito", - "You can't change the credit set to zero from a manager": "No puedes cambiar el cŕedito establecido a cero por un gerente", + "You can't change the credit set to zero from a financialBoss": "No puedes cambiar el cŕedito establecido a cero por un jefe de finanzas", "Amounts do not match": "Las cantidades no coinciden", "The PDF document does not exists": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'", "The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos", @@ -232,6 +232,5 @@ "Fichadas impares": "Fichadas impares", "Descanso diario 12h.": "Descanso diario 12h.", "Descanso semanal 36h. / 72h.": "Descanso semanal 36h. / 72h.", - "Dirección incorrecta": "Dirección incorrecta", - "You cannot close tickets for today": "You cannot close tickets for today" -} \ No newline at end of file + "Dirección incorrecta": "Dirección incorrecta" +} diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index d640356ec..3f6853c55 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -377,8 +377,8 @@ module.exports = Self => { const models = Self.app.models; const userId = ctx.options.accessToken.userId; - const isManager = await models.Account.hasRole(userId, 'manager', ctx.options); - if (!isManager) { + const isFinancialBoss = await models.Account.hasRole(userId, 'financialBoss', ctx.options); + if (!isFinancialBoss) { const lastCredit = await models.ClientCredit.findOne({ where: { clientFk: finalState.id @@ -388,10 +388,10 @@ module.exports = Self => { const lastAmount = lastCredit && lastCredit.amount; const lastWorkerId = lastCredit && lastCredit.workerFk; - const lastWorkerIsManager = await models.Account.hasRole(lastWorkerId, 'manager', ctx.options); + const lastWorkerIsFinancialBoss = await models.Account.hasRole(lastWorkerId, 'financialBoss', ctx.options); - if (lastAmount == 0 && lastWorkerIsManager) - throw new UserError(`You can't change the credit set to zero from a manager`); + if (lastAmount == 0 && lastWorkerIsFinancialBoss) + throw new UserError(`You can't change the credit set to zero from a financialBoss`); const creditLimits = await models.ClientCreditLimit.find({ fields: ['roleFk'], diff --git a/modules/client/back/models/specs/client.spec.js b/modules/client/back/models/specs/client.spec.js index d1a6d77cb..1f7e56cdb 100644 --- a/modules/client/back/models/specs/client.spec.js +++ b/modules/client/back/models/specs/client.spec.js @@ -53,7 +53,7 @@ describe('Client Model', () => { }); describe('changeCredit()', () => { - it('should fail to change the credit as a salesAssistant set to zero by a manager', async() => { + it('should fail to change the credit as a salesAssistant set to zero by a financialBoss', async() => { const tx = await models.Client.beginTransaction({}); let error; @@ -62,7 +62,7 @@ describe('Client Model', () => { const options = {transaction: tx}; const context = {options}; - // Set credit to zero by a manager + // Set credit to zero by a financialBoss const financialBoss = await models.Account.findOne({ where: {name: 'financialBoss'} }, options); @@ -83,7 +83,7 @@ describe('Client Model', () => { await tx.rollback(); } - expect(error.message).toEqual(`You can't change the credit set to zero from a manager`); + expect(error.message).toEqual(`You can't change the credit set to zero from a financialBoss`); }); it('should fail to change to a high credit amount as a salesAssistant', async() => { diff --git a/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js b/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js index 8e1921a0e..86ed9dddc 100644 --- a/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js +++ b/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js @@ -37,7 +37,7 @@ describe('Buy editLatestsBuys()', () => { const options = {transaction: tx}; try { - const filter = {typeFk: 1}; + const filter = {'i.typeFk': 1}; const ctx = { args: { filter: filter diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index adeda5e56..768c8c7ee 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -4,6 +4,7 @@ order="itemFk DESC" limit="20" data="$ctrl.buys" + on-data-change="$ctrl.reCheck()" auto-load="true"> @@ -21,7 +22,7 @@ @@ -123,17 +124,18 @@ @@ -186,7 +188,7 @@ - + @@ -231,7 +233,7 @@ - diff --git a/modules/entry/front/latest-buys/index.js b/modules/entry/front/latest-buys/index.js index ec1109b81..198d38eff 100644 --- a/modules/entry/front/latest-buys/index.js +++ b/modules/entry/front/latest-buys/index.js @@ -7,6 +7,7 @@ export default class Controller extends Section { super($element, $); this.editedColumn; this.checkAll = false; + this.checkedBuys = []; this.smartTableOptions = { activeButtons: { @@ -139,6 +140,7 @@ export default class Controller extends Section { uncheck() { this.checkAll = false; + this.checkedBuys = []; } get totalChecked() { @@ -148,6 +150,23 @@ export default class Controller extends Section { return this.checked.length; } + saveChecked(buyId) { + const index = this.checkedBuys.indexOf(buyId); + if (index !== -1) + return this.checkedBuys.splice(index, 1); + return this.checkedBuys.push(buyId); + } + + reCheck() { + if (!this.$.model.data) return; + if (!this.checkedBuys.length) return; + + this.$.model.data.forEach(buy => { + if (this.checkedBuys.includes(buy.id)) + buy.checked = true; + }); + } + onEditAccept() { const rowsToEdit = []; for (let row of this.checked) diff --git a/modules/entry/front/latest-buys/index.spec.js b/modules/entry/front/latest-buys/index.spec.js index 76e122d80..6574303fc 100644 --- a/modules/entry/front/latest-buys/index.spec.js +++ b/modules/entry/front/latest-buys/index.spec.js @@ -57,5 +57,44 @@ describe('Entry', () => { expect(result.length).toEqual(0); }); }); + + describe('reCheck()', () => { + it(`should recheck buys`, () => { + controller.$.model.data = [ + {checked: false, id: 1}, + {checked: false, id: 2}, + {checked: false, id: 3}, + {checked: false, id: 4}, + ]; + controller.checkedBuys = [1, 2]; + + controller.reCheck(); + + expect(controller.$.model.data[0].checked).toEqual(true); + expect(controller.$.model.data[1].checked).toEqual(true); + expect(controller.$.model.data[2].checked).toEqual(false); + expect(controller.$.model.data[3].checked).toEqual(false); + }); + }); + + describe('saveChecked()', () => { + it(`should check buy`, () => { + const buyCheck = 3; + controller.checkedBuys = [1, 2]; + + controller.saveChecked(buyCheck); + + expect(controller.checkedBuys[2]).toEqual(buyCheck); + }); + + it(`should uncheck buy`, () => { + const buyUncheck = 3; + controller.checkedBuys = [1, 2, 3]; + + controller.saveChecked(buyUncheck); + + expect(controller.checkedBuys[2]).toEqual(undefined); + }); + }); }); }); diff --git a/modules/item/back/methods/item/clone.js b/modules/item/back/methods/item/clone.js index 3e6f3ab5a..6d07e83d3 100644 --- a/modules/item/back/methods/item/clone.js +++ b/modules/item/back/methods/item/clone.js @@ -42,7 +42,6 @@ module.exports = Self => { origin.itemTag = undefined; origin.description = undefined; - origin.image = undefined; origin.comment = undefined; origin.size = undefined; diff --git a/modules/item/back/methods/item/specs/clone.spec.js b/modules/item/back/methods/item/specs/clone.spec.js index d376b9e5b..1f4a87ac1 100644 --- a/modules/item/back/methods/item/specs/clone.spec.js +++ b/modules/item/back/methods/item/specs/clone.spec.js @@ -21,7 +21,7 @@ describe('item clone()', () => { const result = await models.Item.clone(itemFk, options); expect(result.id).toEqual(nextItemId); - expect(result.image).toBeUndefined(); + expect(result.image).toBeDefined(); expect(result.itemTag).toBeUndefined(); expect(result.comment).toBeUndefined(); expect(result.description).toBeUndefined(); diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index 01b6ba093..a6328a456 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -143,6 +143,9 @@ }, "packingShelve": { "type": "number" + }, + "weightByPiece": { + "type": "number" } }, "relations": { diff --git a/modules/route/front/basic-data/index.html b/modules/route/front/basic-data/index.html index d3ba25b11..737bbab13 100644 --- a/modules/route/front/basic-data/index.html +++ b/modules/route/front/basic-data/index.html @@ -21,7 +21,7 @@
{{name}} - {{nickname}}
- diff --git a/modules/shelving/back/model-config.json b/modules/shelving/back/model-config.json index b5619d8c5..c26c39d38 100644 --- a/modules/shelving/back/model-config.json +++ b/modules/shelving/back/model-config.json @@ -7,5 +7,8 @@ }, "ShelvingLog": { "dataSource": "vn" + }, + "Sector": { + "dataSource": "vn" } -} +} \ No newline at end of file diff --git a/modules/shelving/back/models/sector.json b/modules/shelving/back/models/sector.json new file mode 100644 index 000000000..0dc502cd0 --- /dev/null +++ b/modules/shelving/back/models/sector.json @@ -0,0 +1,72 @@ +{ + "name": "Sector", + "base": "VnModel", + "options": { + "mysql": { + "table": "sector" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "description": { + "type": "string", + "required": true + }, + "warehouseFk": { + "type": "number", + "required": true + }, + "isPreviousPreparedByPacking": { + "type": "boolean", + "required": true + }, + "code": { + "type": "string", + "required": false + }, + "isPreviousPrepared": { + "type": "boolean", + "required": true + }, + "isPackagingArea": { + "type": "boolean", + "required": true + }, + "reportFk": { + "type": "number", + "required": false + }, + "sonFk": { + "type": "number", + "required": false + }, + "isMain": { + "type": "boolean", + "required": true + }, + "itemPackingTypeFk": { + "type": "string", + "required": false + }, + "workerFk": { + "type": "number", + "required": false + }, + "printerFk": { + "type": "number", + "required": false + }, + "isHideForPickers": { + "type": "boolean", + "required": true + }, + "isReserve": { + "type": "boolean", + "required": true + } + } +} \ No newline at end of file diff --git a/modules/ticket/back/methods/packaging/specs/listPackaging.spec.js b/modules/ticket/back/methods/packaging/specs/listPackaging.spec.js index e1fdeb0c5..1b5892e04 100644 --- a/modules/ticket/back/methods/packaging/specs/listPackaging.spec.js +++ b/modules/ticket/back/methods/packaging/specs/listPackaging.spec.js @@ -1,7 +1,6 @@ const models = require('vn-loopback/server/server').models; -// 4376 -xdescribe('ticket listPackaging()', () => { +describe('ticket listPackaging()', () => { it('should return the packaging', async() => { const tx = await models.Packaging.beginTransaction({}); diff --git a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js index 132b1938d..1c17d4d0b 100644 --- a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js +++ b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js @@ -82,6 +82,9 @@ describe('ticket setDeleted()', () => { ctx.req.__ = value => { return value; }; + const [ticketCollectionOld] = await models.Ticket.rawSql( + `SELECT COUNT(*) numberRows + FROM vn.ticketCollection`, [], options); const ticketId = 23; await models.Ticket.setDeleted(ctx, ticketId, options); @@ -90,7 +93,7 @@ describe('ticket setDeleted()', () => { `SELECT COUNT(*) numberRows FROM vn.ticketCollection`, [], options); - expect(ticketCollection.numberRows).toEqual(3); + expect(ticketCollection.numberRows).toBeLessThan(ticketCollectionOld.numberRows); await tx.rollback(); } catch (e) { diff --git a/modules/worker/back/methods/calendar/specs/absences.spec.js b/modules/worker/back/methods/calendar/specs/absences.spec.js index 812b9c23c..2180a5312 100644 --- a/modules/worker/back/methods/calendar/specs/absences.spec.js +++ b/modules/worker/back/methods/calendar/specs/absences.spec.js @@ -33,7 +33,7 @@ describe('Worker absences()', () => { const worker = await app.models.WorkerLabour.findById(businessId, null, options); await app.models.WorkerLabour.rawSql( - `UPDATE postgresql.business SET date_end = ? WHERE business_id = ?`, + `UPDATE vn.business SET ended = ? WHERE id = ?`, [null, worker.businessFk], options); const [absences] = await app.models.Calendar.absences(ctx, worker.id, businessId, year, options); @@ -98,7 +98,7 @@ describe('Worker absences()', () => { startingContract.setDate(1); await app.models.WorkerLabour.rawSql( - `UPDATE postgresql.business SET date_start = ?, date_end = ? WHERE business_id = ?`, + `UPDATE vn.business SET started = ?, ended = ? WHERE id = ?`, [startingContract, yearEnd, contract.businessFk], options ); diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 430ec7dfc..1467d6d6b 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -65,9 +65,9 @@ module.exports = Self => { if (args.dated < labour.started || (labour.ended != null && args.dated > labour.ended)) throw new UserError(`The contract was not active during the selected date`); - query = `SELECT * - FROM vn.workerTimeControl - WHERE userFk = ? AND timed BETWEEN DATE(?) AND CONCAT(DATE(?), ' 23:59:59') + query = `SELECT * + FROM vn.workerTimeControl + WHERE userFk = ? AND timed BETWEEN DATE(?) AND CONCAT(DATE(?), ' 23:59:59') LIMIT 1;`; const [hasHoursRecorded] = await Self.rawSql(query, [id, args.dated, args.dated]); @@ -85,12 +85,11 @@ module.exports = Self => { date.setHours(0, 0, 0, 0); const [result] = await Self.rawSql( `SELECT COUNT(*) halfHolidayCounter - FROM vn.calendar c - JOIN postgresql.business b ON b.business_id = c.businessFk - JOIN postgresql.profile p ON p.profile_id = b.client_id - WHERE c.dayOffTypeFk = 6 - AND p.workerFk = ? - AND c.dated BETWEEN util.firstDayOfYear(?) + FROM vn.calendar c + JOIN vn.business b ON b.id = c.businessFk + WHERE c.dayOffTypeFk = 6 + AND b.workerFk = ? + AND c.dated BETWEEN util.firstDayOfYear(?) AND LAST_DAY(DATE_ADD(?, INTERVAL 12 - MONTH(?) MONTH))`, [id, date, now, now]); const hasHalfHoliday = result.halfHolidayCounter > 0; diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index c6b984bd2..c155e331d 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -20,9 +20,6 @@ "EducationLevel": { "dataSource": "vn" }, - "Sector": { - "dataSource": "vn" - }, "WorkCenter": { "dataSource": "vn" }, diff --git a/modules/worker/back/models/sector.json b/modules/worker/back/models/sector.json deleted file mode 100644 index 8bd5e773f..000000000 --- a/modules/worker/back/models/sector.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "Sector", - "base": "VnModel", - "options": { - "mysql": { - "table": "sector" - } - }, - "properties": { - "id": { - "type": "number", - "id": true, - "description": "Identifier" - }, - "description": { - "type": "string", - "required": true - } - } -} \ No newline at end of file diff --git a/package.json b/package.json index 13a7096d6..92ca13e45 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "8.6.0", + "version": "8.8.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", @@ -22,6 +22,7 @@ "i18n": "^0.8.4", "image-type": "^4.1.0", "imap": "^0.8.19", + "jsdom": "^16.7.0", "jszip": "^3.10.0", "ldapjs": "^2.2.0", "loopback": "^3.26.0", @@ -36,7 +37,7 @@ "node-ssh": "^11.0.0", "object-diff": "0.0.4", "object.pick": "^1.3.0", - "puppeteer": "^7.1.0", + "puppeteer": "^18.0.5", "read-chunk": "^3.2.0", "require-yaml": "0.0.1", "sharp": "^0.27.1", diff --git a/print/templates/reports/vehicle-event-expired/assets/css/import.js b/print/templates/reports/vehicle-event-expired/assets/css/import.js new file mode 100644 index 000000000..fd8796c2b --- /dev/null +++ b/print/templates/reports/vehicle-event-expired/assets/css/import.js @@ -0,0 +1,9 @@ +const Stylesheet = require(`${appPath}/core/stylesheet`); + +module.exports = new Stylesheet([ + `${appPath}/common/css/spacing.css`, + `${appPath}/common/css/misc.css`, + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/report.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/templates/reports/vehicle-event-expired/assets/css/style.css b/print/templates/reports/vehicle-event-expired/assets/css/style.css new file mode 100644 index 000000000..1b6428d3c --- /dev/null +++ b/print/templates/reports/vehicle-event-expired/assets/css/style.css @@ -0,0 +1,19 @@ +.column-oriented { + margin-top: 50px !important; +} + +.bottom-line > tr { + border-bottom: 1px solid #ccc; +} + +.bottom-line tr:nth-last-child() { + border-bottom: none; +} + +.report-info { + font-size: 20px +} + +.description strong { + text-transform: uppercase; +} \ No newline at end of file diff --git a/print/templates/reports/vehicle-event-expired/locale/es.yml b/print/templates/reports/vehicle-event-expired/locale/es.yml new file mode 100644 index 000000000..ba7685047 --- /dev/null +++ b/print/templates/reports/vehicle-event-expired/locale/es.yml @@ -0,0 +1,4 @@ +title: Expiración Tarjetas Vehículos +Plate: Matrícula +Concept: Concepto +expirationDate: Fecha caducidad \ No newline at end of file diff --git a/print/templates/reports/vehicle-event-expired/sql/vehicleEvents.sql b/print/templates/reports/vehicle-event-expired/sql/vehicleEvents.sql new file mode 100644 index 000000000..09f9e5853 --- /dev/null +++ b/print/templates/reports/vehicle-event-expired/sql/vehicleEvents.sql @@ -0,0 +1,7 @@ +SELECT + v.numberPlate, + ve.description, + ve.finished +FROM vehicleEvent ve + JOIN vehicle v ON v.id = ve.vehicleFk +WHERE ve.id IN (?) \ No newline at end of file diff --git a/print/templates/reports/vehicle-event-expired/vehicle-event-expired.html b/print/templates/reports/vehicle-event-expired/vehicle-event-expired.html new file mode 100644 index 000000000..2045f2adb --- /dev/null +++ b/print/templates/reports/vehicle-event-expired/vehicle-event-expired.html @@ -0,0 +1,39 @@ + + + +
- - - + {{::buy.packing | dashIfEmpty}} - + {{::buy.grouping | dashIfEmpty}} {{::buy.family}} @@ -204,7 +206,7 @@ - + {{::buy.price2 | currency: 'EUR':2}} {{::buy.price3 | currency: 'EUR':2}}
+ + + + + +
+ + + +
+
+
+

{{$t('title')}}

+
+ + + + + + + + + + + + + + + +
{{$t('Plate')}}{{$t('Concept')}}{{$t('expirationDate')}}
{{vehicleEvent.numberPlate}}{{vehicleEvent.description}}{{vehicleEvent.finished | date('%d-%m-%Y')}}
+
+
+
+ + \ No newline at end of file diff --git a/print/templates/reports/vehicle-event-expired/vehicle-event-expired.js b/print/templates/reports/vehicle-event-expired/vehicle-event-expired.js new file mode 100755 index 000000000..33e60eab7 --- /dev/null +++ b/print/templates/reports/vehicle-event-expired/vehicle-event-expired.js @@ -0,0 +1,28 @@ +const Component = require(`${appPath}/core/component`); +const reportHeader = new Component('report-header'); +const reportFooter = new Component('report-footer'); + +module.exports = { + name: 'vehicle-event-expired', + async serverPrefetch() { + this.vehicleEvents = await this.fetchVehicleEvent(this.eventIds); + + if (!this.vehicleEvents) + throw new Error('Something went wrong'); + }, + methods: { + fetchVehicleEvent(vehicleEventIds) { + return this.rawSqlFromDef('vehicleEvents', [vehicleEventIds]); + }, + }, + components: { + 'report-header': reportHeader.build(), + 'report-footer': reportFooter.build() + }, + props: { + eventIds: { + type: [Array], + required: true + } + } +};