diff --git a/services/client/common/models/client-notification.json b/services/client/common/models/client-sample.json similarity index 60% rename from services/client/common/models/client-notification.json rename to services/client/common/models/client-sample.json index 712ee6169..e5850c6b1 100644 --- a/services/client/common/models/client-notification.json +++ b/services/client/common/models/client-sample.json @@ -1,9 +1,9 @@ { - "name": "ClientNotification", + "name": "ClientSample", "base": "VnModel", "options": { "mysql": { - "table": "clientNotification" + "table": "clientSample" } }, "properties": { @@ -22,15 +22,25 @@ "model": "Client", "foreignKey": "clientFk" }, - "clientNotificationType": { + "type": { "type": "belongsTo", - "model": "ClientNotificationType", - "foreignKey": "clientNotificationTypeFk" + "model": "Sample", + "foreignKey": "typeFk" }, "worker": { "type": "belongsTo", "model": "Worker", "foreignKey": "workerFk" + }, + "account": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "userFk" + }, + "company": { + "type": "belongsTo", + "model": "Company", + "foreignKey": "companyFk" } } } diff --git a/services/client/common/models/client-notification-type.json b/services/client/common/models/sample.json similarity index 87% rename from services/client/common/models/client-notification-type.json rename to services/client/common/models/sample.json index ebd71ce13..25fa2b18e 100644 --- a/services/client/common/models/client-notification-type.json +++ b/services/client/common/models/sample.json @@ -1,9 +1,9 @@ { - "name": "ClientNotificationType", + "name": "Sample", "base": "VnModel", "options": { "mysql": { - "table": "clientNotificationType" + "table": "sample" } }, "properties": { diff --git a/services/client/server/model-config.json b/services/client/server/model-config.json index 76b56f10c..0b68a420f 100644 --- a/services/client/server/model-config.json +++ b/services/client/server/model-config.json @@ -38,10 +38,10 @@ "CreditClassification": { "dataSource": "vn" }, - "ClientNotificationType": { + "Sample": { "dataSource": "vn" }, - "ClientNotification": { + "ClientSample": { "dataSource": "vn" } } diff --git a/services/db/install/changes/1.0.9/04-sample.sql b/services/db/install/changes/1.0.9/04-sample.sql new file mode 100644 index 000000000..3cc6666aa --- /dev/null +++ b/services/db/install/changes/1.0.9/04-sample.sql @@ -0,0 +1,15 @@ +USE `vn`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `sample` AS + SELECT + `e`.`id` AS `id`, + `e`.`abrev` AS `code`, + `e`.`descripcion` AS `description`, + `e`.`visible` AS `isVisible` + FROM + `vn2008`.`escritos` `e`; + +DROP VIEW `vn`.`clientNotificationType`; \ No newline at end of file diff --git a/services/db/install/changes/1.0.9/05-clientSample.sql b/services/db/install/changes/1.0.9/05-clientSample.sql new file mode 100644 index 000000000..26720137b --- /dev/null +++ b/services/db/install/changes/1.0.9/05-clientSample.sql @@ -0,0 +1,18 @@ +USE `vn`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +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`; + +DROP VIEW `vn`.`clientNotification`; \ 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 1227d3b0c..07e704969 100644 --- a/services/db/install/dump/01-structure.sql +++ b/services/db/install/dump/01-structure.sql @@ -17192,7 +17192,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 +17219,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 */ ; @@ -22618,7 +22618,8 @@ 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)); @@ -25034,7 +25035,8 @@ 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) @@ -25068,7 +25070,8 @@ 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 @@ -31606,7 +31609,8 @@ 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) @@ -43227,31 +43231,32 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `clientNotification` +-- Temporary table structure for view `clientSample` -- -DROP TABLE IF EXISTS `clientNotification`; -/*!50001 DROP VIEW IF EXISTS `clientNotification`*/; +DROP TABLE IF EXISTS `clientSample`; +/*!50001 DROP VIEW IF EXISTS `clientSample`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `clientNotification` AS SELECT +/*!50001 CREATE VIEW `clientSample` AS SELECT 1 AS `id`, 1 AS `clientFk`, - 1 AS `clientNotificationTypeFk`, + 1 AS `typeFk`, 1 AS `created`, 1 AS `workerFk`, - 1 AS `userFk`*/; + 1 AS `userFk`, + 1 AS `companyFk`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `clientNotificationType` +-- Temporary table structure for view `sample` -- -DROP TABLE IF EXISTS `clientNotificationType`; -/*!50001 DROP VIEW IF EXISTS `clientNotificationType`*/; +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 `clientNotificationType` AS SELECT +/*!50001 CREATE VIEW `sample` AS SELECT 1 AS `id`, 1 AS `code`, 1 AS `description`, @@ -47706,38 +47711,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 */ ;; @@ -70280,15 +70285,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 */ ; @@ -74253,10 +74258,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `clientNotification` +-- Final view structure for view `clientSample` -- -/*!50001 DROP VIEW IF EXISTS `clientNotification`*/; +/*!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 */; @@ -74265,16 +74270,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `clientNotification` 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 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 `clientNotificationType` +-- Final view structure for view `sample` -- -/*!50001 DROP VIEW IF EXISTS `clientNotificationType`*/; +/*!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 */; @@ -74283,7 +74288,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `clientNotificationType` AS select `e`.`id` AS `id`,`e`.`abrev` AS `code`,`e`.`descripcion` AS `description`,`e`.`visible` AS `isVisible` from `vn2008`.`escritos` `e` */; +/*!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 */; diff --git a/services/db/install/dump/fixtures.sql b/services/db/install/dump/fixtures.sql index 16b42a1ce..9cc6e4030 100644 --- a/services/db/install/dump/fixtures.sql +++ b/services/db/install/dump/fixtures.sql @@ -729,10 +729,10 @@ call vn.manaSpellersRequery(19); call vn.manaSpellersRequery(18); -INSERT INTO `vn`.`clientNotification`(`id`, `clientFk`, `clientNotificationTypeFk`, `created`, `workerFk`) +INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk`, `companyFk`) VALUES - ( 1, 101, 1, CURDATE(), 18), - ( 2, 101, 1, CURDATE(), 18), - ( 3, 101, 2, CURDATE(), 18), - ( 4, 102, 2, CURDATE(), 18), - ( 5, 102, 3, CURDATE(), 19); \ No newline at end of file + ( 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