diff --git a/client/core/src/directives/repeat-last.js b/client/core/src/directives/repeat-last.js index 894666cae..504fa5253 100644 --- a/client/core/src/directives/repeat-last.js +++ b/client/core/src/directives/repeat-last.js @@ -13,7 +13,9 @@ export function directive($parse) { link: function($scope, $element, $attrs) { if ($scope.$last && $attrs.onLast) { let fn = $parse($attrs.onLast); - fn($scope); + setTimeout(() => { + fn($scope); + }); } } }; diff --git a/client/item/src/diary/index.js b/client/item/src/diary/index.js index 79af25b13..15a012291 100644 --- a/client/item/src/diary/index.js +++ b/client/item/src/diary/index.js @@ -25,17 +25,6 @@ class Controller { return this._item; } - get alertLevelIndex() { - let lines = this.$scope.model.data; - for (let i = 0; i < lines.length; i++) { - let isFutureDate = new Date(lines[i].date) > new Date(); - let isGenreOut = lines[i].alertLevel != 0; - - if (!isFutureDate && !isGenreOut) - return i; - } - } - onChange(value) { if (!value) return; @@ -63,15 +52,47 @@ class Controller { } } + get freeLineIndex() { + let lines = this.$scope.model.data; + for (let i = 0; i < lines.length; i++) { + let isFutureDate = new Date(lines[i].date) > new Date(); + let isGenreOut = lines[i].alertLevel != 0; + + if (!isFutureDate && !isGenreOut) + return i; + } + } + + get onPreparationLineIndex() { + let lines = this.$scope.model.data; + + for (let i = this.freeLineIndex; i > 0; i--) { + let line = lines[i]; + + if (line.alertLevel == 1 && line.isPicked || line.alertLevel > 1) { + return i; + } + } + } + scrollToActive() { let body = this.$window.document.body; - let lineIndex = this.alertLevelIndex; + let lineIndex = this.onPreparationLineIndex; let lines = body.querySelector('vn-tbody').children; if (!lineIndex || !lines.length) return; - lines[lineIndex].scrollIntoView(); - lines[lineIndex - 1].querySelector('.balance').classList.add('counter'); + let onPreparationLine = lines[lineIndex]; + + let balance = onPreparationLine.querySelector('.balance'); + balance.classList.add('counter'); + balance.title = 'Visible quantity'; + + let headerOffset = body.querySelector('header').getBoundingClientRect(); + let headerHeight = headerOffset.height; + let offsetTop = onPreparationLine.offsetTop - headerHeight; + + body.querySelector('ui-view').scrollTop = offsetTop; } /** diff --git a/client/item/src/diary/index.spec.js b/client/item/src/diary/index.spec.js index 303a36083..ecece4f86 100644 --- a/client/item/src/diary/index.spec.js +++ b/client/item/src/diary/index.spec.js @@ -1,6 +1,6 @@ import './index.js'; -describe('Item', () => { +fdescribe('Item', () => { describe('Component vnItemDiary', () => { let $componentController; let $scope; @@ -38,19 +38,33 @@ describe('Item', () => { }); }); - describe('alertLevelIndex()', () => { - it(`should call alertLevelIndex() and return an index from line with alertLevel 0 and current date`, () => { + describe('freeLineIndex()', () => { + it(`should call freeLineIndex() and return an index from line with alertLevel 0 and current date`, () => { controller.$scope.model = {data: [ {name: 'My item 1', alertLevel: 3, date: '2018-05-02'}, {name: 'My item 2', alertLevel: 1, date: '2018-05-03'}, {name: 'My item 3', alertLevel: 0, date: new Date()}] }; - let result = controller.alertLevelIndex; + let result = controller.freeLineIndex; expect(result).toEqual(2); }); }); + describe('onPreparationLineIndex()', () => { + it(`should call onPreparationLineIndex() and return an index from line with alertLevel 1 and isPicked true`, () => { + controller.$scope.model = {data: [ + {name: 'My item 1', alertLevel: 3, isPicked: true, date: '2018-05-02'}, + {name: 'My item 3', alertLevel: 1, isPicked: true, date: '2018-05-03'}, + {name: 'My item 4', alertLevel: 1, isPicked: false, date: '2018-05-03'}, + {name: 'My item 5', alertLevel: 0, isPicked: false, date: new Date()}] + }; + let result = controller.onPreparationLineIndex; + + expect(result).toEqual(1); + }); + }); + describe('set item()', () => { it(`should call filterBuilder()`, () => { spyOn(controller, 'filterBuilder'); diff --git a/client/ticket/src/descriptor/index.html b/client/ticket/src/descriptor/index.html index e7a8a37cf..c7339c346 100644 --- a/client/ticket/src/descriptor/index.html +++ b/client/ticket/src/descriptor/index.html @@ -19,13 +19,13 @@ value="{{::$ctrl.ticket.client.name}}"> + value="{{$ctrl.ticket.tracking.state.name}}"> + value="{{$ctrl.ticket.shipped | date: 'dd/MM/yyyy HH:mm' }}"> diff --git a/services/claim/Dockerfile b/services/claim/Dockerfile new file mode 100644 index 000000000..70f5737ae --- /dev/null +++ b/services/claim/Dockerfile @@ -0,0 +1,5 @@ +FROM vn-loopback:latest + +COPY claim /app +WORKDIR /app +CMD ["pm2-docker", "./server/server.js"] diff --git a/services/claim/common/models/claim-beginning.json b/services/claim/common/models/claim-beginning.json new file mode 100644 index 000000000..d74fe0dbe --- /dev/null +++ b/services/claim/common/models/claim-beginning.json @@ -0,0 +1,33 @@ +{ + "name": "ClaimBeginning", + "base": "VnModel", + "options": { + "mysql": { + "table": "claimBeginning", + "database": "vn" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "quantity": { + "type": "Number", + "required": true + } + }, + "relations": { + "claim": { + "type": "belongsTo", + "model": "Claim", + "foreignKey": "claimFk" + }, + "sale": { + "type": "belongsTo", + "model": "Sale", + "foreignKey": "saleFk" + } + } +} diff --git a/services/claim/common/models/claim-destination.json b/services/claim/common/models/claim-destination.json new file mode 100644 index 000000000..ea3228bb0 --- /dev/null +++ b/services/claim/common/models/claim-destination.json @@ -0,0 +1,29 @@ +{ + "name": "ClaimDestination", + "base": "VnModel", + "options": { + "mysql": { + "table": "claimDestination", + "database": "vn" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "description": { + "type": "String", + "required": true + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} diff --git a/services/claim/common/models/claim-development.json b/services/claim/common/models/claim-development.json new file mode 100644 index 000000000..f82d1009b --- /dev/null +++ b/services/claim/common/models/claim-development.json @@ -0,0 +1,54 @@ +{ + "name": "ClaimDevelopment", + "base": "VnModel", + "options": { + "mysql": { + "table": "claimDevelopment", + "database": "vn" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + } + }, + "relations": { + "claim": { + "type": "belongsTo", + "model": "Claim", + "foreignKey": "claimFk" + }, + "claimResponsible": { + "type": "belongsTo", + "model": "ClaimResponsible", + "foreignKey": "claimResponsibleFk" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "claimDestination": { + "type": "belongsTo", + "model": "ClaimDestination", + "foreignKey": "claimDestinationFk" + }, + "claimReason": { + "type": "belongsTo", + "model": "ClaimReason", + "foreignKey": "claimReasonFk" + }, + "claimResult": { + "type": "belongsTo", + "model": "ClaimResult", + "foreignKey": "claimResultFk" + }, + "claimRedelivery": { + "type": "belongsTo", + "model": "ClaimRedelivery", + "foreignKey": "claimRedeliveryFk" + } + } +} diff --git a/services/claim/common/models/claim-end.json b/services/claim/common/models/claim-end.json new file mode 100644 index 000000000..fd81d41bc --- /dev/null +++ b/services/claim/common/models/claim-end.json @@ -0,0 +1,39 @@ +{ + "name": "ClaimEnd", + "base": "VnModel", + "options": { + "mysql": { + "table": "claimEnd", + "database": "vn" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + } + }, + "relations": { + "claim": { + "type": "belongsTo", + "model": "Claim", + "foreignKey": "claimFk" + }, + "sale": { + "type": "belongsTo", + "model": "Sale", + "foreignKey": "saleFk" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "claimDestination": { + "type": "belongsTo", + "model": "ClaimDestination", + "foreignKey": "claimDestinationFk" + } + } +} diff --git a/services/claim/common/models/claim-reason.json b/services/claim/common/models/claim-reason.json new file mode 100644 index 000000000..3ecb9c1db --- /dev/null +++ b/services/claim/common/models/claim-reason.json @@ -0,0 +1,28 @@ +{ + "name": "ClaimReason", + "base": "VnModel", + "options": { + "mysql": { + "table": "claimReason", + "database": "vn" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "description": { + "type": "String" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} diff --git a/services/claim/common/models/claim-redelivery.json b/services/claim/common/models/claim-redelivery.json new file mode 100644 index 000000000..8cb2e77c6 --- /dev/null +++ b/services/claim/common/models/claim-redelivery.json @@ -0,0 +1,29 @@ +{ + "name": "ClaimRedelivery", + "base": "VnModel", + "options": { + "mysql": { + "table": "claimRedelivery", + "database": "vn" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "description": { + "type": "String", + "required": true + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} diff --git a/services/claim/common/models/claim-responsible.json b/services/claim/common/models/claim-responsible.json new file mode 100644 index 000000000..a14800984 --- /dev/null +++ b/services/claim/common/models/claim-responsible.json @@ -0,0 +1,33 @@ +{ + "name": "ClaimResponsible", + "base": "VnModel", + "options": { + "mysql": { + "table": "claimResponsible", + "database": "vn" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "description": { + "type": "String", + "required": true + }, + "responsability": { + "type": "Number", + "required": true + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} diff --git a/services/claim/common/models/claim-result.json b/services/claim/common/models/claim-result.json new file mode 100644 index 000000000..d260603e7 --- /dev/null +++ b/services/claim/common/models/claim-result.json @@ -0,0 +1,28 @@ +{ + "name": "ClaimResult", + "base": "VnModel", + "options": { + "mysql": { + "table": "claimResult", + "database": "vn" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "description": { + "type": "String" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} diff --git a/services/claim/common/models/claim-state.json b/services/claim/common/models/claim-state.json new file mode 100644 index 000000000..5d29d4ea2 --- /dev/null +++ b/services/claim/common/models/claim-state.json @@ -0,0 +1,29 @@ +{ + "name": "ClaimState", + "base": "VnModel", + "options": { + "mysql": { + "table": "claimState", + "database": "vn" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "description": { + "type": "String", + "required": true + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} diff --git a/services/claim/common/models/claim.json b/services/claim/common/models/claim.json new file mode 100644 index 000000000..d6562e867 --- /dev/null +++ b/services/claim/common/models/claim.json @@ -0,0 +1,54 @@ +{ + "name": "Claim", + "base": "VnModel", + "options": { + "mysql": { + "table": "claim", + "database": "vn" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "observation": { + "type": "String" + }, + "ticketCreated": { + "type": "date", + "required": true + }, + "isChargedToMana": { + "type": "Number", + "required": true + }, + "created": { + "type": "date", + "required": true + } + }, + "relations": { + "claimState": { + "type": "belongsTo", + "model": "ClaimState", + "foreignKey": "claimStateFk" + }, + "client": { + "type": "belongsTo", + "model": "Client", + "foreignKey": "clientFk" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "claimResponsible": { + "type": "belongsTo", + "model": "ClaimResponsible", + "foreignKey": "claimResponsibleFk" + } + } +} diff --git a/services/claim/package.json b/services/claim/package.json new file mode 100644 index 000000000..fa65f7ed8 --- /dev/null +++ b/services/claim/package.json @@ -0,0 +1,16 @@ +{ + "name": "vn-claim", + "version": "1.0.0", + "main": "server/server.js", + "scripts": { + "lint": "eslint .", + "start": "node .", + "posttest": "npm run lint && nsp check" + }, + "repository": { + "type": "git", + "url": "https://git.verdnatura.es/salix" + }, + "license": "GPL-3.0", + "description": "vn-claim" +} diff --git a/services/claim/server/model-config.json b/services/claim/server/model-config.json new file mode 100644 index 000000000..26ea7f943 --- /dev/null +++ b/services/claim/server/model-config.json @@ -0,0 +1,32 @@ +{ + "Claim": { + "dataSource": "vn" + }, + "ClaimState": { + "dataSource": "vn" + }, + "ClaimBeginning": { + "dataSource": "vn" + }, + "ClaimReason": { + "dataSource": "vn" + }, + "ClaimResult": { + "dataSource": "vn" + }, + "ClaimRedelivery": { + "dataSource": "vn" + }, + "ClaimDestination": { + "dataSource": "vn" + }, + "ClaimResponsible": { + "dataSource": "vn" + }, + "ClaimEnd": { + "dataSource": "vn" + }, + "claimDevelopment": { + "dataSource": "vn" + } +} diff --git a/services/claim/server/server.js b/services/claim/server/server.js new file mode 100644 index 000000000..030bbc1b4 --- /dev/null +++ b/services/claim/server/server.js @@ -0,0 +1,5 @@ + +var vnLoopback = require('../../loopback/server/server.js'); + +var app = module.exports = vnLoopback.loopback(); +vnLoopback.boot(app, __dirname, module); diff --git a/services/db/export-data.cmd b/services/db/export-data.cmd index 2ef7e5fcc..e0781a267 100755 --- a/services/db/export-data.cmd +++ b/services/db/export-data.cmd @@ -6,7 +6,7 @@ mysqldump --defaults-file=connect.ini --no-create-info salix ACL >> install/dump echo USE `vn`; >> install/dump/03-dumpedFixtures.sql mysqldump --defaults-file=connect.ini --no-create-info vn cplusInvoiceType477 cplusSubjectOp cplusTaxBreak bookingPlanner pgc >> install/dump/03-dumpedFixtures.sql echo USE `vn2008`; >> install/dump/03-dumpedFixtures.sql -mysqldump --defaults-file=connect.ini --no-create-info vn2008 accion_dits Gastos Tintas tarifa_componentes tarifa_componentes_series state bionic_updating_options Grupos Monedas container iva_group_codigo escritos >> install/dump/03-dumpedFixtures.sql +mysqldump --defaults-file=connect.ini --no-create-info vn2008 accion_dits Gastos Tintas tarifa_componentes tarifa_componentes_series state bionic_updating_options Grupos Monedas container iva_group_codigo escritos cl_est cl_con cl_res cl_dev cl_mot cl_sol>> install/dump/03-dumpedFixtures.sql echo USE `bi`; >> install/dump/03-dumpedFixtures.sql mysqldump --defaults-file=connect.ini --no-create-info bi tarifa_componentes tarifa_componentes_series >> install/dump/03-dumpedFixtures.sql echo USE `cache`; >> install/dump/03-dumpedFixtures.sql diff --git a/services/db/export-data.sh b/services/db/export-data.sh index b88433e68..2c254fb3d 100755 --- a/services/db/export-data.sh +++ b/services/db/export-data.sh @@ -7,7 +7,7 @@ mysqldump --defaults-file=connect.ini --no-create-info salix ACL >> install/dump echo "USE \`vn\`;" >> install/dump/03-dumpedFixtures.sql mysqldump --defaults-file=connect.ini --no-create-info vn cplusInvoiceType477 cplusSubjectOp cplusTaxBreak bookingPlanner pgc >> install/dump/03-dumpedFixtures.sql echo "USE \`vn2008\`;" >> install/dump/03-dumpedFixtures.sql -mysqldump --defaults-file=connect.ini --no-create-info vn2008 accion_dits Gastos Tintas tarifa_componentes tarifa_componentes_series state bionic_updating_options Grupos Monedas container iva_group_codigo escritos >> install/dump/03-dumpedFixtures.sql +mysqldump --defaults-file=connect.ini --no-create-info vn2008 accion_dits Gastos Tintas tarifa_componentes tarifa_componentes_series state bionic_updating_options Grupos Monedas container iva_group_codigo escritos cl_est cl_con cl_res cl_dev cl_mot cl_sol>> install/dump/03-dumpedFixtures.sql echo "USE \`bi\`;" >> install/dump/03-dumpedFixtures.sql mysqldump --defaults-file=connect.ini --no-create-info bi tarifa_componentes tarifa_componentes_series >> install/dump/03-dumpedFixtures.sql echo "USE \`cache\`;" >> install/dump/03-dumpedFixtures.sql diff --git a/services/db/install/changes/1.0.10/01-claimBeginning.sql b/services/db/install/changes/1.0.10/01-claimBeginning.sql new file mode 100644 index 000000000..e675c0fbe --- /dev/null +++ b/services/db/install/changes/1.0.10/01-claimBeginning.sql @@ -0,0 +1,13 @@ +USE `vn`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `claimBeginning` AS + SELECT + `c`.`id` AS `id`, + `c`.`cl_main_id` AS `claimFk`, + `c`.`Id_Movimiento` AS `saleFk`, + `c`.`numero` AS `quantity` + FROM + `vn2008`.`cl_det` `c`; diff --git a/services/db/install/changes/1.0.10/02-foreginKey.sql b/services/db/install/changes/1.0.10/02-foreginKey.sql new file mode 100644 index 000000000..0b89737e6 --- /dev/null +++ b/services/db/install/changes/1.0.10/02-foreginKey.sql @@ -0,0 +1,4 @@ +ALTER TABLE `vn2008`.`cl_det` +DROP FOREIGN KEY `cl_det_ibfk_6`; +ALTER TABLE `vn2008`.`cl_det` +DROP INDEX `cl_pet_id` ; diff --git a/services/db/install/changes/1.0.9/01-acl.sql b/services/db/install/changes/1.0.9/01-acl.sql new file mode 100644 index 000000000..0124a6ad3 --- /dev/null +++ b/services/db/install/changes/1.0.9/01-acl.sql @@ -0,0 +1,6 @@ +INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (95, 'ClientNotification', '*', '*', 'ALLOW', 'ROLE', 'employee'); +INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (96, 'ClaimAction', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); +INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (97, 'ClaimAction', '*', 'WRITE', 'ALLOW', 'ROLE', 'salesAssistant'); +INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (98, 'ClaimDetail', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'); +INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (99, 'claimDevelopment', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); +INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (100, 'claimDevelopment', '*', 'WRITE', 'ALLOW', 'ROLE', 'salesAssistant'); \ No newline at end of file diff --git a/services/db/install/changes/1.0.9/logAddWithUser.sql b/services/db/install/changes/1.0.9/02-logAddWithUser.sql similarity index 100% rename from services/db/install/changes/1.0.9/logAddWithUser.sql rename to services/db/install/changes/1.0.9/02-logAddWithUser.sql diff --git a/services/db/install/changes/1.0.9/ticketCreateWithUser.sql b/services/db/install/changes/1.0.9/03-ticketCreateWithUser.sql similarity index 100% rename from services/db/install/changes/1.0.9/ticketCreateWithUser.sql rename to services/db/install/changes/1.0.9/03-ticketCreateWithUser.sql diff --git a/services/db/install/changes/1.0.9/acl.sql b/services/db/install/changes/1.0.9/acl.sql deleted file mode 100644 index cbf36e3aa..000000000 --- a/services/db/install/changes/1.0.9/acl.sql +++ /dev/null @@ -1 +0,0 @@ -INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (95, 'ClientNotification', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/services/db/install/dump/01-structure.sql b/services/db/install/dump/01-structure.sql index 07e704969..101e1a274 100644 --- a/services/db/install/dump/01-structure.sql +++ b/services/db/install/dump/01-structure.sql @@ -363,7 +363,7 @@ CREATE TABLE `user` ( KEY `nickname` (`nickname`), KEY `lang` (`lang`), CONSTRAINT `user_ibfk_2` FOREIGN KEY (`role`) REFERENCES `role` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=14445 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global users'; +) ENGINE=InnoDB AUTO_INCREMENT=14462 DEFAULT CHARSET=utf8 COLLATE=utf8_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 */ ; @@ -2433,7 +2433,7 @@ CREATE TABLE `Agencias_dits` ( `value_old` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `value_new` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`idAgencia_dits`) -) ENGINE=InnoDB AUTO_INCREMENT=21339 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21569 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2529,6 +2529,11 @@ CREATE TABLE `Articles` ( `value7` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `tag8` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `value8` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `tag9` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `value9` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `tag10` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `value10` varchar(20) 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.\n\nMenor que 1 significa que se puede comprimir más que el volumen original.', PRIMARY KEY (`Id_Article`), KEY `Article` (`Article`), KEY `Color` (`Color`), @@ -2544,7 +2549,7 @@ CREATE TABLE `Articles` ( CONSTRAINT `Articles_ibfk_5` FOREIGN KEY (`tipo_id`) REFERENCES `Tipos` (`tipo_id`) ON UPDATE CASCADE, CONSTRAINT `expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `Gastos` (`Id_Gasto`) ON UPDATE CASCADE, CONSTRAINT `producer_id` FOREIGN KEY (`producer_id`) REFERENCES `producer` (`producer_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=317390 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=317656 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2715,7 +2720,7 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`Articles_AFTER_UPDATE` AFTER UPDATE ON `Articles` FOR EACH ROW BEGIN - CALL itemTagArrangedUpdate(NEW.Id_Article); + CALL itemTagArrangedUpdate(NEW.Id_Article); END */;; DELIMITER ; @@ -2818,7 +2823,7 @@ CREATE TABLE `Articles_dits` ( KEY `fgkey1_idx` (`idaccion_dits`), KEY `fgkey2_idx` (`Id_Ticket`), KEY `fgkey3_idx` (`Id_Trabajador`) -) ENGINE=InnoDB AUTO_INCREMENT=20466 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=20473 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2840,7 +2845,7 @@ CREATE TABLE `Articles_nicho` ( KEY `Articles_nicho_wh_fk` (`warehouse_id`), CONSTRAINT `Articles_nicho_wh_fk` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Articles_nichos_fk` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=508972 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=511916 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3004,7 +3009,7 @@ CREATE TABLE `Cajas` ( KEY `warehouse_id` (`warehouse_id`), KEY `fk_Cajas_Proveedores_account1_idx` (`Proveedores_account_Id`), CONSTRAINT `Cajas_ibfk_2` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=601535 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=602874 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -3152,7 +3157,7 @@ CREATE TABLE `Clientes` ( CONSTRAINT `Clientes_ibfk_5` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON UPDATE CASCADE, CONSTRAINT `canal_nuevo_cliente` FOREIGN KEY (`chanel_id`) REFERENCES `chanel` (`chanel_id`) ON UPDATE CASCADE, CONSTRAINT `tipos_de_cliente` FOREIGN KEY (`clientes_tipo_id`) REFERENCES `clientes_tipo` (`clientes_tipo_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=14445 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=14462 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -3435,7 +3440,7 @@ CREATE TABLE `Colas` ( CONSTRAINT `Colas_ibfk_3` FOREIGN KEY (`Id_Prioridad`) REFERENCES `Prioridades` (`Id_Prioridad`) ON UPDATE CASCADE, CONSTRAINT `Colas_ibfk_4` FOREIGN KEY (`Id_Impresora`) REFERENCES `Impresoras` (`Id_Impresora`) ON UPDATE CASCADE, CONSTRAINT `Colas_ibfk_5` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=312061 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=320742 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3517,7 +3522,7 @@ CREATE TABLE `Compres` ( CONSTRAINT `Compres_ibfk_2` FOREIGN KEY (`Id_Cubo`) REFERENCES `Cubos` (`Id_Cubo`) ON UPDATE CASCADE, CONSTRAINT `Compres_ibfk_3` FOREIGN KEY (`container_id`) REFERENCES `container` (`container_id`) ON UPDATE CASCADE, CONSTRAINT `buy_id` FOREIGN KEY (`Id_Entrada`) REFERENCES `Entradas` (`Id_Entrada`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=263702614 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=264445628 DEFAULT CHARSET=utf8 COLLATE=utf8_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 */ ; @@ -3813,7 +3818,7 @@ CREATE TABLE `Consignatarios` ( CONSTRAINT `Consignatarios_ibfk_3` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON UPDATE CASCADE, CONSTRAINT `Consignatarios_ibfk_4` FOREIGN KEY (`Id_Agencia`) REFERENCES `Agencias` (`Id_Agencia`) ON UPDATE CASCADE, CONSTRAINT `address_customer_id` FOREIGN KEY (`Id_cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=25490 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=25516 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4194,7 +4199,7 @@ CREATE TABLE `Entradas` ( CONSTRAINT `Entradas_ibfk_1` FOREIGN KEY (`Id_Proveedor`) REFERENCES `Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE, CONSTRAINT `Entradas_ibfk_6` FOREIGN KEY (`travel_id`) REFERENCES `travel` (`id`) ON UPDATE CASCADE, CONSTRAINT `Entradas_ibfk_7` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=146517 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; +) ENGINE=InnoDB AUTO_INCREMENT=146850 DEFAULT CHARSET=utf8 COLLATE=utf8_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 */ ; @@ -4358,7 +4363,7 @@ CREATE TABLE `Entradas_dits` ( CONSTRAINT `Entradas_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `Entradas` (`Id_Entrada`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fgkey_entradas_1` FOREIGN KEY (`idaccion_dits`) REFERENCES `accion_dits` (`idaccion_dits`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `fgkey_entradas_3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2913868 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2922478 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -4376,7 +4381,7 @@ CREATE TABLE `Entradas_kop` ( PRIMARY KEY (`Id_Entradas_kop`), KEY `entradas_entradas_kop_idx` (`Id_Entrada`), CONSTRAINT `entradas_entradas_kop` FOREIGN KEY (`Id_Entrada`) REFERENCES `Entradas` (`Id_Entrada`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=774 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; +) ENGINE=InnoDB AUTO_INCREMENT=797 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -4619,7 +4624,7 @@ CREATE TABLE `Facturas` ( CONSTRAINT `Facturas_ibfk_4` FOREIGN KEY (`cplusTaxBreakFk`) REFERENCES `vn`.`cplusTaxBreak` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoice_bank_id` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, CONSTRAINT `invoice_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=461076 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=461181 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4837,7 +4842,7 @@ CREATE TABLE `Greuges` ( KEY `Id_Ticket_Greuge_Ticket_idx` (`Id_Ticket`), CONSTRAINT `Id_Ticket_Greuge_Ticket` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `greuges_type_fk` FOREIGN KEY (`Greuges_type_id`) REFERENCES `Greuges_type` (`Greuges_type_id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2327063 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=FIXED; +) ENGINE=InnoDB AUTO_INCREMENT=2337845 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=FIXED; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5038,7 +5043,7 @@ CREATE TABLE `Movimientos` ( KEY `itemFk_ticketFk` (`Id_Article`,`Id_Ticket`), CONSTRAINT `Movimientos_ibfk_1` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON UPDATE CASCADE, CONSTRAINT `movement_ticket_id` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=21497719 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21527515 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5190,7 +5195,7 @@ CREATE TABLE `Movimientos_mark` ( KEY `Id_Movimiento` (`Id_Movimiento`), KEY `fgnStateFk_idx` (`stateFk`), CONSTRAINT `fgnStateFk` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=11348616 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=11411136 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5284,7 +5289,7 @@ CREATE TABLE `Ordenes` ( KEY `Id_Comprador` (`CodCOMPRADOR`), KEY `Id_Movimiento` (`Id_Movimiento`), KEY `Id_Vendedor` (`CodVENDEDOR`) -) ENGINE=InnoDB AUTO_INCREMENT=32790 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=32932 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5456,7 +5461,7 @@ CREATE TABLE `Proveedores` ( CONSTRAINT `pay_dem_id` FOREIGN KEY (`pay_dem_id`) REFERENCES `pay_dem` (`id`) ON UPDATE CASCADE, CONSTRAINT `pay_met_id` FOREIGN KEY (`pay_met_id`) REFERENCES `pay_met` (`id`) ON UPDATE CASCADE, CONSTRAINT `province_id` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2542 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2543 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5482,7 +5487,7 @@ CREATE TABLE `Proveedores_account` ( KEY `fk_Proveedores_account_entity1_idx` (`entity_id`), KEY `fk_banco_prov_account_idx` (`Id_Banco`), CONSTRAINT `fk_banco_prov_account` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=660 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=662 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5573,7 +5578,7 @@ CREATE TABLE `Recibos` ( CONSTRAINT `Recibos_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `Recibos_ibfk_2` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, CONSTRAINT `recibo_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=475796 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=476555 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5684,7 +5689,7 @@ CREATE TABLE `Remesas` ( KEY `empresa_id` (`empresa_id`), CONSTRAINT `Remesas_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `Remesas_ibfk_2` FOREIGN KEY (`Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1111 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1113 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5709,7 +5714,7 @@ CREATE TABLE `Reservas` ( PRIMARY KEY (`Id_Reserva`), KEY `Id_1` (`Id_Ticket`), KEY `Id_Article` (`Id_Article`) -) ENGINE=InnoDB AUTO_INCREMENT=2674 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2805 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5740,7 +5745,7 @@ CREATE TABLE `Rutas` ( KEY `Fecha` (`Fecha`), KEY `gestdoc_id` (`gestdoc_id`), CONSTRAINT `Rutas_ibfk_1` FOREIGN KEY (`gestdoc_id`) REFERENCES `gestdoc` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=40670 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=40799 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5928,7 +5933,7 @@ CREATE TABLE `Split_lines` ( KEY `Id_Compra` (`Id_Compra`), CONSTRAINT `Id_Compra` FOREIGN KEY (`Id_Compra`) REFERENCES `Compres` (`Id_Compra`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Split_lines_ibfk_1` FOREIGN KEY (`Id_Split`) REFERENCES `Splits` (`Id_Split`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=328297 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=329261 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5946,7 +5951,7 @@ CREATE TABLE `Splits` ( `Notas` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`Id_Split`), KEY `Id_Entrada` (`Id_Entrada`) -) ENGINE=InnoDB AUTO_INCREMENT=36309 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=36315 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5974,7 +5979,7 @@ CREATE TABLE `Stockcontrol` ( CONSTRAINT `Stockcontrol_ibfk_1` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Stockcontrol_ibfk_2` FOREIGN KEY (`Id_Remitente`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Stockcontrol_ibfk_3` FOREIGN KEY (`Id_Solver`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=23609 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=23614 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6032,7 +6037,7 @@ CREATE TABLE `Tickets` ( CONSTRAINT `Tickets_ibfk_9` FOREIGN KEY (`Id_Ruta`) REFERENCES `Rutas` (`Id_Ruta`) ON UPDATE CASCADE, CONSTRAINT `ticket_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, CONSTRAINT `tickets_fk10` FOREIGN KEY (`Factura`) REFERENCES `Facturas` (`Id_Factura`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1931370 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1935610 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6246,7 +6251,7 @@ CREATE TABLE `Tickets_dits` ( CONSTRAINT `Tickets_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fgkey1` FOREIGN KEY (`idaccion_dits`) REFERENCES `accion_dits` (`idaccion_dits`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `fgkey3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=59847665 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=59918951 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6452,7 +6457,7 @@ CREATE TABLE `Trabajadores` ( KEY `sub` (`sub`), CONSTRAINT `Clientes` FOREIGN KEY (`Id_Cliente_Interno`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, CONSTRAINT `Trabajadores_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1160 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1162 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6605,7 +6610,7 @@ CREATE TABLE `Vehiculos_consumo` ( PRIMARY KEY (`Vehiculos_consumo_id`,`Id_Vehiculo`), KEY `fk_Vehiculos_consumo_Vehiculos_idx` (`Id_Vehiculo`), CONSTRAINT `fk_Vehiculos_consumo_Vehiculos` FOREIGN KEY (`Id_Vehiculo`) REFERENCES `Vehiculos` (`Id_Vehiculo`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=8671 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntan el importe de los tickets de la gasolinera solred, con quien tenemos un contrato y nos facturan mensualmente'; +) ENGINE=InnoDB AUTO_INCREMENT=8732 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntan el importe de los tickets de la gasolinera solred, con quien tenemos un contrato y nos facturan mensualmente'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6719,7 +6724,7 @@ CREATE TABLE `XDiario` ( PRIMARY KEY (`id`), KEY `empresa_id` (`empresa_id`), CONSTRAINT `XDiario_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3398144 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3400357 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6827,7 +6832,7 @@ CREATE TABLE `account_conciliacion` ( KEY `fg_accconciliacion_key1_idx` (`Id_Proveedores_account`), KEY `index_id_calculated` (`id_calculated`), CONSTRAINT `fg_key1_accountconc` FOREIGN KEY (`Id_Proveedores_account`) REFERENCES `Proveedores_account` (`Id_Proveedores_account`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=5378 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=5671 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7160,7 +7165,7 @@ CREATE TABLE `albaran` ( CONSTRAINT `fk_albaran_empresa1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `fk_albaran_recibida` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `fk_albaran_warehouse1` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2528 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2547 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7237,7 +7242,7 @@ CREATE TABLE `awb` ( CONSTRAINT `awbInvoiceIn` FOREIGN KEY (`invoiceInFk`) REFERENCES `recibida` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `awbTransitoryFk` FOREIGN KEY (`transitario_id`) REFERENCES `Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE, CONSTRAINT `awb_ibfk_1` FOREIGN KEY (`iva_id`) REFERENCES `iva_codigo` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2629 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2636 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7495,7 +7500,7 @@ CREATE TABLE `awb_gestdoc` ( KEY `awb_gestdoc_gestdoc_fk` (`gestdoc_id`), CONSTRAINT `awb_gestdoc_awb_fk` FOREIGN KEY (`awb_id`) REFERENCES `awb` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `awb_gestdoc_gestdoc_fk` FOREIGN KEY (`gestdoc_id`) REFERENCES `gestdoc` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2291 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2298 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7613,7 +7618,7 @@ CREATE TABLE `barcodes` ( UNIQUE KEY `Id_Article_2` (`Id_Article`,`code`), KEY `Id_Article` (`Id_Article`), CONSTRAINT `barcodes_ibfk_1` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=36324 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=36336 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7754,7 +7759,7 @@ CREATE TABLE `buy_edi` ( KEY `kop` (`kop`), KEY `barcode` (`barcode`), KEY `fec` (`fec`) -) ENGINE=InnoDB AUTO_INCREMENT=729001 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=731393 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8008,7 +8013,7 @@ CREATE TABLE `cl_act` ( CONSTRAINT `cl_act_ibfk_1` FOREIGN KEY (`Id_Movimiento`) REFERENCES `Movimientos` (`Id_Movimiento`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `cl_act_ibfk_3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `cl_act_ibfk_4` FOREIGN KEY (`cl_main_id`) REFERENCES `cl_main` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=87589 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=87927 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8042,7 +8047,7 @@ CREATE TABLE `cl_cau` ( CONSTRAINT `cl_cau_ibfk_7` FOREIGN KEY (`cl_mot_id`) REFERENCES `cl_mot` (`id`) ON UPDATE CASCADE, CONSTRAINT `cl_cau_ibfk_8` FOREIGN KEY (`cl_con_id`) REFERENCES `cl_con` (`id`) ON UPDATE CASCADE, CONSTRAINT `cl_cau_ibfk_9` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=46753 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=46887 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8070,7 +8075,7 @@ CREATE TABLE `cl_dep` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, `departamento` varchar(20) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Departamentos para las quejas'; +) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='ELIMINAR Departamentos para las quejas'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8096,7 +8101,7 @@ CREATE TABLE `cl_det` ( CONSTRAINT `cl_det_ibfk_6` FOREIGN KEY (`cl_pet_id`) REFERENCES `cl_pet` (`id`) ON UPDATE CASCADE, CONSTRAINT `cl_det_ibfk_7` FOREIGN KEY (`Id_Movimiento`) REFERENCES `Movimientos` (`Id_Movimiento`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `cl_det_ibfk_8` FOREIGN KEY (`cl_main_id`) REFERENCES `cl_main` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=120079 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=120464 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8153,7 +8158,7 @@ CREATE TABLE `cl_main` ( CONSTRAINT `cl_main_ibfk_3` FOREIGN KEY (`cl_est_id`) REFERENCES `cl_est` (`id`) ON UPDATE CASCADE, CONSTRAINT `cl_main_ibfk_4` FOREIGN KEY (`cl_dep_id`) REFERENCES `cl_dep` (`id`) ON UPDATE CASCADE, CONSTRAINT `cl_main_ibfk_5` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=51989 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; +) ENGINE=InnoDB AUTO_INCREMENT=52169 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8181,7 +8186,7 @@ CREATE TABLE `cl_pet` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `peticion` varchar(15) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Peticiones de los cliente en relacion a las quejas'; +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='ELIMINAR Peticiones de los cliente en relacion a las quejas'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8195,7 +8200,7 @@ CREATE TABLE `cl_que` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `queja` varchar(25) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Queja por linea de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='ELIMINAR Queja por linea de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8266,7 +8271,7 @@ CREATE TABLE `client_observation` ( KEY `Id_Cliente` (`Id_Cliente`), CONSTRAINT `client_observation_ibfk_1` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `client_observation_ibfk_2` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=65649 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=65864 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8432,7 +8437,7 @@ CREATE TABLE `consignatarios_observation` ( `text` text COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`consignatarios_observation_id`), UNIQUE KEY `Id_Consigna` (`Id_Consigna`,`observation_type_id`) -) ENGINE=InnoDB AUTO_INCREMENT=3298 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; +) ENGINE=InnoDB AUTO_INCREMENT=3306 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8514,7 +8519,7 @@ CREATE TABLE `credit` ( KEY `credit_ClienteFk` (`Id_Cliente`), CONSTRAINT `credit_ClienteFk` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `workers_fk` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=64862 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=65001 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8639,7 +8644,7 @@ CREATE TABLE `device` ( PRIMARY KEY (`device_id`), UNIQUE KEY `device_id_UNIQUE` (`device_id`), UNIQUE KEY `sn_UNIQUE` (`sn`) -) ENGINE=InnoDB AUTO_INCREMENT=227 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=229 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9028,7 +9033,7 @@ CREATE TABLE `escritos_det` ( PRIMARY KEY (`id`), KEY `empresa_id` (`empresa_id`), CONSTRAINT `escritos_det_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=15761 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=15784 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9057,7 +9062,7 @@ CREATE TABLE `expeditions` ( KEY `index4` (`ticket_id`), CONSTRAINT `Id_Agencia` FOREIGN KEY (`agency_id`) REFERENCES `Agencias` (`Id_Agencia`) ON UPDATE CASCADE, CONSTRAINT `ticket_id` FOREIGN KEY (`ticket_id`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2506556 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2514238 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -9317,7 +9322,7 @@ CREATE TABLE `gestdoc` ( UNIQUE KEY `emp_id` (`emp_id`,`orden`,`warehouse_id`), KEY `trabajador_id` (`trabajador_id`), KEY `warehouse_id` (`warehouse_id`) -) ENGINE=InnoDB AUTO_INCREMENT=1038334 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='document managment system'; +) ENGINE=InnoDB AUTO_INCREMENT=1040841 DEFAULT CHARSET=utf8 COLLATE=utf8_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 */ ; @@ -9516,7 +9521,7 @@ CREATE TABLE `intrastat_data` ( KEY `recibida` (`recibida_id`), CONSTRAINT `intrastat_data_ibfk_1` FOREIGN KEY (`intrastat_id`) REFERENCES `Intrastat` (`Codintrastat`) ON UPDATE CASCADE, CONSTRAINT `intrastat_data_ibfk_2` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=67333 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=67334 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9854,7 +9859,7 @@ CREATE TABLE `mail` ( `recipientFk` int(11) DEFAULT NULL, `plainTextBody` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=1397408 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=1401931 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9912,7 +9917,7 @@ CREATE TABLE `mandato` ( CONSTRAINT `mandato_fgkey1` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `mandato_fgkey2` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `mandato_fgkey3` FOREIGN KEY (`idmandato_tipo`) REFERENCES `mandato_tipo` (`idmandato_tipo`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=15390 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=15399 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -10121,7 +10126,7 @@ CREATE TABLE `pago` ( CONSTRAINT `pago_moneda` FOREIGN KEY (`id_moneda`) REFERENCES `Monedas` (`Id_Moneda`) ON UPDATE CASCADE, CONSTRAINT `pago_pay_met` FOREIGN KEY (`pay_met_id`) REFERENCES `pay_met` (`id`) ON UPDATE CASCADE, CONSTRAINT `proveedor_pago` FOREIGN KEY (`id_proveedor`) REFERENCES `Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=42715 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=42921 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -10616,7 +10621,7 @@ CREATE TABLE `price_fixed` ( KEY `date_end` (`date_end`), KEY `warehouse_id` (`warehouse_id`), CONSTRAINT `price_fixed_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=54747 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=54928 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -10678,7 +10683,7 @@ CREATE TABLE `producer` ( `visible` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`producer_id`), UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=4897 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4928 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10847,7 +10852,7 @@ CREATE TABLE `recibida` ( CONSTRAINT `recibida_ibfk_5` FOREIGN KEY (`cplusInvoiceType472Fk`) REFERENCES `vn`.`cplusInvoiceType472` (`id`) ON UPDATE CASCADE, CONSTRAINT `recibida_ibfk_6` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `vn`.`cplusRectificationType` (`id`) ON UPDATE CASCADE, CONSTRAINT `recibida_ibfk_7` FOREIGN KEY (`cplusTrascendency472Fk`) REFERENCES `vn`.`cplusTrascendency472` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=70038 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=70155 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -11436,7 +11441,7 @@ CREATE TABLE `recibida_iva` ( CONSTRAINT `recibida_iva_ibfk_2` FOREIGN KEY (`iva_id`) REFERENCES `iva_codigo` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `recibida_iva_ibfk_5` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `recibida_iva_ibfk_6` FOREIGN KEY (`gastos_id`) REFERENCES `Gastos` (`Id_Gasto`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=95620 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=95758 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11459,7 +11464,7 @@ CREATE TABLE `recibida_vencimiento` ( KEY `banco_id` (`banco_id`), CONSTRAINT `recibida_vencimiento_ibfk_6` FOREIGN KEY (`banco_id`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, CONSTRAINT `recibida_vencimiento_ibfk_7` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=92992 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=93163 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -11696,7 +11701,7 @@ CREATE TABLE `scan` ( `name` varchar(45) CHARACTER SET utf8 DEFAULT NULL, `odbc_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=62461 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Se borra automaticamente 8 dias en el pasado desde vn2008.clean'; +) ENGINE=InnoDB AUTO_INCREMENT=62927 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Se borra automaticamente 8 dias en el pasado desde vn2008.clean'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11736,7 +11741,7 @@ CREATE TABLE `scan_line` ( PRIMARY KEY (`scan_line_id`), KEY `id_scan_id_idx` (`scan_id`), CONSTRAINT `id_scan_id` FOREIGN KEY (`scan_id`) REFERENCES `scan` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=785415 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=790585 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11758,7 +11763,7 @@ CREATE TABLE `sharingcart` ( KEY `Suplent` (`Id_Suplente`), CONSTRAINT `Suplent_key` FOREIGN KEY (`Id_Suplente`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `Trabajador_key` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1838 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1857 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12213,7 +12218,7 @@ CREATE TABLE `ticket_observation` ( KEY `observation_type_id` (`observation_type_id`), CONSTRAINT `ticket_observation_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticket_observation_ibfk_2` FOREIGN KEY (`observation_type_id`) REFERENCES `observation_type` (`observation_type_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1113187 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=1116660 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12336,7 +12341,7 @@ CREATE TABLE `travel` ( CONSTRAINT `travel_ibfk_2` FOREIGN KEY (`warehouse_id_out`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_3` FOREIGN KEY (`agency_id`) REFERENCES `Agencias` (`Id_Agencia`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_4` FOREIGN KEY (`cargoSupplierFk`) REFERENCES `Proveedores` (`Id_Proveedor`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=110172 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=110544 DEFAULT CHARSET=utf8 COLLATE=utf8_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 */ ; @@ -12473,7 +12478,7 @@ CREATE TABLE `travel_dits` ( KEY `fgkey2_idx` (`Id_Ticket`), KEY `fgkey3_idx` (`Id_Trabajador`), CONSTRAINT `travel_dits_ibfk_1` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=175463 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=176169 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17192,7 +17197,7 @@ BEGIN DECLARE datINV DATE; SELECT FechaInventario INTO datINV FROM tblContadores; - ALTER TABLE `article_inventory` + ALTER TABLE `article_inventory` ADD `buy_date` datetime NOT NULL; UPDATE article_inventory INNER JOIN @@ -17219,7 +17224,7 @@ BEGIN GROUP BY article_id ) AS buy ON article_inventory.article_id = buy.article_id - SET article_inventory.buy_date = buy.bdate; + SET article_inventory.buy_date = buy.bdate; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -18793,7 +18798,8 @@ proc: BEGIN , 15 , COEFICIENTE_DE_INFLACION_GENERAL * ROUND( - r.cm3 + r.cm3 + * art.compression * IF(a.Vista = 1, (GREATEST(art.density,DENSIDAD_MINIMA_PESO_VOLUMETRICO) / DENSIDAD_MINIMA_PESO_VOLUMETRICO ) , 1) * IFNULL(az.price * az.inflacion ,50) @@ -18816,6 +18822,7 @@ proc: BEGIN , COEFICIENTE_DE_INFLACION_GENERAL * ROUND( r.cm3 + * art.compression * IF(a.Vista = 1, (GREATEST(art.density,DENSIDAD_MINIMA_PESO_VOLUMETRICO) / DENSIDAD_MINIMA_PESO_VOLUMETRICO ) , 1) * awb.bonus * az.inflacion @@ -19084,6 +19091,7 @@ proc: BEGIN , COEFICIENTE_DE_INFLACION_GENERAL * ROUND( r.cm3 + * art.compression * IF(a.Vista = 1, (GREATEST(art.density,DENSIDAD_MINIMA_PESO_VOLUMETRICO) / DENSIDAD_MINIMA_PESO_VOLUMETRICO ) , 1) * az.price * az.inflacion @@ -22618,8 +22626,7 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `calling`() BEGIN - -DROP TEMPORARY TABLE IF EXISTS Agenda, Agenda2; + DROP TEMPORARY TABLE IF EXISTS Agenda, Agenda2; CREATE TEMPORARY TABLE IF NOT EXISTS Agenda (Telefono varchar(15) PRIMARY KEY, Cliente VARCHAR(45)); @@ -23997,6 +24004,247 @@ CREATE DEFINER=`root`@`%` PROCEDURE `comparative`( ,i_tipo INT ,i_filtro INT ) +BEGIN + DECLARE date_cyear_ini DATETIME; + DECLARE date_cyear_end DATETIME; + DECLARE week_count TINYINT DEFAULT 7; + DECLARE w1, w2, w3, w4, w5, w6, w7 INT; + DECLARE y1, y2, y3, y4, y5, y6, y7 INT; + DECLARE wperiod INT;-- DECLARE ws, ys INT; -- PAK 11/01/2016 + DECLARE i INT DEFAULT 0; + DECLARE strFILTRO VARCHAR(255) DEFAULT 'TRUE'; + + IF i_filtro THEN + SELECT `sql` INTO strFILTRO FROM filtros WHERE id = i_filtro; + END IF; + + IF days < 0 OR days > 30 THEN + SET days = 15; + END IF; + + IF i_wh = NULL THEN + SET i_wh = 0; + END IF; + -- JGF 2015-04-16 cambio -21 por -22 para que la semana cuente de domingo a sabado + SET date_cyear_ini = TIMESTAMP(DATE(TIMESTAMPADD(DAY, -22 - WEEKDAY(v_date), v_date)), '00:00:00'); + SET date_cyear_end = TIMESTAMP(DATE(TIMESTAMPADD(DAY, (7 * week_count) -1, date_cyear_ini)), '23:59:59'); + -- Eliminamos el calculo del inventario para fechas en el pasado + + DROP TEMPORARY TABLE IF EXISTS `article_inventory`; + CREATE TEMPORARY TABLE `article_inventory` + ( + `article_id` INT(11) NOT NULL PRIMARY KEY + ) + ENGINE = MEMORY; + + INSERT INTO article_inventory (article_id) + SELECT Id_Article FROM Articles a + JOIN Tipos t ON a.tipo_id = t.tipo_id + LEFT JOIN vn2008.reinos r ON r.id = t.reino_id + WHERE (i_tipo = 0 OR a.tipo_id = i_tipo) + AND r.display <> 0; + + IF v_date < CURDATE() + THEN + ALTER TABLE `article_inventory` + ADD `buy_id` INT NOT NULL DEFAULT 0, + ADD `buy_date` DATE DEFAULT '2000-01-01', + ADD `life` INT DEFAULT 0, + ADD `sd` INT DEFAULT 0, + ADD `avalaible` INT DEFAULT 0, + ADD `visible` INT DEFAULT 0; + + ELSE + + CALL inventario_multiple_2 (v_date, i_wh, days); + + CALL article_multiple_buy (v_date, i_wh); + + CALL article_multiple_buy_date (v_date, i_wh); + + + END IF; + + + DROP TEMPORARY TABLE IF EXISTS wtable; + + CREATE TEMPORARY TABLE wtable ( + cy INT(6), + ly INT(6) + ); + + REPEAT + SET i = i + 1; + SET wperiod = vnperiod(TIMESTAMPADD(DAY, 7*(i - 1), date_cyear_ini)); -- PAK 11/01/2016 + INSERT INTO wtable(cy, ly) VALUES(wperiod, wperiod - 100); -- VALUES( ys * 100 + ws, (ys -1) * 100 + ws); -- PAK 11/01/2016 + + UNTIL i = 7 END REPEAT; + + + SELECT cy, ly INTO w1, y1 FROM wtable limit 1; + SELECT cy, ly INTO w2, y2 FROM wtable WHERE cy > w1 limit 1; + SELECT cy, ly INTO w3, y3 FROM wtable WHERE cy > w2 limit 1; + SELECT cy, ly INTO w4, y4 FROM wtable WHERE cy > w3 limit 1; + + SELECT cy, ly INTO w5, y5 FROM wtable WHERE cy > w4 limit 1; + SELECT cy, ly INTO w6, y6 FROM wtable WHERE cy > w5 limit 1; + SELECT cy, ly INTO w7, y7 FROM wtable WHERE cy > w6 limit 1; + DROP TEMPORARY TABLE wtable; + + -- Genera una tabla con los datos del año pasado. + + DROP TEMPORARY TABLE IF EXISTS last_year; + CREATE TEMPORARY TABLE last_year + (KEY (Id_Article)) + ENGINE = MEMORY + SELECT Id_Article + + ,CAST(SUM(IF(Periodo = y1, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek1 + ,CAST(SUM(IF(Periodo = y2, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek2 + ,CAST(SUM(IF(Periodo = y3, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek3 + ,CAST(SUM(IF(Periodo = y4, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek4 + ,CAST(SUM(IF(Periodo = y5, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek5 + ,CAST(SUM(IF(Periodo = y6, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek6 + ,CAST(SUM(IF(Periodo = y7, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek7 + + ,CAST(SUM(IF(Periodo = y1, price, 0)) AS DECIMAL(10,0)) AS lprice1 + ,CAST(SUM(IF(Periodo = y2, price, 0)) AS DECIMAL(10,0)) AS lprice2 + ,CAST(SUM(IF(Periodo = y3, price, 0)) AS DECIMAL(10,0)) AS lprice3 + ,CAST(SUM(IF(Periodo = y4, price, 0)) AS DECIMAL(10,0)) AS lprice4 + ,CAST(SUM(IF(Periodo = y5, price, 0)) AS DECIMAL(10,0)) AS lprice5 + ,CAST(SUM(IF(Periodo = y6, price, 0)) AS DECIMAL(10,0)) AS lprice6 + ,CAST(SUM(IF(Periodo = y7, price, 0)) AS DECIMAL(10,0)) AS lprice7 + + FROM Comparativa + JOIN warehouse W on W.id = warehouse_id + WHERE (Periodo BETWEEN y1 and y7) + AND IF(i_wh = 0, W.is_comparative, i_wh = warehouse_id) + GROUP BY Id_Article; + + -- Genera una tabla con los datos de este año. + + DROP TEMPORARY TABLE IF EXISTS cur_year; + CREATE TEMPORARY TABLE cur_year + (KEY (Id_Article)) + ENGINE = MEMORY + SELECT Id_Article + + ,CAST(SUM(IF(week = w1, Total, 0)) AS DECIMAL(10,0)) AS cweek1 + ,CAST(SUM(IF(week = w2, Total, 0)) AS DECIMAL(10,0)) AS cweek2 + ,CAST(SUM(IF(week = w3, Total, 0)) AS DECIMAL(10,0)) AS cweek3 + ,CAST(SUM(IF(week = w4, Total, 0)) AS DECIMAL(10,0)) AS cweek4 + ,CAST(SUM(IF(week = w5, Total, 0)) AS DECIMAL(10,0)) AS cweek5 + ,CAST(SUM(IF(week = w6, Total, 0)) AS DECIMAL(10,0)) AS cweek6 + ,CAST(SUM(IF(week = w7, Total, 0)) AS DECIMAL(10,0)) AS cweek7 + + ,CAST(SUM(IF(week = w1, price, 0)) AS DECIMAL(10,0)) AS cprice1 + ,CAST(SUM(IF(week = w2, price, 0)) AS DECIMAL(10,0)) AS cprice2 + ,CAST(SUM(IF(week = w3, price, 0)) AS DECIMAL(10,0)) AS cprice3 + ,CAST(SUM(IF(week = w4, price, 0)) AS DECIMAL(10,0)) AS cprice4 + ,CAST(SUM(IF(week = w5, price, 0)) AS DECIMAL(10,0)) AS cprice5 + ,CAST(SUM(IF(week = w6, price, 0)) AS DECIMAL(10,0)) AS cprice6 + ,CAST(SUM(IF(week = w7, price, 0)) AS DECIMAL(10,0)) AS cprice7 + + FROM ( + SELECT A.Id_Article + ,CTS.period week + ,SUM(Cantidad) AS Total + ,TRUNCATE(SUM(Cantidad * IF(T.Fecha >= '2015-10-01',M.CostFixat,Preu * (100 - Descuento) / 100)),0) AS price + FROM Movimientos M + LEFT JOIN Tickets T ON T.Id_Ticket = M.Id_Ticket + INNER JOIN `time` CTS ON CTS.`date` = DATE(T.Fecha) + INNER JOIN Articles A USING (Id_Article) + INNER JOIN Tipos tp ON tp.tipo_id = A.tipo_id + LEFT JOIN reinos r ON r.id = tp.reino_id + JOIN warehouse W ON W.id = T.warehouse_id + WHERE Fecha BETWEEN date_cyear_ini AND date_cyear_end + AND T.Id_Cliente NOT IN(400,200) + AND IF(i_wh = 0, W.is_comparative, i_wh = T.warehouse_id) + AND r.display <> 0 + + GROUP BY A.Id_Article, week + ) t + GROUP BY Id_Article; + -- Genera la tabla con la comparativa. + + DROP TEMPORARY TABLE IF EXISTS remcom; + + SET strFILTRO = REPLACE(strFILTRO, 'Id_Article','A.Id_Article'); + SET strFILTRO = REPLACE(strFILTRO, 'tipo_id','tp.tipo_id'); + -- select * from article_inventory; + + DROP TEMPORARY TABLE IF EXISTS tmp.comparative; + + CALL util.exec (sql_printf + ( + 'CREATE TEMPORARY TABLE tmp.comparative ENGINE = MEMORY + SELECT + an.nicho, p.name Productor, C.Packing, C.Costefijo + ,A.Color, Id_Tipo as Tipo,A.tipo_id, o.Abreviatura as Origen, A.Categoria + ,A.Tallos, A.Medida, A.Article, TR.CodigoTrabajador + + ,cweek1, cweek2, cweek3, cweek4, cweek5, cweek6, cweek7 + ,lweek1, lweek2, lweek3, lweek4, lweek5, lweek6, lweek7 + + ,cprice1, cprice2, cprice3, cprice4, cprice5, cprice6, cprice7 + ,lprice1, lprice2, lprice3, lprice4, lprice5, lprice6, lprice7 + + ,A.Id_Article, i.buy_id , tp.life , CAST(IFNULL(i.sd,0) AS SIGNED) as sd + ,CAST(i.avalaible AS SIGNED) avalaible, CAST(i.visible AS SIGNED) visible, i.buy_date + ,E.Id_Proveedor AS provider_id + ,A.offer, A.bargain, A.comments, A.relevancy, A.description itemDescription + ,IF(cy.Id_Article IS NULL AND i.visible = 0 AND i.avalaible = 0 AND IFNULL(i.sd, 0) = 0, FALSE, TRUE) AS filtret + ,(IFNULL(it.itemFk,0) != 0) isTagged + + ,A.tag5, A.value5, A.tag6, A.value6, A.tag7, A.value7, A.tag8, A.value8, A.description + FROM vn2008.article_inventory i + JOIN vn2008.Articles A ON A.Id_Article = i.article_id + LEFT JOIN vn.itemTagged it ON it.itemFk = i.article_id + LEFT JOIN vn2008.Articles_nicho an ON A.Id_Article = an.Id_Article AND an.warehouse_id = %s + LEFT JOIN vn2008.producer p ON p.producer_id = A.producer_id + LEFT JOIN vn2008.Tipos tp ON A.tipo_id = tp.tipo_id + LEFT JOIN vn2008.reinos r ON r.id = tp.reino_id + LEFT JOIN vn2008.Trabajadores TR ON TR.Id_Trabajador = tp.Id_Trabajador + LEFT JOIN vn2008.Compres C ON i.buy_id = C.Id_Compra + LEFT JOIN vn2008.Entradas E USING(Id_Entrada) + LEFT JOIN vn2008.Origen o ON o.id = A.id_origen + LEFT JOIN vn2008.last_year ly ON ly.Id_Article = A.Id_Article + LEFT JOIN vn2008.cur_year cy ON cy.Id_Article = A.Id_Article AND (i.avalaible <> 0 OR i.visible <> 0 OR cweek1 OR cweek2 OR cweek3 OR cweek4 + OR cweek5 OR cweek6 OR cweek7 OR lweek1 OR lweek2 OR lweek3 OR lweek4 OR lweek5 + OR lweek6 OR lweek7) + WHERE r.display <> 0 AND %s ' + + ,i_wh,strFILTRO + )); + + -- Destruye las tablas temporales creadas. + + DROP TEMPORARY TABLE last_year; + DROP TEMPORARY TABLE cur_year; + DROP TEMPORARY TABLE article_inventory; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!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 `comparativeKk` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `comparativeKk`( + v_date DATETIME + ,days TINYINT + ,i_wh TINYINT + ,i_tipo INT + ,i_filtro INT +) BEGIN DECLARE wstart INT; DECLARE wend INT; @@ -25035,8 +25283,7 @@ BEGIN -- Insertamos los tickets que ya tienen expediciones, que fallaran si se repite la clave primaria. - INSERT INTO zeleVOL(Provincia, Id_Ticket, Bultos) - SELECT p.name, e.ticket_id, COUNT(e.ticket_id) + INSERT INTO zeleVOL(Provincia, Id_Ticket, Bultos) SELECT p.name, e.ticket_id, COUNT(e.ticket_id) FROM expeditions e JOIN Tickets t ON ticket_id = Id_Ticket JOIN Consignatarios c USING(Id_Consigna) @@ -25070,8 +25317,7 @@ BEGIN GROUP BY p.name, Id_Ticket ) sub GROUP BY province ON DUPLICATE KEY UPDATE Faltan = Faltan; - - -- Mostramos el resultado + -- Mostramos el resultado SELECT Provincia, COUNT(Id_Ticket) expediciones, SUM(Bultos) Bultos, SUM(Faltan) Prevision FROM zeleVOL @@ -30018,7 +30264,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `itemTagUpdatePriority` */; +/*!50003 DROP PROCEDURE IF EXISTS `itemTagUpdatePriorityKk` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -30028,7 +30274,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemTagUpdatePriority`(IN vItem INT) +CREATE DEFINER=`root`@`%` PROCEDURE `itemTagUpdatePriorityKk`(IN vItem INT) BEGIN /* * DEPRECATED @@ -31609,8 +31855,7 @@ BEGIN INSERT INTO Mensajes(Mensaje,Fecha,Remitente,Destinatario) VALUES(memTXT, NOW(),idREM, idDES); - - SELECT LAST_INSERT_ID() INTO last_ID; + SELECT LAST_INSERT_ID() INTO last_ID; INSERT INTO Incidencias(Incidencia,Id_Trabajador,Destino,Fecha,Fecha_Mod) @@ -32465,10 +32710,98 @@ END; call vn2008.itemTagArrangedUpdate(0); INSERT INTO vn2008.daily_task_log(consulta) VALUES('itemTagFormatUpdate END'); + SELECT SLEEP(1) INTO AUX; + INSERT INTO vn2008.daily_task_log(consulta) VALUES('finalitza el event vn2008.nightly_tasks'); + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!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 `nightly_tasksKk` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `nightly_tasksKk`() +BEGIN + +DECLARE AUX INT; + +DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN + GET DIAGNOSTICS CONDITION 2 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT; + SELECT CONCAT('ERROR ', IFNULL(@errno,0), ': ', ifnull(@text,'texto')); + INSERT INTO vn2008.mail (`to`,`subject`,`text`) VALUES ('jgallego@verdnatura.es', 'error nightly tasks' ,CONCAT('ERROR ', IFNULL(@errno,0), ': ', ifnull(@text,'texto'))); + INSERT INTO vn2008.mail (`to`,`subject`,`text`) VALUES ('pako@verdnatura.es', 'error nightly tasks' ,CONCAT('ERROR ', IFNULL(@errno,0), ': ', ifnull(@text,'texto'))); + +END; + + INSERT INTO vn2008.daily_task_log(consulta) VALUES('arranca el event vn2008.nightly_tasks'); + SELECT SLEEP(1) INTO AUX; - CALL vn.itemTagUpdatePriority(0); - INSERT INTO vn2008.daily_task_log(consulta) VALUES('articleTagUpdatePriority END'); - + CALL vn2008.emailYesterdayPurchasesLauncher(); + INSERT INTO vn2008.daily_task_log(consulta) VALUES('emailYesterdayPurchasesLauncher END'); + + SELECT SLEEP(1) INTO AUX; + CALL vn2008.inventory_refresh(); + INSERT INTO vn2008.daily_task_log(consulta) VALUES('inventory refresh END'); + + SELECT SLEEP(1) INTO AUX; + CALL bi.last_buy_id_add; + INSERT INTO vn2008.daily_task_log(consulta) VALUES('last buy id END'); + + SELECT SLEEP(1) INTO AUX; + CALL bi.defaulting(curdate()); + INSERT INTO vn2008.daily_task_log(consulta) VALUES('defaulting END'); + + INSERT INTO vn2008.Colas(Id_Informe,Id_Trabajador) VALUES (11,57); + + SELECT SLEEP(1) INTO AUX; + CALL `bi`.`Ultima_Accion`; + INSERT INTO vn2008.daily_task_log(consulta) VALUES('ultima accion END'); + + SELECT SLEEP(1) INTO AUX; + CALL `bi`.`facturacion_media_anual_update`(); + INSERT INTO vn2008.daily_task_log(consulta) VALUES('facturacion media anual END'); + + SELECT SLEEP(1) INTO AUX; + CALL vn2008.Clientes_calidad; + INSERT INTO vn2008.daily_task_log(consulta) VALUES('clientes calidad END'); + + SELECT SLEEP(1) INTO AUX; + CALL bi.rotacion_update; + INSERT INTO vn2008.daily_task_log(consulta) VALUES('rotation update END'); + + SELECT SLEEP(1) INTO AUX; + CALL bi.rutas_m3_add; + INSERT INTO vn2008.daily_task_log(consulta) VALUES('rutas_m3 END'); + + SELECT SLEEP(1) INTO AUX; + CALL vn2008.tarjetas_credito_0; + INSERT INTO vn2008.daily_task_log(consulta) VALUES('tarjetas credito 0 END'); + + SELECT SLEEP(1) INTO AUX; + CALL bi.comparativa_add(); + INSERT INTO vn2008.daily_task_log(consulta) VALUES('comparativa add END'); + + SELECT SLEEP(1) INTO AUX; + call vn2008.recobro_credito(); -- PAK 12/01/2016 + INSERT INTO vn2008.daily_task_log(consulta) VALUES('recobro_credito END'); + + SELECT SLEEP(1) INTO AUX; + CALL vn2008.accumulatorsReadingDateUpdate(); + INSERT INTO vn2008.daily_task_log(consulta) VALUES('accumulatorsReadingDateUpdate END'); + + SELECT SLEEP(1) INTO AUX; + call vn2008.itemTagArrangedUpdate(0); + INSERT INTO vn2008.daily_task_log(consulta) VALUES('itemTagFormatUpdate END'); + SELECT SLEEP(1) INTO AUX; INSERT INTO vn2008.daily_task_log(consulta) VALUES('finalitza el event vn2008.nightly_tasks'); @@ -43057,6 +43390,89 @@ SET character_set_client = utf8; 1 AS `provinceFk`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `claim` +-- + +DROP TABLE IF EXISTS `claim`; +/*!50001 DROP VIEW IF EXISTS `claim`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `claim` AS SELECT + 1 AS `id`, + 1 AS `ticketCreated`, + 1 AS `claimStateFk`, + 1 AS `observation`, + 1 AS `clientFk`, + 1 AS `workerFk`, + 1 AS `claimResponsibleFk`, + 1 AS `isChargedToMana`, + 1 AS `created`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `claimBeginning` +-- + +DROP TABLE IF EXISTS `claimBeginning`; +/*!50001 DROP VIEW IF EXISTS `claimBeginning`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `claimBeginning` AS SELECT + 1 AS `id`, + 1 AS `claimFk`, + 1 AS `saleFk`, + 1 AS `claimed`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `claimDestination` +-- + +DROP TABLE IF EXISTS `claimDestination`; +/*!50001 DROP VIEW IF EXISTS `claimDestination`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `claimDestination` AS SELECT + 1 AS `id`, + 1 AS `description`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `claimDevelopment` +-- + +DROP TABLE IF EXISTS `claimDevelopment`; +/*!50001 DROP VIEW IF EXISTS `claimDevelopment`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `claimDevelopment` AS SELECT + 1 AS `id`, + 1 AS `claimFk`, + 1 AS `claimResponsibleFk`, + 1 AS `workerFk`, + 1 AS `claimReasonFk`, + 1 AS `claimResultFk`, + 1 AS `claimRedeliveryFk`, + 1 AS `claimDestinationFk`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `claimEnd` +-- + +DROP TABLE IF EXISTS `claimEnd`; +/*!50001 DROP VIEW IF EXISTS `claimEnd`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `claimEnd` AS SELECT + 1 AS `id`, + 1 AS `saleFk`, + 1 AS `claimFk`, + 1 AS `workerFk`, + 1 AS `claimDestinationFk`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `claimRatio` -- @@ -43074,6 +43490,72 @@ SET character_set_client = utf8; 1 AS `packingRate`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `claimReason` +-- + +DROP TABLE IF EXISTS `claimReason`; +/*!50001 DROP VIEW IF EXISTS `claimReason`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `claimReason` AS SELECT + 1 AS `id`, + 1 AS `description`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `claimRedelivery` +-- + +DROP TABLE IF EXISTS `claimRedelivery`; +/*!50001 DROP VIEW IF EXISTS `claimRedelivery`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `claimRedelivery` AS SELECT + 1 AS `id`, + 1 AS `description`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `claimResponsible` +-- + +DROP TABLE IF EXISTS `claimResponsible`; +/*!50001 DROP VIEW IF EXISTS `claimResponsible`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `claimResponsible` AS SELECT + 1 AS `id`, + 1 AS `description`, + 1 AS `responsability`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `claimResult` +-- + +DROP TABLE IF EXISTS `claimResult`; +/*!50001 DROP VIEW IF EXISTS `claimResult`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `claimResult` AS SELECT + 1 AS `id`, + 1 AS `description`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `claimState` +-- + +DROP TABLE IF EXISTS `claimState`; +/*!50001 DROP VIEW IF EXISTS `claimState`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `claimState` AS SELECT + 1 AS `id`, + 1 AS `description`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `client` -- @@ -43213,7 +43695,7 @@ CREATE TABLE `clientLog` ( KEY `userFk` (`userFk`), CONSTRAINT `clientLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=168406 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=168844 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43230,6 +43712,54 @@ SET character_set_client = utf8; 1 AS `dated`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `clientNotificationTypekk` +-- + +DROP TABLE IF EXISTS `clientNotificationTypekk`; +/*!50001 DROP VIEW IF EXISTS `clientNotificationTypekk`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `clientNotificationTypekk` AS SELECT + 1 AS `id`, + 1 AS `code`, + 1 AS `description`, + 1 AS `isVisible`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `clientNotificationkk` +-- + +DROP TABLE IF EXISTS `clientNotificationkk`; +/*!50001 DROP VIEW IF EXISTS `clientNotificationkk`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `clientNotificationkk` AS SELECT + 1 AS `id`, + 1 AS `clientFk`, + 1 AS `clientNotificationTypeFk`, + 1 AS `created`, + 1 AS `workerFk`, + 1 AS `userFk`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `clientObservation` +-- + +DROP TABLE IF EXISTS `clientObservation`; +/*!50001 DROP VIEW IF EXISTS `clientObservation`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `clientObservation` AS SELECT + 1 AS `id`, + 1 AS `clientFk`, + 1 AS `workerFk`, + 1 AS `text`, + 1 AS `created`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `clientSample` -- @@ -43248,37 +43778,6 @@ SET character_set_client = utf8; 1 AS `companyFk`*/; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `sample` --- - -DROP TABLE IF EXISTS `sample`; -/*!50001 DROP VIEW IF EXISTS `sample`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `sample` AS SELECT - 1 AS `id`, - 1 AS `code`, - 1 AS `description`, - 1 AS `isVisible`*/; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `clientObservation` --- - -DROP TABLE IF EXISTS `clientObservation`; -/*!50001 DROP VIEW IF EXISTS `clientObservation`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `clientObservation` AS SELECT - 1 AS `id`, - 1 AS `clientFk`, - 1 AS `workerFk`, - 1 AS `text`, - 1 AS `created`*/; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `clientType` -- @@ -43633,7 +44132,7 @@ CREATE TABLE `creditClassification` ( KEY `creditClassifClientFk_idx` (`client`), KEY `creditClassifdateEnd_idx` (`dateEnd`), CONSTRAINT `creditClassifClientFk` FOREIGN KEY (`client`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2802 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2805 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -43678,7 +44177,7 @@ CREATE TABLE `creditInsurance` ( PRIMARY KEY (`id`), KEY `CreditInsurance_Fk1_idx` (`creditClassification`), CONSTRAINT `CreditInsurance_Fk1` FOREIGN KEY (`creditClassification`) REFERENCES `creditClassification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1996 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; +) ENGINE=InnoDB AUTO_INCREMENT=2011 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; /*!40101 SET character_set_client = @saved_cs_client */; ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -43833,7 +44332,7 @@ CREATE TABLE `dua` ( CONSTRAINT `dua_fk1` FOREIGN KEY (`gestdocFk`) REFERENCES `vn2008`.`gestdoc` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `dua_fk2` FOREIGN KEY (`awbFk`) REFERENCES `vn2008`.`awb` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `dua_fk4` FOREIGN KEY (`companyFk`) REFERENCES `vn2008`.`empresa` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3248 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3255 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44015,7 +44514,7 @@ CREATE TABLE `entryLog` ( KEY `entryLog_ibfk_2` (`userFk`), CONSTRAINT `entryLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Entradas` (`Id_Entrada`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `entryLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=57239 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=57981 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44599,7 +45098,7 @@ CREATE TABLE `invoiceOutExpence` ( KEY `invoiceOutExpence_FK_2_idx` (`expenceFk`), CONSTRAINT `invoiceOutExpence_FK_1` FOREIGN KEY (`invoiceOutFk`) REFERENCES `vn2008`.`Facturas` (`factura_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutExpence_FK_2` FOREIGN KEY (`expenceFk`) REFERENCES `vn2008`.`Gastos` (`Id_Gasto`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=70587 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Desglosa la base imponible de una factura en funcion del tipo de gasto/venta'; +) ENGINE=InnoDB AUTO_INCREMENT=70719 DEFAULT CHARSET=utf8 COLLATE=utf8_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 */; -- @@ -44642,7 +45141,7 @@ CREATE TABLE `invoiceOutTax` ( KEY `pgcFk` (`pgcFk`), CONSTRAINT `invoiceOutFk` FOREIGN KEY (`invoiceOutFk`) REFERENCES `vn2008`.`Facturas` (`factura_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutTax_ibfk_1` FOREIGN KEY (`pgcFk`) REFERENCES `pgc` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=940830 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=940976 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44666,6 +45165,7 @@ SET character_set_client = utf8; 1 AS `producerFk`, 1 AS `intrastatFk`, 1 AS `isOnOffer`, + 1 AS `box`, 1 AS `expenceFk`, 1 AS `isBargain`, 1 AS `comment`, @@ -44876,7 +45376,7 @@ CREATE TABLE `itemShelving` ( CONSTRAINT `itemShelving_fk1` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) 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 `vn2008`.`Cubos` (`Id_Cubo`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44923,7 +45423,7 @@ CREATE TABLE `itemTag` ( KEY `priorityItem` (`itemFk`,`priority`), KEY `tagFk` (`tagFk`,`value`), CONSTRAINT `itemFK` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=379836 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=414080 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45077,7 +45577,7 @@ CREATE TABLE `itemTaxCountry` ( CONSTRAINT `countryFK_paises` FOREIGN KEY (`countryFk`) REFERENCES `vn2008`.`Paises` (`Id`) ON UPDATE CASCADE, CONSTRAINT `itemFK_Article` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `taxClassFK_Iva_Group` FOREIGN KEY (`taxClassFk`) REFERENCES `vn2008`.`iva_group` (`iva_group_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=507938 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; +) ENGINE=InnoDB AUTO_INCREMENT=509366 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -45309,7 +45809,7 @@ CREATE TABLE `message` ( KEY `sender` (`sender`), KEY `recipient` (`recipient`), KEY `uuid` (`uuid`(8)) -) ENGINE=InnoDB AUTO_INCREMENT=1534736 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1539454 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -45331,7 +45831,7 @@ CREATE TABLE `messageInbox` ( PRIMARY KEY (`id`), KEY `uuid` (`uuid`(8)), KEY `finalRecipient` (`finalRecipient`) -) ENGINE=InnoDB AUTO_INCREMENT=1682549 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1687659 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -45579,9 +46079,10 @@ CREATE TABLE `parking` ( `row` varchar(5) COLLATE utf8_unicode_ci NOT NULL, `sectorFk` int(11) NOT NULL DEFAULT '2', PRIMARY KEY (`id`), + UNIQUE KEY `column_UNIQUE` (`column`,`row`), KEY `parking_fk1_idx` (`sectorFk`), CONSTRAINT `parking_fk1` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=617 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46251,7 +46752,7 @@ CREATE TABLE `routeLog` ( `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `description` text COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=534339 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=538450 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46335,7 +46836,7 @@ CREATE TABLE `saleItemShelving` ( `isPicked` tinyint(4) NOT NULL DEFAULT '0', `ubication` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=219 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46357,6 +46858,21 @@ SET character_set_client = utf8; 1 AS `stateFk`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `sample` +-- + +DROP TABLE IF EXISTS `sample`; +/*!50001 DROP VIEW IF EXISTS `sample`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `sample` AS SELECT + 1 AS `id`, + 1 AS `code`, + 1 AS `description`, + 1 AS `isVisible`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `sector` -- @@ -46408,7 +46924,7 @@ CREATE TABLE `sms` ( `status` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=100073 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=100525 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46572,7 +47088,7 @@ CREATE TABLE `stockBuyed` ( UNIQUE KEY `date_UNIQUE` (`date`,`user`), KEY `stockBuyed_user_idx` (`user`), CONSTRAINT `stockBuyedUserFk` FOREIGN KEY (`user`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=356828 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=360603 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46810,7 +47326,7 @@ CREATE TABLE `ticketLog` ( KEY `logTicketuserFk` (`userFk`), CONSTRAINT `ticketLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1096716 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1110706 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46910,7 +47426,7 @@ CREATE TABLE `ticketPackaging` ( KEY `ticketPackaging_fk2_idx` (`packagingFk`), CONSTRAINT `ticketPackaging_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `vn2008`.`Cubos` (`Id_Cubo`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=34863 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=35320 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -47390,7 +47906,7 @@ CREATE TABLE `workerDocument` ( KEY `workerDocument_ibfk_2` (`document`), CONSTRAINT `workerDocument_ibfk_1` FOREIGN KEY (`worker`) REFERENCES `vn2008`.`Trabajadores` (`user_id`) ON UPDATE CASCADE, CONSTRAINT `workerDocument_ibfk_2` FOREIGN KEY (`document`) REFERENCES `vn2008`.`gestdoc` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=6318 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=6345 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -47440,7 +47956,7 @@ CREATE TABLE `workerJourney` ( UNIQUE KEY `userFk_UNIQUE` (`userFk`,`dated`), KEY `fk_workerJourney_user_idx` (`userFk`), CONSTRAINT `fk_workerJourney_user` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4005101 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4166878 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -47462,7 +47978,7 @@ CREATE TABLE `workerLog` ( 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 `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=4964 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4990 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -47499,7 +48015,7 @@ CREATE TABLE `workerTimeControl` ( KEY `warehouseFkfk1_idx` (`warehouseFk`), CONSTRAINT `warehouseFk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `workerTimeControl_fk1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1350792 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; +) ENGINE=InnoDB AUTO_INCREMENT=1352638 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -47711,38 +48227,38 @@ DELIMITER ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`z-developer`@`%`*/ /*!50106 EVENT `printingQueueChecker` ON SCHEDULE EVERY 10 MINUTE STARTS '2018-05-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN - - DECLARE vCurrentCount INT; - DECLARE vCheckSum INT; - DECLARE vIsAlreadyNotified BOOLEAN; - - SELECT COUNT(*), SUM(id) INTO vCurrentCount, vCheckSum - FROM printingQueue WHERE state = 1; - - SELECT isAlreadyNotified INTO vIsAlreadyNotified - FROM printingQueueCheck; - - IF (SELECT lastCount FROM printingQueueCheck) = vCurrentCount AND - (SELECT lastCheckSum FROM printingQueueCheck) = vCheckSum AND - vIsAlreadyNotified = FALSE - THEN - INSERT INTO vn2008.mail (`to`, subject, text) - VALUES ('cau@verdnatura.es', - 'servidor de impresion parado', - CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas')); - UPDATE printingQueueCheck SET isAlreadyNotified = TRUE; - END IF; - - IF (SELECT lastCount FROM printingQueueCheck) > vCurrentCount AND - vIsAlreadyNotified = TRUE - THEN - UPDATE printingQueueCheck SET isAlreadyNotified = FALSE; - END IF; - - UPDATE printingQueueCheck - SET lastCount = vCurrentCount, - lastCheckSum = vCheckSum; +/*!50106 CREATE*/ /*!50117 DEFINER=`z-developer`@`%`*/ /*!50106 EVENT `printingQueueChecker` ON SCHEDULE EVERY 10 MINUTE STARTS '2018-05-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN + + DECLARE vCurrentCount INT; + DECLARE vCheckSum INT; + DECLARE vIsAlreadyNotified BOOLEAN; + + SELECT COUNT(*), SUM(id) INTO vCurrentCount, vCheckSum + FROM printingQueue WHERE state = 1; + + SELECT isAlreadyNotified INTO vIsAlreadyNotified + FROM printingQueueCheck; + + IF (SELECT lastCount FROM printingQueueCheck) = vCurrentCount AND + (SELECT lastCheckSum FROM printingQueueCheck) = vCheckSum AND + vIsAlreadyNotified = FALSE + THEN + INSERT INTO vn2008.mail (`to`, subject, text) + VALUES ('cau@verdnatura.es', + 'servidor de impresion parado', + CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas')); + UPDATE printingQueueCheck SET isAlreadyNotified = TRUE; + END IF; + + IF (SELECT lastCount FROM printingQueueCheck) > vCurrentCount AND + vIsAlreadyNotified = TRUE + THEN + UPDATE printingQueueCheck SET isAlreadyNotified = FALSE; + END IF; + + UPDATE printingQueueCheck + SET lastCount = vCurrentCount, + lastCheckSum = vCheckSum; END */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; @@ -53185,6 +53701,123 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `itemDiary`(IN vItemId INT, IN vWarehouse INT) +BEGIN + DECLARE vDateInventory DATETIME; + DECLARE vCurdate DATE DEFAULT CURDATE(); + DECLARE vDayEnd DATETIME DEFAULT util.dayEnd(vCurdate); + -- traduccion: date, alertLevel, origin, reference, name, In, Out, Balance + SELECT Fechainventario INTO vDateInventory FROM vn2008.tblContadores; + SET @a = 0; + SELECT sql_no_cache DATE(date) AS date, + alertLevel, + stateName, + origin, + reference, + name, + `in`, + `out`, + @a := @a + IFNULL(`in`,0) - IFNULL(`out`,0) as balance + FROM + ( SELECT tr.landed as date, + b.quantity as `in`, + NULL as `out`, + IF(tr.isReceived != FALSE,3, IF(tr.isDelivered,1,0)) as alertLevel, + st.name AS stateName, + s.name as name, + e.ref as reference, + e.id as origin, + TRUE isPicked + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel tr ON tr.id = e.travelFk + JOIN vn.supplier s ON s.id = e.supplierFk + JOIN vn.alertLevel al ON al.alertLevel = + CASE + WHEN tr.isReceived != FALSE THEN 3 + WHEN tr.isDelivered THEN 1 + ELSE 0 + END + JOIN vn.state st ON st.code = al.code + WHERE tr.landed >= vDateInventory + AND vWarehouse = tr.warehouseInFk + AND b.itemFk = vItemId + AND e.isInventory = 0 + + UNION ALL + + SELECT tr.shipped as date, + NULL as `in`, + b.quantity as `out`, + IF(tr.isReceived != FALSE,3, IF(tr.isDelivered,1,0)) as alertLevel, + st.name AS stateName, + s.name as name, + e.ref as reference, + e.id as origin, + TRUE isPicked + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel tr ON tr.id = e.travelFk + JOIN vn.warehouse w ON w.id = tr.warehouseOutFk + JOIN vn.supplier s ON s.id = e.supplierFk + JOIN vn.alertLevel al ON al.alertLevel = + CASE + WHEN tr.isReceived != FALSE THEN 3 + WHEN tr.isDelivered THEN 1 + ELSE 0 + END + JOIN vn.state st ON st.code = al.code + WHERE tr.shipped >= vDateInventory + AND vWarehouse =tr.warehouseOutFk + AND s.id <> 4 + AND b.itemFk = vItemId + AND e.isInventory = 0 + AND w.isFeedStock = 0 + + UNION ALL + + SELECT t.shipped as date, + NULL as `in`, + s.quantity as `out`, + al.alertLevel as alertLevel, + st.name AS stateName, + t.nickname as name, + t.refFk as reference, + t.id as origin, + TRUE as isPicked -- stk.id as isPicked + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + LEFT JOIN vn.ticketState ts ON ts.ticket = t.id + JOIN vn.client c ON c.id = t.clientFk + JOIN vn.alertLevel al ON al.alertLevel = + CASE + WHEN t.shipped < vCurdate THEN 3 + WHEN t.shipped > vDayEnd THEN 0 + ELSE IFNULL(ts.alertLevel, 0) + END + JOIN vn.state st ON st.code = al.code + -- LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.id AND stk.stateFk = 14 + WHERE t.shipped >= vDateInventory + AND s.itemFk = vItemId + AND vWarehouse =t.warehouseFk + ) AS itemDiary + ORDER BY date, alertLevel DESC, isPicked DESC, `in` DESC, `out` DESC; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemDiaryKk` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `itemDiaryKk`(IN vItemId INT, IN vWarehouse INT) BEGIN DECLARE vDateInventory DATETIME; DECLARE vCurdate DATE DEFAULT CURDATE(); @@ -53259,7 +53892,7 @@ BEGIN SELECT t.shipped as date, NULL as `in`, s.quantity as `out`, - IF(t.shipped < vCurdate,3,IF(t.shipped > vCurdate, 0, IFNULL(ts.alertLevel,0))) as alertLevel, + IF(DATE(t.shipped) < vCurdate,3,IF(DATE(t.shipped) > vCurdate, 0, IFNULL(ts.alertLevel,0))) as alertLevel, st.name AS stateName, t.nickname as name, t.refFk as reference, @@ -53270,8 +53903,8 @@ BEGIN JOIN vn.client c ON c.id = t.clientFk JOIN vn.alertLevel al ON al.alertLevel = CASE - WHEN t.shipped < vCurdate THEN 3 - WHEN t.shipped > vCurdate THEN 0 + WHEN DATE(t.shipped) < vCurdate THEN 3 + WHEN DATE(t.shipped) > vCurdate THEN 0 ELSE IFNULL(ts.alertLevel, 0) END JOIN vn.state st ON st.code = al.code @@ -53279,7 +53912,49 @@ BEGIN AND s.itemFk = vItemId AND vWarehouse =t.warehouseFk ) AS itemDiary - ORDER BY date, alertLevel, `in` DESC; + ORDER BY date, alertLevel DESC, `in` DESC; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemGetVisibleAvailable` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `itemGetVisibleAvailable`( + vItem INT, + vDate DATE, + vWarehouse TINYINT, + vRefresh BOOL) +BEGIN + DECLARE vVisibleCalc INT; + DECLARE vAvailableCalc INT; + + -- FIXME: Android app is always passing %TRUE for #vRefresh, this leads to DB performance issues + CALL cache.visible_refresh(vVisibleCalc, vRefresh, vWarehouse); + CALL cache.available_refresh(vAvailableCalc, FALSE /*vRefresh*/, vWarehouse, vDate); + + SELECT i.id, i.longName, i.box, i.typeFk, + i.tag5,i.value5,i.tag6,i.value6,i.tag7,i.value7,i.tag8,i.value8, + ip.code, ip.reserve, + v.visible, + av.available + FROM vn.item i + LEFT JOIN vn.itemPlacement ip + ON i.id = ip.itemFk AND ip.warehouseFk = vWarehouse + LEFT JOIN cache.visible v + ON v.item_id = i.id AND v.calc_id = vVisibleCalc + LEFT JOIN cache.available av + ON av.item_id = i.id AND av.calc_id = vAvailableCalc + WHERE (vItem IS NULL OR i.id = vItem); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -53432,6 +54107,32 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingList` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `itemShelvingList`(vShelvingFk VARCHAR(3)) +BEGIN + + SELECT ish.itemFk as item, + IFNULL(i.subName, CONCAT(i.name, ' ',i.size)) as description, + ish.visible as quantity + FROM vn.itemShelving ish + JOIN vn.item i ON i.id = ish.itemFk + WHERE ish.shelvingFk =vShelvingFk; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!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 `itemShelvingMake` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -53540,9 +54241,7 @@ BEGIN LEFT JOIN producer p ON p.id = i.producerFk WHERE it.itemFk IS NULL AND (vItem IS NULL OR vItem = i.id); - - CALL itemTagUpdatePriority(vItem); - /* +/* UPDATE itemTagArranged SET tag1 = NULL, val1 = NULL, @@ -53610,74 +54309,73 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemTagMake`(vWorker INT) +CREATE DEFINER=`root`@`%` PROCEDURE `itemTagMake`() BEGIN - INSERT IGNORE INTO itemTag(itemFk, tagFk, value, priority) - SELECT i.id, 4, i.size, 1 - FROM item i - JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemTag itg ON itg.itemFk = i.id AND itg.priority = 1 AND itg.tagFk = 4 - WHERE it.workerFk = vWorker AND itg.itemFk IS NULL; +/* Crea los tags para articulos que no los tengan. + * Quitar los triggers de las tablas itemTag insert + * y Articles update +*/ + DROP TEMPORARY TABLE IF EXISTS upda; + create temporary table upda + SELECT i.id + FROM vn.item i + LEFT JOIN itemTag it ON it.itemFk = i.id + JOIN itemType ity ON ity.id = i.typeFk + WHERE it.itemFk IS NULL AND ity.workerFk = 740; + + INSERT IGNORE INTO itemTag(itemFk, tagFk, value, priority) + SELECT i.id, 8, i.size, 1 + FROM item i + JOIN upda u ON i.id = u.id; + INSERT IGNORE INTO itemTag(itemFk, tagFk, value, priority) SELECT i.id, 1, ik.name, 2 FROM item i - JOIN ink ik ON ik.id = i.inkFk - JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemTag itg ON itg.itemFk = i.id AND itg.priority = 2 AND itg.tagFk = 1 - WHERE it.workerFk = vWorker AND itg.itemFk IS NULL; - + JOIN upda u ON i.id = u.id + JOIN ink ik ON ik.id = i.inkFk; + INSERT IGNORE INTO itemTag(itemFk, tagFk, value, priority) - SELECT i.id, 67, i.Category, 3 + SELECT i.id, 12, i.category, 3 FROM item i - JOIN ink ik ON ik.id = i.inkFk - JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemTag itg ON itg.itemFk = i.id AND itg.priority = 3 AND itg.tagFk = 67 - WHERE it.workerFk = vWorker AND itg.itemFk IS NULL; - -/* -ANTIGUO - DELETE FROM itemTag WHERE itemFk = vItemFk; + JOIN upda u ON i.id = u.id; + + -- Parte dos en la que se actualiza el articulo + + UPDATE item i + JOIN upda u ON i.id = u.id + JOIN producer p ON p.id = i.producerFk + SET i.subName = p.name + WHERE p.isVisible; - INSERT INTO itemTag(itemFk, tagFk, value, priority) - SELECT vItemFk, t.id, CONCAT(val1,' cm'), 1 - FROM itemTagArranged ita - JOIN tag t ON t.name = 'Longitud' COLLATE utf8_general_ci - WHERE ita.itemFk = vItemFk; + UPDATE item i + JOIN upda u ON i.id = u.id + JOIN itemTag it ON it.itemFk = i.id + JOIN tag t ON t.id = it.tagFk + SET tag5 = t.name, value5 = it.value + WHERE it.priority = 1; - INSERT INTO itemTag(itemFk, tagFk, value, priority) - SELECT vItemFk, t.id, val2, 2 - FROM itemTagArranged ita - JOIN tag t ON t.name = ita.tag2 COLLATE utf8_general_ci - WHERE ita.itemFk = vItemFk; + UPDATE item i + JOIN upda u ON i.id = u.id + JOIN itemTag it ON it.itemFk = i.id + JOIN tag t ON t.id = it.tagFk + SET tag6 = t.name, value6 = it.value + WHERE it.priority = 2; - INSERT INTO itemTag(itemFk, tagFk, value, priority) - SELECT vItemFk, t.id, val3, 3 - FROM itemTagArranged ita - JOIN tag t ON t.name = ita.tag3 COLLATE utf8_general_ci - WHERE ita.itemFk = vItemFk; + UPDATE item i + JOIN upda u ON i.id = u.id + JOIN itemTag it ON it.itemFk = i.id + JOIN tag t ON t.id = it.tagFk + SET tag7 = t.name, value7 = it.value + WHERE it.priority = 3; - INSERT INTO itemTag(itemFk, tagFk, value, priority) - SELECT vItemFk, t.id, val4, 4 - FROM itemTagArranged ita - JOIN tag t ON t.name = ita.tag4 COLLATE utf8_general_ci - WHERE ita.itemFk = vItemFk; - - INSERT INTO itemTag(itemFk, tagFk, value, priority) - SELECT vItemFk, t.id, val5, 5 - FROM itemTagArranged ita - JOIN tag t ON t.name = ita.tag5 COLLATE utf8_general_ci - WHERE ita.itemFk = vItemFk; - - INSERT INTO itemTag(itemFk, tagFk, value, priority) - SELECT vItemFk, t.id, val6, 6 - FROM itemTagArranged ita - JOIN tag t ON t.name = ita.tag6 COLLATE utf8_general_ci - WHERE ita.itemFk = vItemFk; - - CALL itemTagArrangedUpdate(vItemFk); -*/ + UPDATE item i + JOIN upda u ON i.id = u.id + JOIN itemTag it ON it.itemFk = i.id + JOIN tag t ON t.id = it.tagFk + SET tag8 = t.name, value8 = it.value + WHERE it.priority = 4; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -53712,7 +54410,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `itemTagUpdatePriority` */; +/*!50003 DROP PROCEDURE IF EXISTS `itemTagUpdatePriorityKk` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -53722,7 +54420,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemTagUpdatePriority`(IN vItem INT) +CREATE DEFINER=`root`@`%` PROCEDURE `itemTagUpdatePriorityKk`(IN vItem INT) BEGIN -- OBSOLETO, CON EL NUEVO SISTEMA NO SE PUEDE ORDENAR @@ -53758,7 +54456,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `itemTagUpdatePriority_launcher` */; +/*!50003 DROP PROCEDURE IF EXISTS `itemTagUpdatePriority_launcherKk` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -53768,10 +54466,10 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemTagUpdatePriority_launcher`() +CREATE DEFINER=`root`@`%` PROCEDURE `itemTagUpdatePriority_launcherKk`() BEGIN - CALL vn.itemTagUpdatePriority(0); + -- CALL vn.itemTagUpdatePriority(0); END ;; DELIMITER ; @@ -53870,6 +54568,45 @@ DELIMITER ; /*!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 `logAddWithUser` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `logAddWithUser`(vOriginFk INT, vUserId INT, vActionCode VARCHAR(45), vEntity VARCHAR(45), vDescription TEXT) +BEGIN +/** + * Guarda las acciones realizadas por el usuario + * + * @param vOriginFk Id del registro de origen. + * @param vUserId Id del usuario. + * @param vActionCode Código de la acción {insert | delete | update}. + * @param vEntity Nombre que hace referencia a la tabla. + * @param descripcion Descripción de la acción realizada por el usuario. + */ + DECLARE vTableName VARCHAR(45); + + SET vTableName = CONCAT(vEntity, 'Log'); + + SET @qryLog := CONCAT( + 'INSERT INTO ', vTableName, ' (originFk, userFk, action, description)', + ' VALUES (', vOriginFk, ', ', vUserId, ', "', vActionCode, '", "', vDescription, '")' + ); + + PREPARE stmt FROM @qryLog; + EXECUTE stmt; + DEALLOCATE PREPARE stmt; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!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 `logShow` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54331,6 +55068,59 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `nextShelvingCodeMake` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `nextShelvingCodeMake`() +BEGIN + + DECLARE newShelving VARCHAR(3); + DECLARE vCode VARCHAR(3); + + SELECT MAX(code) INTO vCode + FROM vn.shelving; + + 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 ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!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 `observationAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54649,8 +55439,8 @@ BEGIN Max(b.date_end) AS toDated, blp.importepactado, bl.porhoras, - IF(wj.userFk != @userFk, CAST(a.Anticipos AS DECIMAL(10,2)), 0) AS Anticipos, - IF(wj.userFk != @userFk, CAST(se.SaldoEuros AS DECIMAL(10,2)), 0) AS SaldoEuros, + IF(wj.userFk != @userFk, CAST(IFNULL(a.Anticipos,0) AS DECIMAL(10,2)), 0) AS Anticipos, + IF(wj.userFk != @userFk, CAST(IFNULL(se.SaldoEuros,0) AS DECIMAL(10,2)), 0) AS SaldoEuros, @userFk := wj.userFk as userFk FROM vn.worker w @@ -54659,7 +55449,7 @@ BEGIN JOIN postgresql.department d ON bl.department_id = d.department_id JOIN postgresql.business_labour_payroll blp ON bl.business_id = blp.business_id JOIN postgresql.business b ON b.business_id = wj.businessFk - JOIN + LEFT JOIN (SELECT userFk, sum(debe) as Anticipos FROM postgresql.income_employee ie JOIN postgresql.person pe ON ie.person_id = pe.person_id @@ -54668,8 +55458,8 @@ BEGIN AND id_incomeType = 14 -- Salario GROUP BY userFk ) a ON a.userFk = wj.userFk - JOIN - (SELECT userFk, sum(debe - haber) as SaldoEuros + LEFT JOIN + (SELECT userFk, sum(debe) - sum(haber) as SaldoEuros FROM postgresql.income_employee ie JOIN postgresql.person pe ON ie.person_id = pe.person_id JOIN vn.worker w ON w.id = pe.id_trabajador @@ -54846,6 +55636,30 @@ BEGIN rg.ready = IF(rg.freeTickets, FALSE, rg.ready); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `saleItemShelvingIsPicked` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `saleItemShelvingIsPicked`(vTicketFk INT, vIsPicked INT(1)) +BEGIN + + UPDATE vn.sale s + JOIN vn.itemShelvingAvailable isa ON isa.saleFk = s.id + SET s.isPicked = vIsPicked + WHERE s.ticketFk = vTicketFk; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -54906,7 +55720,6 @@ BEGIN JOIN vn.parking p ON p.sectorFk = sc.id JOIN vn.shelving sh ON sh.parkingFk = p.id JOIN vn.itemShelving ish ON ish.shelvingFk = sh.code AND ish.itemFk = s.itemFk - -- JOIN (SELECT @rest:=0,@reserved:=0,@saleFk:=0) sub WHERE t.id = vTicketFk AND sc.id = vSectorFk ORDER BY s.id, @@ -54916,6 +55729,23 @@ BEGIN ) sub ) sub2 WHERE Reserved > 0; + + DELETE sis.* + FROM vn.saleItemShelving sis + JOIN ( + SELECT sis.saleFk, s.quantity, sum(sis.quantity) as reserved + FROM vn.saleItemShelving sis + JOIN vn.sale s ON s.id = sis.saleFk + WHERE s.ticketFk = vTicketFk + GROUP BY sis.saleFk + ) sub ON sis.saleFk = sub.saleFk + WHERE sub.quantity > sub.reserved; + + UPDATE vn.itemShelving ish + JOIN vn.saleItemShelving sis ON sis.itemShelvingFk = ish.id + JOIN vn.sale s ON s.id = sis.saleFk + SET ish.available = ish.available - sis.quantity + WHERE s.ticketFk = vTicketFk; END ;; DELIMITER ; @@ -55195,6 +56025,36 @@ BEGIN VALUES(vItemFk, vWarehouseFk, vPlacement, vReserve); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!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 `shelvingPark` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `shelvingPark`(vShelvingFk VARCHAR(3), vParkingCode VARCHAR(8)) +BEGIN + + DECLARE vParkingFk INT; + + SELECT id INTO vParkingFk + FROM vn.parking + WHERE `column` = LEFT(vParkingCode,3) + AND `row` = RIGHT(vParkingCode,2); + + UPDATE vn.shelving + SET parkingFk = vParkingFk + WHERE `code` = vShelvingFk; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -56947,6 +57807,95 @@ DELIMITER ; /*!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 `ticketCreateWithUser` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketCreateWithUser`( + vClientId INT + ,vShipped DATE + ,vWarehouseId INT + ,vCompanyFk INT + ,vAddressFk INT + ,vAgencyType INT + ,vRouteFk INT + ,vlanded DATE + ,vUserId INT + ,OUT vNewTicket INT) +BEGIN + + DECLARE vClientOrnamentales INT DEFAULT 5270; + DECLARE vCompanyOrn INT DEFAULT 1381; + DECLARE vProvinceName VARCHAR(255); + + SELECT p.name INTO vProvinceName + FROM vn.client c + JOIN province p ON p.id = c.provinceFk + WHERE c.id = vClientId; + + IF vProvinceName IN ('SANTA CRUZ DE TENERIFE', 'LAS PALMAS DE GRAN CANARIA') AND vClientId <> vClientOrnamentales THEN + SET vCompanyFk = vCompanyOrn; + END IF; + + IF NOT vAddressFk THEN + SELECT id INTO vAddressFk + FROM address + WHERE clientFk = vClientId AND isDefaultAddress; + END IF; + + INSERT INTO vn2008.Tickets ( + Id_Cliente, + Fecha, + Id_Consigna, + Id_Agencia, + Alias, + warehouse_id, + Id_Ruta, + empresa_id, + landing + ) + SELECT + vClientId, + vShipped, + a.id, + IF(vAgencyType, vAgencyType, a.agencyModeFk), + a.nickname, + vWarehouseId, + IF(vRouteFk,vRouteFk,NULL), + vCompanyFk, + vlanded + FROM address a + JOIN agencyMode am ON am.id = a.agencyModeFk + WHERE a.id = vAddressFk; + + SET vNewTicket = LAST_INSERT_ID(); + + INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) + SELECT vNewTicket, ao.observationTypeFk, ao.description + FROM addressObservation ao + JOIN address a ON a.id = ao.addressFk + WHERE a.id = vAddressFk; + + CALL logAddWithUser(vNewTicket, vUserId, 'insert', 'ticket', CONCAT('Ha creado el ticket', ' ', vNewTicket)); + + IF (SELECT isCreatedAsServed FROM vn.client WHERE id = vClientId ) <> FALSE THEN + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT id, vNewTicket, getWorker() + FROM state + WHERE `code` = 'DELIVERED'; + 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 `ticketGetProblems` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58123,7 +59072,7 @@ BEGIN GROUP BY userFk, DATE(timed); -- Establece el orden en que se han de leer las fichadas - CALL tmp.workerTimeControlSetOrder; + CALL vn.workerTimeControlSetOrder; -- Marca los impares para facilitar la consulta siguiente UPDATE tmp.workerTimeControl @@ -58272,6 +59221,33 @@ BEGIN AND isPaid = FALSE AND isUpdated = 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 DROP PROCEDURE IF EXISTS `workerJourneyReplaceLauncher` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`z-developer`@`%` PROCEDURE `workerJourneyReplaceLauncher`() +BEGIN + + DECLARE vDateStart DATE; + DECLARE vDateEnd DATE; + + SET vDateStart = TIMESTAMPADD(MONTH,-1,CURDATE()); + SET vDateEnd = util.yesterday(); + + CALL vn.workerJourneyReplace(vDateStart,vDateEnd,0); + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -58339,18 +59315,17 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControlSetOrder`(IN vUserFk INT, IN vDated DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControlSetOrder`() BEGIN SET @order := 1; SET @userFk := 0; SET @day := 0; - UPDATE workerTimeControl + UPDATE tmp.workerTimeControl SET `order` = IF(userFk = @userFk AND day(timed) = @day, @order := @order + 1, @order := 1), userFk = @userFk := userFk, manual = manual + (0 * @day := day(timed)) - WHERE vUserFk IN (0,userFk) AND vDated IN (0,DATE(timed)) ORDER BY userFk, timed; END ;; @@ -58359,6 +59334,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 DROP PROCEDURE IF EXISTS `workerTimeControlSOWP` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControlSOWP`(IN vUserFk INT, IN vDated DATE) +BEGIN + SET @order := 0; + UPDATE workerTimeControl SET `order` = @order := @order + 1 + + WHERE vUserFk =userFk AND vDated =DATE(timed) + ORDER BY userFk; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!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 `workingHours` */; ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -58719,7 +59717,7 @@ CREATE TABLE `batch` ( KEY `buy_edi_id` (`buy_edi_id`), CONSTRAINT `batch_ibfk_1` FOREIGN KEY (`message_id`) REFERENCES `message` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `batch_ibfk_2` FOREIGN KEY (`buy_edi_id`) REFERENCES `vn2008`.`buy_edi` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=345296 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=347133 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -59106,7 +60104,7 @@ CREATE TABLE `message` ( UNIQUE KEY `mail_id` (`mail_id`), KEY `sender_id` (`sender_id`), CONSTRAINT `message_ibfk_2` FOREIGN KEY (`sender_id`) REFERENCES `mail` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=366962 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=368847 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -59909,6 +60907,14 @@ CREATE TABLE `indicators` ( `lastMonthLostClients` int(11) DEFAULT NULL, `lastMonthNewClients` int(11) DEFAULT NULL, `lastMonthWebBuyingRate` decimal(5,4) DEFAULT NULL, + `productionHours` decimal(10,1) DEFAULT NULL, + `dailyWorkersCost` decimal(10,0) DEFAULT NULL, + `volumeM3` decimal(10,0) DEFAULT NULL, + `salesValue` decimal(10,0) DEFAULT NULL, + `valueM3` decimal(10,0) DEFAULT NULL, + `hoursM3` decimal(5,2) DEFAULT NULL, + `workerCostM3` decimal(10,1) DEFAULT NULL, + `salesWorkersCostRate` decimal(10,2) DEFAULT NULL, 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.'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -59942,7 +60948,15 @@ SET character_set_client = utf8; 1 AS `lastMonthNewClients`, 1 AS `incLastMonthNewClients`, 1 AS `lastMonthWebBuyingRate`, - 1 AS `incLastMonthWebBuyingRate`*/; + 1 AS `incLastMonthWebBuyingRate`, + 1 AS `productionHours`, + 1 AS `dailyWorkersCost`, + 1 AS `volumeM3`, + 1 AS `salesValue`, + 1 AS `valueM3`, + 1 AS `hoursM3`, + 1 AS `workerCostM3`, + 1 AS `salesWorkersCostRate`*/; SET character_set_client = @saved_cs_client; -- @@ -60113,7 +61127,7 @@ CREATE TABLE `nightTask` ( `schema` varchar(45) COLLATE utf8_unicode_ci NOT NULL, `procedure` varchar(100) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=45 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60164,6 +61178,27 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Temporary table structure for view `productionIndicators` +-- + +DROP TABLE IF EXISTS `productionIndicators`; +/*!50001 DROP VIEW IF EXISTS `productionIndicators`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `productionIndicators` AS SELECT + 1 AS `dated`, + 1 AS `productionHours`, + 1 AS `dailyWorkersCost`, + 1 AS `VolumeM3`, + 1 AS `salesValue`, + 1 AS `valueM3`, + 1 AS `hoursM3`, + 1 AS `Dia`, + 1 AS `workerCostM3`, + 1 AS `salesWorkersCostRate`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `v_ventas` -- @@ -60472,21 +61507,20 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `bancos_evolution_add`() BEGIN -/* + /* -Inserta en la tabla bancos_evolution los saldos acumulados + Inserta en la tabla bancos_evolution los saldos acumulados -*/ + */ -DECLARE vCurrentDate DATE; -DECLARE vStartingDate DATE DEFAULT '2015-01-01'; -DECLARE vMaxDate DATE DEFAULT TIMESTAMPADD(MONTH, 2, CURDATE()); + DECLARE vCurrentDate DATE; + DECLARE vStartingDate DATE DEFAULT '2016-01-01'; + DECLARE vMaxDate DATE DEFAULT TIMESTAMPADD(MONTH, 2, CURDATE()); -DELETE FROM bs.bancos_evolution -WHERE Fecha > vStartingDate; + DELETE FROM bs.bancos_evolution WHERE Fecha > vStartingDate; -SET vCurrentDate = vStartingDate; + SET vCurrentDate = vStartingDate; WHILE vCurrentDate < vMaxDate DO @@ -61186,7 +62220,18 @@ BEGIN ) WHERE updated = vDated; - + -- Indicadores de producción + UPDATE indicators i + JOIN productionIndicators pi ON pi.dated = i.updated + SET i.productionHours = pi.productionHours, + i.dailyWorkersCost = pi.dailyWorkersCost, + i.volumeM3 = pi.volumeM3, + i.salesValue = pi.salesValue, + i.valueM3 = pi.valueM3, + i.hoursM3 = pi.hoursM3, + i.workerCostM3 = pi.workerCostM3, + i.salesWorkersCostRate = pi.salesWorkersCostRate + WHERE updated BETWEEN oneMonthBefore AND vDated; END ;; DELIMITER ; @@ -62727,6 +63772,7 @@ CREATE TABLE `rotacion` ( `manipulacion` decimal(10,4) NOT NULL DEFAULT '0.0000', `auxiliar` decimal(10,4) NOT NULL DEFAULT '0.0000', `mermas` decimal(10,4) NOT NULL DEFAULT '0.0000', + `cm3reparto` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`Id_Article`,`warehouse_id`), KEY `id_article_rotacion_idx` (`Id_Article`), KEY `warehouse_id_rotacion_idx` (`warehouse_id`), @@ -64034,14 +65080,14 @@ INSERT INTO vn2008.daily_task_log(consulta) VALUES('bi.facturacion_media_anual_u TRUNCATE TABLE bi.facturacion_media_anual; REPLACE bi.facturacion_media_anual(Id_Cliente, Consumo) -select Id_Cliente, avg(Consumo) -from ( - Select Id_Cliente, YEAR(fecha) year, MONTH(fecha) month, sum(importe) as Consumo - from bs.ventas - where fecha >= TIMESTAMPADD(YEAR,-1,CURDATE()) - group by Id_Cliente, year, month -) vol -group by Id_Cliente; + SELECT clientFk, avg(Facturacion) + FROM ( + SELECT clientFk, YEAR(issued) year, MONTH(issued) month, sum(amount) as Facturacion + FROM vn.invoiceOut + WHERE issued BETWEEN TIMESTAMPADD(YEAR,-1,CURDATE()) AND TIMESTAMPADD(DAY, - DAY(CURDATE()),CURDATE()) + GROUP BY clientFk, year, month + ) vol + GROUP BY clientFk; END ;; DELIMITER ; @@ -65345,7 +66391,7 @@ CREATE TABLE `cdr` ( KEY `dstchannel` (`dst_channel`), KEY `disposition` (`disposition`), KEY `src` (`src`) -) ENGINE=MyISAM AUTO_INCREMENT=209546 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=210001 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -66137,7 +67183,7 @@ CREATE TABLE `cache_calc` ( KEY `cache_id` (`cache_id`), KEY `cacheName` (`cacheName`), KEY `expires` (`expires`) -) ENGINE=InnoDB AUTO_INCREMENT=148274 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=150148 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -67664,7 +68710,7 @@ CREATE TABLE `ACL` ( `principalType` set('ROLE','USER') COLLATE utf8_unicode_ci DEFAULT 'ROLE', `principalId` varchar(512) CHARACTER SET utf8 DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=95 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -67906,7 +68952,7 @@ CREATE TABLE `inter` ( CONSTRAINT `inter_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inter_state` FOREIGN KEY (`state_id`) REFERENCES `vn2008`.`state` (`id`) ON UPDATE CASCADE, CONSTRAINT `responsable` FOREIGN KEY (`Id_Supervisor`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=11676724 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=11754074 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68643,7 +69689,7 @@ CREATE TABLE `news` ( 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=InnoDB AUTO_INCREMENT=13017 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=13018 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -68694,7 +69740,7 @@ CREATE TABLE `order` ( CONSTRAINT `order_ibfk_5` FOREIGN KEY (`address_id`) REFERENCES `vn2008`.`Consignatarios` (`id_consigna`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_8` FOREIGN KEY (`delivery_method_id`) REFERENCES `vn2008`.`Vistas` (`vista_id`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_9` FOREIGN KEY (`agency_id`) REFERENCES `vn2008`.`Agencias` (`Id_Agencia`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1477609 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1483201 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -68793,7 +69839,7 @@ CREATE TABLE `orderRow` ( KEY `warehouse_shipment` (`warehouseFk`,`shipment`), CONSTRAINT `orderRow_ibfk_2` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON UPDATE CASCADE, CONSTRAINT `orderRow_ibfk_3` FOREIGN KEY (`orderFk`) REFERENCES `order` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=9085127 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=9114478 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -69140,7 +70186,7 @@ CREATE TABLE `tpvTransaction` ( CONSTRAINT `receipt_id` FOREIGN KEY (`receiptFk`) REFERENCES `vn2008`.`Recibos` (`Id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_2` FOREIGN KEY (`merchantFk`) REFERENCES `tpvMerchant` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=232406 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; +) ENGINE=InnoDB AUTO_INCREMENT=233383 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -69175,7 +70221,7 @@ CREATE TABLE `visit` ( PRIMARY KEY (`id`), KEY `firstAgent` (`firstAgent`), CONSTRAINT `visit_ibfk_1` FOREIGN KEY (`firstAgent`) REFERENCES `visitAgent` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1323501 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1327505 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -69195,7 +70241,7 @@ CREATE TABLE `visitAccess` ( KEY `visit_access_idx_agent` (`agent`), KEY `stamp` (`stamp`), CONSTRAINT `visitAccess_ibfk_1` FOREIGN KEY (`agent`) REFERENCES `visitAgent` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2901916 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2912494 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -69220,7 +70266,7 @@ CREATE TABLE `visitAgent` ( KEY `firstAccess` (`firstAccess`), CONSTRAINT `visitAgent_ibfk_1` FOREIGN KEY (`visit`) REFERENCES `visit` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `visitAgent_ibfk_2` FOREIGN KEY (`firstAccess`) REFERENCES `visitAccess` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1871318 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1875701 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -69240,7 +70286,7 @@ CREATE TABLE `visitUser` ( KEY `date_time` (`stamp`), KEY `user_id` (`user`), CONSTRAINT `visitUser_ibfk_1` FOREIGN KEY (`access`) REFERENCES `visitAccess` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2752569 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2761177 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -70285,15 +71331,15 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `myTicketGetRows`(`vTicket` INT) -BEGIN - - SELECT r.itemFk, r.quantity, r.concept, r.price, r.discount, - i.image, i.category, i.size, i.stems, i.inkFk, - i.tag5, i.value5, i.tag6, i.value6, i.tag7, i.value7 - FROM myTicketRow r - JOIN vn.item i ON i.id = r.itemFk - WHERE r.ticketFk = vTicket - ORDER BY r.concept; +BEGIN + + SELECT r.itemFk, r.quantity, r.concept, r.price, r.discount, + i.image, i.category, i.size, i.stems, i.inkFk, + i.tag5, i.value5, i.tag6, i.value6, i.tag7, i.value7 + FROM myTicketRow r + JOIN vn.item i ON i.id = r.itemFk + WHERE r.ticketFk = vTicket + ORDER BY r.concept; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -74167,6 +75213,96 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `claim` +-- + +/*!50001 DROP VIEW IF EXISTS `claim`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `claim` AS select `c`.`id` AS `id`,`c`.`Fecha` AS `ticketCreated`,`c`.`cl_est_id` AS `claimStateFk`,`c`.`notas` AS `observation`,`c`.`Id_Cliente` AS `clientFk`,`c`.`Id_Trabajador` AS `workerFk`,`c`.`sensib` AS `claimResponsibleFk`,`c`.`mana` AS `isChargedToMana`,`c`.`odbc_date` AS `created` from `vn2008`.`cl_main` `c` */; +/*!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 `claimBeginning` +-- + +/*!50001 DROP VIEW IF EXISTS `claimBeginning`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `claimBeginning` AS select `c`.`id` AS `id`,`c`.`cl_main_id` AS `claimFk`,`c`.`Id_Movimiento` AS `saleFk`,`c`.`numero` AS `claimed` from `vn2008`.`cl_det` `c` */; +/*!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 `claimDestination` +-- + +/*!50001 DROP VIEW IF EXISTS `claimDestination`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `claimDestination` AS select `c`.`id` AS `id`,`c`.`solucion` AS `description` from `vn2008`.`cl_sol` `c` */; +/*!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 `claimDevelopment` +-- + +/*!50001 DROP VIEW IF EXISTS `claimDevelopment`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `claimDevelopment` AS select `c`.`id` AS `id`,`c`.`cl_main_id` AS `claimFk`,`c`.`cl_res_id` AS `claimResponsibleFk`,`c`.`Id_Trabajador` AS `workerFk`,`c`.`cl_mot_id` AS `claimReasonFk`,`c`.`cl_con_id` AS `claimResultFk`,`c`.`cl_dev` AS `claimRedeliveryFk`,`c`.`cl_sol` AS `claimDestinationFk` from `vn2008`.`cl_cau` `c` */; +/*!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 `claimEnd` +-- + +/*!50001 DROP VIEW IF EXISTS `claimEnd`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `claimEnd` AS select `c`.`id` AS `id`,`c`.`Id_Movimiento` AS `saleFk`,`c`.`cl_main_id` AS `claimFk`,`c`.`Id_Trabajador` AS `workerFk`,`c`.`cl_sol_id` AS `claimDestinationFk` from `vn2008`.`cl_act` `c` */; +/*!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 `claimRatio` -- @@ -74185,6 +75321,96 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `claimReason` +-- + +/*!50001 DROP VIEW IF EXISTS `claimReason`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `claimReason` AS select `c`.`id` AS `id`,`c`.`motivo` AS `description` from `vn2008`.`cl_mot` `c` */; +/*!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 `claimRedelivery` +-- + +/*!50001 DROP VIEW IF EXISTS `claimRedelivery`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `claimRedelivery` AS select `e`.`id` AS `id`,`e`.`devolucion` AS `description` from `vn2008`.`cl_dev` `e` */; +/*!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 `claimResponsible` +-- + +/*!50001 DROP VIEW IF EXISTS `claimResponsible`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `claimResponsible` AS select `c`.`id` AS `id`,`c`.`responsable` AS `description`,`c`.`sensibility` AS `responsability` from `vn2008`.`cl_res` `c` */; +/*!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 `claimResult` +-- + +/*!50001 DROP VIEW IF EXISTS `claimResult`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `claimResult` AS select `c`.`id` AS `id`,`c`.`consecuencia` AS `description` from `vn2008`.`cl_con` `c` */; +/*!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 `claimState` +-- + +/*!50001 DROP VIEW IF EXISTS `claimState`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `claimState` AS select `c`.`id` AS `id`,`c`.`estado` AS `description` from `vn2008`.`cl_est` `c` */; +/*!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 `client` -- @@ -74258,10 +75484,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `clientSample` +-- Final view structure for view `clientNotificationTypekk` -- -/*!50001 DROP VIEW IF EXISTS `clientSample`*/; +/*!50001 DROP VIEW IF EXISTS `clientNotificationTypekk`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -74270,16 +75496,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `clientSample` AS select `e`.`id` AS `id`,`e`.`Id_Cliente` AS `clientFk`,`e`.`escritos_id` AS `typeFk`,`e`.`fecha` AS `created`,`e`.`Id_Trabajador` AS `workerFk`,`e`.`userFk` AS `userFk`,`e`.`empresa_id` AS `companyFk` from `vn2008`.`escritos_det` `e` */; +/*!50001 VIEW `clientNotificationTypekk` AS select `e`.`id` AS `id`,`e`.`abrev` AS `code`,`e`.`descripcion` AS `description`,`e`.`visible` AS `isVisible` from `vn2008`.`escritos` `e` */; /*!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 `sample` +-- Final view structure for view `clientNotificationkk` -- -/*!50001 DROP VIEW IF EXISTS `sample`*/; +/*!50001 DROP VIEW IF EXISTS `clientNotificationkk`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -74288,7 +75514,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `sample` AS select `e`.`id` AS `id`,`e`.`abrev` AS `code`,`e`.`descripcion` AS `description`,`e`.`visible` AS `isVisible` from `vn2008`.`escritos` `e` */; +/*!50001 VIEW `clientNotificationkk` AS select `e`.`id` AS `id`,`e`.`Id_Cliente` AS `clientFk`,`e`.`escritos_id` AS `clientNotificationTypeFk`,`e`.`fecha` AS `created`,`e`.`Id_Trabajador` AS `workerFk`,`e`.`userFk` AS `userFk` from `vn2008`.`escritos_det` `e` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -74311,6 +75537,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `clientSample` +-- + +/*!50001 DROP VIEW IF EXISTS `clientSample`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `clientSample` AS select `e`.`id` AS `id`,`e`.`Id_Cliente` AS `clientFk`,`e`.`escritos_id` AS `typeFk`,`e`.`fecha` AS `created`,`e`.`Id_Trabajador` AS `workerFk`,`e`.`userFk` AS `userFk`,`e`.`empresa_id` AS `companyFk` from `vn2008`.`escritos_det` `e` */; +/*!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 `clientType` -- @@ -75188,7 +76432,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `item` AS select `t`.`Id_Article` AS `id`,`t`.`Article` AS `name`,`t`.`tipo_id` AS `typeFk`,`t`.`Medida` AS `size`,`t`.`Color` AS `inkFk`,`t`.`Categoria` AS `category`,`t`.`Tallos` AS `stems`,`t`.`id_origen` AS `originFk`,`t`.`description` AS `description`,`t`.`producer_id` AS `producerFk`,`t`.`Codintrastat` AS `intrastatFk`,`t`.`offer` AS `isOnOffer`,`t`.`expenceFk` AS `expenceFk`,`t`.`bargain` AS `isBargain`,`t`.`comments` AS `comment`,`t`.`relevancy` AS `relevancy`,`t`.`Foto` AS `image`,`t`.`generic` AS `generic`,`t`.`density` AS `density`,`t`.`iva_group_id` AS `taxClassFk`,`t`.`PVP` AS `minPrice`,`t`.`Min` AS `hasMinPrice`,`t`.`isActive` AS `isActive`,`t`.`longName` AS `longName`,`t`.`subName` AS `subName`,`t`.`tag5` AS `tag5`,`t`.`value5` AS `value5`,`t`.`tag6` AS `tag6`,`t`.`value6` AS `value6`,`t`.`tag7` AS `tag7`,`t`.`value7` AS `value7`,`t`.`tag8` AS `tag8`,`t`.`value8` AS `value8` from `vn2008`.`Articles` `t` */; +/*!50001 VIEW `item` AS select `t`.`Id_Article` AS `id`,`t`.`Article` AS `name`,`t`.`tipo_id` AS `typeFk`,`t`.`Medida` AS `size`,`t`.`Color` AS `inkFk`,`t`.`Categoria` AS `category`,`t`.`Tallos` AS `stems`,`t`.`id_origen` AS `originFk`,`t`.`description` AS `description`,`t`.`producer_id` AS `producerFk`,`t`.`Codintrastat` AS `intrastatFk`,`t`.`offer` AS `isOnOffer`,`t`.`caja` AS `box`,`t`.`expenceFk` AS `expenceFk`,`t`.`bargain` AS `isBargain`,`t`.`comments` AS `comment`,`t`.`relevancy` AS `relevancy`,`t`.`Foto` AS `image`,`t`.`generic` AS `generic`,`t`.`density` AS `density`,`t`.`iva_group_id` AS `taxClassFk`,`t`.`PVP` AS `minPrice`,`t`.`Min` AS `hasMinPrice`,`t`.`isActive` AS `isActive`,`t`.`longName` AS `longName`,`t`.`subName` AS `subName`,`t`.`tag5` AS `tag5`,`t`.`value5` AS `value5`,`t`.`tag6` AS `tag6`,`t`.`value6` AS `value6`,`t`.`tag7` AS `tag7`,`t`.`value7` AS `value7`,`t`.`tag8` AS `tag8`,`t`.`value8` AS `value8` from `vn2008`.`Articles` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -76093,6 +77337,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `sample` +-- + +/*!50001 DROP VIEW IF EXISTS `sample`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `sample` AS select `e`.`id` AS `id`,`e`.`abrev` AS `code`,`e`.`descripcion` AS `description`,`e`.`visible` AS `isVisible` from `vn2008`.`escritos` `e` */; +/*!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 `specialPrice` -- @@ -76766,7 +78028,7 @@ USE `bs`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `lastIndicators` AS select `i`.`updated` AS `updated`,`i`.`lastYearSales` AS `lastYearSales`,(`i`.`lastYearSales` - `yi`.`lastYearSales`) AS `incLastYearSales`,`i`.`totalGreuge` AS `totalGreuge`,(`i`.`totalGreuge` - `yi`.`totalGreuge`) AS `incTotalGreuge`,`i`.`latePaymentRate` AS `latePaymentRate`,(`i`.`latePaymentRate` - `yi`.`latePaymentRate`) AS `incLatePaymentRate`,`i`.`countEmployee` AS `countEmployee`,(`i`.`countEmployee` - `yi`.`countEmployee`) AS `incCountEmployee`,`i`.`averageMana` AS `averageMana`,(`i`.`averageMana` - `yi`.`averageMana`) AS `incAverageMana`,`i`.`bankingPool` AS `bankingPool`,(`i`.`bankingPool` - `yi`.`bankingPool`) AS `incbankingPool`,`i`.`lastMonthActiveClients` AS `lastMonthActiveClients`,(`i`.`lastMonthActiveClients` - `yi`.`lastMonthActiveClients`) AS `incLastMonthActiveClients`,`i`.`lastMonthLostClients` AS `lastMonthLostClients`,(`i`.`lastMonthLostClients` - `yi`.`lastMonthLostClients`) AS `incLastMonthLostClients`,`i`.`lastMonthNewClients` AS `lastMonthNewClients`,(`i`.`lastMonthNewClients` - `yi`.`lastMonthNewClients`) AS `incLastMonthNewClients`,`i`.`lastMonthWebBuyingRate` AS `lastMonthWebBuyingRate`,(`i`.`lastMonthWebBuyingRate` - `yi`.`lastMonthWebBuyingRate`) AS `incLastMonthWebBuyingRate` 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` 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 */; @@ -76825,6 +78087,24 @@ USE `bs`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `productionIndicators` +-- + +/*!50001 DROP VIEW IF EXISTS `productionIndicators`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `productionIndicators` AS select `wj`.`dated` AS `dated`,cast(sum((`wj`.`total` + `wj`.`lunch`)) as decimal(10,1)) AS `productionHours`,cast(sum(((`wj`.`total` + `wj`.`lunch`) * `wj`.`priceOrdinaryHour`)) as decimal(10,0)) AS `dailyWorkersCost`,`ms`.`Volumen` AS `VolumeM3`,`ms`.`Euros` AS `salesValue`,cast((`ms`.`Euros` / `ms`.`Volumen`) as decimal(10,0)) AS `valueM3`,cast((sum((`wj`.`total` + `wj`.`lunch`)) / `ms`.`Volumen`) as decimal(5,2)) AS `hoursM3`,`ms`.`dayName` AS `Dia`,cast((sum(((`wj`.`total` + `wj`.`lunch`) * `wj`.`priceOrdinaryHour`)) / `ms`.`Volumen`) as decimal(10,1)) AS `workerCostM3`,cast((sum(((`wj`.`total` + `wj`.`lunch`) * `wj`.`priceOrdinaryHour`)) / `ms`.`Euros`) as decimal(10,2)) AS `salesWorkersCostRate` from (((`vn`.`workerJourney` `wj` join `postgresql`.`business_labour` `bl` on((`bl`.`business_id` = `wj`.`businessFk`))) join `postgresql`.`department` `d` on((`d`.`department_id` = `bl`.`department_id`))) join `bs`.`m3Silla` `ms` on((`ms`.`fecha` = `wj`.`dated`))) where (`d`.`production` and (`wj`.`dated` >= '2017-01-01')) group by `wj`.`dated` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `v_ventas` -- @@ -77421,4 +78701,4 @@ USE `stock`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-07-23 14:19:55 +-- Dump completed on 2018-07-27 11:53:09 diff --git a/services/db/install/dump/03-dumpedFixtures.sql b/services/db/install/dump/03-dumpedFixtures.sql index df3daa6ab..836309c1a 100644 --- a/services/db/install/dump/03-dumpedFixtures.sql +++ b/services/db/install/dump/03-dumpedFixtures.sql @@ -55,7 +55,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-07-25 20:27:54 +-- Dump completed on 2018-07-27 11:47:45 USE `salix`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- @@ -80,7 +80,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','employee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','employee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','employee'),(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','employee'),(28,'ClientObservation','*','READ','ALLOW','ROLE','employee'),(30,'GreugeType','*','READ','ALLOW','ROLE','employee'),(31,'Mandate','*','READ','ALLOW','ROLE','employee'),(32,'MandateType','*','READ','ALLOW','ROLE','employee'),(33,'Company','*','READ','ALLOW','ROLE','employee'),(34,'Greuge','*','READ','ALLOW','ROLE','employee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(52,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','employee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(57,'CreditClassification','*','READ','ALLOW','ROLE','employee'),(58,'CreditClassification','*','*','ALLOW','ROLE','creditInsurance'),(59,'CreditInsurance','*','READ','ALLOW','ROLE','employee'),(60,'CreditInsurance','*','*','ALLOW','ROLE','creditInsurance'),(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'),(67,'TicketState','*','*','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','*','READ','ALLOW','ROLE','employee'),(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','removes','*','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','*','*','ALLOW','ROLE','employee'),(92,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(93,'Sale','reserve','*','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(95,'ClientNotification','*','*','ALLOW','ROLE','employee'); +INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','employee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','employee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','employee'),(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','employee'),(28,'ClientObservation','*','READ','ALLOW','ROLE','employee'),(30,'GreugeType','*','READ','ALLOW','ROLE','employee'),(31,'Mandate','*','READ','ALLOW','ROLE','employee'),(32,'MandateType','*','READ','ALLOW','ROLE','employee'),(33,'Company','*','READ','ALLOW','ROLE','employee'),(34,'Greuge','*','READ','ALLOW','ROLE','employee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(52,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','employee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(57,'CreditClassification','*','READ','ALLOW','ROLE','employee'),(58,'CreditClassification','*','*','ALLOW','ROLE','creditInsurance'),(59,'CreditInsurance','*','READ','ALLOW','ROLE','employee'),(60,'CreditInsurance','*','*','ALLOW','ROLE','creditInsurance'),(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'),(67,'TicketState','*','*','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','*','READ','ALLOW','ROLE','employee'),(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','removes','*','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','*','*','ALLOW','ROLE','employee'),(92,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(93,'Sale','reserve','*','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(95,'ClientSample','*','*','ALLOW','ROLE','employee'),(96,'ClaimAction','*','READ','ALLOW','ROLE','employee'),(97,'ClaimAction','*','WRITE','ALLOW','ROLE','salesAssistant'),(98,'ClaimDetail','*','WRITE','ALLOW','ROLE','employee'),(99,'claimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'claimDevelopment','*','WRITE','ALLOW','ROLE','salesAssistant'); /*!40000 ALTER TABLE `ACL` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -93,7 +93,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-07-25 20:27:54 +-- Dump completed on 2018-07-27 11:47:45 USE `vn`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- @@ -171,7 +171,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-07-25 20:27:54 +-- Dump completed on 2018-07-27 11:47:45 USE `vn2008`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- @@ -289,6 +289,66 @@ LOCK TABLES `escritos` WRITE; INSERT INTO `escritos` VALUES (1,'Carta_1','Aviso inicial por saldo deudor',1),(2,'Carta_2','Reiteracion de aviso por saldo deudor',1),(3,'Cred_Up','Notificación de aumento de crédito',0),(4,'Cred_down','Notificación de reducción de crédito',0),(5,'Pet_CC','Petición de datos bancarios B2B',0),(6,'SolCredito','Solicitud de crédito',0),(7,'LeyPago','Ley de pagos',0),(8,'Pet_CC_Core','Petición de datos bancarios CORE',1),(9,'nueva_alta','Documento de nueva alta de cliente',0),(10,'client_welcome','Email de bienvenida para nuevo cliente',1),(11,'setup_printer','Email de instalación de impresora',1),(12,'client-welcome','Email de bienvenida como nuevo cliente.',0),(13,'printer-setup','Email de instalación y configuración de impresora de coronas.',0),(14,'sepa-core','Email de solicitud de datos bancarios core.',0),(15,'letter-debtor-st','Email de aviso inicial por saldo deudor',0),(16,'letter-debtor-nd','Email de aviso reiterado por saldo deudor',0); /*!40000 ALTER TABLE `escritos` ENABLE KEYS */; UNLOCK TABLES; + +-- +-- Dumping data for table `cl_est` +-- + +LOCK TABLES `cl_est` WRITE; +/*!40000 ALTER TABLE `cl_est` DISABLE KEYS */; +INSERT INTO `cl_est` VALUES (1,'Pendiente'),(2,'Gestionado'),(3,'Resuelto'),(4,'Anulado'),(5,'Cuestionado'); +/*!40000 ALTER TABLE `cl_est` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `cl_con` +-- + +LOCK TABLES `cl_con` WRITE; +/*!40000 ALTER TABLE `cl_con` DISABLE KEYS */; +INSERT INTO `cl_con` VALUES (1,'Otros daños'),(2,'Roces'),(3,'Humedad'),(4,'Deshidratacion'),(5,'Error identidad'),(6,'Incompleto (Faltas)'),(7,'Error packing'),(8,'Error color'),(9,'Error medida'),(10,'Error origen'),(11,'Envejecido'),(12,'Venta Perdida'),(13,'Duplicacion'),(14,'Rechazado'),(15,'Rotura'),(16,'Deterioro/Estrepeado'),(17,'Podrido'),(18,'Baboso'),(19,'Cocido'),(20,'Congelado'),(21,'Machacado'),(22,'Error precio'),(23,'Manchado'),(24,'No entregado'),(25,'Cobro indebido'),(26,'Decepcion/Esperaba mas'),(27,'Otros'); +/*!40000 ALTER TABLE `cl_con` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `cl_res` +-- + +LOCK TABLES `cl_res` WRITE; +/*!40000 ALTER TABLE `cl_res` DISABLE KEYS */; +INSERT INTO `cl_res` VALUES (1,'Compradores',0),(2,'Proveedor',0),(3,'Entradores',0),(4,'Camareros',0),(6,'Sacadores',0),(7,'Revisadores',0),(8,'Calidad general',0),(9,'Encajadores',0),(11,'Comerciales',1),(12,'Clientes',1),(13,'Administración',0),(14,'Agencia',0),(15,'Repartidores',0),(16,'Informatica',0),(17,'Transp.origen',0),(18,'Confeccion',0),(19,'OTROS',0),(21,'Gerencia',0),(22,'Paletizadores',0); +/*!40000 ALTER TABLE `cl_res` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `cl_dev` +-- + +LOCK TABLES `cl_dev` WRITE; +/*!40000 ALTER TABLE `cl_dev` DISABLE KEYS */; +INSERT INTO `cl_dev` VALUES (1,'Cliente'),(2,'No dev./No especif.'),(3,'Reparto'),(4,'Agencia'); +/*!40000 ALTER TABLE `cl_dev` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `cl_mot` +-- + +LOCK TABLES `cl_mot` WRITE; +/*!40000 ALTER TABLE `cl_mot` DISABLE KEYS */; +INSERT INTO `cl_mot` VALUES (1,'Prisas'),(2,'Novato'),(3,'Exceso de confianza'),(4,'Exceso de celo'),(5,'Indiferencia'),(6,'Extraviado o Hurto'),(7,'Incompetencia'),(8,'Ubicación erronea'),(9,'Dat.Inctos/Pak.conf'),(10,'Datos duplicados'),(11,'Fallo stock'),(12,'Innovación'),(13,'Distracción'),(15,'Portes indebidos'),(16,'Baja calidad'),(17,'Defectuoso'),(19,'Endiñado'),(20,'Calor'),(21,'Frio'),(22,'Cambiado'),(24,'Cansancio'),(25,'Mal etiquetado'),(26,'Cantidad malentendido'),(30,'No revisado'),(34,'Error fotografia'),(40,'Fallo Personal VN'),(41,'Fallo Personal Cliente'),(42,'Otros'),(43,'Precio alto'),(44,'Abuso de confianza'),(45,'Retraso Agencia'),(46,'Delicado'); +/*!40000 ALTER TABLE `cl_mot` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `cl_sol` +-- + +LOCK TABLES `cl_sol` WRITE; +/*!40000 ALTER TABLE `cl_sol` DISABLE KEYS */; +INSERT INTO `cl_sol` VALUES (1,'Bueno'),(2,'Basura/Perd.'),(3,'Confección'),(4,'Reclam.PR/AG'),(5,'Corregido'); +/*!40000 ALTER TABLE `cl_sol` ENABLE KEYS */; +UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -299,7 +359,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-07-25 20:27:54 +-- Dump completed on 2018-07-27 11:47:46 USE `bi`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- @@ -347,7 +407,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-07-25 20:27:54 +-- Dump completed on 2018-07-27 11:47:46 USE `cache`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- @@ -385,4 +445,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-07-25 20:27:55 +-- Dump completed on 2018-07-27 11:47:46 diff --git a/services/db/install/dump/fixtures.sql b/services/db/install/dump/fixtures.sql index 9cc6e4030..9ab3abf94 100644 --- a/services/db/install/dump/fixtures.sql +++ b/services/db/install/dump/fixtures.sql @@ -479,10 +479,12 @@ INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`) VALUES - ( 1, 1, 1, 'Gem of Time', 5 , 23.5, 0, 0, 0, CURDATE()), - ( 2, 2, 1, 'Gem of Mind', 10 , 4.5, 0, 0, 0, CURDATE()), - ( 3, 1, 1, 'Gem of Time', 2 , 23.5, 0, 0, 0, CURDATE()), - ( 4, 4, 1, 'Mark I', 20 , 9, 0, 0, 0, CURDATE()); + ( 1, 1, 1, 'Gem of Time', 5 , 23.5, 0, 0, 0, CURDATE()), + ( 2, 2, 1, 'Gem of Mind', 10 , 4.5 , 0, 0, 0, CURDATE()), + ( 3, 1, 1, 'Gem of Time', 2 , 23.5, 0, 0, 0, CURDATE()), + ( 4, 4, 1, 'Mark I' , 20 , 9 , 0, 0, 0, CURDATE()), + ( 5, 1, 2, 'Gem of Time', 10 , 23.5, 0, 0, 0, CURDATE()), + ( 6, 1, 3, 'Gem of Time', 15 , 23.5, 0, 0, 0, CURDATE()); INSERT INTO `vn`.`saleChecked`(`saleFk`, `isChecked`) VALUES @@ -510,7 +512,21 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) ( 4, 10, 1), ( 2, 17, 3.5), ( 4, 39, 5), - ( 4, 37, 2); + ( 4, 37, 2), + ( 5, 10, 1), + ( 5, 14, 2.5), + ( 5, 15, 3), + ( 5, 17, 4.5), + ( 5, 21, 5), + ( 5, 23, 6.5), + ( 5, 28, 1), + ( 6, 10, 1), + ( 6, 14, 2.5), + ( 6, 15, 3), + ( 6, 17, 4.5), + ( 6, 21, 5), + ( 6, 23, 6.5), + ( 6, 28, 1); INSERT INTO `vn`.`saleTracking`(`saleFk`, `isChecked`, `created`, `originalQuantity`, `workerFk`, `actionFk`, `id`, `stateFk`) VALUES @@ -729,10 +745,37 @@ call vn.manaSpellersRequery(19); call vn.manaSpellersRequery(18); -INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk`, `companyFk`) +INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk`, `userFk`, `companyFk`) VALUES - ( 1, 101, 1, CURDATE(), 18, 442), - ( 2, 101, 1, CURDATE(), 18, 442), - ( 3, 101, 2, CURDATE(), 18, 442), - ( 4, 102, 2, CURDATE(), 18, 567), - ( 5, 102, 3, CURDATE(), 19, 567); \ No newline at end of file + ( 1, 101, 1, CURDATE(), 18, 18, 442), + ( 2, 101, 1, CURDATE(), 18, 18, 442), + ( 3, 101, 2, CURDATE(), 18, 18, 442), + ( 4, 102, 2, CURDATE(), 18, 18, 567), + ( 5, 102, 3, CURDATE(), 19, 19, 567); + +INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `observation`, `clientFk`, `workerFk`, `claimResponsibleFk`, `isChargedToMana`, `created` ) + VALUES + ( 1, CURDATE(), 1, 'observation one' , 101, 18, 3, 0, CURDATE()), + ( 2, CURDATE(), 2, 'observation two' , 101, 18, 3, 0, CURDATE()), + ( 3, CURDATE(), 3, 'observation three' , 101, 18, 3, 0, CURDATE()); + +INSERT INTO `vn`.`claimBeginning`(`id`, `claimFk`, `saleFk`, `quantity`) + VALUES + ( 1, 1, 1, 5), + ( 2, 1, 2, 4), + ( 3, 2, 5, 10), + ( 4, 3, 6, 5); + +INSERT INTO `vn`.`claimDevelopment`(`id`, `claimFk`, `claimResponsibleFk`, `workerFk`, `claimReasonFk`, `claimResultFk`, `claimRedeliveryFk`, `claimDestinationFk`) + VALUES + ( 1, 1, 1, 21, 1 , 1, 2, 5), + ( 2, 1, 1, 21, 7 , 2, 2, 5), + ( 3, 2, 7, 21, 9 , 3, 2, 5), + ( 4, 3, 7, 21, 15, 8, 2, 5); + +INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestinationFk`) + VALUES + ( 1, 1, 1, 9, 5), + ( 2, 2, 1, 9, 5), + ( 3, 5, 2, 9, 5), + ( 4, 6, 3, 9, 5); \ No newline at end of file diff --git a/services/item/server/model-config.json b/services/item/server/model-config.json index 9954710f4..6723f86f6 100644 --- a/services/item/server/model-config.json +++ b/services/item/server/model-config.json @@ -1,41 +1,41 @@ { - "TaxClass": { - "dataSource": "vn" - }, - "TaxCode": { - "dataSource": "vn" - }, - "TaxType": { - "dataSource": "vn" - }, - "ItemNiche": { - "dataSource": "vn" - }, - "ItemLog": { - "dataSource": "vn" - }, - "ItemBarcode": { - "dataSource": "vn" - }, - "ItemBotanical": { - "dataSource": "vn" - }, - "ItemPlacement": { - "dataSource": "vn" - }, - "ItemTaxCountry": { - "dataSource": "vn" - }, - "Warehouse": { - "dataSource": "vn" - }, - "Specie": { - "dataSource": "edi" - }, - "Genus": { - "dataSource": "edi" - }, - "ItemTypeTag": { - "dataSource": "vn" - } + "TaxClass": { + "dataSource": "vn" + }, + "TaxCode": { + "dataSource": "vn" + }, + "TaxType": { + "dataSource": "vn" + }, + "ItemNiche": { + "dataSource": "vn" + }, + "ItemLog": { + "dataSource": "vn" + }, + "ItemBarcode": { + "dataSource": "vn" + }, + "ItemBotanical": { + "dataSource": "vn" + }, + "ItemPlacement": { + "dataSource": "vn" + }, + "ItemTaxCountry": { + "dataSource": "vn" + }, + "Warehouse": { + "dataSource": "vn" + }, + "Specie": { + "dataSource": "edi" + }, + "Genus": { + "dataSource": "edi" + }, + "ItemTypeTag": { + "dataSource": "vn" + } }