From c40dc134f811cebef8a51ad16cb6928eeb423d66 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 29 Nov 2023 12:15:38 +0100 Subject: [PATCH] refs #5858 feat: sql files for new version --- .../234801/06-zoneincluded_notification.sql | 6 +- db/changes/234802/00-zoneIncluded_trigger.sql | 73 +++++++++++++++++++ ...1-zoneIncluded_table_zoneincludedCheck.sql | 14 ++++ .../02-zoneIncluded_event_checkCollisions.sql | 5 ++ ...zoneIncluded_procedure_checkCollisions.sql | 33 +++++++++ .../04-remove-procedure-bs_nightTask.sql | 2 + .../05-drop-procedure-zone_getCollisions.sql | 1 + .../234802/06-zoneincluded_notification.sql | 11 +++ .../email/zone-included/zone-included.html | 29 +++++++- .../email/zone-included/zone-included.js | 6 ++ 10 files changed, 174 insertions(+), 6 deletions(-) create mode 100644 db/changes/234802/00-zoneIncluded_trigger.sql create mode 100644 db/changes/234802/01-zoneIncluded_table_zoneincludedCheck.sql create mode 100644 db/changes/234802/02-zoneIncluded_event_checkCollisions.sql create mode 100644 db/changes/234802/03-zoneIncluded_procedure_checkCollisions.sql create mode 100644 db/changes/234802/04-remove-procedure-bs_nightTask.sql create mode 100644 db/changes/234802/05-drop-procedure-zone_getCollisions.sql create mode 100644 db/changes/234802/06-zoneincluded_notification.sql diff --git a/db/changes/234801/06-zoneincluded_notification.sql b/db/changes/234801/06-zoneincluded_notification.sql index 53b2a9189..3de713884 100644 --- a/db/changes/234801/06-zoneincluded_notification.sql +++ b/db/changes/234801/06-zoneincluded_notification.sql @@ -1,11 +1,9 @@ --- Auto-generated SQL script #202311241021 INSERT INTO util.notification (name,description) VALUES ('zone-included','An email to notify zoneCollisions'); --- Auto-generated SQL script #202311241051 INSERT INTO util.notificationSubscription (notificationFk,userFk) - SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included" + SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included"; INSERT INTO util.notificationAcl (notificationFk,roleFk) - SELECT id, account.role FROM util.notification WHERE name= "zone-included" + SELECT id, (SELECT id from `account`.`role` where name = "system") FROM util.notification WHERE name= "zone-included"; diff --git a/db/changes/234802/00-zoneIncluded_trigger.sql b/db/changes/234802/00-zoneIncluded_trigger.sql new file mode 100644 index 000000000..4de0416b7 --- /dev/null +++ b/db/changes/234802/00-zoneIncluded_trigger.sql @@ -0,0 +1,73 @@ +DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterInsert`; +USE `vn`; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterInsert` + AFTER INSERT ON `zoneIncluded` + FOR EACH ROW +BEGIN + INSERT INTO zoneLog + SET `action` = 'insert', + `changedModel` = 'zoneIncluded', + `changedModelId` = NEW.zoneFk, + `userFk` = account.myUser_getId(); + INSERT INTO zoneIncludedCheck + SET + `action`= 'insert', + `zoneFk` = NEW.zoneFk, + `geoFk` = NEW.geoFk, + `userFk` = account.myUser_getId(); + -- CALL `vn`.`zoneIncluded_checkCollisions`(NEW.zoneFk, NEW.geoFk); + +END$$ +DELIMITER ; + +DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterUpdate`; +USE `vn`; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterUpdate` + AFTER UPDATE ON `zoneIncluded` + FOR EACH ROW +BEGIN + INSERT INTO zoneLog + SET `action` = 'update', + `changedModel` = 'zoneIncluded', + `changedModelId` = OLD.zoneFk, + `userFk` = account.myUser_getId(); + INSERT INTO zoneIncludedCheck + SET + `action`= 'update', + `zoneFk` = NEW.zoneFk, + `geoFk` = NEW.geoFk, + `userFk` = account.myUser_getId(); + + -- CALL `vn`.`zoneIncluded_checkCollisions`(); + + +END$$ +DELIMITER ; + +DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterDelete`; +USE `vn`; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterDelete` + AFTER DELETE ON `zoneIncluded` + FOR EACH ROW +BEGIN + INSERT INTO zoneLog + SET `action` = 'delete', + `changedModel` = 'zoneIncluded', + `changedModelId` = OLD.zoneFk, + `userFk` = account.myUser_getId(); + INSERT INTO zoneIncludedCheck + SET + `action`= 'delete', + `zoneFk` = OLD.zoneFk, + `geoFk` = OLD.geoFk, + `userFk` = account.myUser_getId(); + + -- CALL `vn`.`zoneIncluded_checkCollisions`(); +END$$ +DELIMITER ; diff --git a/db/changes/234802/01-zoneIncluded_table_zoneincludedCheck.sql b/db/changes/234802/01-zoneIncluded_table_zoneincludedCheck.sql new file mode 100644 index 000000000..ba52f76b0 --- /dev/null +++ b/db/changes/234802/01-zoneIncluded_table_zoneincludedCheck.sql @@ -0,0 +1,14 @@ +CREATE TABLE `vn`.`zoneIncludedCheck` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `zoneFK` int(11) NOT NULL, + `geoFK` int(11) NOT NULL, + `userFK` int(10) unsigned NOT NULL, + `action`set('insert','update','delete') NOT NULL, + PRIMARY KEY (`id`), + CONSTRAINT `user_FK` FOREIGN KEY (`userFK`) REFERENCES `account`.`user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT `zone_FK` FOREIGN KEY (`zoneFK`) REFERENCES `vn`.`zone` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT `geo_FK` FOREIGN KEY (`geoFK`) REFERENCES `vn`.`zoneGeo` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + UNIQUE INDEX (`zoneFK`, `geoFK`, `userFK`, `action`) +) + +comment 'Table to save temporarily zone changes'; diff --git a/db/changes/234802/02-zoneIncluded_event_checkCollisions.sql b/db/changes/234802/02-zoneIncluded_event_checkCollisions.sql new file mode 100644 index 000000000..3a6dd32b8 --- /dev/null +++ b/db/changes/234802/02-zoneIncluded_event_checkCollisions.sql @@ -0,0 +1,5 @@ +USE vn; +CREATE EVENT zoneCollisionsCheck +ON SCHEDULE AT CURRENT_TIMESTAMP +DISABLE ON SLAVE +DO SELECT vn.zoneIncluded_checkCollisions; diff --git a/db/changes/234802/03-zoneIncluded_procedure_checkCollisions.sql b/db/changes/234802/03-zoneIncluded_procedure_checkCollisions.sql new file mode 100644 index 000000000..8959b3945 --- /dev/null +++ b/db/changes/234802/03-zoneIncluded_procedure_checkCollisions.sql @@ -0,0 +1,33 @@ +DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`; +DELIMITER $$ + +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`() +BEGIN +DECLARE done INT DEFAULT 0; +DECLARE zic_id, zic_zone, zic_geo, zic_action, zic_userFk INT; +DECLARE z_name VARCHAR(255); +DECLARE g_name VARCHAR(255); + +DECLARE my_cur CURSOR FOR + SELECT zic.id, z.name , zg.name , zic.geoFk ,zic.`action` , zic.userFK FROM vn.zoneIncludedCheck zic, vn.`zone` z, vn.zoneGeo zg WHERE zic.zoneFK =z.id AND zic.geoFK = zg.id ; +DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; + +OPEN my_cur; + my_cur_loop: + LOOP FETCH my_cur INTO zic_id, z_name,g_name, zic_geo, zic_action, zic_userFk ; + IF done = 1 THEN + select concat('NO REDCORDS' ) AS '** DEBUG:'; + LEAVE my_cur_loop; + END IF; + SELECT concat('** ', zic_id, '** ',z_name, '** ',g_name,'**',zic_geo,'** ', zic_action,'** ', zic_userFk ) AS '** DEBUG:'; + DELETE FROM vn.zoneIncludedCheck WHERE id =zic_id; + SELECT util.notification_send('zone-included', + JSON_OBJECT('zoneSelected', z_name, 'geoSelected', g_name), + account.myUser_getId() + ); + END LOOP my_cur_loop; +CLOSE my_cur; + + +END$$ +DELIMITER ; diff --git a/db/changes/234802/04-remove-procedure-bs_nightTask.sql b/db/changes/234802/04-remove-procedure-bs_nightTask.sql new file mode 100644 index 000000000..530dc6ef5 --- /dev/null +++ b/db/changes/234802/04-remove-procedure-bs_nightTask.sql @@ -0,0 +1,2 @@ +DELETE FROM bs.nightTask + WHERE `procedure` ='zone_getCollisions'; diff --git a/db/changes/234802/05-drop-procedure-zone_getCollisions.sql b/db/changes/234802/05-drop-procedure-zone_getCollisions.sql new file mode 100644 index 000000000..9d0db5465 --- /dev/null +++ b/db/changes/234802/05-drop-procedure-zone_getCollisions.sql @@ -0,0 +1 @@ +DROP PROCEDURE vn.zone_getCollisions; diff --git a/db/changes/234802/06-zoneincluded_notification.sql b/db/changes/234802/06-zoneincluded_notification.sql new file mode 100644 index 000000000..53b2a9189 --- /dev/null +++ b/db/changes/234802/06-zoneincluded_notification.sql @@ -0,0 +1,11 @@ +-- Auto-generated SQL script #202311241021 +INSERT INTO util.notification (name,description) + VALUES ('zone-included','An email to notify zoneCollisions'); + +-- Auto-generated SQL script #202311241051 +INSERT INTO util.notificationSubscription (notificationFk,userFk) + SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included" + + +INSERT INTO util.notificationAcl (notificationFk,roleFk) + SELECT id, account.role FROM util.notification WHERE name= "zone-included" diff --git a/print/templates/email/zone-included/zone-included.html b/print/templates/email/zone-included/zone-included.html index 76f59e9f9..95f43b570 100644 --- a/print/templates/email/zone-included/zone-included.html +++ b/print/templates/email/zone-included/zone-included.html @@ -1,8 +1,33 @@
-

{{ $t('subject') }}

-

{{ $t('title', [zoneSelected,geoSelected]) }}

+ + + + + + + + + + + + + + + + + +
C.PostalNúmero de zonaPrecioZonaAlmacénSalix
{{ zn.name }}{{ zoneFk }}{{ z.price }}{{ z.name }}{{ w.name }}' + 'https://salix.verdnatura.es/#!/zone/', + zoneFk, + '/location?q=%7B%22search%22:%22', + zn.name, + '%22%7D
diff --git a/print/templates/email/zone-included/zone-included.js b/print/templates/email/zone-included/zone-included.js index 6ed8964b1..7fb60fb63 100755 --- a/print/templates/email/zone-included/zone-included.js +++ b/print/templates/email/zone-included/zone-included.js @@ -5,6 +5,12 @@ module.exports = { name: 'zone-included', components: { 'email-body': emailBody.build(), + }, + computed: { + + }, + methods: { + }, props: { zoneSelected: {