diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index d315933fa..268b83030 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1127,7 +1127,7 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `companyFk`, (6, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 6, 442, 'Movement 6', 'this is the note six', 'observation six'), (7, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 442, 'Movement 7', 'this is the note seven', 'observation seven'); -INSERT INTO `bi`.`claims_ratio`(`id_Cliente`, `Consumo`, `Reclamaciones`, `Ratio`, `recobro`, `inflacion`) +INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`) VALUES (101, 500, NULL, 0.00, 0.00, 1.00), (102, 1000, 2.00, 0.01, 0.05, 1.00), diff --git a/db/dump/structure.sql b/db/dump/structure.sql index c25d129d6..be5776c58 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -2157,23 +2157,21 @@ CREATE TABLE `calidad_parametros` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `claims_ratio` +-- Temporary table structure for view `claims_ratio` -- DROP TABLE IF EXISTS `claims_ratio`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `claims_ratio` ( - `Id_Cliente` int(11) NOT NULL DEFAULT '0', - `Consumo` decimal(10,2) DEFAULT NULL, - `Reclamaciones` decimal(10,2) DEFAULT NULL, - `Ratio` decimal(5,2) DEFAULT NULL, - `recobro` decimal(5,2) DEFAULT NULL, - `inflacion` decimal(5,2) NOT NULL DEFAULT '1.00', - PRIMARY KEY (`Id_Cliente`), - CONSTRAINT `claims_ratio_ibfk_1` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `claims_ratio`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `claims_ratio` AS SELECT + 1 AS `Id_Cliente`, + 1 AS `Consumo`, + 1 AS `Reclamaciones`, + 1 AS `Ratio`, + 1 AS `recobro`, + 1 AS `inflacion`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `customerDebtInventory` @@ -2349,73 +2347,25 @@ CREATE TABLE `primer_pedido` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `rotacion` +-- Temporary table structure for view `rotacion` -- DROP TABLE IF EXISTS `rotacion`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `rotacion` ( - `Id_Article` int(11) NOT NULL, - `warehouse_id` smallint(6) unsigned NOT NULL, - `total` int(10) NOT NULL DEFAULT '0', - `rotacion` decimal(10,4) NOT NULL DEFAULT '0.0000', - `cm3` int(11) NOT NULL DEFAULT '0', - `almacenaje` decimal(10,4) NOT NULL DEFAULT '0.0000', - `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 `warehouse_id_rotacion_idx` (`warehouse_id`), - CONSTRAINT `id_article_rotaci` FOREIGN KEY (`Id_Article`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `warehouse_id_rotaci` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los valores de rotacion en los ultimos 365 dias'; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `bi`.`rotacion_beforeInsert` - BEFORE INSERT ON `rotacion` - FOR EACH ROW -BEGIN - IF NEW.Id_Article IN (95, 98) THEN - SET NEW.cm3 = 0; - END IF; -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `bi`.`rotacion_beforeUpdate` - BEFORE UPDATE ON `rotacion` - FOR EACH ROW -BEGIN - IF NEW.Id_Article IN (95, 98) THEN - SET NEW.cm3 = 0; - END IF; -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50001 DROP VIEW IF EXISTS `rotacion`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `rotacion` AS SELECT + 1 AS `Id_Article`, + 1 AS `warehouse_id`, + 1 AS `total`, + 1 AS `rotacion`, + 1 AS `cm3`, + 1 AS `almacenaje`, + 1 AS `manipulacion`, + 1 AS `auxiliar`, + 1 AS `mermas`, + 1 AS `cm3reparto`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `rutasBoard` @@ -5979,6 +5929,30 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `bs` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; +/*!50003 DROP PROCEDURE IF EXISTS `clean` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `clean`() +BEGIN + DECLARE vFourYearsAgo DATETIME; + + SET vFourYearsAgo = TIMESTAMPADD(YEAR, -4,CURDATE()); + + DELETE FROM ventas + WHERE fecha < vFourYearsAgo; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!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 `clientDied` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -8482,9 +8456,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -8492,11 +8466,11 @@ CREATE DEFINER=`root`@`%` PROCEDURE `weekWaste`() BEGIN DECLARE vWeek INT; DECLARE vYear INT; - + SELECT week, year INTO vWeek, vYear FROM vn.time - WHERE dated = CURDATE(); + WHERE dated = DATE_ADD(CURDATE(), INTERVAL -1 WEEK); SELECT *, 100 * dwindle / total AS percentage FROM ( @@ -8506,7 +8480,6 @@ BEGIN FROM bs.waste WHERE year = vYear and week = vWeek GROUP BY buyer - ) sub ORDER BY percentage DESC; END ;; @@ -8534,7 +8507,7 @@ BEGIN SELECT week, year INTO vWeek, vYear FROM vn.time - WHERE dated = CURDATE(); + WHERE dated = TIMESTAMPADD(WEEK,-1,CURDATE()); SELECT *, 100 * mermas / total as porcentaje FROM ( @@ -8555,6 +8528,43 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `weekWaste_getDetail` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `weekWaste_getDetail`() +BEGIN + DECLARE vLastWeek DATE; + DECLARE vWeek INT; + DECLARE vYear INT; + + SET vLastWeek = TIMESTAMPADD(WEEK,-1,CURDATE()); + SET vYear = YEAR(vLastWeek); + SET vWeek = WEEK(vLastWeek, 1); + + SELECT *, 100 * dwindle / total AS percentage + FROM ( + SELECT buyer, + ws.family, + sum(ws.saleTotal) AS total, + sum(ws.saleWaste) AS dwindle + FROM bs.waste ws + WHERE year = vYear AND week = vWeek + GROUP BY buyer, family + ) sub + ORDER BY percentage DESC; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerSpeed` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -21672,14 +21682,33 @@ CREATE TABLE `claimLog` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `claimRatio` +-- Table structure for table `claimRatio` -- DROP TABLE IF EXISTS `claimRatio`; -/*!50001 DROP VIEW IF EXISTS `claimRatio`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `claimRatio` ( + `clientFk` int(11) NOT NULL DEFAULT '0', + `yearSale` decimal(10,2) DEFAULT NULL, + `claimAmount` decimal(10,2) DEFAULT NULL, + `claimingRate` decimal(5,2) DEFAULT NULL, + `priceIncreasing` decimal(5,2) DEFAULT NULL, + `packingRate` decimal(5,2) NOT NULL DEFAULT '1.00', + PRIMARY KEY (`clientFk`), + CONSTRAINT `claimRatio_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `claimRatio__` +-- + +DROP TABLE IF EXISTS `claimRatio__`; +/*!50001 DROP VIEW IF EXISTS `claimRatio__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `claimRatio` AS SELECT +/*!50001 CREATE VIEW `claimRatio__` AS SELECT 1 AS `clientFk`, 1 AS `yearSale`, 1 AS `claimAmount`, @@ -22406,6 +22435,7 @@ CREATE TABLE `collectionVolumetry` ( `level` int(10) unsigned NOT NULL DEFAULT '0', `lines` int(10) unsigned NOT NULL DEFAULT '1', `liters` int(10) unsigned NOT NULL DEFAULT '0', + `height` int(10) NOT NULL DEFAULT '20', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -22687,9 +22717,9 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`country_beforeUpdate` BEFORE UPDATE ON `country` FOR EACH ROW BEGIN - IF !(OLD.geoFk <=> NEW.geoFk) THEN - CALL zoneGeo_throwNotEditable; - END IF; + -- IF !(OLD.geoFk <=> NEW.geoFk) THEN + -- CALL zoneGeo_throwNotEditable; + -- END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -25057,6 +25087,7 @@ CREATE TABLE `itemCategory` ( `merchandise` tinyint(1) NOT NULL DEFAULT '1', `icon` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `isReclining` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `reino_UNIQUE` (`name`), KEY `itemCategory_idx3` (`merchandise`) @@ -25091,6 +25122,19 @@ SET character_set_client = utf8; 1 AS `name`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `itemColor` +-- + +DROP TABLE IF EXISTS `itemColor`; +/*!50001 DROP VIEW IF EXISTS `itemColor`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `itemColor` AS SELECT + 1 AS `itemFk`, + 1 AS `color`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `itemConversor` -- @@ -25108,6 +25152,71 @@ CREATE TABLE `itemConversor` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona los item específicos con los genéricos'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `itemCost` +-- + +DROP TABLE IF EXISTS `itemCost`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemCost` ( + `itemFk` int(11) NOT NULL, + `warehouseFk` smallint(6) unsigned NOT NULL, + `quantity` int(10) NOT NULL DEFAULT '0', + `rotation` decimal(10,4) NOT NULL DEFAULT '0.0000', + `cm3` int(11) NOT NULL DEFAULT '0', + `storage` decimal(10,4) NOT NULL DEFAULT '0.0000', + `handling` decimal(10,4) NOT NULL DEFAULT '0.0000', + `extraCharge` decimal(10,4) NOT NULL DEFAULT '0.0000', + `wated` decimal(10,4) NOT NULL DEFAULT '0.0000', + `cm3delivery` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`itemFk`,`warehouseFk`), + KEY `warehouse_id_rotacion_idx` (`warehouseFk`), + CONSTRAINT `id_article_rotaci` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `warehouse_id_rotaci` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los valores de rotacion en los ultimos 365 dias'; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`itemCost_beforeInsert` BEFORE INSERT ON `vn`.`itemCost` FOR EACH ROW +BEGIN + IF NEW.itemFk IN (95, 98) THEN + SET NEW.cm3 = 0; + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`itemCost_beforeUpdate` BEFORE UPDATE ON `vn`.`itemCost` FOR EACH ROW +BEGIN + IF NEW.itemFk IN (95, 98) THEN + SET NEW.cm3 = 0; + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; + -- -- Temporary table structure for view `itemEntryIn` -- @@ -25312,6 +25421,19 @@ SET character_set_client = utf8; 1 AS `sectorFk`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `itemProductor` +-- + +DROP TABLE IF EXISTS `itemProductor`; +/*!50001 DROP VIEW IF EXISTS `itemProductor`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `itemProductor` AS SELECT + 1 AS `itemFk`, + 1 AS `productor`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `itemRepo` -- @@ -26299,7 +26421,9 @@ CREATE TABLE `orderTicket` ( `orderFk` int(10) unsigned NOT NULL, `ticketFk` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`ticketFk`,`orderFk`), - KEY `order_id` (`orderFk`) + KEY `order_id` (`orderFk`), + CONSTRAINT `hedera_id` FOREIGN KEY (`orderFk`) REFERENCES `hedera`.`order` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `idTicketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26738,9 +26862,9 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `postCode_beforeUpdate` BEFORE UPDATE ON `postCode` FOR EACH ROW BEGIN - IF !(OLD.geoFk <=> NEW.geoFk) THEN - CALL zoneGeo_throwNotEditable; - END IF; + -- IF !(OLD.geoFk <=> NEW.geoFk) THEN + -- CALL zoneGeo_throwNotEditable; + -- END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -26794,22 +26918,6 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; --- --- Table structure for table `postCodeBack__` --- - -DROP TABLE IF EXISTS `postCodeBack__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `postCodeBack__` ( - `code` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `townFk` int(11) NOT NULL, - `geoFk` int(11) DEFAULT NULL, - PRIMARY KEY (`code`,`townFk`), - KEY `postCodeTownFk_idx2` (`townFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `priceBuilderTag__` -- @@ -27151,9 +27259,9 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`province_beforeUpdate` BEFORE UPDATE ON `province` FOR EACH ROW BEGIN - IF !(OLD.geoFk <=> NEW.geoFk) THEN - CALL zoneGeo_throwNotEditable; - END IF; + -- IF !(OLD.geoFk <=> NEW.geoFk) THEN + -- CALL zoneGeo_throwNotEditable; + -- END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -29043,6 +29151,19 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `ticketDocumentation` +-- + +DROP TABLE IF EXISTS `ticketDocumentation`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ticketDocumentation` ( + `ticketFk` int(11) NOT NULL, + PRIMARY KEY (`ticketFk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Marca si se ha revisado el ticket para aportar la documentación CRM/DUA (relativa al trasporte internacional de mercancias)'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `ticketDown` -- @@ -29670,9 +29791,9 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `town_beforeUpdate` BEFORE UPDATE ON `town` FOR EACH ROW BEGIN - IF !(OLD.geoFk <=> NEW.geoFk) THEN - CALL zoneGeo_throwNotEditable; - END IF; + -- IF !(OLD.geoFk <=> NEW.geoFk) THEN + -- CALL zoneGeo_throwNotEditable; + -- END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -30135,6 +30256,7 @@ CREATE TABLE `warehouse` ( `pickUpAgencyModeFk` int(11) DEFAULT NULL, `isBuyerToBeEmailed` tinyint(2) NOT NULL DEFAULT '0', `aliasFk` smallint(5) unsigned DEFAULT NULL, + `labelReport` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`), KEY `Id_Paises` (`countryFk`), @@ -31001,6 +31123,7 @@ CREATE TABLE `zone` ( `bonus` double NOT NULL DEFAULT '0', `isVolumetric` tinyint(1) NOT NULL DEFAULT '0', `inflation` decimal(5,2) NOT NULL DEFAULT '1.00', + `m3Max` decimal(10,2) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_zone_1_idx` (`warehouseFk__`), KEY `fk_zone_2_idx` (`agencyModeFk`), @@ -31027,6 +31150,35 @@ CREATE TABLE `zoneCalendar` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `zoneClosure` +-- + +DROP TABLE IF EXISTS `zoneClosure`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `zoneClosure` ( + `zoneFk` int(11) NOT NULL, + `dated` date NOT NULL, + `hour` time NOT NULL, + PRIMARY KEY (`zoneFk`,`dated`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `zoneConfig` +-- + +DROP TABLE IF EXISTS `zoneConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `zoneConfig` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `scope` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `zoneEvent` -- @@ -33069,9 +33221,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -33126,14 +33278,14 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.workerComercial; CREATE TEMPORARY TABLE tmp.workerComercial ENGINE = MEMORY - SELECT worker FROM `grant` g - JOIN grantGroup gg ON g.`group` = gg.id + SELECT workerFk as worker FROM `grant` g + JOIN grantGroup gg ON g.`groupFk` = gg.id WHERE gg.description = 'Comerciales'; DELETE wc.* FROM tmp.workerComercial wc - JOIN `grant` g ON g.worker = wc.worker - JOIN grantGroup gg ON g.`group` = gg.id + JOIN `grant` g ON g.workerFk = wc.worker + JOIN grantGroup gg ON g.`groupFk` = gg.id WHERE gg.description = 'Gerencia'; DROP TEMPORARY TABLE IF EXISTS tmp.production_buffer; @@ -34825,6 +34977,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 FUNCTION IF EXISTS `worker_isWorking` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` FUNCTION `worker_isWorking`(vWorkerFk INT) RETURNS tinyint(1) + READS SQL DATA +BEGIN +/** + * Comprueba si el trabajador está trabajando en el momento de la consulta + * @return Devuelve TRUE en caso de que este trabajando. Si se encuentra en un descanso devolverá FALSE + */ + DECLARE vLastIn DATETIME ; + + SELECT MAX(timed) INTO vLastIn + FROM vn.workerTimeControl + WHERE userFk = vWorkerFk AND + direction = 'in'; + + IF (SELECT MOD(COUNT(*),2) + FROM vn.workerTimeControl + WHERE userFk = vWorkerFk AND + timed >= vLastIn + ) THEN + RETURN TRUE; + ELSE + RETURN FALSE; + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP FUNCTION IF EXISTS `xdiario_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -37104,35 +37295,31 @@ BEGIN DECLARE vNewTicket INT DEFAULT 0; - IF account.myUserHasRole('administrative') THEN - - CALL vn.clientPackagingOverstock(vClientFk,vGraceDays); - - CALL vn.ticketCreate( - vClientFk - ,curdate() - ,1 -- Silla FV - ,442 -- Verdnatura - ,NULL -- address - ,2 -- Rec_Silla - ,NULL -- route - ,curdate() - ,vNewTicket); - - INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price) - SELECT vNewTicket, cpo.itemFk, - cpo.abonables, i.longName, p.price - FROM tmp.clientPackagingOverstock cpo - JOIN vn.item i ON i.id = cpo.itemFk - JOIN vn.packaging p ON p.itemFk = cpo.itemFk - WHERE cpo.abonables > 0; - - INSERT INTO vn.ticketPackaging(ticketFk, packagingFk, quantity) - SELECT vNewTicket, p.id, cpo.abonables - FROM tmp.clientPackagingOverstock cpo - JOIN vn.packaging p ON p.itemFk = cpo.itemFk - WHERE cpo.abonables > 0; + CALL vn.clientPackagingOverstock(vClientFk,vGraceDays); - END IF; + CALL vn.ticketCreate( + vClientFk + ,curdate() + ,1 -- Silla FV + ,442 -- Verdnatura + ,NULL -- address + ,2 -- Rec_Silla + ,NULL -- route + ,curdate() + ,vNewTicket); + + INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price) + SELECT vNewTicket, cpo.itemFk, - cpo.abonables, i.longName, p.price + FROM tmp.clientPackagingOverstock cpo + JOIN vn.item i ON i.id = cpo.itemFk + JOIN vn.packaging p ON p.itemFk = cpo.itemFk + WHERE cpo.abonables > 0; + + INSERT INTO vn.ticketPackaging(ticketFk, packagingFk, quantity) + SELECT vNewTicket, p.id, cpo.abonables + FROM tmp.clientPackagingOverstock cpo + JOIN vn.packaging p ON p.itemFk = cpo.itemFk + WHERE cpo.abonables > 0; SELECT vNewTicket; @@ -37418,6 +37605,7 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `collectionPlacement_get`(vCollectionFk INT) BEGIN + DECLARE vCalcFk INT; DECLARE vWarehouseFk INT; DECLARE vWarehouseAliasFk INT; @@ -37427,6 +37615,7 @@ BEGIN FROM vn.ticket t JOIN vn.ticketCollection tc ON tc.ticketFk = t.id JOIN vn.warehouse w ON w.id = t.warehouseFk + WHERE tc.collectionFk = vCollectionFk LIMIT 1; CALL cache.visible_refresh(vCalcFk,FALSE,vWarehouseFk); @@ -37446,7 +37635,7 @@ BEGIN WHERE w.aliasFk = vWarehouseAliasFk GROUP BY iss.itemFk ) iss ON iss.itemFk = pk.itemFk SET pk.quantity = iss.visible; - + DROP TEMPORARY TABLE IF EXISTS tmp.`grouping`; CREATE TEMPORARY TABLE tmp.`grouping` ENGINE MEMORY @@ -37523,9 +37712,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -37541,7 +37730,15 @@ BEGIN reserved, max(isPreviousPrepared) as isPreviousPrepared, max(isPrepared) as isPrepared, - max(isControlled) as isControlled + max(isControlled) as isControlled, + color, + productor, + discount, + price, + stems, + category, + origin, + clientFk FROM ( SELECT s.ticketFk, s.id as saleFk, @@ -37552,12 +37749,25 @@ BEGIN s.reserved, IF(st.semaphore <=> 1, TRUE, FALSE) as isPreviousPrepared, IF(st.semaphore <=> 2, TRUE, FALSE) as isPrepared, - IF(st.semaphore <=> 3, TRUE, FALSE) as isControlled + IF(st.semaphore <=> 3, TRUE, FALSE) as isControlled, + ic.color, + ip.productor, + s.discount, + s.price, + i.stems, + i.category, + o.code AS origin, + t.clientFk FROM vn.sale s JOIN vn.item i ON i.id = s.itemFk LEFT JOIN vn.saleTracking str ON str.saleFk = s.id AND str.isChecked = 1 LEFT JOIN vn.state st ON st.id = str.stateFk + LEFT JOIN vn.itemColor ic ON ic.itemFk = s.itemFk + LEFT JOIN vn.itemProductor ip ON ip.itemFk = s.itemFk + LEFT JOIN vn.origin o ON o.id = i.originFk JOIN vn.ticketCollection tc ON tc.ticketFk = s.ticketFk + JOIN vn.ticket t ON t.id = tc.ticketFk + WHERE tc.collectionFk = vCollectionFk ) sub @@ -37575,7 +37785,15 @@ BEGIN 0 AS reserved, IF(st.semaphore <=> 1,TRUE, FALSE) as isPreviousPrepared, IF(st.semaphore <=> 2,TRUE, FALSE) as isPrepared, - IF(st.semaphore <=> 3,TRUE, FALSE) as isControlled + IF(st.semaphore <=> 3,TRUE, FALSE) as isControlled, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL FROM vn.ticketCollection tc JOIN vn.stowaway stow ON stow.shipFk = tc.ticketFk LEFT JOIN vn.ticketState ts ON ts.ticketFk = stow.id @@ -37600,17 +37818,19 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `collectionStickers_print`(vCollectionFk INT) BEGIN - + UPDATE vn.ticket t JOIN vn.ticketCollection tc ON tc.ticketFk = t.id SET t.notes = CONCAT('COL ',vCollectionFk,'-',tc.`level`) WHERE tc.collectionFk = vCollectionFk; - - INSERT INTO vn.printServerQueue(reportFk, param1, workerFk) - SELECT 23, tc.ticketFk, getUser() + + INSERT INTO vn.printServerQueue(reportFk, param1, workerFk) + SELECT w.labelReport, tc.ticketFk, getUser() FROM vn.ticketCollection tc + JOIN vn.ticket t ON t.id = tc.ticketFk + JOIN vn.warehouse w ON w.id = t.warehouseFk WHERE tc.collectionFk = vCollectionFk; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -37839,6 +38059,18 @@ proc:BEGIN SET c.stateFk = st.id WHERE c.id = vCollectionFk; + INSERT IGNORE INTO vn.ticketDown(ticketFk) + SELECT DISTINCT tc.ticketFk + FROM vn.ticketCollection tc + JOIN vncontrol.inter vi ON vi.Id_Ticket = tc.ticketFk + JOIN vn.state st ON st.id = vi.state_id + JOIN vn.ticket t ON t.id = tc.ticketFk + JOIN vn.warehouse w ON w.id = t.warehouseFk + WHERE tc.collectionFk = vCollectionFk + AND w.name = 'Silla FV' + AND st.code = 'PREVIOUS_PREPARATION'; + + SELECT vCollectionFk; CLOSE cVolumetry; @@ -37867,23 +38099,39 @@ proc:BEGIN DECLARE vIsPreviousPrepared BOOLEAN; DECLARE vCollectionFk INT; DECLARE vWarehouseFk INT; + DECLARE vTicketLiters INT; DECLARE vTicketLines INT; DECLARE vTicketFk INT; + DECLARE vTicketHeight INT; + DECLARE vTicketHeightTop INT; + DECLARE vTicketHeightFloor INT; DECLARE vIsTicketCollected BOOLEAN; DECLARE vMaxTickets INT; DECLARE vStateFk INT; + DECLARE vTopTicketFk INT; + DECLARE vFloorTicketFk INT; + DECLARE vVolumetryLiters INT; DECLARE vVolumetryLines INT; DECLARE vVolumetryFk INT; DECLARE vVolumetryLevel INT; + DECLARE vVolumetryHeight INT; DECLARE vVolumetryLitersMax INT; DECLARE vVolumetryLinesMax INT; + DECLARE vVolumetryHeightTop INT; + DECLARE vVolumetryHeightFloor INT; + + DECLARE vDone BOOLEAN DEFAULT FALSE; DECLARE vWorkerCode VARCHAR(3); + + + + DECLARE cVolumetry CURSOR FOR - SELECT level, liters, `lines` + SELECT level, liters, `lines`, height FROM vn.collectionVolumetry ORDER BY `level`; @@ -37924,6 +38172,8 @@ proc:BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket; + -- Recogida Silla requiere carros individuales + IF (SELECT pb.Agencia FROM tmp.production_buffer pb JOIN vn.state s ON s.id = pb.state @@ -37952,7 +38202,8 @@ proc:BEGIN CREATE TEMPORARY TABLE tmp.ticket SELECT pb.Id_Ticket ticketFk, pb.lines, - pb.m3 * 1000 liters + pb.m3 * 1000 liters, + 0 as height FROM tmp.production_buffer pb JOIN vn.state s ON s.id = pb.state LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket @@ -37962,15 +38213,70 @@ proc:BEGIN AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC LIMIT vMaxTickets; + + -- Establece altura máxima por pedido, porque las plantas no se pueden recostar. + + UPDATE tmp.ticket t + JOIN + (SELECT MAX(i.size) maxHeigth, tc.ticketFk + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + WHERE ic.isReclining = FALSE + AND tc.collectionFk = vCollectionFk + GROUP BY tc.ticketFk) sub ON sub.ticketFk = t.ticketFk + SET t.height = sub.maxHeigth; + + + -- Si hay un ticket con una planta que supera la máxima altura para la bandeja superior, el pedido ha de ser único. Por tanto, eliminamos el resto. + -- Si hay dos tickets con plantas que superen la medida inferior, el carro llevará una bandeja. Hay que eliminar los otros dos. + + SELECT height, ticketFk + INTO vTicketHeightTop, vTopTicketFk + FROM tmp.ticket + ORDER BY height DESC + LIMIT 1; + + SELECT max(height) + INTO vVolumetryHeightTop + FROM vn.collectionVolumetry; + + SELECT height, ticketFk + INTO vTicketHeightFloor, vFloorTicketFk + FROM tmp.ticket + WHERE ticketFk != vTopTicketFk + ORDER BY height DESC + LIMIT 1; + + SELECT height + INTO vVolumetryHeightFloor + FROM vn.collectionVolumetry + WHERE level = 1; + + IF vTicketHeightTop > vVolumetryHeightTop + OR vTicketHeightFloor > vVolumetryHeightFloor THEN + + DELETE FROM tmp.ticket WHERE ticketFk != vTopTicketFk; + + ELSEIF vTicketHeightFloor <= vVolumetryHeightFloor THEN + + DELETE FROM tmp.ticket WHERE ticketFk NOT IN (vTopTicketFk, vFloorTicketFk); + + END IF; + + END IF; + -- Empieza el bucle OPEN cVolumetry; OPEN cTicket; - FETCH cTicket INTO vTicketFk, vTicketLines, vTicketLiters; - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines; + FETCH cTicket INTO vTicketFk, vTicketLines, vTicketLiters, vTicketHeight; + FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines, vVolumetryHeight; IF NOT vDone THEN @@ -38028,12 +38334,12 @@ proc:BEGIN IF vTicketLiters > 0 OR vTicketLines > 0 THEN - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines; + FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines, vVolumetryHeight; ELSE - FETCH cTicket INTO vTicketFk, vTicketLines, vTicketLiters; - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines; + FETCH cTicket INTO vTicketFk, vTicketLines, vTicketLiters, vTicketHeight; + FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines, vVolumetryHeight; END IF; @@ -38045,196 +38351,23 @@ proc:BEGIN SET c.stateFk = st.id WHERE c.id = vCollectionFk; - SELECT vCollectionFk; - - CLOSE cVolumetry; - CLOSE cTicket; - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collection_new__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = 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 `collection_new__`(vSectorFk INT) -proc:BEGIN + INSERT IGNORE INTO vn.ticketDown(ticketFk) + SELECT DISTINCT tc.ticketFk + FROM vn.ticketCollection tc + JOIN vncontrol.inter vi ON vi.Id_Ticket = tc.ticketFk + JOIN vn.state st ON st.id = vi.state_id + JOIN vn.ticket t ON t.id = tc.ticketFk + JOIN vn.warehouse w ON w.id = t.warehouseFk + WHERE tc.collectionFk = vCollectionFk + AND w.name = 'Silla FV' + AND st.code = 'PREVIOUS_PREPARATION'; - DECLARE vIsPreviousPrepared BOOLEAN; - DECLARE vCollectionFk INT; - DECLARE vWarehouseFk INT; - DECLARE vTicketLiters INT; - DECLARE vTicketLines INT; - DECLARE vTicketFk INT; - DECLARE vIsTicketCollected BOOLEAN; - DECLARE vMaxTickets INT; - DECLARE vStateFk INT; - DECLARE vVolumetryLiters INT; - DECLARE vVolumetryLines INT; - DECLARE vVolumetryFk INT; - DECLARE vVolumetryLevel INT; - DECLARE vVolumetryLitersMax INT; - DECLARE vVolumetryLinesMax INT; - DECLARE vDone BOOLEAN DEFAULT FALSE; - DECLARE vWorkerCode VARCHAR(3); - - DECLARE cVolumetry CURSOR FOR - SELECT level, liters, `lines` - FROM vn.collectionVolumetry - ORDER BY `level`; - - DECLARE cTicket CURSOR FOR - SELECT pb.Id_Ticket ticketFk, - pb.lines, - pb.m3 * 1000 liters - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket - WHERE pb.problems = 0 - AND tc.ticketFk IS NULL - AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC - LIMIT vMaxTickets; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - SELECT isPreviousPrepared, warehouseFk - INTO vIsPreviousPrepared, vWarehouseFk - FROM vn.sector - WHERE id = vSectorFk; - - SELECT w.code - INTO vWorkerCode - FROM vn.worker w - WHERE w.id = account.myUserGetId(); - - IF vIsPreviousPrepared THEN - - SELECT id INTO vStateFk - FROM vn.state - WHERE `code` = 'PREVIOUS_PREPARATION'; - ELSE - - SELECT id INTO vStateFk - FROM vn.state - WHERE `code` = 'ON_PREPARATION'; - - END IF; - - SELECT COUNT(*), sum(liters), sum(`lines`) - INTO vMaxTickets, vVolumetryLitersMax, vVolumetryLinesMax - FROM vn.collectionVolumetry; - - CALL vn2008.production_control_source(vWarehouseFk, 0); - - -- Empieza el bucle - OPEN cVolumetry; - OPEN cTicket; - /* - DROP TEMPORARY TABLE IF EXISTS tmp.kk; - CREATE TEMPORARY TABLE tmp.kk - SELECT pb.Id_Ticket ticketFk,pb.Hora, pb.Minuto, - pb.lines, - pb.m3 * 1000 liters - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket - WHERE pb.problems = 0 - AND tc.ticketFk IS NULL - AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC - LIMIT vMaxTickets; - */ - FETCH cTicket INTO vTicketFk, vTicketLines, vTicketLiters; - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines; - - IF NOT vDone THEN - - INSERT INTO vn.collection - SET workerFk = account.myUserGetId(); - - SELECT LAST_INSERT_ID() INTO vCollectionFk; - - END IF; - - bucle:WHILE NOT vDone DO - - IF (vVolumetryLitersMax < vTicketLiters OR vVolumetryLinesMax < vTicketLines) AND vVolumetryLevel > 1 THEN - - LEAVE bucle; - - END IF; - - SELECT COUNT(*) INTO vIsTicketCollected - FROM vn.ticketCollection - WHERE ticketFk = vTicketFk - AND collectionFk = vCollectionFk; - - IF vIsTicketCollected THEN - - UPDATE vn.ticketCollection - SET level = CONCAT(level, vVolumetryLevel) - WHERE ticketFk = vTicketFk - AND collectionFk = vCollectionFk; - - ELSE - - INSERT INTO vn.ticketCollection - SET collectionFk = vCollectionFk, - ticketFk = vTicketFk, - level = vVolumetryLevel; - - INSERT INTO vncontrol.inter - SET state_id = vStateFk, - Id_Ticket = vTicketFk, - Id_Trabajador = account.myUserGetId(); - - END IF; - - SET vVolumetryLitersMax = GREATEST(0,vVolumetryLitersMax - vVolumetryLiters); - SET vVolumetryLinesMax = GREATEST(0,vVolumetryLinesMax - vVolumetryLines); - SET vTicketLiters = GREATEST(0,vTicketLiters - vVolumetryLiters); - SET vTicketLines = GREATEST(0,vTicketLines - vVolumetryLines); - - IF vVolumetryLitersMax = 0 OR vVolumetryLinesMax = 0 THEN - - LEAVE bucle; - - END IF; - - IF vTicketLiters > 0 OR vTicketLines > 0 THEN - - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines; - - ELSE - - FETCH cTicket INTO vTicketFk, vTicketLines, vTicketLiters; - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines; - - END IF; - - END WHILE; - - - UPDATE vn.collection c - JOIN vn.state st ON st.code = 'ON_PREPARATION' - SET c.stateFk = st.id - WHERE c.id = vCollectionFk; SELECT vCollectionFk; CLOSE cVolumetry; CLOSE cTicket; + -- DROP TEMPORARY TABLE IF EXISTS tmp.ticket; END ;; DELIMITER ; @@ -46868,7 +47001,7 @@ BEGIN SET vColumn = vFromColumn; SET vRow = vFromRow; - SET vCode = CONCAT(LPAD(vColumn,3,'0'),IF(vIsLetterMode, MID(vLetters, vRow, 1), CONCAT('-',LPAD(vRow, 2,'0')))); + SET vCode = CONCAT(LPAD(vColumn,3,'0'),'-',IF(vIsLetterMode, MID(vLetters, vRow, 1), LPAD(vRow, 2,'0'))); SELECT MAX(id) INTO vMaxId FROM vn.parking; @@ -46889,7 +47022,7 @@ BEGIN SET vRow = vFromRow; SET vColumn = vColumn + 1; - SET vCode = CONCAT(LPAD(vColumn,3,'0'),IF(vIsLetterMode, MID(vLetters, vRow, 1), CONCAT('-',LPAD(vRow, 2,'0')))); + SET vCode = CONCAT(LPAD(vColumn,3,'0'),'-',IF(vIsLetterMode, MID(vLetters, vRow, 1), LPAD(vRow, 2,'0'))); END WHILE; @@ -55526,63 +55659,6 @@ SELECT 7_dias_antes,6_dias_antes,5_dias_antes,4_dias_antes,3_dias_antes,2_dias_a DROP TEMPORARY TABLE tmp.workerWeekTiming; DROP TEMPORARY TABLE tmp.workerWeekTiming_Aux; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `worker_getHierarch` */; -/*!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 `worker_getHierarch`(vBoss INT) -BEGIN --- eliminar no se usa - DECLARE EXIT HANDLER FOR 1062 BEGIN - CALL util.throw('INFINITE_LOOP'); - END; - - DROP TEMPORARY TABLE IF EXISTS workerHierarch; - CREATE TEMPORARY TABLE workerHierarch - (PRIMARY KEY (workerFk)) - ENGINE = MEMORY - SELECT vBoss AS workerFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.workerHierarchList; - CREATE TEMPORARY TABLE tmp.workerHierarchList - (PRIMARY KEY (workerFk)) - ENGINE = MEMORY - SELECT vBoss AS workerFk, 0 AS isChecked; - - - WHILE (SELECT COUNT(*) FROM tmp.workerHierarchList WHERE NOT isChecked) > 0 DO - - INSERT INTO tmp.workerHierarchList - SELECT w.id, 0 - FROM worker w - JOIN workerHierarch wh ON wh.workerFk = w.bossFk; - - UPDATE tmp.workerHierarchList whl - JOIN workerHierarch wh ON wh.workerFk = whl.workerFk - SET whl.isChecked = 1; - - TRUNCATE workerHierarch; - - INSERT INTO workerHierarch - SELECT workerFk - FROM tmp.workerHierarchList - WHERE NOT isChecked; - - END WHILE; - - DROP TEMPORARY TABLE IF EXISTS workerHierarch; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -55645,6 +55721,64 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `worker_getHierarch__` */; +/*!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 `worker_getHierarch__`(vBoss INT) +BEGIN +-- eliminar no se usa + -- usar worker_getHierarchy + DECLARE EXIT HANDLER FOR 1062 BEGIN + CALL util.throw('INFINITE_LOOP'); + END; + + DROP TEMPORARY TABLE IF EXISTS workerHierarch; + CREATE TEMPORARY TABLE workerHierarch + (PRIMARY KEY (workerFk)) + ENGINE = MEMORY + SELECT vBoss AS workerFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.workerHierarchList; + CREATE TEMPORARY TABLE tmp.workerHierarchList + (PRIMARY KEY (workerFk)) + ENGINE = MEMORY + SELECT vBoss AS workerFk, 0 AS isChecked; + + + WHILE (SELECT COUNT(*) FROM tmp.workerHierarchList WHERE NOT isChecked) > 0 DO + + INSERT INTO tmp.workerHierarchList + SELECT w.id, 0 + FROM worker w + JOIN workerHierarch wh ON wh.workerFk = w.bossFk; + + UPDATE tmp.workerHierarchList whl + JOIN workerHierarch wh ON wh.workerFk = whl.workerFk + SET whl.isChecked = 1; + + TRUNCATE workerHierarch; + + INSERT INTO workerHierarch + SELECT workerFk + FROM tmp.workerHierarchList + WHERE NOT isChecked; + + END WHILE; + + DROP TEMPORARY TABLE IF EXISTS workerHierarch; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `worker_getProductionErrors` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55842,6 +55976,64 @@ DELIMITER ; /*!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 `zoneClosure_recalc` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `zoneClosure_recalc`() +proc: BEGIN +/** + * Recalculates the delivery time (hour) for every zone in days + scope in future + */ + DECLARE vScope INT; + DECLARE vCounter INT DEFAULT 0; + DECLARE vShipped DATE DEFAULT CURDATE(); + + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + DO RELEASE_LOCK('vn.zoneClosure_recalc'); + RESIGNAL; + END; + + IF NOT GET_LOCK('vn.zoneClosure_recalc', 0) THEN + LEAVE proc; + END IF; + + SELECT scope INTO vScope + FROM zoneConfig; + + DROP TEMPORARY TABLE IF EXISTS tmp.zone; + CREATE TEMPORARY TABLE tmp.zone + (INDEX (id)) + ENGINE = MEMORY + SELECT id FROM zone; + + TRUNCATE TABLE zoneClosure; + + REPEAT + CALL zone_getOptionsForShipment(vShipped); + INSERT INTO zoneClosure(zoneFk, dated, `hour`) + SELECT zoneFk, vShipped, `hour` FROM tmp.zoneOption; + + SET vCounter = vCounter + 1; + SET vShipped = TIMESTAMPADD(DAY, 1, vShipped); + UNTIL vCounter > vScope + END REPEAT; + + DROP TEMPORARY TABLE tmp.zone; + DO RELEASE_LOCK('vn.zoneClosure_recalc'); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!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 `zoneGeo_calcTree` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57029,52 +57221,20 @@ DELIMITER ;; BEFORE INSERT ON `inter` FOR EACH ROW BEGIN -/* - -- PAK 08/05/18 Los tickets no se pueden marcar como servidos en el futuro - - IF NEW.state_id = 16 AND (SELECT date(landed) FROM vn.ticket WHERE id = NEW.Id_Ticket) > CURDATE() THEN -- Entregado - SET NEW.state_id = 22; -- ¿ Fecha ? - END IF; -*//* - -- PAK 08/05/18 Los sacadores no deben de poner los tickets en revisión - - DECLARE vIsSacador BOOL; + DECLARE vState VARCHAR(15); + DECLARE vZoneFk INT; + + SELECT s.code INTO vState + FROM vn.state s + WHERE s.id = NEW.state_id; + + SELECT t.zonefk INTO vZoneFk + FROM vn.ticket t + WHERE t.id = NEW.Id_Ticket; - IF NEW.state_id = 6 THEN -- Revisión - SELECT COUNT(*) > 0 INTO vIsSacador - FROM inter - WHERE state_id = 5 -- Preparacion - AND Id_Trabajador = NEW.Id_Trabajador - AND Id_Ticket = NEW.Id_Ticket; - - IF vIsSacador THEN - SET NEW.state_id = 5; - END IF; - END IF; -*//* - -- PAK 08/05/18 Este código parece fósil. Lo comento. - - DECLARE contados INT; - DECLARE vSupervisor INT; - - SELECT Id_Trabajador INTO vSupervisor - FROM vn2008.Trabajadores WHERE user_id = account.userGetId(); - - SET NEW.Id_Supervisor = IFNULL(vSupervisor,20); - - IF NEW.state_id = 5 THEN -- Preparación - SELECT COUNT(Id_Ticket) INTO contados - FROM vncontrol.inter - WHERE state_id = 5 - AND Id_Ticket = NEW.Id_Ticket - AND IFNULL(Id_Supervisor,-1) <> vSupervisor - AND TIMESTAMPADD(SECOND, 60, odbc_date) >= NOW(); - - IF contados <> 0 THEN - CALL util.throw ('FALLO_AL_INSERTAR'); - END IF; - END IF; -*/ + IF vState = 'OK' AND vZoneFk IS NULL THEN + CALL util.throw("ASSIGN_ZONE_FIRST"); + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -57340,6 +57500,24 @@ USE `bi`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `claims_ratio` +-- + +/*!50001 DROP VIEW IF EXISTS `claims_ratio`*/; +/*!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 `claims_ratio` AS select `cr`.`clientFk` AS `Id_Cliente`,`cr`.`yearSale` AS `Consumo`,`cr`.`claimAmount` AS `Reclamaciones`,`cr`.`claimingRate` AS `Ratio`,`cr`.`priceIncreasing` AS `recobro`,`cr`.`packingRate` AS `inflacion` from `vn`.`claimRatio` `cr` */; +/*!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 `customerRiskOverdue` -- @@ -57358,6 +57536,24 @@ USE `bi`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `rotacion` +-- + +/*!50001 DROP VIEW IF EXISTS `rotacion`*/; +/*!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 `rotacion` AS select `ic`.`itemFk` AS `Id_Article`,`ic`.`warehouseFk` AS `warehouse_id`,`ic`.`quantity` AS `total`,`ic`.`rotation` AS `rotacion`,`ic`.`cm3` AS `cm3`,`ic`.`storage` AS `almacenaje`,`ic`.`handling` AS `manipulacion`,`ic`.`extraCharge` AS `auxiliar`,`ic`.`wated` AS `mermas`,`ic`.`cm3delivery` AS `cm3reparto` from `vn`.`itemCost` `ic` */; +/*!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 `saleVolume` -- @@ -58169,10 +58365,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `claimRatio` +-- Final view structure for view `claimRatio__` -- -/*!50001 DROP VIEW IF EXISTS `claimRatio`*/; +/*!50001 DROP VIEW IF EXISTS `claimRatio__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -58181,7 +58377,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `claimRatio` AS select `bi`.`claims_ratio`.`Id_Cliente` AS `clientFk`,`bi`.`claims_ratio`.`Consumo` AS `yearSale`,`bi`.`claims_ratio`.`Reclamaciones` AS `claimAmount`,`bi`.`claims_ratio`.`Ratio` AS `claimingRate`,`bi`.`claims_ratio`.`recobro` AS `priceIncreasing`,`bi`.`claims_ratio`.`inflacion` AS `packingRate` from `bi`.`claims_ratio` */; +/*!50001 VIEW `claimRatio__` AS select `claims_ratio`.`Id_Cliente` AS `clientFk`,`claims_ratio`.`Consumo` AS `yearSale`,`claims_ratio`.`Reclamaciones` AS `claimAmount`,`claims_ratio`.`Ratio` AS `claimingRate`,`claims_ratio`.`recobro` AS `priceIncreasing`,`claims_ratio`.`inflacion` AS `packingRate` from `bi`.`claims_ratio` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -58654,6 +58850,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `itemColor` +-- + +/*!50001 DROP VIEW IF EXISTS `itemColor`*/; +/*!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 `itemColor` AS select `it`.`itemFk` AS `itemFk`,`it`.`value` AS `color` from (`itemTag` `it` join `tag` `t` on((`t`.`id` = `it`.`tagFk`))) where (`t`.`code` = 'COLOR') */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `itemEntryIn` -- @@ -58726,6 +58940,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `itemProductor` +-- + +/*!50001 DROP VIEW IF EXISTS `itemProductor`*/; +/*!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 `itemProductor` AS select `it`.`itemFk` AS `itemFk`,`it`.`value` AS `productor` from (`itemTag` `it` join `tag` `t` on((`t`.`id` = `it`.`tagFk`))) where (`t`.`code` = 'PRODUCER') */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `itemShelvingAvailable` -- @@ -59407,4 +59639,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-01-15 13:30:07 +-- Dump completed on 2020-01-22 14:08:58